Title: [188136] trunk/Source/_javascript_Core
Revision
188136
Author
[email protected]
Date
2015-08-07 10:41:22 -0700 (Fri, 07 Aug 2015)

Log Message

Interpreter::unwind shouldn't be responsible for assigning the correct scope.
https://bugs.webkit.org/show_bug.cgi?id=147666

Reviewed by Geoffrey Garen.

If we make the bytecode generator know about every local scope it
creates, and if we give each local scope a unique register, the
bytecode generator has all the information it needs to assign
the correct scope to a catch handler. Because the bytecode generator
knows this information, it's a better separation of responsibilties
for it to set up the proper scope instead of relying on the exception
handling runtime to find the scope.

* bytecode/BytecodeList.json:
* bytecode/BytecodeUseDef.h:
(JSC::computeUsesForBytecodeOffset):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::CodeBlock):
* bytecode/HandlerInfo.h:
(JSC::UnlinkedHandlerInfo::UnlinkedHandlerInfo):
(JSC::HandlerInfo::initialize):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::pushLexicalScopeInternal):
(JSC::BytecodeGenerator::emitGetScope):
(JSC::BytecodeGenerator::emitPushWithScope):
(JSC::BytecodeGenerator::emitGetParentScope):
(JSC::BytecodeGenerator::emitPopScope):
(JSC::BytecodeGenerator::emitPopWithScope):
(JSC::BytecodeGenerator::allocateAndEmitScope):
(JSC::BytecodeGenerator::emitComplexPopScopes):
(JSC::BytecodeGenerator::pushTry):
(JSC::BytecodeGenerator::popTryAndEmitCatch):
(JSC::BytecodeGenerator::localScopeDepth):
(JSC::BytecodeGenerator::calculateTargetScopeDepthForExceptionHandler): Deleted.
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::WithNode::emitBytecode):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::unwind):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_push_with_scope):
(JSC::JIT::compileOpStrictEq):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_push_with_scope):
(JSC::JIT::emit_op_to_number):
* jit/JITOperations.cpp:
* jit/JITOperations.h:
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* llint/LLIntSlowPaths.h:
* llint/LowLevelInterpreter.asm:
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):
* runtime/CommonSlowPaths.h:
* runtime/JSScope.cpp:
(JSC::JSScope::objectAtScope):
(JSC::isUnscopable):
(JSC::JSScope::depth): Deleted.
* runtime/JSScope.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (188135 => 188136)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-07 17:41:22 UTC (rev 188136)
@@ -1,3 +1,67 @@
+2015-08-07  Saam barati  <[email protected]>
+
+        Interpreter::unwind shouldn't be responsible for assigning the correct scope.
+        https://bugs.webkit.org/show_bug.cgi?id=147666
+
+        Reviewed by Geoffrey Garen.
+
+        If we make the bytecode generator know about every local scope it 
+        creates, and if we give each local scope a unique register, the
+        bytecode generator has all the information it needs to assign
+        the correct scope to a catch handler. Because the bytecode generator
+        knows this information, it's a better separation of responsibilties
+        for it to set up the proper scope instead of relying on the exception
+        handling runtime to find the scope.
+
+        * bytecode/BytecodeList.json:
+        * bytecode/BytecodeUseDef.h:
+        (JSC::computeUsesForBytecodeOffset):
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::dumpBytecode):
+        (JSC::CodeBlock::CodeBlock):
+        * bytecode/HandlerInfo.h:
+        (JSC::UnlinkedHandlerInfo::UnlinkedHandlerInfo):
+        (JSC::HandlerInfo::initialize):
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::generate):
+        (JSC::BytecodeGenerator::pushLexicalScopeInternal):
+        (JSC::BytecodeGenerator::emitGetScope):
+        (JSC::BytecodeGenerator::emitPushWithScope):
+        (JSC::BytecodeGenerator::emitGetParentScope):
+        (JSC::BytecodeGenerator::emitPopScope):
+        (JSC::BytecodeGenerator::emitPopWithScope):
+        (JSC::BytecodeGenerator::allocateAndEmitScope):
+        (JSC::BytecodeGenerator::emitComplexPopScopes):
+        (JSC::BytecodeGenerator::pushTry):
+        (JSC::BytecodeGenerator::popTryAndEmitCatch):
+        (JSC::BytecodeGenerator::localScopeDepth):
+        (JSC::BytecodeGenerator::calculateTargetScopeDepthForExceptionHandler): Deleted.
+        * bytecompiler/BytecodeGenerator.h:
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::WithNode::emitBytecode):
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::unwind):
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::emit_op_push_with_scope):
+        (JSC::JIT::compileOpStrictEq):
+        * jit/JITOpcodes32_64.cpp:
+        (JSC::JIT::emit_op_push_with_scope):
+        (JSC::JIT::emit_op_to_number):
+        * jit/JITOperations.cpp:
+        * jit/JITOperations.h:
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+        * llint/LLIntSlowPaths.h:
+        * llint/LowLevelInterpreter.asm:
+        * runtime/CommonSlowPaths.cpp:
+        (JSC::SLOW_PATH_DECL):
+        * runtime/CommonSlowPaths.h:
+        * runtime/JSScope.cpp:
+        (JSC::JSScope::objectAtScope):
+        (JSC::isUnscopable):
+        (JSC::JSScope::depth): Deleted.
+        * runtime/JSScope.h:
+
 2015-08-07  Yusuke Suzuki  <[email protected]>
 
         Add MacroAssembler::patchableBranch64 and fix ARM64's patchableBranchPtr

Modified: trunk/Source/_javascript_Core/bytecode/BytecodeList.json (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecode/BytecodeList.json	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeList.json	2015-08-07 17:41:22 UTC (rev 188136)
@@ -107,7 +107,7 @@
             { "name" : "op_put_to_scope", "length" : 7 },
             { "name" : "op_get_from_arguments", "length" : 5 },
             { "name" : "op_put_to_arguments", "length" : 4 },
-            { "name" : "op_push_with_scope", "length" : 3 },
+            { "name" : "op_push_with_scope", "length" : 4 },
             { "name" : "op_create_lexical_environment", "length" : 5 },
             { "name" : "op_get_parent_scope", "length" : 3 },
             { "name" : "op_catch", "length" : 3 },

Modified: trunk/Source/_javascript_Core/bytecode/BytecodeUseDef.h (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecode/BytecodeUseDef.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeUseDef.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -116,7 +116,6 @@
     case op_get_enumerable_length:
     case op_new_func_exp:
     case op_to_index_string:
-    case op_push_with_scope:
     case op_create_lexical_environment:
     case op_resolve_scope:
     case op_get_from_scope:
@@ -177,6 +176,7 @@
     case op_stricteq:
     case op_neq:
     case op_eq:
+    case op_push_with_scope:
     case op_del_by_val: {
         functor(codeBlock, instruction, opcodeID, instruction[2].u.operand);
         functor(codeBlock, instruction, opcodeID, instruction[3].u.operand);

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -644,8 +644,8 @@
         unsigned i = 0;
         do {
             HandlerInfo& handler = m_rareData->m_exceptionHandlers[i];
-            out.printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] depth: [%4d] } %s\n",
-                i + 1, handler.start, handler.end, handler.target, handler.scopeDepth, handler.typeName());
+            out.printf("\t %d: { start: [%4d] end: [%4d] target: [%4d] } %s\n",
+                i + 1, handler.start, handler.end, handler.target, handler.typeName());
             ++i;
         } while (i < m_rareData->m_exceptionHandlers.size());
     }
@@ -1429,8 +1429,9 @@
         case op_push_with_scope: {
             int dst = (++it)->u.operand;
             int newScope = (++it)->u.operand;
+            int currentScope = (++it)->u.operand;
             printLocationAndOp(out, exec, location, it, "push_with_scope");
-            out.printf("%s, %s", registerName(dst).data(), registerName(newScope).data());
+            out.printf("%s, %s, %s", registerName(dst).data(), registerName(newScope).data(), registerName(currentScope).data());
             break;
         }
         case op_get_parent_scope: {
@@ -1789,15 +1790,13 @@
         }
         if (size_t count = unlinkedCodeBlock->numberOfExceptionHandlers()) {
             m_rareData->m_exceptionHandlers.resizeToFit(count);
-            size_t nonLocalScopeDepth = scope->depth();
             for (size_t i = 0; i < count; i++) {
                 const UnlinkedHandlerInfo& unlinkedHandler = unlinkedCodeBlock->exceptionHandler(i);
                 HandlerInfo& handler = m_rareData->m_exceptionHandlers[i];
 #if ENABLE(JIT)
-                handler.initialize(unlinkedHandler, nonLocalScopeDepth,
-                    CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(op_catch))));
+                handler.initialize(unlinkedHandler, CodeLocationLabel(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(op_catch))));
 #else
-                handler.initialize(unlinkedHandler, nonLocalScopeDepth);
+                handler.initialize(unlinkedHandler);
 #endif
             }
         }

Modified: trunk/Source/_javascript_Core/bytecode/HandlerInfo.h (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecode/HandlerInfo.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecode/HandlerInfo.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -61,36 +61,33 @@
     uint32_t start;
     uint32_t end;
     uint32_t target;
-    uint32_t scopeDepth : 30;
     uint32_t typeBits : 2; // HandlerType
 };
 
 struct UnlinkedHandlerInfo : public HandlerInfoBase {
-    UnlinkedHandlerInfo(uint32_t start, uint32_t end, uint32_t target, uint32_t scopeDepth, HandlerType handlerType)
+    UnlinkedHandlerInfo(uint32_t start, uint32_t end, uint32_t target, HandlerType handlerType)
     {
         this->start = start;
         this->end = end;
         this->target = target;
-        this->scopeDepth = scopeDepth;
         setType(handlerType);
         ASSERT(type() == handlerType);
     }
 };
 
 struct HandlerInfo : public HandlerInfoBase {
-    void initialize(const UnlinkedHandlerInfo& unlinkedInfo, size_t nonLocalScopeDepth)
+    void initialize(const UnlinkedHandlerInfo& unlinkedInfo)
     {
         start = unlinkedInfo.start;
         end = unlinkedInfo.end;
         target = unlinkedInfo.target;
-        scopeDepth = unlinkedInfo.scopeDepth + nonLocalScopeDepth;
         typeBits = unlinkedInfo.typeBits;
     }
 
 #if ENABLE(JIT)
-    void initialize(const UnlinkedHandlerInfo& unlinkedInfo, size_t nonLocalScopeDepth, CodeLocationLabel label)
+    void initialize(const UnlinkedHandlerInfo& unlinkedInfo, CodeLocationLabel label)
     {
-        initialize(unlinkedInfo, nonLocalScopeDepth);
+        initialize(unlinkedInfo);
         nativeCode = label;
     }
 

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -74,29 +74,16 @@
 
     {
         RefPtr<RegisterID> temp = newTemporary();
-        RefPtr<RegisterID> globalScope;
+        RefPtr<RegisterID> globalScope = m_topMostScope;
         for (auto functionPair : m_functionsToInitialize) {
             FunctionBodyNode* functionBody = functionPair.first;
             FunctionVariableType functionType = functionPair.second;
             emitNewFunction(temp.get(), functionBody);
             if (functionType == NormalFunctionVariable)
                 initializeVariable(variable(functionBody->ident()) , temp.get());
-            else if (functionType == GlobalFunctionVariable) {
-                if (!globalScope) {
-                    if (m_symbolTableStack.isEmpty() || !m_symbolTableStack.first().m_scope) {
-                        // We haven't allocated a lexical scope on top of the global object, so scopeRegister() will correspond to the global scope.
-                        globalScope = scopeRegister();
-                    } else {
-                        // We know this will resolve to the global object because our parser doesn't allow
-                        // "let" variables to have the same names as functions.
-                        ASSERT(m_scopeNode->lexicalVariables().hasCapturedVariables());
-                        RefPtr<RegisterID> globalObjectScope = emitResolveScope(nullptr, Variable(functionBody->ident()));
-                        globalScope = newBlockScopeVariable();
-                        emitMove(globalScope.get(), globalObjectScope.get());
-                    }
-                }
+            else if (functionType == GlobalFunctionVariable)
                 emitPutToScope(globalScope.get(), Variable(functionBody->ident()), temp.get(), ThrowIfNotFound);
-            } else
+            else
                 RELEASE_ASSERT_NOT_REACHED();
         }
     }
@@ -137,11 +124,9 @@
         if (end <= start)
             continue;
         
-        ASSERT(range.tryData->targetScopeDepth != UINT_MAX);
         ASSERT(range.tryData->handlerType != HandlerType::Illegal);
         UnlinkedHandlerInfo info(static_cast<uint32_t>(start), static_cast<uint32_t>(end),
-            static_cast<uint32_t>(range.tryData->target->bind()), range.tryData->targetScopeDepth,
-            range.tryData->handlerType);
+            static_cast<uint32_t>(range.tryData->target->bind()), range.tryData->handlerType);
         m_codeBlock->addExceptionHandler(info);
     }
     
@@ -2635,13 +2620,21 @@
     instructions().append(scopeRegister()->index());
 }
 
-RegisterID* BytecodeGenerator::emitPushWithScope(RegisterID* dst, RegisterID* scope)
+RegisterID* BytecodeGenerator::emitPushWithScope(RegisterID* objectScope)
 {
     pushScopedControlFlowContext();
+    RegisterID* newScope = newBlockScopeVariable();
+    newScope->ref();
 
-    RegisterID* result = emitUnaryOp(op_push_with_scope, dst, scope);
-    m_symbolTableStack.append(SymbolTableStackEntry{ Strong<SymbolTable>(), nullptr, true, 0 });
-    return result;
+    emitOpcode(op_push_with_scope);
+    instructions().append(newScope->index());
+    instructions().append(objectScope->index());
+    instructions().append(scopeRegister()->index());
+
+    emitMove(scopeRegister(), newScope);
+    m_symbolTableStack.append(SymbolTableStackEntry{ Strong<SymbolTable>(), newScope, true, 0 });
+
+    return newScope;
 }
 
 RegisterID* BytecodeGenerator::emitGetParentScope(RegisterID* dst, RegisterID* scope)
@@ -2658,11 +2651,12 @@
     emitMove(dst, parentScope.get());
 }
 
-void BytecodeGenerator::emitPopWithScope(RegisterID* srcDst)
+void BytecodeGenerator::emitPopWithScope()
 {
-    emitPopScope(srcDst, srcDst);
+    emitPopScope(scopeRegister(), scopeRegister());
     popScopedControlFlowContext();
     SymbolTableStackEntry stackEntry = m_symbolTableStack.takeLast();
+    stackEntry.m_scope->deref();
     RELEASE_ASSERT(stackEntry.m_isWithScope);
 }
 
@@ -2841,6 +2835,8 @@
     m_scopeRegister->ref();
     m_codeBlock->setScopeRegister(scopeRegister()->virtualRegister());
     emitGetScope();
+    m_topMostScope = addVar();
+    emitMove(m_topMostScope, scopeRegister());
 }
 
 void BytecodeGenerator::emitComplexPopScopes(RegisterID* scope, ControlFlowContext* topScope, ControlFlowContext* bottomScope)
@@ -2998,7 +2994,6 @@
 {
     TryData tryData;
     tryData.target = newLabel();
-    tryData.targetScopeDepth = UINT_MAX;
     tryData.handlerType = HandlerType::Illegal;
     m_tryData.append(tryData);
     TryData* result = &m_tryData.last();
@@ -3026,27 +3021,24 @@
     m_tryContextStack.removeLast();
     
     emitLabel(tryRange.tryData->target.get());
-    tryRange.tryData->targetScopeDepth = calculateTargetScopeDepthForExceptionHandler();
     tryRange.tryData->handlerType = handlerType;
 
     emitOpcode(op_catch);
     instructions().append(exceptionRegister->index());
     instructions().append(thrownValueRegister->index());
-}
 
-int BytecodeGenerator::calculateTargetScopeDepthForExceptionHandler() const
-{
-    int depth = localScopeDepth();
-
-    // Currently, we're maintaing compatibility with how things are done and letting the exception handling
-    // code take into consideration the base activation of the function. There is no reason we shouldn't
-    // be able to calculate the exact depth here and let the exception handler not worry if there is a base
-    // activation or not.
-    if (m_lexicalEnvironmentRegister)
-        depth--;
-
-    ASSERT(depth >= 0);
-    return depth;
+    bool foundLocalScope = false;
+    for (unsigned i = m_symbolTableStack.size(); i--; ) {
+        // Note that if we don't find a local scope in the current function/program, 
+        // we must grab the outer-most scope of this bytecode generation.
+        if (m_symbolTableStack[i].m_scope) {
+            foundLocalScope = true;
+            emitMove(scopeRegister(), m_symbolTableStack[i].m_scope);
+            break;
+        }
+    }
+    if (!foundLocalScope)
+        emitMove(scopeRegister(), m_topMostScope);
 }
 
 int BytecodeGenerator::localScopeDepth() const

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -176,7 +176,6 @@
 
     struct TryData {
         RefPtr<Label> target;
-        unsigned targetScopeDepth;
         HandlerType handlerType;
     };
 
@@ -593,10 +592,8 @@
         void emitPopCatchScope(VariableEnvironment&);
 
         void emitGetScope();
-        RegisterID* emitPushWithScope(RegisterID* dst, RegisterID* scope);
-        void emitPopScope(RegisterID* dst, RegisterID* scope);
-        void emitPopWithScope(RegisterID* srcDst);
-        RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope);
+        RegisterID* emitPushWithScope(RegisterID* objectScope);
+        void emitPopWithScope();
 
         void emitDebugHook(DebugHookID, unsigned line, unsigned charOffset, unsigned lineStart);
 
@@ -636,6 +633,8 @@
         enum class ScopeRegisterType { Var, Block };
         void pushLexicalScopeInternal(VariableEnvironment&, bool canOptimizeTDZChecks, RegisterID** constantSymbolTableResult, TDZRequirement, ScopeType, ScopeRegisterType);
         void popLexicalScopeInternal(VariableEnvironment&, TDZRequirement);
+        void emitPopScope(RegisterID* dst, RegisterID* scope);
+        RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope);
     public:
         void pushLexicalScope(VariableEnvironmentNode*, bool canOptimizeTDZChecks, RegisterID** constantSymbolTableResult = nullptr);
         void popLexicalScope(VariableEnvironmentNode*);
@@ -767,6 +766,7 @@
         RegisterID m_thisRegister;
         RegisterID m_calleeRegister;
         RegisterID* m_scopeRegister { nullptr };
+        RegisterID* m_topMostScope { nullptr };
         RegisterID* m_argumentsRegister { nullptr };
         RegisterID* m_lexicalEnvironmentRegister { nullptr };
         RegisterID* m_emptyValueRegister { nullptr };
@@ -783,7 +783,6 @@
         int m_localScopeDepth { 0 };
         const CodeType m_codeType;
 
-        int calculateTargetScopeDepthForExceptionHandler() const;
         int localScopeDepth() const;
         void pushScopedControlFlowContext();
         void popScopedControlFlowContext();

Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -2574,9 +2574,9 @@
 
     RefPtr<RegisterID> scope = generator.emitNode(m_expr);
     generator.emitExpressionInfo(m_divot, m_divot - m_expressionLength, m_divot);
-    generator.emitPushWithScope(generator.scopeRegister(), scope.get());
+    generator.emitPushWithScope(scope.get());
     generator.emitNode(dst, m_statement);
-    generator.emitPopWithScope(generator.scopeRegister());
+    generator.emitPopWithScope();
 }
 
 // ------------------------------ CaseClauseNode --------------------------------

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -705,21 +705,6 @@
     if (LegacyProfiler* profiler = vm.enabledProfiler())
         profiler->exceptionUnwind(callFrame);
 
-    // Unwind the scope chain within the exception handler's call frame.
-    int targetScopeDepth = handler->scopeDepth;
-    if (codeBlock->needsActivation() && callFrame->hasActivation())
-        ++targetScopeDepth;
-
-    int scopeRegisterOffset = codeBlock->scopeRegister().offset();
-    JSScope* scope = callFrame->scope(scopeRegisterOffset);
-    int scopeDelta = scope->depth() - targetScopeDepth;
-    RELEASE_ASSERT(scopeDelta >= 0);
-
-    while (scopeDelta--)
-        scope = scope->next();
-
-    callFrame->setScope(scopeRegisterOffset, scope);
-
     return handler;
 }
 

Modified: trunk/Source/_javascript_Core/jit/JITOpcodes.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/jit/JITOpcodes.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -425,9 +425,8 @@
 
 void JIT::emit_op_push_with_scope(Instruction* currentInstruction)
 {
-    int dst = currentInstruction[1].u.operand;
-    emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
-    callOperation(operationPushWithScope, dst, regT0);
+    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_push_with_scope);
+    slowPathCall.call();
 }
 
 void JIT::compileOpStrictEq(Instruction* currentInstruction, CompileOpStrictEqType type)

Modified: trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -748,9 +748,8 @@
 
 void JIT::emit_op_push_with_scope(Instruction* currentInstruction)
 {
-    int dst = currentInstruction[1].u.operand;
-    emitLoad(currentInstruction[2].u.operand, regT1, regT0);
-    callOperation(operationPushWithScope, dst, regT1, regT0);
+    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_push_with_scope);
+    slowPathCall.call();
 }
 
 void JIT::emit_op_to_number(Instruction* currentInstruction)

Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/jit/JITOperations.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -1339,21 +1339,6 @@
 }
 #endif
 
-void JIT_OPERATION operationPushWithScope(ExecState* exec, int32_t dst, EncodedJSValue encodedValue)
-{
-    VM& vm = exec->vm();
-    NativeCallFrameTracer tracer(&vm, exec);
-
-    JSObject* o = JSValue::decode(encodedValue).toObject(exec);
-    if (vm.exception())
-        return;
-
-    // FIXME: This won't work if this operation is called from the DFG or FTL.
-    // This should be changed to pass in the old scope and return the new scope.
-    JSScope* currentScope = exec->uncheckedR(dst).Register::scope();
-    exec->uncheckedR(dst) = JSWithScope::create(exec, o, currentScope);
-}
-
 void JIT_OPERATION operationPopScope(ExecState* exec, int32_t scopeReg)
 {
     VM& vm = exec->vm();

Modified: trunk/Source/_javascript_Core/jit/JITOperations.h (188135 => 188136)


--- trunk/Source/_javascript_Core/jit/JITOperations.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/jit/JITOperations.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -308,7 +308,6 @@
 void JIT_OPERATION operationPutGetterSetter(ExecState*, JSCell*, Identifier*, JSCell*, JSCell*) WTF_INTERNAL;
 #endif
 void JIT_OPERATION operationPushFunctionNameScope(ExecState*, int32_t, SymbolTable*, EncodedJSValue) WTF_INTERNAL;
-void JIT_OPERATION operationPushWithScope(ExecState*, int32_t, EncodedJSValue) WTF_INTERNAL;
 void JIT_OPERATION operationPopScope(ExecState*, int32_t) WTF_INTERNAL;
 void JIT_OPERATION operationProfileDidCall(ExecState*, EncodedJSValue) WTF_INTERNAL;
 void JIT_OPERATION operationProfileWillCall(ExecState*, EncodedJSValue) WTF_INTERNAL;

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -1263,20 +1263,6 @@
     LLINT_RETURN(LLINT_OP_C(2).jsValue().toPrimitive(exec));
 }
 
-LLINT_SLOW_PATH_DECL(slow_path_push_with_scope)
-{
-    LLINT_BEGIN();
-    JSValue v = LLINT_OP_C(2).jsValue();
-    JSObject* o = v.toObject(exec);
-    LLINT_CHECK_EXCEPTION();
-
-    int scopeReg = pc[1].u.operand;
-    JSScope* currentScope = exec->uncheckedR(scopeReg).Register::scope();
-    exec->uncheckedR(scopeReg) = JSWithScope::create(exec, o, currentScope);
-    
-    LLINT_END();
-}
-
 LLINT_SLOW_PATH_DECL(slow_path_throw)
 {
     LLINT_BEGIN();

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h (188135 => 188136)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -106,7 +106,6 @@
 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_tear_off_arguments);
 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_strcat);
 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_to_primitive);
-LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_push_with_scope);
 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_throw);
 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_throw_static_error);
 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_handle_watchdog_timer);

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (188135 => 188136)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2015-08-07 17:41:22 UTC (rev 188136)
@@ -1283,8 +1283,8 @@
 
 _llint_op_push_with_scope:
     traceExecution()
-    callSlowPath(_llint_slow_path_push_with_scope)
-    dispatch(3)
+    callSlowPath(_slow_path_push_with_scope)
+    dispatch(4)
 
 
 _llint_op_create_lexical_environment:

Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -649,4 +649,15 @@
     RETURN(newScope);
 }
 
+SLOW_PATH_DECL(slow_path_push_with_scope)
+{
+    BEGIN();
+    JSObject* newScope = OP_C(2).jsValue().toObject(exec);
+    CHECK_EXCEPTION();
+
+    int scopeReg = pc[3].u.operand;
+    JSScope* currentScope = exec->uncheckedR(scopeReg).Register::scope();
+    RETURN(JSWithScope::create(exec, newScope, currentScope));
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h (188135 => 188136)


--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -234,6 +234,7 @@
 SLOW_PATH_HIDDEN_DECL(slow_path_to_index_string);
 SLOW_PATH_HIDDEN_DECL(slow_path_profile_type_clear_log);
 SLOW_PATH_HIDDEN_DECL(slow_path_create_lexical_environment);
+SLOW_PATH_HIDDEN_DECL(slow_path_push_with_scope);
 
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/runtime/JSScope.cpp (188135 => 188136)


--- trunk/Source/_javascript_Core/runtime/JSScope.cpp	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/runtime/JSScope.cpp	2015-08-07 17:41:22 UTC (rev 188136)
@@ -124,14 +124,6 @@
     return object;
 }
 
-int JSScope::depth()
-{
-    int depth = 0;
-    for (JSScope* scope = this; scope; scope = scope->next())
-        ++depth;
-    return depth;
-}
-
 // When an exception occurs, the result of isUnscopable becomes false.
 static inline bool isUnscopable(ExecState* exec, JSScope* scope, JSObject* object, const Identifier& ident)
 {

Modified: trunk/Source/_javascript_Core/runtime/JSScope.h (188135 => 188136)


--- trunk/Source/_javascript_Core/runtime/JSScope.h	2015-08-07 17:31:27 UTC (rev 188135)
+++ trunk/Source/_javascript_Core/runtime/JSScope.h	2015-08-07 17:41:22 UTC (rev 188136)
@@ -171,7 +171,6 @@
     ScopeChainIterator begin();
     ScopeChainIterator end();
     JSScope* next();
-    int depth();
 
     JSGlobalObject* globalObject();
     VM* vm();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to