Changeset 147184 in webkit


Ignore:
Timestamp:
Mar 28, 2013, 5:09:56 PM (12 years ago)
Author:
ggaren@apple.com
Message:

Simplified the bytecode by removing op_jmp_scopes
https://bugs.webkit.org/show_bug.cgi?id=113545

Reviewed by Filip Pizlo.

We already have op_pop_scope and op_jmp, so we don't need op_jmp_scopes.
Using op_jmp_scopes was also adding a "jump to self" to codegen for
return statements, which was pretty silly.

(JSC::CodeBlock::dumpBytecode):

  • bytecode/Opcode.h:

(JSC::padOpcodeName):

  • bytecode/PreciseJumpTargets.cpp:

(JSC::computePreciseJumpTargets):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitComplexPopScopes):
(JSC::BytecodeGenerator::emitPopScopes):

  • bytecompiler/BytecodeGenerator.h:

(BytecodeGenerator):

  • bytecompiler/NodesCodegen.cpp:

(JSC::ContinueNode::emitBytecode):
(JSC::BreakNode::emitBytecode):
(JSC::ReturnNode::emitBytecode):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):

  • jit/JIT.h:
  • jit/JITOpcodes.cpp:
  • jit/JITOpcodes32_64.cpp:
  • jit/JITStubs.cpp:
  • jit/JITStubs.h:
  • llint/LLIntSlowPaths.cpp:
  • llint/LLIntSlowPaths.h:
  • llint/LowLevelInterpreter.asm:
Location:
trunk/Source/JavaScriptCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r147150 r147184  
     12013-03-28  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Simplified the bytecode by removing op_jmp_scopes
     4        https://bugs.webkit.org/show_bug.cgi?id=113545
     5
     6        Reviewed by Filip Pizlo.
     7
     8        We already have op_pop_scope and op_jmp, so we don't need op_jmp_scopes.
     9        Using op_jmp_scopes was also adding a "jump to self" to codegen for
     10        return statements, which was pretty silly.
     11
     12        * JavaScriptCore.order:
     13        * bytecode/CodeBlock.cpp:
     14        (JSC::CodeBlock::dumpBytecode):
     15        * bytecode/Opcode.h:
     16        (JSC::padOpcodeName):
     17        * bytecode/PreciseJumpTargets.cpp:
     18        (JSC::computePreciseJumpTargets):
     19        * bytecompiler/BytecodeGenerator.cpp:
     20        (JSC::BytecodeGenerator::emitComplexPopScopes):
     21        (JSC::BytecodeGenerator::emitPopScopes):
     22        * bytecompiler/BytecodeGenerator.h:
     23        (BytecodeGenerator):
     24        * bytecompiler/NodesCodegen.cpp:
     25        (JSC::ContinueNode::emitBytecode):
     26        (JSC::BreakNode::emitBytecode):
     27        (JSC::ReturnNode::emitBytecode):
     28        * jit/JIT.cpp:
     29        (JSC::JIT::privateCompileMainPass):
     30        * jit/JIT.h:
     31        * jit/JITOpcodes.cpp:
     32        * jit/JITOpcodes32_64.cpp:
     33        * jit/JITStubs.cpp:
     34        * jit/JITStubs.h:
     35        * llint/LLIntSlowPaths.cpp:
     36        * llint/LLIntSlowPaths.h:
     37        * llint/LowLevelInterpreter.asm:
     38
    1392013-03-28  Mark Hahnenberg  <mhahnenberg@apple.com>
    240
  • trunk/Source/JavaScriptCore/JavaScriptCore.order

    r146318 r147184  
    12711271_cti_op_nstricteq
    12721272__ZN3JSC14LogicalNotNode30emitBytecodeInConditionContextERNS_17BytecodeGeneratorEPNS_5LabelES4_b
    1273 __ZN3JSC3JIT18emit_op_jmp_scopesEPNS_11InstructionE
    12741273_cti_op_negate
    12751274__ZN3JSCL16mathProtoFuncMaxEPNS_9ExecStateE
     
    14721471__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
    14731472__ZN3JSC23createNotAFunctionErrorEPNS_9ExecStateENS_7JSValueE
    1474 _cti_op_jmp_scopes
    14751473__ZNK3WTF6String6latin1Ev
    14761474__ZN3JSC3JIT30privateCompileGetByIdProtoListEPNS_17StructureStubInfoEPNS_30PolymorphicAccessStructureListEiPNS_9StructureES6_RKNS_10IdentifierERKNS_12PropertySlotEmPNS_9ExecStateE
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r146669 r147184  
    14481448            break;
    14491449        }
    1450         case op_jmp_scopes: {
    1451             int scopeDelta = (++it)->u.operand;
    1452             int offset = (++it)->u.operand;
    1453             out.printf("[%4d] jmp_scopes\t^%d, %d(->%d)", location, scopeDelta, offset, location + offset);
    1454             break;
    1455         }
    14561450        case op_catch: {
    14571451            int r0 = (++it)->u.operand;
  • trunk/Source/JavaScriptCore/bytecode/Opcode.h

    r145000 r147184  
    173173    macro(op_jngreater, 4) \
    174174    macro(op_jngreatereq, 4) \
    175     macro(op_jmp_scopes, 3) \
    176175    macro(op_loop, 2) \
    177176    macro(op_loop_if_true, 3) \
  • trunk/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp

    r141931 r147184  
    6262        case op_jeq_null:
    6363        case op_jneq_null:
    64         case op_jmp_scopes:
    6564        case op_loop_if_true:
    6665        case op_loop_if_false:
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r146318 r147184  
    22432243}
    22442244
    2245 PassRefPtr<Label> BytecodeGenerator::emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope)
     2245void BytecodeGenerator::emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope)
    22462246{
    22472247    while (topScope > bottomScope) {
     
    22572257
    22582258        if (nNormalScopes) {
    2259             size_t begin = instructions().size();
    2260 
    22612259            // We need to remove a number of dynamic scopes to get to the next
    22622260            // finally block
    2263             emitOpcode(op_jmp_scopes);
    2264             instructions().append(nNormalScopes);
    2265 
    2266             // If topScope == bottomScope then there isn't actually a finally block
    2267             // left to emit, so make the jmp_scopes jump directly to the target label
    2268             if (topScope == bottomScope) {
    2269                 instructions().append(target->bind(begin, instructions().size()));
    2270                 return target;
    2271             }
    2272 
    2273             // Otherwise we just use jmp_scopes to pop a group of scopes and go
    2274             // to the next instruction
    2275             RefPtr<Label> nextInsn = newLabel();
    2276             instructions().append(nextInsn->bind(begin, instructions().size()));
    2277             emitLabel(nextInsn.get());
     2261            while (nNormalScopes--)
     2262                emitOpcode(op_pop_scope);
     2263
     2264            // If topScope == bottomScope then there isn't a finally block left to emit.
     2265            if (topScope == bottomScope)
     2266                return;
    22782267        }
    22792268       
     
    23652354        }
    23662355    }
    2367     return emitJump(target);
    2368 }
    2369 
    2370 PassRefPtr<Label> BytecodeGenerator::emitJumpScopes(Label* target, int targetScopeDepth)
     2356}
     2357
     2358void BytecodeGenerator::emitPopScopes(int targetScopeDepth)
    23712359{
    23722360    ASSERT(scopeDepth() - targetScopeDepth >= 0);
    2373     ASSERT(target->isForward());
    23742361
    23752362    size_t scopeDelta = scopeDepth() - targetScopeDepth;
    23762363    ASSERT(scopeDelta <= m_scopeContextStack.size());
    23772364    if (!scopeDelta)
    2378         return emitJump(target);
    2379 
    2380     if (m_finallyDepth)
    2381         return emitComplexJumpScopes(target, &m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta);
    2382 
    2383     size_t begin = instructions().size();
    2384 
    2385     emitOpcode(op_jmp_scopes);
    2386     instructions().append(scopeDelta);
    2387     instructions().append(target->bind(begin, instructions().size()));
    2388     return target;
     2365        return;
     2366
     2367    if (!m_finallyDepth) {
     2368        while (scopeDelta--)
     2369            emitOpcode(op_pop_scope);
     2370        return;
     2371    }
     2372
     2373    emitComplexPopScopes(&m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta);
    23892374}
    23902375
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r146318 r147184  
    487487        PassRefPtr<Label> emitJumpIfNotFunctionCall(RegisterID* cond, Label* target);
    488488        PassRefPtr<Label> emitJumpIfNotFunctionApply(RegisterID* cond, Label* target);
    489         PassRefPtr<Label> emitJumpScopes(Label* target, int targetScopeDepth);
     489        void emitPopScopes(int targetScopeDepth);
    490490
    491491        RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, Label* breakTarget);
     
    563563        ALWAYS_INLINE void rewindUnaryOp();
    564564
    565         PassRefPtr<Label> emitComplexJumpScopes(Label* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
     565        void emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope);
    566566
    567567        typedef HashMap<double, JSValue> NumberMap;
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r146318 r147184  
    17861786    ASSERT(scope);
    17871787
    1788     generator.emitJumpScopes(scope->continueTarget(), scope->scopeDepth());
     1788    generator.emitPopScopes(scope->scopeDepth());
     1789    generator.emitJump(scope->continueTarget());
    17891790    return dst;
    17901791}
     
    18001801    ASSERT(scope);
    18011802
    1802     generator.emitJumpScopes(scope->breakTarget(), scope->scopeDepth());
     1803    generator.emitPopScopes(scope->scopeDepth());
     1804    generator.emitJump(scope->breakTarget());
    18031805    return dst;
    18041806}
     
    18131815    if (dst == generator.ignoredResult())
    18141816        dst = 0;
    1815     RegisterID* r0 = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined());
    1816     RefPtr<RegisterID> returnRegister;
     1817
     1818    RefPtr<RegisterID> returnRegister = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined());
    18171819    if (generator.scopeDepth()) {
    1818         RefPtr<Label> l0 = generator.newLabel();
    1819         if (generator.hasFinaliser()) {
    1820             returnRegister = generator.emitMove(generator.newTemporary(), r0);
    1821             r0 = returnRegister.get();
    1822         }
    1823         generator.emitJumpScopes(l0.get(), 0);
    1824         generator.emitLabel(l0.get());
    1825     }
     1820        returnRegister = generator.emitMove(generator.newTemporary(), returnRegister.get());
     1821        generator.emitPopScopes(0);
     1822    }
     1823
    18261824    generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine(), charPosition());
    1827     return generator.emitReturn(r0);
     1825    return generator.emitReturn(returnRegister.get());
    18281826}
    18291827
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r145000 r147184  
    294294        DEFINE_OP(op_jfalse)
    295295        DEFINE_OP(op_jmp)
    296         DEFINE_OP(op_jmp_scopes)
    297296        DEFINE_OP(op_jneq_null)
    298297        DEFINE_OP(op_jneq_ptr)
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r145000 r147184  
    679679        void emit_op_jfalse(Instruction*);
    680680        void emit_op_jmp(Instruction*);
    681         void emit_op_jmp_scopes(Instruction*);
    682681        void emit_op_jneq_null(Instruction*);
    683682        void emit_op_jneq_ptr(Instruction*);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r144137 r147184  
    718718    store64(TrustedImm64(JSValue::encode(JSValue())), Address(regT3, OBJECT_OFFSETOF(JSGlobalData, exception)));
    719719    emitPutVirtualRegister(currentInstruction[1].u.operand);
    720 }
    721 
    722 void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)
    723 {
    724     JITStubCall stubCall(this, cti_op_jmp_scopes);
    725     stubCall.addArgument(TrustedImm32(currentInstruction[1].u.operand));
    726     stubCall.call();
    727     addJump(jump(), currentInstruction[2].u.operand);
    728720}
    729721
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r142769 r147184  
    10331033}
    10341034
    1035 void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)
    1036 {
    1037     JITStubCall stubCall(this, cti_op_jmp_scopes);
    1038     stubCall.addArgument(TrustedImm32(currentInstruction[1].u.operand));
    1039     stubCall.call();
    1040     addJump(jump(), currentInstruction[2].u.operand);
    1041 }
    1042 
    10431035void JIT::emit_op_switch_imm(Instruction* currentInstruction)
    10441036{
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r146669 r147184  
    33073307}
    33083308
    3309 DEFINE_STUB_FUNCTION(void, op_jmp_scopes)
    3310 {
    3311     STUB_INIT_STACK_FRAME(stackFrame);
    3312 
    3313     unsigned count = stackFrame.args[0].int32();
    3314     CallFrame* callFrame = stackFrame.callFrame;
    3315 
    3316     JSScope* tmp = callFrame->scope();
    3317     while (count--)
    3318         tmp = tmp->next();
    3319     callFrame->setScope(tmp);
    3320 }
    3321 
    33223309DEFINE_STUB_FUNCTION(void, op_put_by_index)
    33233310{
  • trunk/Source/JavaScriptCore/jit/JITStubs.h

    r144043 r147184  
    411411void JIT_STUB cti_op_debug(STUB_ARGS_DECLARATION) WTF_INTERNAL;
    412412void JIT_STUB cti_op_end(STUB_ARGS_DECLARATION) WTF_INTERNAL;
    413 void JIT_STUB cti_op_jmp_scopes(STUB_ARGS_DECLARATION) WTF_INTERNAL;
    414413void JIT_STUB cti_op_pop_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL;
    415414void JIT_STUB cti_op_profile_did_call(STUB_ARGS_DECLARATION) WTF_INTERNAL;
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r146552 r147184  
    12051205}
    12061206
    1207 LLINT_SLOW_PATH_DECL(slow_path_jmp_scopes)
    1208 {
    1209     LLINT_BEGIN();
    1210     unsigned count = pc[1].u.operand;
    1211     JSScope* tmp = exec->scope();
    1212     while (count--)
    1213         tmp = tmp->next();
    1214     exec->setScope(tmp);
    1215     pc += pc[2].u.operand;
    1216     LLINT_END();
    1217 }
    1218 
    12191207LLINT_SLOW_PATH_DECL(slow_path_jtrue)
    12201208{
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.h

    r133688 r147184  
    175175LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_by_index);
    176176LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_getter_setter);
    177 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jmp_scopes);
    178177LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jtrue);
    179178LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jfalse);
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r146459 r147184  
    974974
    975975
    976 _llint_op_jmp_scopes:
    977     traceExecution()
    978     callSlowPath(_llint_slow_path_jmp_scopes)
    979     dispatch(0)
    980 
    981 
    982976_llint_op_loop_if_true:
    983977    traceExecution()
Note: See TracChangeset for help on using the changeset viewer.