Changeset 175508 in webkit


Ignore:
Timestamp:
Nov 3, 2014 7:36:28 PM (9 years ago)
Author:
msaboff@apple.com
Message:

Add "get scope" byte code
https://bugs.webkit.org/show_bug.cgi?id=138326

Reviewed by Mark Lam.

Added op_get_scope. Added implementations for the LLInt and baseline JIT.
Provided nop implementation for DFG and FTL. The new byte code is emitted
after op_enter for any function, program or eval. It is expected that the
DFG will be implemented such that unneeded op_get_scope would be eliminated
during DFG compilation.

  • bytecode/BytecodeList.json:
  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):
Added new op_get_scope bytecode.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitGetScope):

  • bytecompiler/BytecodeGenerator.h:

Emit new op_get_scope bytecode.

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):
Added framework for new op_get_scope bytecode.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):

  • jit/JIT.h:
  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_get_scope):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_get_scope):

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:

Implementation of op_get_scope bytecode.

Location:
trunk/Source/JavaScriptCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r175493 r175508  
     12014-11-03  Michael Saboff  <msaboff@apple.com>
     2
     3        Add "get scope" byte code
     4        https://bugs.webkit.org/show_bug.cgi?id=138326
     5
     6        Reviewed by Mark Lam.
     7
     8        Added op_get_scope.  Added implementations for the LLInt and baseline JIT.
     9        Provided nop implementation for DFG and FTL.  The new byte code is emitted
     10        after op_enter for any function, program or eval.  It is expected that the
     11        DFG will be implemented such that unneeded op_get_scope would be eliminated
     12        during DFG compilation.
     13
     14        * bytecode/BytecodeList.json:
     15        * bytecode/BytecodeUseDef.h:
     16        (JSC::computeUsesForBytecodeOffset):
     17        (JSC::computeDefsForBytecodeOffset):
     18        Added new op_get_scope bytecode.
     19
     20        * bytecompiler/BytecodeGenerator.cpp:
     21        (JSC::BytecodeGenerator::BytecodeGenerator):
     22        (JSC::BytecodeGenerator::emitGetScope):
     23        * bytecompiler/BytecodeGenerator.h:
     24        Emit new op_get_scope bytecode.
     25
     26        * dfg/DFGByteCodeParser.cpp:
     27        (JSC::DFG::ByteCodeParser::parseBlock):
     28        * dfg/DFGCapabilities.cpp:
     29        (JSC::DFG::capabilityLevel):
     30        Added framework for new op_get_scope bytecode.
     31
     32        * bytecode/CodeBlock.cpp:
     33        (JSC::CodeBlock::dumpBytecode):
     34        * jit/JIT.cpp:
     35        (JSC::JIT::privateCompileMainPass):
     36        * jit/JIT.h:
     37        * jit/JITOpcodes.cpp:
     38        (JSC::JIT::emit_op_get_scope):
     39        * jit/JITOpcodes32_64.cpp:
     40        (JSC::JIT::emit_op_get_scope):
     41        * llint/LowLevelInterpreter32_64.asm:
     42        * llint/LowLevelInterpreter64.asm:
     43        Implementation of op_get_scope bytecode.
     44
    1452014-11-03  Joseph Pecoraro  <pecoraro@apple.com>
    246
  • trunk/Source/JavaScriptCore/bytecode/BytecodeList.json

    r175471 r175508  
    66            { "name" : "op_enter", "length" : 1 },
    77            { "name" : "op_create_lexical_environment", "length" : 2 },
     8            { "name" : "op_get_scope", "length" : 2 },
    89            { "name" : "op_touch_entry", "length" : 1 },
    910            { "name" : "op_init_lazy_reg", "length" : 2 },
  • trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h

    r174401 r175508  
    6060    case op_new_func:
    6161    case op_create_lexical_environment:
     62    case op_get_scope:
    6263    case op_create_arguments:
    6364    case op_to_this:
     
    366367    case op_init_lazy_reg:
    367368    case op_create_lexical_environment:
     369    case op_get_scope:
    368370    case op_create_arguments:
    369371    case op_del_by_id:
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r175471 r175508  
    747747            int r0 = (++it)->u.operand;
    748748            printLocationOpAndRegisterOperand(out, exec, location, it, "create_lexical_environment", r0);
     749            break;
     750        }
     751        case op_get_scope: {
     752            int r0 = (++it)->u.operand;
     753            printLocationOpAndRegisterOperand(out, exec, location, it, "get_scope", r0);
    749754            break;
    750755        }
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r175471 r175508  
    191191    emitOpcode(op_enter);
    192192
     193    emitGetScope();
     194
    193195    const VarStack& varStack = programNode->varStack();
    194196    const FunctionStack& functionStack = programNode->functionStack();
     
    249251
    250252    emitOpcode(op_enter);
     253
     254    emitGetScope();
     255
    251256    if (m_codeBlock->needsFullScopeChain() || m_shouldEmitDebugHooks) {
    252257        m_lexicalEnvironmentRegister = addVar();
     
    473478
    474479    emitOpcode(op_enter);
     480
     481    emitGetScope();
    475482
    476483    const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack();
     
    20542061    instructions().append(dst->index());
    20552062    instructions().append(src->index());
     2063}
     2064
     2065void BytecodeGenerator::emitGetScope()
     2066{
     2067    emitOpcode(op_get_scope);
     2068    instructions().append(scopeRegister()->index());
    20562069}
    20572070
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r175426 r175508  
    542542        void emitPushCatchScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes);
    543543
     544        void emitGetScope();
    544545        RegisterID* emitPushWithScope(RegisterID* dst, RegisterID* scope);
    545546        void emitPopScope(RegisterID* srcDst);
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r175471 r175508  
    34003400        }
    34013401           
     3402        case op_get_scope: {
     3403            NEXT_OPCODE(op_get_scope);
     3404        }
     3405           
    34023406        case op_create_arguments: {
    34033407            m_graph.m_hasArguments = true;
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r175471 r175508  
    193193    case op_switch_char:
    194194    case op_in:
     195    case op_get_scope:
    195196    case op_get_from_scope:
    196197    case op_get_enumerable_length:
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r174933 r175508  
    211211        DEFINE_OP(op_enter)
    212212        DEFINE_OP(op_create_lexical_environment)
     213        DEFINE_OP(op_get_scope)
    213214        DEFINE_OP(op_eq)
    214215        DEFINE_OP(op_eq_null)
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r174401 r175508  
    476476        void emit_op_enter(Instruction*);
    477477        void emit_op_create_lexical_environment(Instruction*);
     478        void emit_op_get_scope(Instruction*);
    478479        void emit_op_eq(Instruction*);
    479480        void emit_op_eq_null(Instruction*);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r175426 r175508  
    671671}
    672672
     673void JIT::emit_op_get_scope(Instruction* currentInstruction)
     674{
     675    int dst = currentInstruction[1].u.operand;
     676    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
     677    loadPtr(Address(regT0, JSFunction::offsetOfScopeChain()), regT0);
     678    emitStoreCell(dst, regT0);
     679}
     680
    673681void JIT::emit_op_create_arguments(Instruction* currentInstruction)
    674682{
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r175426 r175508  
    895895}
    896896
     897void JIT::emit_op_get_scope(Instruction* currentInstruction)
     898{
     899    int dst = currentInstruction[1].u.operand;
     900    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
     901    loadPtr(Address(regT0, JSFunction::offsetOfScopeChain()), regT0);
     902    emitStoreCell(dst, regT0);
     903}
     904
    897905void JIT::emit_op_create_arguments(Instruction* currentInstruction)
    898906{
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r175471 r175508  
    724724    loadi 4[PC], t0
    725725    callSlowPath(_llint_slow_path_create_lexical_environment)
     726    dispatch(2)
     727
     728
     729_llint_op_get_scope:
     730    traceExecution()
     731    loadi Callee + PayloadOffset[cfr], t0
     732    loadi JSCallee::m_scope[t0], t0
     733    loadisFromInstruction(1, t1)
     734    storei CellTag, TagOffset[cfr, t1, 8]
     735    storei t0, PayloadOffset[cfr, t1, 8]
    726736    dispatch(2)
    727737
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r175471 r175508  
    612612    loadisFromInstruction(1, t0)
    613613    callSlowPath(_llint_slow_path_create_lexical_environment)
     614    dispatch(2)
     615
     616
     617_llint_op_get_scope:
     618    traceExecution()
     619    loadp Callee[cfr], t0
     620    loadp JSCallee::m_scope[t0], t0
     621    loadisFromInstruction(1, t1)
     622    storeq t0, [cfr, t1, 8]
    614623    dispatch(2)
    615624
Note: See TracChangeset for help on using the changeset viewer.