Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (197307 => 197308)
--- trunk/Source/_javascript_Core/ChangeLog 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-02-29 05:26:05 UTC (rev 197308)
@@ -1,5 +1,27 @@
2016-02-28 Andreas Kling <[email protected]>
+ Make JSFunction.name allocation fully lazy.
+ <https://webkit.org/b/154806>
+
+ Reviewed by Saam Barati.
+
+ We were reifying the "name" field on functions lazily, but created the string
+ value itself up front. This patch gets rid of the up-front allocation,
+ saving us a JSString allocation per function in most cases.
+
+ * builtins/BuiltinExecutables.cpp:
+ (JSC::createExecutableInternal):
+ * bytecode/UnlinkedFunctionExecutable.cpp:
+ (JSC::UnlinkedFunctionExecutable::visitChildren):
+ * bytecode/UnlinkedFunctionExecutable.h:
+ * runtime/CodeCache.cpp:
+ (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
+ * runtime/Executable.h:
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::reifyName):
+
+2016-02-28 Andreas Kling <[email protected]>
+
REGRESSION(r197303): 4 jsc tests failing on bots.
Unreviewed follow-up fix.
Modified: trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp (197307 => 197308)
--- trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp 2016-02-29 05:26:05 UTC (rev 197308)
@@ -109,7 +109,6 @@
metadata->overrideName(name);
VariableEnvironment dummyTDZVariables;
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, kind, constructAbility, dummyTDZVariables, DerivedContextType::None, WTFMove(sourceOverride));
- functionExecutable->setNameValue(vm, jsString(&vm, name.string()));
return functionExecutable;
}
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (197307 => 197308)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2016-02-29 05:26:05 UTC (rev 197308)
@@ -116,7 +116,6 @@
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_unlinkedCodeBlockForCall);
visitor.append(&thisObject->m_unlinkedCodeBlockForConstruct);
- visitor.append(&thisObject->m_nameValue);
}
FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource, int overrideLineNumber)
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h (197307 => 197308)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2016-02-29 05:26:05 UTC (rev 197308)
@@ -76,8 +76,6 @@
const Identifier& name() const { return m_name; }
const Identifier& inferredName() const { return m_inferredName; }
- JSString* nameValue() const { return m_nameValue.get(); }
- void setNameValue(VM& vm, JSString* nameValue) { m_nameValue.set(vm, this, nameValue); }
unsigned parameterCount() const { return m_parameterCount; };
SourceParseMode parseMode() const { return static_cast<SourceParseMode>(m_sourceParseMode); };
bool isInStrictContext() const { return m_isInStrictContext; }
@@ -162,18 +160,11 @@
Identifier m_name;
Identifier m_inferredName;
- WriteBarrier<JSString> m_nameValue;
RefPtr<SourceProvider> m_sourceOverride;
VariableEnvironment m_parentScopeTDZVariables;
protected:
- void finishCreation(VM& vm)
- {
- Base::finishCreation(vm);
- m_nameValue.set(vm, this, jsString(&vm, name().string()));
- }
-
static void visitChildren(JSCell*, SlotVisitor&);
public:
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (197307 => 197308)
--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2016-02-29 05:26:05 UTC (rev 197308)
@@ -187,13 +187,12 @@
if (!metadata)
return nullptr;
+ metadata->overrideName(name);
metadata->setEndPosition(positionBeforeLastNewline);
// The Function constructor only has access to global variables, so no variables will be under TDZ.
VariableEnvironment emptyTDZVariables;
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables, DerivedContextType::None);
- functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string()));
-
m_sourceCode.addCache(key, SourceCodeValue(vm, functionExecutable, m_sourceCode.age()));
return functionExecutable;
}
Modified: trunk/Source/_javascript_Core/runtime/Executable.h (197307 => 197308)
--- trunk/Source/_javascript_Core/runtime/Executable.h 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/runtime/Executable.h 2016-02-29 05:26:05 UTC (rev 197308)
@@ -667,7 +667,6 @@
bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
const Identifier& name() { return m_unlinkedExecutable->name(); }
const Identifier& inferredName() { return m_unlinkedExecutable->inferredName(); }
- JSString* nameValue() const { return m_unlinkedExecutable->nameValue(); }
size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
SourceParseMode parseMode() const { return m_unlinkedExecutable->parseMode(); }
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (197307 => 197308)
--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2016-02-29 04:36:06 UTC (rev 197307)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2016-02-29 05:26:05 UTC (rev 197308)
@@ -589,10 +589,9 @@
ASSERT(!hasReifiedName());
ASSERT(!isHostFunction());
- JSValue initialValue = jsExecutable()->nameValue();
unsigned initialAttributes = DontEnum | ReadOnly;
const Identifier& identifier = exec->propertyNames().name;
- putDirect(vm, identifier, initialValue, initialAttributes);
+ putDirect(vm, identifier, jsString(exec, jsExecutable()->name().string()), initialAttributes);
rareData->setHasReifiedName();
}