Changeset 153161 in webkit for trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp
- Timestamp:
- Jul 24, 2013, 9:00:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp
r153144 r153161 30 30 #include "JSString.h" 31 31 32 33 32 #if ENABLE(DFG_JIT) 34 33 35 #include "DFGArgumentsSimplificationPhase.h" 36 #include "DFGBackwardsPropagationPhase.h" 37 #include "DFGByteCodeParser.h" 38 #include "DFGCFAPhase.h" 39 #include "DFGCFGSimplificationPhase.h" 40 #include "DFGCPSRethreadingPhase.h" 41 #include "DFGCSEPhase.h" 42 #include "DFGConstantFoldingPhase.h" 43 #include "DFGDCEPhase.h" 44 #include "DFGFixupPhase.h" 45 #include "DFGJITCompiler.h" 46 #include "DFGPredictionInjectionPhase.h" 47 #include "DFGPredictionPropagationPhase.h" 48 #include "DFGTypeCheckHoistingPhase.h" 49 #include "DFGUnificationPhase.h" 50 #include "DFGValidate.h" 51 #include "DFGVirtualRegisterAllocationPhase.h" 52 #include "FTLCapabilities.h" 53 #include "FTLCompile.h" 54 #include "FTLLink.h" 55 #include "FTLLowerDFGToLLVM.h" 56 #include "FTLState.h" 34 #include "DFGJITCode.h" 35 #include "DFGPlan.h" 36 #include "DFGThunks.h" 37 #include "FTLThunks.h" 38 #include "JITCode.h" 57 39 #include "Operations.h" 58 40 #include "Options.h" 59 #include <wtf/CompilationThread.h>60 41 61 42 namespace JSC { namespace DFG { … … 68 49 } 69 50 70 static void dumpAndVerifyGraph(Graph& graph, const char* text)71 {72 GraphDumpMode modeForFinalValidate = DumpGraph;73 if (verboseCompilationEnabled()) {74 dataLog(text, "\n");75 graph.dump();76 modeForFinalValidate = DontDumpGraph;77 }78 if (validationEnabled())79 validate(graph, modeForFinalValidate);80 }81 82 enum CompileMode { CompileFunction, CompileOther };83 51 static bool compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex) 84 52 { 85 53 SamplingRegion samplingRegion("DFG Compilation (Driver)"); 86 CompilationScope compilationScope;87 54 88 55 numCompilations++; … … 103 70 dataLog("DFG compiling ", *codeBlock, ", number of instructions = ", codeBlock->instructionCount(), "\n"); 104 71 72 // Make sure that any stubs that the DFG is going to use are initialized. We want to 73 // make sure that al JIT code generation does finalization on the main thread. 74 exec->vm().getCTIStub(osrExitGenerationThunkGenerator); 75 exec->vm().getCTIStub(throwExceptionFromCallSlowPathGenerator); 76 exec->vm().getCTIStub(linkCallThunkGenerator); 77 exec->vm().getCTIStub(linkConstructThunkGenerator); 78 exec->vm().getCTIStub(linkClosureCallThunkGenerator); 79 exec->vm().getCTIStub(virtualCallThunkGenerator); 80 exec->vm().getCTIStub(virtualConstructThunkGenerator); 81 #if ENABLE(FTL_JIT) 82 exec->vm().getCTIStub(FTL::osrExitGenerationThunkGenerator); 83 #endif 84 105 85 // Derive our set of must-handle values. The compilation must be at least conservative 106 86 // enough to allow for OSR entry with these values. … … 110 90 else 111 91 numVarsWithValues = 0; 112 Operands<JSValue> mustHandleValues(codeBlock->numParameters(), numVarsWithValues);113 for (size_t i = 0; i < mustHandleValues.size(); ++i) {114 int operand = mustHandleValues.operandForIndex(i);92 Plan plan(compileMode, codeBlock, osrEntryBytecodeIndex, numVarsWithValues); 93 for (size_t i = 0; i < plan.mustHandleValues.size(); ++i) { 94 int operand = plan.mustHandleValues.operandForIndex(i); 115 95 if (operandIsArgument(operand) 116 96 && !operandToArgument(operand) … … 121 101 // but it has to be an actual value that can be grokked by subsequent DFG passes, 122 102 // so we sanitize it here by turning it into Undefined. 123 mustHandleValues[i] = jsUndefined();103 plan.mustHandleValues[i] = jsUndefined(); 124 104 } else 125 mustHandleValues[i] = exec->uncheckedR(operand).jsValue();105 plan.mustHandleValues[i] = exec->uncheckedR(operand).jsValue(); 126 106 } 127 107 128 Graph dfg(exec->vm(), codeBlock, osrEntryBytecodeIndex, mustHandleValues);129 if ( !parse(dfg))108 plan.compileInThread(); 109 if (plan.finalize(jitCode, jitCodeWithArityCheck) != CompilationSuccessful) 130 110 return false; 131 132 // By this point the DFG bytecode parser will have potentially mutated various tables 133 // in the CodeBlock. This is a good time to perform an early shrink, which is more 134 // powerful than a late one. It's safe to do so because we haven't generated any code 135 // that references any of the tables directly, yet. 136 codeBlock->shrinkToFit(CodeBlock::EarlyShrink); 137 138 if (validationEnabled()) 139 validate(dfg); 140 141 performCPSRethreading(dfg); 142 performUnification(dfg); 143 performPredictionInjection(dfg); 144 145 if (validationEnabled()) 146 validate(dfg); 147 148 performBackwardsPropagation(dfg); 149 performPredictionPropagation(dfg); 150 performFixup(dfg); 151 performTypeCheckHoisting(dfg); 152 153 dfg.m_fixpointState = FixpointNotConverged; 154 155 performCSE(dfg); 156 performArgumentsSimplification(dfg); 157 performCPSRethreading(dfg); // This should usually be a no-op since CSE rarely dethreads, and arguments simplification rarely does anything. 158 performCFA(dfg); 159 performConstantFolding(dfg); 160 performCFGSimplification(dfg); 161 162 dfg.m_fixpointState = FixpointConverged; 163 164 performStoreElimination(dfg); 165 performCPSRethreading(dfg); 166 performDCE(dfg); 167 168 #if ENABLE(FTL_JIT) 169 if (Options::useExperimentalFTL() 170 && compileMode == CompileFunction 171 && FTL::canCompile(dfg)) { 172 173 dumpAndVerifyGraph(dfg, "Graph just before FTL lowering:"); 174 175 // FIXME: Support OSR entry. 176 // https://bugs.webkit.org/show_bug.cgi?id=113625 177 178 FTL::State state(dfg); 179 FTL::lowerDFGToLLVM(state); 180 FTL::compile(state); 181 compilationScope.leaveEarly(); 182 return FTL::link(state, jitCode, *jitCodeWithArityCheck); 183 } 184 #endif // ENABLE(FTL_JIT) 185 186 performVirtualRegisterAllocation(dfg); 187 dumpAndVerifyGraph(dfg, "Graph after optimization:"); 188 189 JITCompiler dataFlowJIT(dfg); 190 bool result; 191 if (compileMode == CompileFunction) { 192 ASSERT(jitCodeWithArityCheck); 193 194 if (!dataFlowJIT.compileFunction()) 195 return false; 196 compilationScope.leaveEarly(); 197 result = dataFlowJIT.linkFunction(jitCode, *jitCodeWithArityCheck); 198 } else { 199 ASSERT(compileMode == CompileOther); 200 ASSERT(!jitCodeWithArityCheck); 201 202 if (!dataFlowJIT.compile()) 203 return false; 204 compilationScope.leaveEarly(); 205 result = dataFlowJIT.link(jitCode); 206 } 207 208 return result; 111 return true; 209 112 } 210 113
Note:
See TracChangeset
for help on using the changeset viewer.