Title: [199394] trunk/Source/_javascript_Core
- Revision
- 199394
- Author
- [email protected]
- Date
- 2016-04-12 15:42:06 -0700 (Tue, 12 Apr 2016)
Log Message
Lets not iterate over the constant pool twice every time we link a code block
https://bugs.webkit.org/show_bug.cgi?id=156517
Reviewed by Mark Lam.
I introduced a second iteration over the constant pool when I implemented
block scoping. I did this because we must clone all the symbol tables when
we link a CodeBlock. We can just do this cloning when setting the constant
registers for the first time. There is no need to iterate over the constant
pool a second time.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::finishCreation):
(JSC::CodeBlock::~CodeBlock):
(JSC::CodeBlock::setConstantRegisters):
(JSC::CodeBlock::setAlternative):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::replaceConstant):
(JSC::CodeBlock::setConstantRegisters): Deleted.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (199393 => 199394)
--- trunk/Source/_javascript_Core/ChangeLog 2016-04-12 22:40:25 UTC (rev 199393)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-04-12 22:42:06 UTC (rev 199394)
@@ -1,3 +1,25 @@
+2016-04-12 Saam barati <[email protected]>
+
+ Lets not iterate over the constant pool twice every time we link a code block
+ https://bugs.webkit.org/show_bug.cgi?id=156517
+
+ Reviewed by Mark Lam.
+
+ I introduced a second iteration over the constant pool when I implemented
+ block scoping. I did this because we must clone all the symbol tables when
+ we link a CodeBlock. We can just do this cloning when setting the constant
+ registers for the first time. There is no need to iterate over the constant
+ pool a second time.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::~CodeBlock):
+ (JSC::CodeBlock::setConstantRegisters):
+ (JSC::CodeBlock::setAlternative):
+ * bytecode/CodeBlock.h:
+ (JSC::CodeBlock::replaceConstant):
+ (JSC::CodeBlock::setConstantRegisters): Deleted.
+
2016-04-12 Mark Lam <[email protected]>
ES6: Implement String.prototype.split and RegExp.prototype[@@split].
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (199393 => 199394)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-04-12 22:40:25 UTC (rev 199393)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-04-12 22:42:06 UTC (rev 199394)
@@ -1886,31 +1886,6 @@
m_constantRegisters[registerIndex].set(*m_vm, this, m_globalObject->jsCellForLinkTimeConstant(type));
}
-#if !ASSERT_DISABLED
- HashSet<int, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> clonedConstantSymbolTables;
-#endif
- {
-#if !ASSERT_DISABLED
- HashSet<SymbolTable*> clonedSymbolTables;
-#endif
- bool hasTypeProfiler = !!vm.typeProfiler();
- for (unsigned i = 0; i < m_constantRegisters.size(); i++) {
- if (m_constantRegisters[i].get().isEmpty())
- continue;
- if (SymbolTable* symbolTable = jsDynamicCast<SymbolTable*>(m_constantRegisters[i].get())) {
- ASSERT(clonedSymbolTables.add(symbolTable).isNewEntry);
- if (hasTypeProfiler) {
- ConcurrentJITLocker locker(symbolTable->m_lock);
- symbolTable->prepareForTypeProfiling(locker);
- }
- m_constantRegisters[i].set(*m_vm, this, symbolTable->cloneScopePart(*m_vm));
-#if !ASSERT_DISABLED
- clonedConstantSymbolTables.add(i + FirstConstantRegisterIndex);
-#endif
- }
- }
- }
-
// We already have the cloned symbol table for the module environment since we need to instantiate
// the module environments before linking the code block. We replace the stored symbol table with the already cloned one.
if (UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock = jsDynamicCast<UnlinkedModuleProgramCodeBlock*>(unlinkedCodeBlock)) {
@@ -2106,14 +2081,6 @@
case op_get_array_length:
CRASH();
-#if !ASSERT_DISABLED
- case op_create_lexical_environment: {
- int symbolTableIndex = pc[3].u.operand;
- ASSERT(clonedConstantSymbolTables.contains(symbolTableIndex));
- break;
- }
-#endif
-
case op_resolve_scope: {
const Identifier& ident = identifier(pc[3].u.operand);
ResolveType type = static_cast<ResolveType>(pc[4].u.operand);
@@ -2177,7 +2144,6 @@
// Only do watching if the property we're putting to is not anonymous.
if (static_cast<unsigned>(pc[2].u.operand) != UINT_MAX) {
int symbolTableIndex = pc[5].u.operand;
- ASSERT(clonedConstantSymbolTables.contains(symbolTableIndex));
SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex));
const Identifier& ident = identifier(pc[2].u.operand);
ConcurrentJITLocker locker(symbolTable->m_lock);
@@ -2248,7 +2214,6 @@
}
case ProfileTypeBytecodeLocallyResolved: {
int symbolTableIndex = pc[2].u.operand;
- ASSERT(clonedConstantSymbolTables.contains(symbolTableIndex));
SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex));
const Identifier& ident = identifier(pc[4].u.operand);
ConcurrentJITLocker locker(symbolTable->m_lock);
@@ -2419,6 +2384,31 @@
#endif // ENABLE(JIT)
}
+void CodeBlock::setConstantRegisters(const Vector<WriteBarrier<Unknown>>& constants, const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation)
+{
+ ASSERT(constants.size() == constantsSourceCodeRepresentation.size());
+ size_t count = constants.size();
+ m_constantRegisters.resizeToFit(count);
+ bool hasTypeProfiler = !!m_vm->typeProfiler();
+ for (size_t i = 0; i < count; i++) {
+ JSValue constant = constants[i].get();
+
+ if (!constant.isEmpty()) {
+ if (SymbolTable* symbolTable = jsDynamicCast<SymbolTable*>(constant)) {
+ if (hasTypeProfiler) {
+ ConcurrentJITLocker locker(symbolTable->m_lock);
+ symbolTable->prepareForTypeProfiling(locker);
+ }
+ constant = symbolTable->cloneScopePart(*m_vm);
+ }
+ }
+
+ m_constantRegisters[i].set(*m_vm, this, constant);
+ }
+
+ m_constantsSourceCodeRepresentation = constantsSourceCodeRepresentation;
+}
+
void CodeBlock::setAlternative(VM& vm, CodeBlock* alternative)
{
m_alternative.set(vm, this, alternative);
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (199393 => 199394)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-04-12 22:40:25 UTC (rev 199393)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-04-12 22:42:06 UTC (rev 199394)
@@ -936,15 +936,7 @@
void updateAllPredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles);
- void setConstantRegisters(const Vector<WriteBarrier<Unknown>>& constants, const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation)
- {
- ASSERT(constants.size() == constantsSourceCodeRepresentation.size());
- size_t count = constants.size();
- m_constantRegisters.resizeToFit(count);
- for (size_t i = 0; i < count; i++)
- m_constantRegisters[i].set(*m_vm, this, constants[i].get());
- m_constantsSourceCodeRepresentation = constantsSourceCodeRepresentation;
- }
+ void setConstantRegisters(const Vector<WriteBarrier<Unknown>>& constants, const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation);
void replaceConstant(int index, JSValue value)
{
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes