Changeset 154824 in webkit for trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
- Timestamp:
- Aug 29, 2013, 11:25:36 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r154814 r154824 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 #if ENABLE(LLINT) 2704 switch (codeType()) { 2705 case GlobalCode: 2706 LLInt::setProgramEntrypoint(vm, static_cast<ProgramCodeBlock*>(this)); 2707 break; 2708 case EvalCode: 2709 LLInt::setEvalEntrypoint(vm, static_cast<EvalCodeBlock*>(this)); 2710 break; 2711 case FunctionCode: 2712 LLInt::setFunctionEntrypoint(vm, static_cast<FunctionCodeBlock*>(this)); 2713 break; 2714 } 2715 return CompilationSuccessful; 2716 #else // ENABLE(LLINT) 2717 return CompilationFailed; 2718 #endif // ENABLE(LLINT) 2719 } 2720 2721 #if ENABLE(JIT) 2722 if (JITCode::isOptimizingJIT(jitType)) { 2723 ASSERT(effort == JITCompilationCanFail); 2724 bool hadCallback = !!callback; 2725 CompilationResult result = DFG::tryCompile(exec, this, bytecodeIndex, callback); 2726 ASSERT_UNUSED(hadCallback, result != CompilationDeferred || hadCallback); 2727 return result; 2728 } 2729 2730 MacroAssemblerCodePtr jitCodeWithArityCheck; 2731 RefPtr<JITCode> jitCode = JIT::compile(&vm, this, effort, &jitCodeWithArityCheck); 2732 if (!jitCode) 2733 return CompilationFailed; 2734 setJITCode(jitCode, jitCodeWithArityCheck); 2735 return CompilationSuccessful; 2736 #else 2737 UNUSED_PARAM(effort); 2738 UNUSED_PARAM(bytecodeIndex); 2739 UNUSED_PARAM(callback); 2740 return CompilationFailed; 2741 #endif // ENABLE(JIT) 2742 } 2743 2744 CompilationResult CodeBlock::prepareForExecution( 2745 ExecState* exec, JITCode::JITType jitType, 2746 JITCompilationEffort effort, unsigned bytecodeIndex) 2747 { 2748 CompilationResult result = 2749 prepareForExecutionImpl(exec, jitType, effort, bytecodeIndex, 0); 2750 ASSERT(result != CompilationDeferred); 2751 return result; 2752 } 2753 2754 CompilationResult CodeBlock::prepareForExecutionAsynchronously( 2755 ExecState* exec, JITCode::JITType jitType, 2756 PassRefPtr<DeferredCompilationCallback> passedCallback, 2757 JITCompilationEffort effort, unsigned bytecodeIndex) 2758 { 2759 RefPtr<DeferredCompilationCallback> callback = passedCallback; 2760 CompilationResult result = 2761 prepareForExecutionImpl(exec, jitType, effort, bytecodeIndex, callback); 2762 if (result != CompilationDeferred) 2763 callback->compilationDidComplete(this, result); 2764 return result; 2765 } 2766 2767 void CodeBlock::install() 2768 { 2769 ownerExecutable()->installCode(this); 2770 } 2771 2772 PassRefPtr<CodeBlock> CodeBlock::newReplacement() 2773 { 2774 return ownerExecutable()->newReplacementCodeBlockFor(specializationKind()); 2775 } 2776 2692 2777 #if ENABLE(JIT) 2693 2778 void CodeBlock::reoptimize() … … 2715 2800 return &static_cast<FunctionExecutable*>(ownerExecutable())->generatedBytecodeFor(m_isConstructor ? CodeForConstruct : CodeForCall); 2716 2801 } 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 2802 2765 2803 DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal() … … 2804 2842 { 2805 2843 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 2844 } 2828 2845 #endif
Note:
See TracChangeset
for help on using the changeset viewer.