Changeset 154804 in webkit for trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
- Timestamp:
- Aug 28, 2013, 9:03:05 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r154162 r154804 35 35 #include "DFGCapabilities.h" 36 36 #include "DFGCommon.h" 37 #include "DFGDriver.h" 37 38 #include "DFGNode.h" 38 39 #include "DFGRepatch.h" … … 46 47 #include "JSFunction.h" 47 48 #include "JSNameScope.h" 49 #include "LLIntEntrypoints.h" 48 50 #include "LowLevelInterpreter.h" 49 51 #include "Operations.h" … … 2537 2539 m_incomingCalls.push(incoming); 2538 2540 } 2541 #endif // ENABLE(JIT) 2539 2542 2540 2543 void CodeBlock::unlinkIncomingCalls() … … 2543 2546 while (m_incomingLLIntCalls.begin() != m_incomingLLIntCalls.end()) 2544 2547 m_incomingLLIntCalls.begin()->unlink(); 2545 #endif 2548 #endif // ENABLE(LLINT) 2549 #if ENABLE(JIT) 2546 2550 if (m_incomingCalls.isEmpty()) 2547 2551 return; … … 2549 2553 while (m_incomingCalls.begin() != m_incomingCalls.end()) 2550 2554 m_incomingCalls.begin()->unlink(*m_vm, repatchBuffer); 2551 }2552 2555 #endif // ENABLE(JIT) 2556 } 2553 2557 2554 2558 #if ENABLE(LLINT) … … 2690 2694 } 2691 2695 2696 CompilationResult CodeBlock::prepareForExecutionImpl( 2697 ExecState* exec, JITCode::JITType jitType, JITCompilationEffort effort, 2698 unsigned bytecodeIndex, PassRefPtr<DeferredCompilationCallback> callback) 2699 { 2700 VM& vm = exec->vm(); 2701 2702 if (jitType == JITCode::InterpreterThunk) { 2703 switch (codeType()) { 2704 case GlobalCode: 2705 LLInt::setProgramEntrypoint(vm, static_cast<ProgramCodeBlock*>(this)); 2706 break; 2707 case EvalCode: 2708 LLInt::setEvalEntrypoint(vm, static_cast<EvalCodeBlock*>(this)); 2709 break; 2710 case FunctionCode: 2711 LLInt::setFunctionEntrypoint(vm, static_cast<FunctionCodeBlock*>(this)); 2712 break; 2713 } 2714 return CompilationSuccessful; 2715 } 2716 2717 #if ENABLE(JIT) 2718 if (JITCode::isOptimizingJIT(jitType)) { 2719 ASSERT(effort == JITCompilationCanFail); 2720 bool hadCallback = !!callback; 2721 CompilationResult result = DFG::tryCompile(exec, this, bytecodeIndex, callback); 2722 ASSERT_UNUSED(hadCallback, result != CompilationDeferred || hadCallback); 2723 return result; 2724 } 2725 2726 MacroAssemblerCodePtr jitCodeWithArityCheck; 2727 RefPtr<JITCode> jitCode = JIT::compile(&vm, this, effort, &jitCodeWithArityCheck); 2728 if (!jitCode) 2729 return CompilationFailed; 2730 setJITCode(jitCode, jitCodeWithArityCheck); 2731 return CompilationSuccessful; 2732 #else 2733 UNUSED_PARAM(effort); 2734 UNUSED_PARAM(bytecodeIndex); 2735 UNUSED_PARAM(callback); 2736 return CompilationFailed; 2737 #endif // ENABLE(JIT) 2738 } 2739 2740 CompilationResult CodeBlock::prepareForExecution( 2741 ExecState* exec, JITCode::JITType jitType, 2742 JITCompilationEffort effort, unsigned bytecodeIndex) 2743 { 2744 CompilationResult result = 2745 prepareForExecutionImpl(exec, jitType, effort, bytecodeIndex, 0); 2746 ASSERT(result != CompilationDeferred); 2747 return result; 2748 } 2749 2750 CompilationResult CodeBlock::prepareForExecutionAsynchronously( 2751 ExecState* exec, JITCode::JITType jitType, 2752 PassRefPtr<DeferredCompilationCallback> passedCallback, 2753 JITCompilationEffort effort, unsigned bytecodeIndex) 2754 { 2755 RefPtr<DeferredCompilationCallback> callback = passedCallback; 2756 CompilationResult result = 2757 prepareForExecutionImpl(exec, jitType, effort, bytecodeIndex, callback); 2758 if (result != CompilationDeferred) 2759 callback->compilationDidComplete(this, result); 2760 return result; 2761 } 2762 2763 void CodeBlock::install() 2764 { 2765 ownerExecutable()->installCode(this); 2766 } 2767 2768 PassRefPtr<CodeBlock> CodeBlock::newReplacement() 2769 { 2770 return ownerExecutable()->newReplacementCodeBlockFor(specializationKind()); 2771 } 2772 2692 2773 #if ENABLE(JIT) 2693 2774 void CodeBlock::reoptimize() … … 2715 2796 return &static_cast<FunctionExecutable*>(ownerExecutable())->generatedBytecodeFor(m_isConstructor ? CodeForConstruct : CodeForCall); 2716 2797 } 2717 2718 #if ENABLE(DFG_JIT)2719 JSObject* ProgramCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)2720 {2721 if (JITCode::isHigherTier(replacement()->jitType(), jitType())) {2722 result = CompilationNotNeeded;2723 return 0;2724 }2725 JSObject* error = static_cast<ProgramExecutable*>(ownerExecutable())->compileOptimized(exec, scope, result, bytecodeIndex);2726 return error;2727 }2728 2729 CompilationResult ProgramCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)2730 {2731 return static_cast<ProgramExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCode(plan);2732 }2733 2734 JSObject* EvalCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)2735 {2736 if (JITCode::isHigherTier(replacement()->jitType(), jitType())) {2737 result = CompilationNotNeeded;2738 return 0;2739 }2740 JSObject* error = static_cast<EvalExecutable*>(ownerExecutable())->compileOptimized(exec, scope, result, bytecodeIndex);2741 return error;2742 }2743 2744 CompilationResult EvalCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)2745 {2746 return static_cast<EvalExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCode(plan);2747 }2748 2749 JSObject* FunctionCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)2750 {2751 if (JITCode::isHigherTier(replacement()->jitType(), jitType())) {2752 result = CompilationNotNeeded;2753 return 0;2754 }2755 JSObject* error = static_cast<FunctionExecutable*>(ownerExecutable())->compileOptimizedFor(exec, scope, result, bytecodeIndex, m_isConstructor ? CodeForConstruct : CodeForCall);2756 return error;2757 }2758 2759 CompilationResult FunctionCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)2760 {2761 return static_cast<FunctionExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCodeFor(plan, m_isConstructor ? CodeForConstruct : CodeForCall);2762 }2763 #endif // ENABLE(DFG_JIT)2764 2798 2765 2799 DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal() … … 2804 2838 { 2805 2839 static_cast<FunctionExecutable*>(ownerExecutable())->jettisonOptimizedCodeFor(*vm(), m_isConstructor ? CodeForConstruct : CodeForCall); 2806 }2807 2808 CompilationResult ProgramCodeBlock::jitCompileImpl(ExecState* exec)2809 {2810 ASSERT(jitType() == JITCode::InterpreterThunk);2811 ASSERT(this == replacement());2812 return static_cast<ProgramExecutable*>(ownerExecutable())->jitCompile(exec);2813 }2814 2815 CompilationResult EvalCodeBlock::jitCompileImpl(ExecState* exec)2816 {2817 ASSERT(jitType() == JITCode::InterpreterThunk);2818 ASSERT(this == replacement());2819 return static_cast<EvalExecutable*>(ownerExecutable())->jitCompile(exec);2820 }2821 2822 CompilationResult FunctionCodeBlock::jitCompileImpl(ExecState* exec)2823 {2824 ASSERT(jitType() == JITCode::InterpreterThunk);2825 ASSERT(this == replacement());2826 return static_cast<FunctionExecutable*>(ownerExecutable())->jitCompileFor(exec, m_isConstructor ? CodeForConstruct : CodeForCall);2827 2840 } 2828 2841 #endif
Note:
See TracChangeset
for help on using the changeset viewer.