Title: [188219] trunk/Source/_javascript_Core
Revision
188219
Author
[email protected]
Date
2015-08-10 13:24:35 -0700 (Mon, 10 Aug 2015)

Log Message

Let's rename FunctionBodyNode
https://bugs.webkit.org/show_bug.cgi?id=147292

Reviewed by Mark Lam & Saam Barati.

FunctionBodyNode => FunctionMetadataNode

Make FunctionMetadataNode inherit from Node instead of StatementNode
because a FunctionMetadataNode can appear in _expression_ context and does
not have a next statement.

(I decided to continue allocating FunctionMetadataNode in the AST arena,
and to retain "Node" in its name, because it really is a parsing
construct, and we transform its data before consuming it elsewhere.

There is still room for a future patch to distill and simplify the
metadata we track about functions between FunDeclNode/FuncExprNode,
FunctionMetadataNode, and UnlinkedFunctionExecutable. But this is a start.)

* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutableInternal):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* bytecode/UnlinkedCodeBlock.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitNewArray):
(JSC::BytecodeGenerator::emitNewFunction):
(JSC::BytecodeGenerator::emitNewFunctionExpression):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::makeFunction):
* bytecompiler/NodesCodegen.cpp:
(JSC::EvalNode::emitBytecode):
(JSC::FunctionNode::emitBytecode):
(JSC::FunctionBodyNode::emitBytecode): Deleted.
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionExpr):
(JSC::ASTBuilder::createFunctionBody):
* parser/NodeConstructors.h:
(JSC::FunctionParameters::FunctionParameters):
(JSC::FuncExprNode::FuncExprNode):
(JSC::FuncDeclNode::FuncDeclNode):
* parser/Nodes.cpp:
(JSC::EvalNode::EvalNode):
(JSC::FunctionMetadataNode::FunctionMetadataNode):
(JSC::FunctionMetadataNode::finishParsing):
(JSC::FunctionMetadataNode::setEndPosition):
(JSC::FunctionBodyNode::FunctionBodyNode): Deleted.
(JSC::FunctionBodyNode::finishParsing): Deleted.
(JSC::FunctionBodyNode::setEndPosition): Deleted.
* parser/Nodes.h:
(JSC::FuncExprNode::body):
(JSC::FuncDeclNode::body):
* parser/Parser.h:
(JSC::Parser::isFunctionMetadataNode):
(JSC::Parser::next):
(JSC::Parser<LexerType>::parse):
(JSC::Parser::isFunctionBodyNode): Deleted.
* runtime/CodeCache.cpp:
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):
* runtime/CodeCache.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (188218 => 188219)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-10 20:24:35 UTC (rev 188219)
@@ -1,3 +1,69 @@
+2015-08-07  Geoffrey Garen  <[email protected]>
+
+        Let's rename FunctionBodyNode
+        https://bugs.webkit.org/show_bug.cgi?id=147292
+
+        Reviewed by Mark Lam & Saam Barati.
+
+        FunctionBodyNode => FunctionMetadataNode
+
+        Make FunctionMetadataNode inherit from Node instead of StatementNode
+        because a FunctionMetadataNode can appear in _expression_ context and does
+        not have a next statement.
+
+        (I decided to continue allocating FunctionMetadataNode in the AST arena,
+        and to retain "Node" in its name, because it really is a parsing
+        construct, and we transform its data before consuming it elsewhere.
+
+        There is still room for a future patch to distill and simplify the
+        metadata we track about functions between FunDeclNode/FuncExprNode,
+        FunctionMetadataNode, and UnlinkedFunctionExecutable. But this is a start.)
+
+        * builtins/BuiltinExecutables.cpp:
+        (JSC::BuiltinExecutables::createExecutableInternal):
+        * bytecode/UnlinkedCodeBlock.cpp:
+        (JSC::generateFunctionCodeBlock):
+        (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
+        * bytecode/UnlinkedCodeBlock.h:
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::generate):
+        (JSC::BytecodeGenerator::BytecodeGenerator):
+        (JSC::BytecodeGenerator::emitNewArray):
+        (JSC::BytecodeGenerator::emitNewFunction):
+        (JSC::BytecodeGenerator::emitNewFunctionExpression):
+        * bytecompiler/BytecodeGenerator.h:
+        (JSC::BytecodeGenerator::makeFunction):
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::EvalNode::emitBytecode):
+        (JSC::FunctionNode::emitBytecode):
+        (JSC::FunctionBodyNode::emitBytecode): Deleted.
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::createFunctionExpr):
+        (JSC::ASTBuilder::createFunctionBody):
+        * parser/NodeConstructors.h:
+        (JSC::FunctionParameters::FunctionParameters):
+        (JSC::FuncExprNode::FuncExprNode):
+        (JSC::FuncDeclNode::FuncDeclNode):
+        * parser/Nodes.cpp:
+        (JSC::EvalNode::EvalNode):
+        (JSC::FunctionMetadataNode::FunctionMetadataNode):
+        (JSC::FunctionMetadataNode::finishParsing):
+        (JSC::FunctionMetadataNode::setEndPosition):
+        (JSC::FunctionBodyNode::FunctionBodyNode): Deleted.
+        (JSC::FunctionBodyNode::finishParsing): Deleted.
+        (JSC::FunctionBodyNode::setEndPosition): Deleted.
+        * parser/Nodes.h:
+        (JSC::FuncExprNode::body):
+        (JSC::FuncDeclNode::body):
+        * parser/Parser.h:
+        (JSC::Parser::isFunctionMetadataNode):
+        (JSC::Parser::next):
+        (JSC::Parser<LexerType>::parse):
+        (JSC::Parser::isFunctionBodyNode): Deleted.
+        * runtime/CodeCache.cpp:
+        (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
+        * runtime/CodeCache.h:
+
 2015-08-09  Chris Dumez  <[email protected]>
 
         Regression(r188105): Seems to have caused crashes during PLT on some iPads

Modified: trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -84,16 +84,16 @@
     ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
     RELEASE_ASSERT(funcExpr);
     RELEASE_ASSERT(funcExpr->isFuncExprNode());
-    FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
+    FunctionMetadataNode* metadata = static_cast<FuncExprNode*>(funcExpr)->metadata();
     RELEASE_ASSERT(!program->hasCapturedVariables());
     
-    body->setEndPosition(positionBeforeLastNewline);
-    RELEASE_ASSERT(body);
-    RELEASE_ASSERT(body->ident().isNull());
+    metadata->setEndPosition(positionBeforeLastNewline);
+    RELEASE_ASSERT(metadata);
+    RELEASE_ASSERT(metadata->ident().isNull());
     
     // This function assumes an input string that would result in a single anonymous function _expression_.
-    body->setEndPosition(positionBeforeLastNewline);
-    RELEASE_ASSERT(body);
+    metadata->setEndPosition(positionBeforeLastNewline);
+    RELEASE_ASSERT(metadata);
     for (const auto& closedVariable : program->closedVariables()) {
         if (closedVariable == m_vm.propertyNames->arguments.impl())
             continue;
@@ -101,9 +101,9 @@
         if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl())
             continue;
     }
-    body->overrideName(name);
+    metadata->overrideName(name);
     VariableEnvironment dummyTDZVariables;
-    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&m_vm, source, body, kind, constructAbility, dummyTDZVariables, WTF::move(sourceOverride));
+    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&m_vm, source, metadata, kind, constructAbility, dummyTDZVariables, WTF::move(sourceOverride));
     functionExecutable->m_nameValue.set(m_vm, functionExecutable, jsString(&m_vm, name.string()));
     return functionExecutable;
 }

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -80,7 +80,7 @@
     return result;
 }
 
-UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionBodyNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables)
+UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables)
     : Base(*vm, structure)
     , m_name(node->ident())
     , m_inferredName(node->inferredName())

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (188218 => 188219)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -48,7 +48,7 @@
 namespace JSC {
 
 class Debugger;
-class FunctionBodyNode;
+class FunctionMetadataNode;
 class FunctionExecutable;
 class JSScope;
 class ParserError;
@@ -108,7 +108,7 @@
     typedef JSCell Base;
     static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
 
-    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionBodyNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, RefPtr<SourceProvider>&& sourceOverride = nullptr)
+    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, RefPtr<SourceProvider>&& sourceOverride = nullptr)
     {
         UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap))
             UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, parentScopeTDZVariables);
@@ -168,7 +168,7 @@
     const VariableEnvironment* parentScopeTDZVariables() const { return &m_parentScopeTDZVariables; }
 
 private:
-    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionBodyNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&);
+    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&);
     WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForCall;
     WriteBarrier<UnlinkedFunctionCodeBlock> m_codeBlockForConstruct;
 

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -76,13 +76,13 @@
         RefPtr<RegisterID> temp = newTemporary();
         RefPtr<RegisterID> globalScope = m_topMostScope;
         for (auto functionPair : m_functionsToInitialize) {
-            FunctionBodyNode* functionBody = functionPair.first;
+            FunctionMetadataNode* metadata = functionPair.first;
             FunctionVariableType functionType = functionPair.second;
-            emitNewFunction(temp.get(), functionBody);
+            emitNewFunction(temp.get(), metadata);
             if (functionType == NormalFunctionVariable)
-                initializeVariable(variable(functionBody->ident()) , temp.get());
+                initializeVariable(variable(metadata->ident()) , temp.get());
             else if (functionType == GlobalFunctionVariable)
-                emitPutToScope(globalScope.get(), Variable(functionBody->ident()), temp.get(), ThrowIfNotFound);
+                emitPutToScope(globalScope.get(), Variable(metadata->ident()), temp.get(), ThrowIfNotFound);
             else
                 RELEASE_ASSERT_NOT_REACHED();
         }
@@ -162,7 +162,7 @@
     const FunctionStack& functionStack = programNode->functionStack();
 
     for (size_t i = 0; i < functionStack.size(); ++i) {
-        FunctionBodyNode* function = functionStack[i];
+        FunctionMetadataNode* function = functionStack[i];
         m_functionsToInitialize.append(std::make_pair(function, GlobalFunctionVariable));
     }
     if (Options::validateBytecode()) {
@@ -271,7 +271,7 @@
 
     // Need to know what our functions are called. Parameters have some goofy behaviors when it
     // comes to functions of the same name.
-    for (FunctionBodyNode* function : functionNode->functionStack())
+    for (FunctionMetadataNode* function : functionNode->functionStack())
         m_functions.add(function->ident().impl());
     
     if (needsArguments) {
@@ -378,7 +378,7 @@
         ASSERT(!parameters.hasDefaultParameterValues());
         createVariable(ident, varKind(ident.impl()), functionSymbolTable);
     }
-    for (FunctionBodyNode* function : functionNode->functionStack()) {
+    for (FunctionMetadataNode* function : functionNode->functionStack()) {
         const Identifier& ident = function->ident();
         createVariable(ident, varKind(ident.impl()), functionSymbolTable);
         m_functionsToInitialize.append(std::make_pair(function, NormalFunctionVariable));
@@ -2232,7 +2232,7 @@
     return dst;
 }
 
-RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* function)
+RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionMetadataNode* function)
 {
     return emitNewFunctionInternal(dst, m_codeBlock->addFunctionDecl(makeFunction(function)));
 }
@@ -2256,8 +2256,8 @@
 
 RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n)
 {
-    FunctionBodyNode* function = n->body();
-    unsigned index = m_codeBlock->addFunctionExpr(makeFunction(function));
+    FunctionMetadataNode* metadata = n->metadata();
+    unsigned index = m_codeBlock->addFunctionExpr(makeFunction(metadata));
 
     emitOpcode(op_new_func_exp);
     instructions().append(r0->index());

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (188218 => 188219)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -477,7 +477,7 @@
         RegisterID* emitNewObject(RegisterID* dst);
         RegisterID* emitNewArray(RegisterID* dst, ElementNode*, unsigned length); // stops at first elision
 
-        RegisterID* emitNewFunction(RegisterID* dst, FunctionBodyNode*);
+        RegisterID* emitNewFunction(RegisterID* dst, FunctionMetadataNode*);
         RegisterID* emitNewFunctionInternal(RegisterID* dst, unsigned index);
         RegisterID* emitNewFunctionExpression(RegisterID* dst, FuncExprNode* func);
         RegisterID* emitNewDefaultConstructor(RegisterID* dst, ConstructorKind, const Identifier& name);
@@ -712,17 +712,17 @@
 
         unsigned addConstantBuffer(unsigned length);
         
-        UnlinkedFunctionExecutable* makeFunction(FunctionBodyNode* body)
+        UnlinkedFunctionExecutable* makeFunction(FunctionMetadataNode* metadata)
         {
             VariableEnvironment variablesUnderTDZ;
             getVariablesUnderTDZ(variablesUnderTDZ);
 
-            FunctionParseMode parseMode = body->parseMode();
+            FunctionParseMode parseMode = metadata->parseMode();
             ConstructAbility constructAbility = ConstructAbility::CanConstruct;
-            if (parseMode == GetterMode || parseMode == SetterMode || parseMode == ArrowFunctionMode || (parseMode == MethodMode && body->constructorKind() == ConstructorKind::None))
+            if (parseMode == GetterMode || parseMode == SetterMode || parseMode == ArrowFunctionMode || (parseMode == MethodMode && metadata->constructorKind() == ConstructorKind::None))
                 constructAbility = ConstructAbility::CannotConstruct;
 
-            return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), body, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, variablesUnderTDZ);
+            return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, variablesUnderTDZ);
         }
 
         void getVariablesUnderTDZ(VariableEnvironment&);
@@ -792,7 +792,7 @@
         Vector<std::unique_ptr<ForInContext>> m_forInContextStack;
         Vector<TryContext> m_tryContextStack;
         enum FunctionVariableType : uint8_t { NormalFunctionVariable, GlobalFunctionVariable };
-        Vector<std::pair<FunctionBodyNode*, FunctionVariableType>> m_functionsToInitialize;
+        Vector<std::pair<FunctionMetadataNode*, FunctionVariableType>> m_functionsToInitialize;
         bool m_needToInitializeArguments { false };
         
         Vector<TryRange> m_tryRanges;
@@ -800,7 +800,7 @@
 
         int m_nextConstantOffset { 0 };
 
-        typedef HashMap<FunctionBodyNode*, unsigned> FunctionOffsetMap;
+        typedef HashMap<FunctionMetadataNode*, unsigned> FunctionOffsetMap;
         FunctionOffsetMap m_functionOffsets;
         
         // Constant pool

Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -2907,12 +2907,8 @@
     generator.emitEnd(dstRegister.get());
 }
 
-// ------------------------------ FunctionBodyNode -----------------------------
+// ------------------------------ FunctionNode -----------------------------
 
-void FunctionBodyNode::emitBytecode(BytecodeGenerator&, RegisterID*)
-{
-}
-
 void FunctionNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
 {
     if (generator.vm()->typeProfiler()) {

Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/ASTBuilder.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -109,7 +109,7 @@
     typedef TemplateLiteralNode* TemplateLiteral;
 #endif
     typedef FunctionParameters* FormalParameterList;
-    typedef FunctionBodyNode* FunctionBody;
+    typedef FunctionMetadataNode* FunctionBody;
 #if ENABLE(ES6_CLASS_SYNTAX)
     typedef ClassExprNode* ClassExpression;
 #endif
@@ -336,7 +336,7 @@
     ExpressionNode* createAssignResolve(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* rhs, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end, AssignmentContext assignmentContext)
     {
         if (rhs->isFuncExprNode())
-            static_cast<FuncExprNode*>(rhs)->body()->setInferredName(ident);
+            static_cast<FuncExprNode*>(rhs)->metadata()->setInferredName(ident);
         AssignResolveNode* node = new (m_parserArena) AssignResolveNode(location, ident, rhs, assignmentContext);
         setExceptionLocation(node, start, divot, end);
         return node;
@@ -358,13 +358,13 @@
         return result;
     }
 
-    FunctionBodyNode* createFunctionBody(
+    FunctionMetadataNode* createFunctionMetadata(
         const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, 
         unsigned startColumn, unsigned endColumn, int functionKeywordStart, 
         int functionNameStart, int parametersStart, bool inStrictContext, 
         ConstructorKind constructorKind, unsigned parameterCount, FunctionParseMode mode)
     {
-        return new (m_parserArena) FunctionBodyNode(
+        return new (m_parserArena) FunctionMetadataNode(
             m_parserArena, startLocation, endLocation, startColumn, endColumn, 
             functionKeywordStart, functionNameStart, parametersStart, 
             inStrictContext, constructorKind, parameterCount, mode);
@@ -408,7 +408,7 @@
     PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding = SuperBinding::NotNeeded)
     {
         if (node->isFuncExprNode())
-            static_cast<FuncExprNode*>(node)->body()->setInferredName(*propertyName);
+            static_cast<FuncExprNode*>(node)->metadata()->setInferredName(*propertyName);
         return new (m_parserArena) PropertyNode(*propertyName, node, type, putType, superBinding);
     }
     PropertyNode* createProperty(VM* vm, ParserArena& parserArena, double propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool)
@@ -438,7 +438,7 @@
             m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn));
         if (*functionInfo.name == m_vm->propertyNames->arguments)
             usesArguments();
-        m_scope.m_funcDeclarations.append(decl->body());
+        m_scope.m_funcDeclarations.append(decl->metadata());
         functionInfo.body->setLoc(functionInfo.startLine, functionInfo.endLine, location.startOffset, location.lineStartOffset);
         return decl;
     }
@@ -1211,7 +1211,7 @@
         ResolveNode* resolve = static_cast<ResolveNode*>(loc);
         if (op == OpEqual) {
             if (expr->isFuncExprNode())
-                static_cast<FuncExprNode*>(expr)->body()->setInferredName(resolve->identifier());
+                static_cast<FuncExprNode*>(expr)->metadata()->setInferredName(resolve->identifier());
             AssignResolveNode* node = new (m_parserArena) AssignResolveNode(location, resolve->identifier(), expr, AssignmentContext::AssignmentExpression);
             setExceptionLocation(node, start, divot, end);
             return node;
@@ -1230,7 +1230,7 @@
     DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
     if (op == OpEqual) {
         if (expr->isFuncExprNode())
-            static_cast<FuncExprNode*>(expr)->body()->setInferredName(dot->identifier());
+            static_cast<FuncExprNode*>(expr)->metadata()->setInferredName(dot->identifier());
         return new (m_parserArena) AssignDotNode(location, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), start, end);
     }
 

Modified: trunk/Source/_javascript_Core/parser/NodeConstructors.h (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/NodeConstructors.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/NodeConstructors.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -884,18 +884,18 @@
     {
     }
 
-    inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source)
+    inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* m_metadata, const SourceCode& source)
         : ExpressionNode(location)
-        , m_body(body)
+        , m_metadata(m_metadata)
     {
-        m_body->finishParsing(source, ident, FunctionExpression);
+        m_metadata->finishParsing(source, ident, FunctionExpression);
     }
 
-    inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source)
+    inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* m_metadata, const SourceCode& source)
         : StatementNode(location)
-        , m_body(body)
+        , m_metadata(m_metadata)
     {
-        m_body->finishParsing(source, ident, FunctionDeclaration);
+        m_metadata->finishParsing(source, ident, FunctionDeclaration);
     }
 
 #if ENABLE(ES6_CLASS_SYNTAX)

Modified: trunk/Source/_javascript_Core/parser/Nodes.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/Nodes.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/Nodes.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -145,14 +145,14 @@
 {
 }
 
-// ------------------------------ FunctionBodyNode -----------------------------
+// ------------------------------ FunctionMetadataNode -----------------------------
 
-FunctionBodyNode::FunctionBodyNode(
+FunctionMetadataNode::FunctionMetadataNode(
     ParserArena&, const JSTokenLocation& startLocation, 
     const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, 
     int functionKeywordStart, int functionNameStart, int parametersStart, bool isInStrictContext, 
     ConstructorKind constructorKind, unsigned parameterCount, FunctionParseMode mode)
-        : StatementNode(endLocation)
+        : Node(endLocation)
         , m_startColumn(startColumn)
         , m_endColumn(endColumn)
         , m_functionKeywordStart(functionKeywordStart)
@@ -167,14 +167,14 @@
     ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
 }
 
-void FunctionBodyNode::finishParsing(const SourceCode& source, const Identifier& ident, enum FunctionMode functionMode)
+void FunctionMetadataNode::finishParsing(const SourceCode& source, const Identifier& ident, enum FunctionMode functionMode)
 {
     m_source = source;
     m_ident = ident;
     m_functionMode = functionMode;
 }
 
-void FunctionBodyNode::setEndPosition(JSTextPosition position)
+void FunctionMetadataNode::setEndPosition(JSTextPosition position)
 {
     m_lastLine = position.line;
     m_endColumn = position.offset - position.lineStartOffset;

Modified: trunk/Source/_javascript_Core/parser/Nodes.h (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/Nodes.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/Nodes.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -41,7 +41,7 @@
 
     class ArgumentListNode;
     class BytecodeGenerator;
-    class FunctionBodyNode;
+    class FunctionMetadataNode;
     class FunctionParameters;
     class Label;
     class PropertyListNode;
@@ -81,7 +81,7 @@
     typedef HashSet<RefPtr<UniquedStringImpl>, IdentifierRepHash> IdentifierSet;
 
     namespace DeclarationStacks {
-        typedef Vector<FunctionBodyNode*> FunctionStack;
+        typedef Vector<FunctionMetadataNode*> FunctionStack;
     }
 
     struct SwitchInfo {
@@ -1779,18 +1779,16 @@
         bool m_hasDefaultParameterValues { false };
     };
 
-    class FunctionBodyNode final : public StatementNode, public ParserArenaDeletable {
+    class FunctionMetadataNode final : public Node, public ParserArenaDeletable {
     public:
         using ParserArenaDeletable::operator new;
 
-        FunctionBodyNode(
+        FunctionMetadataNode(
             ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, 
             unsigned startColumn, unsigned endColumn, int functionKeywordStart, 
             int functionNameStart, int parametersStart, bool isInStrictContext, 
             ConstructorKind, unsigned, FunctionParseMode);
 
-        virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
-
         void finishParsing(const SourceCode&, const Identifier&, FunctionMode);
         
         void overrideName(const Identifier& ident) { m_ident = ident; }
@@ -1816,6 +1814,14 @@
         bool isInStrictContext() const { return m_isInStrictContext; }
         ConstructorKind constructorKind() { return static_cast<ConstructorKind>(m_constructorKind); }
 
+        void setLoc(unsigned firstLine, unsigned lastLine, int startOffset, int lineStartOffset)
+        {
+            m_lastLine = lastLine;
+            m_position = JSTextPosition(firstLine, startOffset, lineStartOffset);
+            ASSERT(m_position.offset >= m_position.lineStartOffset);
+        }
+        unsigned lastLine() const { return m_lastLine; }
+
     protected:
         Identifier m_ident;
         Identifier m_inferredName;
@@ -1828,6 +1834,7 @@
         SourceCode m_source;
         int m_startStartOffset;
         unsigned m_parameterCount;
+        int m_lastLine;
         FunctionParseMode m_parseMode;
         unsigned m_isInStrictContext : 1;
         unsigned m_constructorKind : 2;
@@ -1862,16 +1869,16 @@
 
     class FuncExprNode : public ExpressionNode {
     public:
-        FuncExprNode(const JSTokenLocation&, const Identifier&, FunctionBodyNode*, const SourceCode&);
+        FuncExprNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&);
 
-        FunctionBodyNode* body() { return m_body; }
+        FunctionMetadataNode* metadata() { return m_metadata; }
 
     private:
         virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
 
         virtual bool isFuncExprNode() const override { return true; }
 
-        FunctionBodyNode* m_body;
+        FunctionMetadataNode* m_metadata;
     };
 
 #if ENABLE(ES6_CLASS_SYNTAX)
@@ -1997,15 +2004,15 @@
 
     class FuncDeclNode : public StatementNode {
     public:
-        FuncDeclNode(const JSTokenLocation&, const Identifier&, FunctionBodyNode*, const SourceCode&);
+        FuncDeclNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&);
 
         virtual bool isFuncDeclNode() const override { return true; }
-        FunctionBodyNode* body() { return m_body; }
+        FunctionMetadataNode* metadata() { return m_metadata; }
 
     private:
         virtual void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
 
-        FunctionBodyNode* m_body;
+        FunctionMetadataNode* m_metadata;
     };
 
 #if ENABLE(ES6_CLASS_SYNTAX)

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -1536,7 +1536,7 @@
         next();
         if (match(CLOSEBRACE)) {
             unsigned endColumn = tokenColumn();
-            return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, parameterCount, parseMode);
+            return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, parameterCount, parseMode);
         }
     }
 
@@ -1548,7 +1548,7 @@
     else
         failIfFalse(parseSourceElements(syntaxChecker, CheckForStrictMode), bodyType == StandardFunctionBodyBlock ? "Cannot parse body of this function" : "Cannot parse body of this arrow function");
     unsigned endColumn = tokenColumn();
-    return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, parameterCount, parseMode);
+    return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, parameterCount, parseMode);
 }
 
 static const char* stringForFunctionMode(FunctionParseMode mode)
@@ -1741,7 +1741,7 @@
             endLocation.startOffset - endLocation.lineStartOffset;
         unsigned currentLineStartOffset = m_token.m_location.lineStartOffset;
 
-        functionInfo.body = context.createFunctionBody(
+        functionInfo.body = context.createFunctionMetadata(
             startLocation, endLocation, functionInfo.bodyStartColumn, bodyEndColumn, 
             functionKeywordStart, functionNameStart, parametersStart, 
             cachedInfo->strictMode, constructorKind, cachedInfo->parameterCount, mode);

Modified: trunk/Source/_javascript_Core/parser/Parser.h (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/Parser.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -53,7 +53,7 @@
 namespace JSC {
 
 class ExecState;
-class FunctionBodyNode;
+class FunctionMetadataNode;
 class FunctionParameters;
 class Identifier;
 class VM;
@@ -838,8 +838,8 @@
     void didFinishParsing(SourceElements*, DeclarationStacks::FunctionStack&, VariableEnvironment&, CodeFeatures, int, const Vector<RefPtr<UniquedStringImpl>>&&);
 
     // Used to determine type of error to report.
-    bool isFunctionBodyNode(ScopeNode*) { return false; }
-    bool isFunctionBodyNode(FunctionBodyNode*) { return true; }
+    bool isFunctionMetadataNode(ScopeNode*) { return false; }
+    bool isFunctionMetadataNode(FunctionMetadataNode*) { return true; }
 
     ALWAYS_INLINE void next(unsigned lexerFlags = 0)
     {
@@ -1315,7 +1315,7 @@
         // we ran out of stack while parsing. If we see an error while parsing eval or program
         // code we assume that it was a syntax error since running out of stack is much less
         // likely, and we are currently unable to distinguish between the two cases.
-        if (isFunctionBodyNode(static_cast<ParsedNode*>(0)) || m_hasStackOverflow)
+        if (isFunctionMetadataNode(static_cast<ParsedNode*>(0)) || m_hasStackOverflow)
             error = ParserError(ParserError::StackOverflow, ParserError::SyntaxErrorNone, m_token);
         else {
             ParserError::SyntaxErrorType errorType = ParserError::SyntaxErrorIrrecoverable;

Modified: trunk/Source/_javascript_Core/parser/SyntaxChecker.h (188218 => 188219)


--- trunk/Source/_javascript_Core/parser/SyntaxChecker.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/parser/SyntaxChecker.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -186,7 +186,7 @@
     ClassExpression createClassExpr(const JSTokenLocation&, const Identifier&, ExpressionType, ExpressionType, PropertyList, PropertyList) { return ClassExpr; }
 #endif
     ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
-    int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, unsigned, int) { return FunctionBodyResult; }
+    int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, unsigned, int) { return FunctionBodyResult; }
     ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
     void setFunctionNameStart(int, int) { }
     int createArguments() { return ArgumentsResult; }

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (188218 => 188219)


--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2015-08-10 20:24:35 UTC (rev 188219)
@@ -166,15 +166,15 @@
     if (!funcDecl || !funcDecl->isFuncDeclNode())
         return nullptr;
 
-    FunctionBodyNode* body = static_cast<FuncDeclNode*>(funcDecl)->body();
-    ASSERT(body);
-    if (!body)
+    FunctionMetadataNode* metadata = static_cast<FuncDeclNode*>(funcDecl)->metadata();
+    ASSERT(metadata);
+    if (!metadata)
         return nullptr;
     
-    body->setEndPosition(positionBeforeLastNewline);
+    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, body, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables);
+    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables);
     functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string()));
 
     m_sourceCode.addCache(key, SourceCodeValue(vm, functionExecutable, m_sourceCode.age()));

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (188218 => 188219)


--- trunk/Source/_javascript_Core/runtime/CodeCache.h	2015-08-10 19:18:50 UTC (rev 188218)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h	2015-08-10 20:24:35 UTC (rev 188219)
@@ -40,7 +40,7 @@
 namespace JSC {
 
 class EvalExecutable;
-class FunctionBodyNode;
+class FunctionMetadataNode;
 class Identifier;
 class JSScope;
 class ParserError;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to