Changeset 62612 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jul 6, 2010, 6:35:56 PM (15 years ago)
Author:
[email protected]
Message:

2010-07-06 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

Make it possible to have both the JIT and Interpreter available in a single build
https://bugs.webkit.org/show_bug.cgi?id=41722

Separate the concept of !ENABLE(JIT) and ENABLE(INTERPRETER) and make it possible
to have both JIT and INTERPRETER enabled at the same time. This doesn't add
support for mix mode execution, but it does allow a single build to contain all
the code needed to use either the interpreter or the jit.

If both ENABLE(INTERPRETER) and ENABLE(JIT) are true then setting the environment
variable JSC_FORCE_INTERPRETER will force JSC to use the interpreter.

This patch basically consists of replacing !ENABLE(JIT) with ENABLE(INTERPRETER),
or converting #if ENABLE(JIT) ... #else ... into #if ENABLE(JIT) ... #endif
#if ENABLE(INTERPRETER), etc. There are also a few functions that need to be
renamed to resolve return type ambiguity.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h:
  • interpreter/CallFrame.h: (JSC::ExecState::returnVPC):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::throwException): (JSC::Interpreter::execute): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::prepareForRepeatCall): (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveLastCaller):
  • interpreter/Interpreter.h:
  • runtime/ArrayPrototype.cpp: (JSC::isNumericCompareFunction):
  • runtime/Executable.cpp: (JSC::EvalExecutable::generateJITCode): (JSC::ProgramExecutable::generateJITCode): (JSC::FunctionExecutable::generateJITCodeForCall): (JSC::FunctionExecutable::generateJITCodeForConstruct): (JSC::FunctionExecutable::reparseExceptionInfo): (JSC::EvalExecutable::reparseExceptionInfo):
  • runtime/JSFunction.cpp:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSGlobalData.h: (JSC::JSGlobalData::canUseJIT):
  • wtf/Platform.h:
Location:
trunk/JavaScriptCore/interpreter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/CallFrame.h

    r61553 r62612  
    107107#if ENABLE(JIT)
    108108        ReturnAddressPtr returnPC() const { return ReturnAddressPtr(this[RegisterFile::ReturnPC].vPC()); }
    109 #else
    110         Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
     109#endif
     110#if ENABLE(INTERPRETER)
     111        Instruction* returnVPC() const { return this[RegisterFile::ReturnPC].vPC(); }
    111112#endif
    112113
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r62464 r62612  
    8080}
    8181
    82 #if !ENABLE(JIT)
     82#if ENABLE(INTERPRETER)
    8383NEVER_INLINE bool Interpreter::resolve(CallFrame* callFrame, Instruction* vPC, JSValue& exceptionValue)
    8484{
     
    295295}
    296296
    297 #endif // !ENABLE(JIT)
     297#endif // ENABLE(INTERPRETER)
    298298
    299299ALWAYS_INLINE CallFrame* Interpreter::slideRegisterWindowForCall(CodeBlock* newCodeBlock, RegisterFile* registerFile, CallFrame* callFrame, size_t registerOffset, int argc)
     
    334334}
    335335
    336 #if !ENABLE(JIT)
     336#if ENABLE(INTERPRETER)
    337337static NEVER_INLINE bool isInvalidParamForIn(CallFrame* callFrame, CodeBlock* codeBlock, const Instruction* vPC, JSValue value, JSValue& exceptionData)
    338338{
     
    548548
    549549    codeBlock = callerFrame->codeBlock();
    550     bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     550#if ENABLE(JIT)
     551#if ENABLE(INTERPRETER)
     552    if (callerFrame->globalData().canUseJIT())
     553#endif
     554        bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     555#if ENABLE(INTERPRETER)
     556    else
     557        bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnVPC());
     558#endif
     559#else
     560    bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnVPC());
     561#endif
    551562    callFrame = callerFrame;
    552563    return true;
     
    595606    // we'll never reach the relevant op_profile_did_call.
    596607    if (Profiler* profiler = *Profiler::enabledProfilerReference()) {
    597 #if !ENABLE(JIT)
    598         // FIXME: Why 8? - work out what this magic value is, replace the constant with something more helpful.
    599         if (isCallBytecode(codeBlock->instructions()[bytecodeOffset].u.opcode))
    600             profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 1].u.operand).jsValue());
    601         else if (codeBlock->instructions().size() > (bytecodeOffset + 8) && codeBlock->instructions()[bytecodeOffset + 8].u.opcode == getOpcode(op_construct))
    602             profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 9].u.operand).jsValue());
    603 #else
    604         int functionRegisterIndex;
    605         if (codeBlock->functionRegisterForBytecodeOffset(bytecodeOffset, functionRegisterIndex))
    606             profiler->didExecute(callFrame, callFrame->r(functionRegisterIndex).jsValue());
     608#if ENABLE(INTERPRETER)
     609        if (!callFrame->globalData().canUseJIT()) {
     610            // FIXME: Why 8? - work out what this magic value is, replace the constant with something more helpful.
     611            if (isCallBytecode(codeBlock->instructions()[bytecodeOffset].u.opcode))
     612                profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 1].u.operand).jsValue());
     613            else if (codeBlock->instructions().size() > (bytecodeOffset + 8) && codeBlock->instructions()[bytecodeOffset + 8].u.opcode == getOpcode(op_construct))
     614                profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 9].u.operand).jsValue());
     615        }
     616#if ENABLE(JIT)
     617        else
     618#endif
     619#endif
     620#if ENABLE(JIT)
     621        {
     622            int functionRegisterIndex;
     623            if (codeBlock->functionRegisterForBytecodeOffset(bytecodeOffset, functionRegisterIndex))
     624                profiler->didExecute(callFrame, callFrame->r(functionRegisterIndex).jsValue());
     625        }
    607626#endif
    608627    }
     
    677696        SamplingTool::CallRecord callRecord(m_sampler.get());
    678697
    679         m_reentryDepth++;
     698        m_reentryDepth++; 
    680699#if ENABLE(JIT)
    681         result = program->jitCode(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
    682 #else
    683         result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
    684 #endif
     700#if ENABLE(INTERPRETER)
     701        if (callFrame->globalData().canUseJIT())
     702#endif
     703            result = program->jitCode(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
     704#if ENABLE(INTERPRETER)
     705        else
     706#endif
     707#endif
     708#if ENABLE(INTERPRETER)
     709            result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     710#endif
     711
    685712        m_reentryDepth--;
    686713    }
     
    750777            SamplingTool::CallRecord callRecord(m_sampler.get());
    751778
    752             m_reentryDepth++;
    753     #if ENABLE(JIT)
    754             result = callData.js.functionExecutable->jitCodeForCall(newCallFrame, callDataScopeChain).execute(&m_registerFile, newCallFrame, callDataScopeChain->globalData, exception);
    755     #else
    756             result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
    757     #endif
     779            m_reentryDepth++; 
     780#if ENABLE(JIT)
     781#if ENABLE(INTERPRETER)
     782            if (callFrame->globalData().canUseJIT())
     783#endif
     784                result = callData.js.functionExecutable->jitCodeForCall(newCallFrame, callDataScopeChain).execute(&m_registerFile, newCallFrame, callDataScopeChain->globalData, exception);
     785#if ENABLE(INTERPRETER)
     786            else
     787#endif
     788#endif
     789#if ENABLE(INTERPRETER)
     790                result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     791#endif
    758792            m_reentryDepth--;
    759793        }
     
    842876            SamplingTool::CallRecord callRecord(m_sampler.get());
    843877
    844             m_reentryDepth++;
    845     #if ENABLE(JIT)
    846             result = constructData.js.functionExecutable->jitCodeForConstruct(newCallFrame, constructDataScopeChain).execute(&m_registerFile, newCallFrame, constructDataScopeChain->globalData, exception);
    847     #else
    848             result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
    849     #endif
     878            m_reentryDepth++; 
     879#if ENABLE(JIT)
     880#if ENABLE(INTERPRETER)
     881            if (callFrame->globalData().canUseJIT())
     882#endif
     883                result = constructData.js.functionExecutable->jitCodeForConstruct(newCallFrame, constructDataScopeChain).execute(&m_registerFile, newCallFrame, constructDataScopeChain->globalData, exception);
     884#if ENABLE(INTERPRETER)
     885            else
     886#endif
     887#endif
     888#if ENABLE(INTERPRETER)
     889                result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     890#endif
    850891            m_reentryDepth--;
    851892        }
     
    923964    }
    924965    // a 0 codeBlock indicates a built-in caller
    925     newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function);
     966    newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function); 
    926967#if ENABLE(JIT)
    927     FunctionExecutable->jitCodeForCall(newCallFrame, scopeChain);
    928 #endif
    929 
     968#if ENABLE(INTERPRETER)
     969    if (callFrame->globalData().canUseJIT())
     970#endif
     971        FunctionExecutable->jitCodeForCall(newCallFrame, scopeChain);
     972#endif
    930973    CallFrameClosure result = { callFrame, newCallFrame, function, FunctionExecutable, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc };
    931974    return result;
     
    943986        SamplingTool::CallRecord callRecord(m_sampler.get());
    944987       
    945         m_reentryDepth++;
     988        m_reentryDepth++; 
    946989#if ENABLE(JIT)
    947         result = closure.functionExecutable->generatedJITCodeForCall().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
    948 #else
    949         result = privateExecute(Normal, &m_registerFile, closure.newCallFrame, exception);
     990#if ENABLE(INTERPRETER)
     991        if (closure.newCallFrame->globalData().canUseJIT())
     992#endif
     993            result = closure.functionExecutable->generatedJITCodeForCall().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
     994#if ENABLE(INTERPRETER)
     995        else
     996#endif
     997#endif
     998#if ENABLE(INTERPRETER)
     999            result = privateExecute(Normal, &m_registerFile, closure.newCallFrame, exception);
    9501000#endif
    9511001        m_reentryDepth--;
     
    10421092
    10431093        m_reentryDepth++;
     1094       
    10441095#if ENABLE(JIT)
    1045         result = eval->jitCode(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
    1046 #else
    1047         result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     1096#if ENABLE(INTERPRETER)
     1097        if (callFrame->globalData().canUseJIT())
     1098#endif
     1099            result = eval->jitCode(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
     1100#if ENABLE(INTERPRETER)
     1101        else
     1102#endif
     1103#endif
     1104#if ENABLE(INTERPRETER)
     1105            result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
    10481106#endif
    10491107        m_reentryDepth--;
     
    10851143}
    10861144   
    1087 #if !ENABLE(JIT)
     1145#if ENABLE(INTERPRETER)
    10881146NEVER_INLINE ScopeChainNode* Interpreter::createExceptionScope(CallFrame* callFrame, const Instruction* vPC)
    10891147{
     
    13211379}
    13221380
    1323 #endif // !ENABLE(JIT)
     1381#endif // ENABLE(INTERPRETER)
    13241382
    13251383JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFile, CallFrame* callFrame, JSValue* exception)
     
    13371395        return JSValue();
    13381396    }
    1339 
     1397   
    13401398#if ENABLE(JIT)
     1399#if ENABLE(INTERPRETER)
    13411400    // Mixing Interpreter + JIT is not supported.
    1342     ASSERT_NOT_REACHED();
    1343 #endif
    1344 #if !!ENABLE(JIT)
     1401    if (callFrame->globalData().canUseJIT())
     1402#endif
     1403        ASSERT_NOT_REACHED();
     1404#endif
     1405
     1406#if !ENABLE(INTERPRETER)
    13451407    UNUSED_PARAM(registerFile);
    13461408    UNUSED_PARAM(callFrame);
     
    37053767            }
    37063768            ASSERT(!asFunction(callFrame->callee())->isHostFunction());
    3707             uint32_t expectedParams = asFunction(callFrame->callee())->jsExecutable()->parameterCount();
    3708             uint32_t inplaceArgs = min(argCount, expectedParams);
    3709             uint32_t i = 0;
     3769            int32_t expectedParams = asFunction(callFrame->callee())->jsExecutable()->parameterCount();
     3770            int32_t inplaceArgs = min(static_cast<int32_t>(argCount), expectedParams);
     3771            int32_t i = 0;
    37103772            Register* argStore = callFrame->registers() + argsOffset;
    37113773
     
    37143776                argStore[i] = callFrame->registers()[i - RegisterFile::CallFrameHeaderSize - expectedParams];
    37153777            // Then we copy any additional arguments that may be further up the stack ('-1' to account for 'this')
    3716             for (; i < argCount; i++)
     3778            for (; i < static_cast<int32_t>(argCount); i++)
    37173779                argStore[i] = callFrame->registers()[i - RegisterFile::CallFrameHeaderSize - expectedParams - argCount - 1];
    37183780        } else if (!arguments.isUndefinedOrNull()) {
     
    39083970        JSValue returnValue = callFrame->r(result).jsValue();
    39093971
    3910         vPC = callFrame->returnPC();
     3972        vPC = callFrame->returnVPC();
    39113973        callFrame = callFrame->callerFrame();
    39123974       
     
    39524014            returnValue = callFrame->r(vPC[2].u.operand).jsValue();
    39534015
    3954         vPC = callFrame->returnPC();
     4016        vPC = callFrame->returnVPC();
    39554017        callFrame = callFrame->callerFrame();
    39564018
     
    41374199            codeBlock = newCodeBlock;
    41384200            vPC = newCodeBlock->instructions().begin();
    4139 
    41404201#if ENABLE(OPCODE_STATS)
    41414202            OpcodeStats::resetLastInstruction();
     
    45374598    #undef CHECK_FOR_EXCEPTION
    45384599    #undef CHECK_FOR_TIMEOUT
    4539 #endif // !ENABLE(JIT)
     4600#endif // ENABLE(INTERPRETER)
    45404601}
    45414602
     
    45934654    if (!callerCodeBlock)
    45944655        return;
    4595 
    4596     unsigned bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     4656    unsigned bytecodeOffset = 0;
     4657#if ENABLE(INTERPRETER)
     4658    if (!callerFrame->globalData().canUseJIT())
     4659        bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnVPC());
     4660#if ENABLE(JIT)
     4661    else
     4662        bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     4663#endif
     4664#else
     4665    bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     4666#endif
    45974667    lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(callerFrame, bytecodeOffset - 1);
    45984668    sourceID = callerCodeBlock->ownerExecutable()->sourceID();
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r60708 r62612  
    124124        JSValue execute(EvalExecutable*, CallFrame*, JSObject* thisObject, int globalRegisterOffset, ScopeChainNode*, JSValue* exception);
    125125
    126 #if !ENABLE(JIT)
     126#if ENABLE(INTERPRETER)
    127127        NEVER_INLINE bool resolve(CallFrame*, Instruction*, JSValue& exceptionValue);
    128128        NEVER_INLINE bool resolveSkip(CallFrame*, Instruction*, JSValue& exceptionValue);
     
    137137        void tryCachePutByID(CallFrame*, CodeBlock*, Instruction*, JSValue baseValue, const PutPropertySlot&);
    138138        void uncachePutByID(CodeBlock*, Instruction* vPC);       
    139 #endif // !ENABLE(JIT)
     139#endif // ENABLE(INTERPRETER)
    140140
    141141        NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue, unsigned& bytecodeOffset, CodeBlock*&);
Note: See TracChangeset for help on using the changeset viewer.