| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +35 lines
Lines 1-5 a/Source/JavaScriptCore/ChangeLog_sec1
1
2011-12-16  Andy Wingo  <wingo@igalia.com>
1
2011-12-16  Andy Wingo  <wingo@igalia.com>
2
2
3
        Remove the `value' argument to op_push_new_scope
4
        https://bugs.webkit.org/show_bug.cgi?id=74718
5
6
        For exception scopes, instead of pushing a scope with a value
7
        already set in it, push a fresh scope and use op_put_scoped_var to
8
        bind the var.  This will allow op_push_new_scope to be used for
9
        multi-variable scopes, like ES6 block scopes.
10
11
        Reviewed by NOBODY (OOPS!).
12
13
        * bytecode/CodeBlock.cpp (JSC::CodeBlock::dump): Update dump.
14
        * bytecode/Opcode.h:
15
        * bytecompiler/BytecodeGenerator.cpp:
16
        (JSC::BytecodeGenerator::emitPushBlockScope): Use the variant of
17
        JSStaticScope::clone that doesn't bind a variable.  (The other one
18
        is used by named function expressions.)
19
        (JSC::BytecodeGenerator::emitInitializeBlockScopedLocal): New
20
        helper to initialize a variable known to be at the last-pushed
21
        block scope.
22
        * bytecompiler/BytecodeGenerator.h: Update declarations.
23
        * bytecompiler/NodesCodegen.cpp:
24
        (JSC::TryNode::emitBytecode): Use emitInitializeBlockScopedLocal
25
        to initialize exception var.
26
        * interpreter/Interpreter.cpp:
27
        (JSC::Interpreter::createExceptionScope): Simplify.
28
        (JSC::Interpreter::privateExecute):
29
        * jit/JITOpcodes.cpp:
30
        (JSC::JIT::emit_op_push_new_scope):
31
        * jit/JITOpcodes32_64.cpp:
32
        (JSC::JIT::emit_op_push_new_scope):
33
        * jit/JITStubs.cpp:
34
        (JSC::DEFINE_STUB_FUNCTION): Adapt to op_push_new_scope change.
35
36
2011-12-16  Andy Wingo  <wingo@igalia.com>
37
3
        Optimize access to block-scoped local variables
38
        Optimize access to block-scoped local variables
4
        https://bugs.webkit.org/show_bug.cgi?id=74708
39
        https://bugs.webkit.org/show_bug.cgi?id=74708
5
40
- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp -2 / +1 lines
Lines 1220-1227 void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator& a/Source/JavaScriptCore/bytecode/CodeBlock.cpp_sec1
1220
        case op_push_new_scope: {
1220
        case op_push_new_scope: {
1221
            int r0 = (++it)->u.operand;
1221
            int r0 = (++it)->u.operand;
1222
            int r1 = (++it)->u.operand;
1222
            int r1 = (++it)->u.operand;
1223
            int r2 = (++it)->u.operand;
1223
            printf("[%4d] push_new_scope \t%s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
1224
            printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data(), registerName(exec, r2).data());
1225
            break;
1224
            break;
1226
        }
1225
        }
1227
        case op_jmp_scopes: {
1226
        case op_jmp_scopes: {
- a/Source/JavaScriptCore/bytecode/Opcode.h -1 / +1 lines
Lines 183-189 namespace JSC { a/Source/JavaScriptCore/bytecode/Opcode.h_sec1
183
        \
183
        \
184
        macro(op_push_scope, 2) \
184
        macro(op_push_scope, 2) \
185
        macro(op_pop_scope, 1) \
185
        macro(op_pop_scope, 1) \
186
        macro(op_push_new_scope, 4) \
186
        macro(op_push_new_scope, 3) \
187
        \
187
        \
188
        macro(op_catch, 2) \
188
        macro(op_catch, 2) \
189
        macro(op_throw, 2) \
189
        macro(op_throw, 2) \
- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp -2 / +1 lines
Lines 2245-2251 void BytecodeGenerator::emitSubroutineReturn(RegisterID* retAddrSrc) a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp_sec1
2245
    instructions().append(retAddrSrc->index());
2245
    instructions().append(retAddrSrc->index());
2246
}
2246
}
2247
2247
2248
void BytecodeGenerator::emitPushBlockScope(RegisterID* dst, JSStaticScopeObject *scopeTemplate, RegisterID* value)
2248
void BytecodeGenerator::emitPushBlockScope(RegisterID* dst, JSStaticScopeObject *scopeTemplate)
2249
{
2249
{
2250
    ControlFlowContext context;
2250
    ControlFlowContext context;
2251
    context.blockType = ScopeBlock;
2251
    context.blockType = ScopeBlock;
Lines 2257-2263 void BytecodeGenerator::emitPushBlockScope(RegisterID* dst, JSStaticScopeObject a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp_sec2
2257
    emitOpcode(op_push_new_scope);
2257
    emitOpcode(op_push_new_scope);
2258
    instructions().append(dst->index());
2258
    instructions().append(dst->index());
2259
    instructions().append(templ->index());
2259
    instructions().append(templ->index());
2260
    instructions().append(value->index());
2261
}
2260
}
2262
2261
2263
void BytecodeGenerator::emitPopBlockScope()
2262
void BytecodeGenerator::emitPopBlockScope()
- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h -1 / +1 lines
Lines 456-462 namespace JSC { a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h_sec1
456
456
457
        void emitThrowReferenceError(const UString& message);
457
        void emitThrowReferenceError(const UString& message);
458
458
459
        void emitPushBlockScope(RegisterID* dst, JSStaticScopeObject *scopeTemplate, RegisterID* value);
459
        void emitPushBlockScope(RegisterID* dst, JSStaticScopeObject *scopeTemplate);
460
        void emitPopBlockScope();
460
        void emitPopBlockScope();
461
461
462
        RegisterID* emitPushScope(RegisterID* scope);
462
        RegisterID* emitPushScope(RegisterID* scope);
- a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp -1 / +2 lines
Lines 1926-1932 RegisterID* TryNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp_sec1
1926
        } else {
1926
        } else {
1927
            JSStaticScopeObject* scopeTemplate = JSStaticScopeObject::create(generator.scopeChain()->globalObject->globalExec());
1927
            JSStaticScopeObject* scopeTemplate = JSStaticScopeObject::create(generator.scopeChain()->globalObject->globalExec());
1928
            scopeTemplate->addVariable(m_exceptionIdent, DontDelete);
1928
            scopeTemplate->addVariable(m_exceptionIdent, DontDelete);
1929
            generator.emitPushBlockScope(exceptionRegister.get(), scopeTemplate, exceptionRegister.get());
1929
            generator.emitPushBlockScope(generator.newTemporary(), scopeTemplate);
1930
            generator.emitPutStaticVar(generator.resolve(m_exceptionIdent), exceptionRegister.get());
1930
        }
1931
        }
1931
        generator.emitNode(dst, m_catchBlock);
1932
        generator.emitNode(dst, m_catchBlock);
1932
        if (m_catchHasEval)
1933
        if (m_catchHasEval)
- a/Source/JavaScriptCore/interpreter/Interpreter.cpp -6 / +5 lines
Lines 1440-1451 NEVER_INLINE ScopeChainNode* Interpreter::createExceptionScope(CallFrame* callFr a/Source/JavaScriptCore/interpreter/Interpreter.cpp_sec1
1440
{
1440
{
1441
    int dst = vPC[1].u.operand;
1441
    int dst = vPC[1].u.operand;
1442
    int templ = vPC[2].u.operand;
1442
    int templ = vPC[2].u.operand;
1443
    int value = vPC[3].u.operand;
1444
1443
1445
    ASSERT(callFrame->r(templ).jsValue().isObject());
1444
    ASSERT(callFrame->r(templ).jsValue().isObject());
1446
    JSObject* scopeTemplate = asObject(callFrame->r(templ).jsValue());
1445
    JSObject* scopeTemplate = asObject(callFrame->r(templ).jsValue());
1447
    ASSERT(scopeTemplate->isStaticScopeObject());
1446
    ASSERT(scopeTemplate->isStaticScopeObject());
1448
    JSStaticScopeObject* newScope = static_cast<JSStaticScopeObject*>(scopeTemplate)->clone(callFrame, callFrame->r(value).jsValue());
1447
    JSStaticScopeObject* newScope = static_cast<JSStaticScopeObject*>(scopeTemplate)->clone(callFrame);
1449
    callFrame->uncheckedR(dst) = newScope;
1448
    callFrame->uncheckedR(dst) = newScope;
1450
1449
1451
    return callFrame->scopeChain()->push(newScope);
1450
    return callFrame->scopeChain()->push(newScope);
Lines 4906-4916 skip_id_custom_self: a/Source/JavaScriptCore/interpreter/Interpreter.cpp_sec2
4906
    goto *(&&skip_new_scope);
4905
    goto *(&&skip_new_scope);
4907
#endif
4906
#endif
4908
    DEFINE_OPCODE(op_push_new_scope) {
4907
    DEFINE_OPCODE(op_push_new_scope) {
4909
        /* new_scope dst(r) templ(r) value(r)
4908
        /* new_scope dst(r) templ(r)
4910
         
4909
         
4911
           Constructs a new StaticScopeObject whose one property is set to
4910
           Constructs a new StaticScopeObject, using templ as a template. That
4912
           value.  That scope object is then pushed onto the ScopeChain.  The
4911
           scope object is then pushed onto the ScopeChain. The scope object is
4913
           scope object is then stored in dst for GC.
4912
           then stored in dst for GC.
4914
         */
4913
         */
4915
        callFrame->setScopeChain(createExceptionScope(callFrame, vPC));
4914
        callFrame->setScopeChain(createExceptionScope(callFrame, vPC));
4916
4915
- a/Source/JavaScriptCore/jit/JITOpcodes.cpp -1 lines
Lines 1013-1019 void JIT::emit_op_push_new_scope(Instruction* currentInstruction) a/Source/JavaScriptCore/jit/JITOpcodes.cpp_sec1
1013
{
1013
{
1014
    JITStubCall stubCall(this, cti_op_push_new_scope);
1014
    JITStubCall stubCall(this, cti_op_push_new_scope);
1015
    stubCall.addArgument(currentInstruction[2].u.operand, regT1);
1015
    stubCall.addArgument(currentInstruction[2].u.operand, regT1);
1016
    stubCall.addArgument(currentInstruction[3].u.operand, regT2);
1017
    stubCall.call(currentInstruction[1].u.operand);
1016
    stubCall.call(currentInstruction[1].u.operand);
1018
}
1017
}
1019
1018
- a/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp -1 lines
Lines 1332-1338 void JIT::emit_op_push_new_scope(Instruction* currentInstruction) a/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp_sec1
1332
{
1332
{
1333
    JITStubCall stubCall(this, cti_op_push_new_scope);
1333
    JITStubCall stubCall(this, cti_op_push_new_scope);
1334
    stubCall.addArgument(currentInstruction[2].u.operand);
1334
    stubCall.addArgument(currentInstruction[2].u.operand);
1335
    stubCall.addArgument(currentInstruction[3].u.operand);
1336
    stubCall.call(currentInstruction[1].u.operand);
1335
    stubCall.call(currentInstruction[1].u.operand);
1337
}
1336
}
1338
1337
- a/Source/JavaScriptCore/jit/JITStubs.cpp -2 / +1 lines
Lines 3400-3407 DEFINE_STUB_FUNCTION(JSObject*, op_push_new_scope) a/Source/JavaScriptCore/jit/JITStubs.cpp_sec1
3400
    ASSERT(scopeTemplate->isStaticScopeObject());
3400
    ASSERT(scopeTemplate->isStaticScopeObject());
3401
3401
3402
    CallFrame* callFrame = stackFrame.callFrame;
3402
    CallFrame* callFrame = stackFrame.callFrame;
3403
    JSValue value = stackFrame.args[1].jsValue();
3403
    JSStaticScopeObject* newScope = static_cast<JSStaticScopeObject*>(scopeTemplate)->clone(callFrame);
3404
    JSStaticScopeObject* newScope = static_cast<JSStaticScopeObject*>(scopeTemplate)->clone(callFrame, value);
3405
    callFrame->setScopeChain(callFrame->scopeChain()->push(newScope));
3404
    callFrame->setScopeChain(callFrame->scopeChain()->push(newScope));
3406
    return newScope;
3405
    return newScope;
3407
}
3406
}

Return to Bug 74718