DFG should support activations and nested functions
https://bugs.webkit.org/show_bug.cgi?id=79554
Reviewed by Oliver Hunt.
Wrote the simplest possible implementation of activations. Big speed-up on
code that uses activations, no speed-up on major benchmarks (SunSpider, V8,
Kraken) because they do not appear to have sufficient coverage over code
that uses activations.
* bytecode/PredictedType.cpp:
(JSC::predictionToString):
(JSC::predictionFromValue):
* bytecode/PredictedType.h:
(JSC):
(JSC::isEmptyPrediction):
* dfg/DFGAbstractState.cpp:
(JSC::DFG::AbstractState::execute):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::ByteCodeParser):
(ByteCodeParser):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::buildOperandMapsIfNecessary):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
(JSC::DFG::ByteCodeParser::parse):
* dfg/DFGCapabilities.h:
(JSC::DFG::canCompileOpcode):
(JSC::DFG::canInlineOpcode):
* dfg/DFGGraph.h:
(JSC::DFG::Graph::needsActivation):
* dfg/DFGNode.h:
(DFG):
(JSC::DFG::Node::storageAccessDataIndex):
(Node):
(JSC::DFG::Node::hasFunctionDeclIndex):
(JSC::DFG::Node::functionDeclIndex):
(JSC::DFG::Node::hasFunctionExprIndex):
(JSC::DFG::Node::functionExprIndex):
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileNewFunctionNoCheck):
(DFG):
(JSC::DFG::SpeculativeJIT::compileNewFunctionExpression):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp
index 165a214..efbf972 100644
--- a/Source/JavaScriptCore/dfg/DFGOperations.cpp
+++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp
@@ -33,8 +33,10 @@
#include "GetterSetter.h"
#include "InlineASM.h"
#include "Interpreter.h"
+#include "JSActivation.h"
#include "JSByteArray.h"
#include "JSGlobalData.h"
+#include "JSStaticScopeObject.h"
#include "Operations.h"
#if ENABLE(DFG_JIT)
@@ -974,6 +976,43 @@
return JSValue::encode(RegExpObject::create(exec->globalData(), exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regexp));
}
+JSCell* DFG_OPERATION operationCreateActivation(ExecState* exec)
+{
+ JSGlobalData& globalData = exec->globalData();
+ JSActivation* activation = JSActivation::create(
+ globalData, exec, static_cast<FunctionExecutable*>(exec->codeBlock()->ownerExecutable()));
+ exec->setScopeChain(exec->scopeChain()->push(activation));
+ return activation;
+}
+
+void DFG_OPERATION operationTearOffActivation(ExecState* exec, JSCell* activation)
+{
+ ASSERT(activation);
+ ASSERT(activation->inherits(&JSActivation::s_info));
+ static_cast<JSActivation*>(activation)->tearOff(exec->globalData());
+}
+
+JSCell* DFG_OPERATION operationNewFunction(ExecState* exec, JSCell* functionExecutable)
+{
+ ASSERT(functionExecutable->inherits(&FunctionExecutable::s_info));
+ return static_cast<FunctionExecutable*>(functionExecutable)->make(exec, exec->scopeChain());
+}
+
+JSCell* DFG_OPERATION operationNewFunctionExpression(ExecState* exec, JSCell* functionExecutableAsCell)
+{
+ ASSERT(functionExecutableAsCell->inherits(&FunctionExecutable::s_info));
+ FunctionExecutable* functionExecutable =
+ static_cast<FunctionExecutable*>(functionExecutableAsCell);
+ JSFunction *function = functionExecutable->make(exec, exec->scopeChain());
+ if (!functionExecutable->name().isNull()) {
+ JSStaticScopeObject* functionScopeObject =
+ JSStaticScopeObject::create(
+ exec, functionExecutable->name(), function, ReadOnly | DontDelete);
+ function->setScope(exec->globalData(), function->scope()->push(functionScopeObject));
+ }
+ return function;
+}
+
DFGHandlerEncoded DFG_OPERATION lookupExceptionHandler(ExecState* exec, uint32_t callIndex)
{
JSGlobalData* globalData = &exec->globalData();