Title: [195876] trunk/Source/_javascript_Core
Revision
195876
Author
sbar...@apple.com
Date
2016-01-29 18:05:17 -0800 (Fri, 29 Jan 2016)

Log Message

Pack FunctionExecutable and UnlinkedFunctionExecutable harder
https://bugs.webkit.org/show_bug.cgi?id=153687

Reviewed by Andreas Kling.

This patch reduces FunctionExecutable from 120 to 104 bytes.
This patch reduces UnlinkedFunctionExecutable from 144 to 136 bytes.

* bytecode/ExecutableInfo.h:
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* bytecode/UnlinkedFunctionExecutable.h:
* parser/ParserModes.h:
(JSC::functionNameScopeIsDynamic):
* runtime/Executable.cpp:
(JSC::ScriptExecutable::ScriptExecutable):
* runtime/Executable.h:
(JSC::ScriptExecutable::needsActivation):
(JSC::ScriptExecutable::isArrowFunctionContext):
(JSC::ScriptExecutable::isStrictMode):
(JSC::ScriptExecutable::derivedContextType):
(JSC::ScriptExecutable::ecmaMode):
(JSC::ScriptExecutable::finishCreation):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (195875 => 195876)


--- trunk/Source/_javascript_Core/ChangeLog	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-01-30 02:05:17 UTC (rev 195876)
@@ -1,5 +1,31 @@
 2016-01-29  Saam barati  <sbar...@apple.com>
 
+        Pack FunctionExecutable and UnlinkedFunctionExecutable harder
+        https://bugs.webkit.org/show_bug.cgi?id=153687
+
+        Reviewed by Andreas Kling.
+
+        This patch reduces FunctionExecutable from 120 to 104 bytes.
+        This patch reduces UnlinkedFunctionExecutable from 144 to 136 bytes.
+
+        * bytecode/ExecutableInfo.h:
+        * bytecode/UnlinkedFunctionExecutable.cpp:
+        (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
+        * bytecode/UnlinkedFunctionExecutable.h:
+        * parser/ParserModes.h:
+        (JSC::functionNameScopeIsDynamic):
+        * runtime/Executable.cpp:
+        (JSC::ScriptExecutable::ScriptExecutable):
+        * runtime/Executable.h:
+        (JSC::ScriptExecutable::needsActivation):
+        (JSC::ScriptExecutable::isArrowFunctionContext):
+        (JSC::ScriptExecutable::isStrictMode):
+        (JSC::ScriptExecutable::derivedContextType):
+        (JSC::ScriptExecutable::ecmaMode):
+        (JSC::ScriptExecutable::finishCreation):
+
+2016-01-29  Saam barati  <sbar...@apple.com>
+
         JSC Sampling Profiler: Come up with a (program counter => CodeOrigin) mapping
         https://bugs.webkit.org/show_bug.cgi?id=152629
 

Modified: trunk/Source/_javascript_Core/bytecode/ExecutableInfo.h (195875 => 195876)


--- trunk/Source/_javascript_Core/bytecode/ExecutableInfo.h	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/bytecode/ExecutableInfo.h	2016-01-30 02:05:17 UTC (rev 195876)
@@ -30,7 +30,7 @@
 
 namespace JSC {
     
-enum class DerivedContextType { None, DerivedConstructorContext, DerivedMethodContext };
+enum class DerivedContextType : uint8_t { None, DerivedConstructorContext, DerivedMethodContext };
 
 // FIXME: These flags, ParserModes and propagation to XXXCodeBlocks should be reorganized.
 // https://bugs.webkit.org/show_bug.cgi?id=151547

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (195875 => 195876)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp	2016-01-30 02:05:17 UTC (rev 195876)
@@ -80,9 +80,6 @@
 
 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, DerivedContextType derivedContextType)
     : Base(*vm, structure)
-    , m_name(node->ident())
-    , m_inferredName(node->inferredName())
-    , m_sourceOverride(WTFMove(sourceOverride))
     , m_firstLineOffset(node->firstLine() - source.firstLine())
     , m_lineCount(node->lastLine() - node->firstLine())
     , m_unlinkedFunctionNameStart(node->functionNameStart() - source.startOffset())
@@ -94,7 +91,6 @@
     , m_typeProfilingStartOffset(node->functionKeywordStart())
     , m_typeProfilingEndOffset(node->startStartOffset() + node->source().length() - 1)
     , m_parameterCount(node->parameterCount())
-    , m_parseMode(node->parseMode())
     , m_features(0)
     , m_isInStrictContext(node->isInStrictContext())
     , m_hasCapturedVariables(false)
@@ -104,6 +100,10 @@
     , m_functionMode(node->functionMode())
     , m_superBinding(static_cast<unsigned>(node->superBinding()))
     , m_derivedContextType(static_cast<unsigned>(derivedContextType))
+    , m_sourceParseMode(static_cast<unsigned>(node->parseMode()))
+    , m_name(node->ident())
+    , m_inferredName(node->inferredName())
+    , m_sourceOverride(WTFMove(sourceOverride))
 {
     ASSERT(m_constructorKind == static_cast<unsigned>(node->constructorKind()));
     m_parentScopeTDZVariables.swap(parentScopeTDZVariables);

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h (195875 => 195876)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h	2016-01-30 02:05:17 UTC (rev 195876)
@@ -79,7 +79,7 @@
     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 m_parseMode; };
+    SourceParseMode parseMode() const { return static_cast<SourceParseMode>(m_sourceParseMode); };
     bool isInStrictContext() const { return m_isInStrictContext; }
     FunctionMode functionMode() const { return static_cast<FunctionMode>(m_functionMode); }
     ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); }
@@ -128,21 +128,13 @@
     bool isClassConstructorFunction() const { return constructorKind() != ConstructorKind::None; }
     const VariableEnvironment* parentScopeTDZVariables() const { return &m_parentScopeTDZVariables; }
     
-    bool isArrowFunction() const { return m_parseMode == SourceParseMode::ArrowFunctionMode; }
+    bool isArrowFunction() const { return parseMode() == SourceParseMode::ArrowFunctionMode; }
 
     JSC::DerivedContextType derivedContextType() const {return static_cast<JSC::DerivedContextType>(m_derivedContextType); }
     
 private:
     UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&,  JSC::DerivedContextType);
 
-    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall;
-    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct;
-
-    Identifier m_name;
-    Identifier m_inferredName;
-    WriteBarrier<JSString> m_nameValue;
-    RefPtr<SourceProvider> m_sourceOverride;
-    VariableEnvironment m_parentScopeTDZVariables;
     unsigned m_firstLineOffset;
     unsigned m_lineCount;
     unsigned m_unlinkedFunctionNameStart;
@@ -154,10 +146,7 @@
     unsigned m_typeProfilingStartOffset;
     unsigned m_typeProfilingEndOffset;
     unsigned m_parameterCount;
-    SourceParseMode m_parseMode;
-
     CodeFeatures m_features;
-
     unsigned m_isInStrictContext : 1;
     unsigned m_hasCapturedVariables : 1;
     unsigned m_isBuiltinFunction : 1;
@@ -166,7 +155,18 @@
     unsigned m_functionMode : 1; // FunctionMode
     unsigned m_superBinding : 1;
     unsigned m_derivedContextType: 2;
+    unsigned m_sourceParseMode : 4; // SourceParseMode
 
+    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall;
+    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct;
+
+    Identifier m_name;
+    Identifier m_inferredName;
+    WriteBarrier<JSString> m_nameValue;
+    RefPtr<SourceProvider> m_sourceOverride;
+
+    VariableEnvironment m_parentScopeTDZVariables;
+
 protected:
     void finishCreation(VM& vm)
     {

Modified: trunk/Source/_javascript_Core/parser/ParserModes.h (195875 => 195876)


--- trunk/Source/_javascript_Core/parser/ParserModes.h	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/parser/ParserModes.h	2016-01-30 02:05:17 UTC (rev 195876)
@@ -44,7 +44,7 @@
 
 enum FunctionMode { FunctionExpression, FunctionDeclaration };
 
-enum class SourceParseMode {
+enum class SourceParseMode : uint8_t {
     NormalFunctionMode,
     GeneratorBodyMode,
     GeneratorWrapperFunctionMode,
@@ -145,7 +145,7 @@
     return true;
 }
 
-typedef unsigned CodeFeatures;
+typedef uint16_t CodeFeatures;
 
 const CodeFeatures NoFeatures =                       0;
 const CodeFeatures EvalFeature =                 1 << 0;

Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (195875 => 195876)


--- trunk/Source/_javascript_Core/runtime/Executable.cpp	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp	2016-01-30 02:05:17 UTC (rev 195876)
@@ -133,13 +133,13 @@
 
 ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, bool isInArrowFunctionContext)
     : ExecutableBase(vm, structure, NUM_PARAMETERS_NOT_COMPILED)
-    , m_source(source)
     , m_features(isInStrictContext ? StrictModeFeature : 0)
+    , m_didTryToEnterInLoop(false)
     , m_hasCapturedVariables(false)
     , m_neverInline(false)
-    , m_didTryToEnterInLoop(false)
-    , m_derivedContextType(derivedContextType)
+    , m_neverOptimize(false)
     , m_isArrowFunctionContext(isInArrowFunctionContext)
+    , m_derivedContextType(static_cast<unsigned>(derivedContextType))
     , m_overrideLineNumber(-1)
     , m_firstLine(-1)
     , m_lastLine(-1)
@@ -147,6 +147,7 @@
     , m_endColumn(UINT_MAX)
     , m_typeProfilingStartOffset(UINT_MAX)
     , m_typeProfilingEndOffset(UINT_MAX)
+    , m_source(source)
 {
 }
 

Modified: trunk/Source/_javascript_Core/runtime/Executable.h (195875 => 195876)


--- trunk/Source/_javascript_Core/runtime/Executable.h	2016-01-30 01:53:53 UTC (rev 195875)
+++ trunk/Source/_javascript_Core/runtime/Executable.h	2016-01-30 02:05:17 UTC (rev 195876)
@@ -350,7 +350,7 @@
     bool usesArguments() const { return m_features & ArgumentsFeature; }
     bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
     bool isStrictMode() const { return m_features & StrictModeFeature; }
-    DerivedContextType derivedContextType() const { return m_derivedContextType; }
+    DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); }
 
     ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
         
@@ -413,14 +413,14 @@
 #endif
     }
 
-    SourceCode m_source;
     CodeFeatures m_features;
-    bool m_hasCapturedVariables;
-    bool m_neverInline;
-    bool m_neverOptimize { false };
     bool m_didTryToEnterInLoop;
-    DerivedContextType m_derivedContextType;
-    bool m_isArrowFunctionContext;
+    bool m_hasCapturedVariables : 1;
+    bool m_neverInline : 1;
+    bool m_neverOptimize : 1;
+    bool m_isArrowFunctionContext : 1;
+    unsigned m_derivedContextType : 2; // DerivedContextType
+
     int m_overrideLineNumber;
     int m_firstLine;
     int m_lastLine;
@@ -428,6 +428,7 @@
     unsigned m_endColumn;
     unsigned m_typeProfilingStartOffset;
     unsigned m_typeProfilingEndOffset;
+    SourceCode m_source;
 };
 
 class EvalExecutable final : public ScriptExecutable {
@@ -699,11 +700,11 @@
 
     friend class ScriptExecutable;
     
+    unsigned m_parametersStartOffset;
     WriteBarrier<UnlinkedFunctionExecutable> m_unlinkedExecutable;
     WriteBarrier<FunctionCodeBlock> m_codeBlockForCall;
     WriteBarrier<FunctionCodeBlock> m_codeBlockForConstruct;
     RefPtr<TypeSet> m_returnStatementTypeSet;
-    unsigned m_parametersStartOffset;
     WriteBarrier<InferredValue> m_singletonFunction;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to