Changeset 156376 in webkit


Ignore:
Timestamp:
Sep 24, 2013 5:37:57 PM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

op_get_callee shouldn't use value profiling
https://bugs.webkit.org/show_bug.cgi?id=121821

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Currently it's one of the two opcodes that uses m_singletonValue, which is unnecessary.
Our current plan is to remove m_singletonValue so that GenGC can have a simpler story
for handling CodeBlocks/FunctionExecutables during nursery collections.

Instead of using a ValueProfile op_get_callee now has a simple inline cache of the most
recent JSFunction that we saw.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::finalizeUnconditionally):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitCreateThis):

  • dfg/DFGByteCodeParser.cpp:

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

  • jit/JIT.cpp:

(JSC::JIT::privateCompileSlowCases):

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

(JSC::JIT::emit_op_get_callee):
(JSC::JIT::emitSlow_op_get_callee):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_get_callee):
(JSC::JIT::emitSlow_op_get_callee):

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:

LayoutTests:

Added two tests to make sure we didn't regress the performance of op_get_callee.

  • js/regress/get_callee_monomorphic-expected.txt: Added.
  • js/regress/get_callee_monomorphic.html: Added.
  • js/regress/get_callee_polymorphic-expected.txt: Added.
  • js/regress/get_callee_polymorphic.html: Added.
  • js/regress/script-tests/get_callee_monomorphic.js: Added.
  • js/regress/script-tests/get_callee_polymorphic.js: Added.
Location:
trunk
Files:
6 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r156375 r156376  
     12013-09-24  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        op_get_callee shouldn't use value profiling
     4        https://bugs.webkit.org/show_bug.cgi?id=121821
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Added two tests to make sure we didn't regress the performance of op_get_callee.
     9
     10        * js/regress/get_callee_monomorphic-expected.txt: Added.
     11        * js/regress/get_callee_monomorphic.html: Added.
     12        * js/regress/get_callee_polymorphic-expected.txt: Added.
     13        * js/regress/get_callee_polymorphic.html: Added.
     14        * js/regress/script-tests/get_callee_monomorphic.js: Added.
     15        * js/regress/script-tests/get_callee_polymorphic.js: Added.
     16
    1172013-09-24  Bear Travis  <betravis@adobe.com>
    218
  • trunk/Source/JavaScriptCore/ChangeLog

    r156374 r156376  
     12013-09-24  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        op_get_callee shouldn't use value profiling
     4        https://bugs.webkit.org/show_bug.cgi?id=121821
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Currently it's one of the two opcodes that uses m_singletonValue, which is unnecessary.
     9        Our current plan is to remove m_singletonValue so that GenGC can have a simpler story
     10        for handling CodeBlocks/FunctionExecutables during nursery collections.
     11
     12        Instead of using a ValueProfile op_get_callee now has a simple inline cache of the most
     13        recent JSFunction that we saw.
     14
     15        * bytecode/CodeBlock.cpp:
     16        (JSC::CodeBlock::CodeBlock):
     17        (JSC::CodeBlock::finalizeUnconditionally):
     18        * bytecompiler/BytecodeGenerator.cpp:
     19        (JSC::BytecodeGenerator::emitCreateThis):
     20        * dfg/DFGByteCodeParser.cpp:
     21        (JSC::DFG::ByteCodeParser::parseBlock):
     22        * jit/JIT.cpp:
     23        (JSC::JIT::privateCompileSlowCases):
     24        * jit/JIT.h:
     25        * jit/JITOpcodes.cpp:
     26        (JSC::JIT::emit_op_get_callee):
     27        (JSC::JIT::emitSlow_op_get_callee):
     28        * jit/JITOpcodes32_64.cpp:
     29        (JSC::JIT::emit_op_get_callee):
     30        (JSC::JIT::emitSlow_op_get_callee):
     31        * llint/LowLevelInterpreter32_64.asm:
     32        * llint/LowLevelInterpreter64.asm:
     33        * runtime/CommonSlowPaths.cpp:
     34        (JSC::SLOW_PATH_DECL):
     35        * runtime/CommonSlowPaths.h:
     36
    1372013-09-24  Mark Lam  <mark.lam@apple.com>
    238
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r156374 r156376  
    17371737        case op_to_this:
    17381738        case op_get_by_id:
    1739         case op_call_varargs:
    1740         case op_get_callee: {
     1739        case op_call_varargs: {
    17411740            ValueProfile* profile = &m_valueProfiles[pc[i + opLength - 1].u.operand];
    17421741            ASSERT(profile->m_bytecodeOffset == -1);
     
    22392238                break;
    22402239            case op_get_array_length:
     2240                break;
     2241            case op_get_callee:
     2242                if (!curInstruction[2].u.jsCell || Heap::isMarked(curInstruction[2].u.jsCell.get()))
     2243                    break;
     2244                if (Options::verboseOSR())
     2245                    dataLogF("Clearing LLInt get callee with function %p.\n", curInstruction[2].u.jsCell.get());
     2246                curInstruction[2].u.jsCell.clear();
    22412247                break;
    22422248            case op_get_from_scope:
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r156374 r156376  
    14051405    RefPtr<RegisterID> func = newTemporary();
    14061406
    1407     UnlinkedValueProfile profile = emitProfiledOpcode(op_get_callee);
     1407    emitOpcode(op_get_callee);
    14081408    instructions().append(func->index());
    1409     instructions().append(profile);
     1409    instructions().append(0);
    14101410
    14111411    size_t begin = instructions().size();
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r156300 r156376  
    20082008           
    20092009        case op_get_callee: {
    2010             ConcurrentJITLocker locker(m_inlineStackTop->m_profiledBlock->m_lock);
    2011             ValueProfile* profile = currentInstruction[2].u.profile;
    2012             profile->computeUpdatedPrediction(locker);
    2013             if (profile->m_singletonValueIsTop
    2014                 || !profile->m_singletonValue
    2015                 || !profile->m_singletonValue.isCell())
     2010            JSCell* cachedFunction = currentInstruction[2].u.jsCell.get();
     2011            if (!cachedFunction
     2012                || m_inlineStackTop->m_profiledBlock->couldTakeSlowCase(m_currentIndex)
     2013                || m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadFunction)) {
    20162014                set(currentInstruction[1].u.operand, get(JSStack::Callee));
    2017             else {
    2018                 ASSERT(profile->m_singletonValue.asCell()->inherits(JSFunction::info()));
     2015            } else {
     2016                ASSERT(cachedFunction->inherits(JSFunction::info()));
    20192017                Node* actualCallee = get(JSStack::Callee);
    2020                 addToGraph(CheckFunction, OpInfo(profile->m_singletonValue.asCell()), actualCallee);
    2021                 set(currentInstruction[1].u.operand, addToGraph(WeakJSConstant, OpInfo(profile->m_singletonValue.asCell())));
     2018                addToGraph(CheckFunction, OpInfo(cachedFunction), actualCallee);
     2019                set(currentInstruction[1].u.operand, addToGraph(WeakJSConstant, OpInfo(cachedFunction)));
    20222020            }
    20232021            NEXT_OPCODE(op_get_callee);
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r156247 r156376  
    408408        DEFINE_SLOWCASE_OP(op_div)
    409409        DEFINE_SLOWCASE_OP(op_eq)
     410        DEFINE_SLOWCASE_OP(op_get_callee)
    410411        case op_get_by_id_out_of_line:
    411412        case op_get_array_length:
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r156184 r156376  
    747747        void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
    748748        void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
     749        void emitSlow_op_get_callee(Instruction*, Vector<SlowCaseEntry>::iterator&);
    749750        void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
    750751        void emitSlow_op_get_arguments_length(Instruction*, Vector<SlowCaseEntry>::iterator&);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r156374 r156376  
    879879{
    880880    int result = currentInstruction[1].u.operand;
     881    WriteBarrierBase<JSCell>* cachedFunction = &currentInstruction[2].u.jsCell;
    881882    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
    882     emitValueProfilingSite(regT4);
     883
     884    loadPtr(cachedFunction, regT2);
     885    addSlowCase(branchPtr(NotEqual, regT0, regT2));
     886
    883887    emitPutVirtualRegister(result);
     888}
     889
     890void JIT::emitSlow_op_get_callee(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     891{
     892    linkSlowCase(iter);
     893
     894    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_get_callee);
     895    slowPathCall.call();
     896    emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
    884897}
    885898
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r156374 r156376  
    11301130void JIT::emit_op_get_callee(Instruction* currentInstruction)
    11311131{
    1132     int dst = currentInstruction[1].u.operand;
     1132    int result = currentInstruction[1].u.operand;
     1133    WriteBarrierBase<JSCell>* cachedFunction = &currentInstruction[2].u.jsCell;
    11331134    emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
     1135
     1136    loadPtr(cachedFunction, regT2);
     1137    addSlowCase(branchPtr(NotEqual, regT0, regT2));
     1138
    11341139    move(TrustedImm32(JSValue::CellTag), regT1);
    1135     emitValueProfilingSite(regT4);
    1136     emitStore(dst, regT1, regT0);
     1140    emitStore(result, regT1, regT0);
     1141}
     1142
     1143void JIT::emitSlow_op_get_callee(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1144{
     1145    linkSlowCase(iter);
     1146
     1147    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_get_callee);
     1148    slowPathCall.call();
     1149    emitLoad(currentInstruction[1].u.operand, regT1, regT0);
    11371150}
    11381151
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r155711 r156376  
    415415    loadi 4[PC], t0
    416416    loadp PayloadOffset + Callee[cfr], t1
    417     valueProfile(CellTag, t1, 8, t2)
     417    loadpFromInstruction(2, t2)
     418    bpneq t1, t2, .opGetCalleeSlow
    418419    storei CellTag, TagOffset[cfr, t0, 8]
    419420    storei t1, PayloadOffset[cfr, t0, 8]
    420421    dispatch(3)
    421422
     423.opGetCalleeSlow:
     424    callSlowPath(_slow_path_get_callee)
     425    dispatch(3)
    422426
    423427_llint_op_to_this:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r155711 r156376  
    296296    loadisFromInstruction(1, t0)
    297297    loadp Callee[cfr], t1
    298     valueProfile(t1, 2, t2)
     298    loadpFromInstruction(2, t2)
     299    bpneq t1, t2, .opGetCalleeSlow
    299300    storep t1, [cfr, t0, 8]
    300301    dispatch(3)
    301302
     303.opGetCalleeSlow:
     304    callSlowPath(_slow_path_get_callee)
     305    dispatch(3)
    302306
    303307_llint_op_to_this:
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r156242 r156376  
    194194}
    195195
     196SLOW_PATH_DECL(slow_path_get_callee)
     197{
     198    BEGIN();
     199    JSFunction* callee = jsCast<JSFunction*>(exec->callee());
     200    pc[2].u.jsCell.set(exec->vm(), exec->codeBlock()->ownerExecutable(), callee);
     201    RETURN(callee);
     202}
     203
    196204SLOW_PATH_DECL(slow_path_create_arguments)
    197205{
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h

    r156046 r156376  
    154154SLOW_PATH_HIDDEN_DECL(slow_path_create_arguments);
    155155SLOW_PATH_HIDDEN_DECL(slow_path_create_this);
     156SLOW_PATH_HIDDEN_DECL(slow_path_get_callee);
    156157SLOW_PATH_HIDDEN_DECL(slow_path_to_this);
    157158SLOW_PATH_HIDDEN_DECL(slow_path_not);
Note: See TracChangeset for help on using the changeset viewer.