Split out FunctionNode from FunctionBodyNode
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Dec 2014 23:47:49 +0000 (23:47 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Dec 2014 23:47:49 +0000 (23:47 +0000)
commitd14f013a9d9547a4aee559ad4d261e2e9f11ce24
treebd34f536988a50335dfc47e5a2bc1a3ae699bfbf
parent0251a625cb28ea47772dfb153db333cd73323a67
Split out FunctionNode from FunctionBodyNode
https://bugs.webkit.org/show_bug.cgi?id=139273

Reviewed by Andreas Kling.

This is step toward a parser speedup.

We used to use FunctionBodyNode for two different purposes:

(1) "I am the root function you are currently parsing";

(2) "I am a lazy record of a nested function, which you will parse later".

This made for awkward lifetime semantics and interfaces.

Now, case (1) is handled by FunctionBodyNode, and case (2) is handled by
a new node named FunctionNode.

Since case (1) no longer needs to handle being the root of the parse
tree, FunctionBodyNode can be a normal arena-allocated node.

* bytecode/UnlinkedCodeBlock.cpp:
(JSC::generateFunctionCodeBlock): Use FunctionNode instead of
FunctionBodyNode, since we are producing the root of the function parse
tree.

(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): Removed
some unused data, and default-initialized other data, which isn't filled
in meaningfully until recordParse() is called. (The previous values were
incorrect / meaningless, since the FunctionBodyNode didn't have
meaningful values in this case.)

* bytecode/UnlinkedCodeBlock.h: Ditto.

(JSC::UnlinkedFunctionExecutable::forceUsesArguments): Deleted.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator): Use FunctionNode instead of
FunctionBodyNode, since we are generating code starting at the root of
the parse tree.

(JSC::BytecodeGenerator::resolveCallee):
(JSC::BytecodeGenerator::addCallee):
* bytecompiler/BytecodeGenerator.h: Ditto.

* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionBodyNode::emitBytecode):
(JSC::FunctionNode::emitBytecode): Moved the emitBytecode implementation
to FunctionNode, since we never generate code for FunctionBodyNode,
since it's just a placeholder in the AST.

* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionBody):
(JSC::ASTBuilder::setUsesArguments): Deleted. Updated for interface
changes.

* parser/Nodes.cpp:
(JSC::FunctionBodyNode::FunctionBodyNode):
(JSC::FunctionBodyNode::finishParsing):
(JSC::FunctionBodyNode::setEndPosition):
(JSC::FunctionNode::FunctionNode):
(JSC::FunctionNode::create):
(JSC::FunctionNode::finishParsing):
(JSC::FunctionBodyNode::create): Deleted.

* parser/Nodes.h:
(JSC::FunctionBodyNode::parameters):
(JSC::FunctionBodyNode::source):
(JSC::FunctionBodyNode::startStartOffset):
(JSC::FunctionBodyNode::isInStrictContext):
(JSC::FunctionNode::parameters):
(JSC::FunctionNode::ident):
(JSC::FunctionNode::functionMode):
(JSC::FunctionNode::startColumn):
(JSC::FunctionNode::endColumn):
(JSC::ScopeNode::setSource): Deleted.
(JSC::FunctionBodyNode::parameterCount): Deleted. Split out the differences
between FunctionNode and FunctionBodyNode.

* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createClauseList):
(JSC::SyntaxChecker::setUsesArguments): Deleted. Removed setUsesArguments
since it wasn't used.

* runtime/Executable.cpp:
(JSC::ProgramExecutable::checkSyntax): Removed a branch that was always
false.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176822 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/Nodes.cpp
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/SyntaxChecker.h
Source/JavaScriptCore/runtime/Executable.cpp