Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: src/interpreter/interpreter.cc

Issue 2251713002: [Compiler] Add compile to CompilerDispatcherJob. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_compilerdispatcher
Patch Set: Fix comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 } 144 }
145 } 145 }
146 146
147 // static 147 // static
148 int Interpreter::InterruptBudget() { 148 int Interpreter::InterruptBudget() {
149 return FLAG_interrupt_budget * kCodeSizeMultiplier; 149 return FLAG_interrupt_budget * kCodeSizeMultiplier;
150 } 150 }
151 151
152 InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info) 152 InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info)
153 : CompilationJob(info, "Ignition"), generator_(info) {} 153 : CompilationJob(info->isolate(), info, "Ignition"), generator_(info) {}
154 154
155 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() { 155 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
156 if (FLAG_print_bytecode || FLAG_print_ast) {
157 OFStream os(stdout);
158 std::unique_ptr<char[]> name = info()->GetDebugName();
159 os << "[generating bytecode for function: " << info()->GetDebugName().get()
160 << "]" << std::endl
161 << std::flush;
162 }
163
164 #ifdef DEBUG
165 if (info()->parse_info() && FLAG_print_ast) {
166 OFStream os(stdout);
167 os << "--- AST ---" << std::endl
168 << AstPrinter(info()->isolate()).PrintProgram(info()->literal())
169 << std::endl
170 << std::flush;
171 }
172 #endif // DEBUG
173
156 return SUCCEEDED; 174 return SUCCEEDED;
157 } 175 }
158 176
159 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() { 177 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
160 generator()->GenerateBytecode(); 178 // TODO(5203): These timers aren't thread safe, move to using the CompilerJob
179 // timers.
180 RuntimeCallTimerScope runtimeTimer(info()->isolate(),
181 &RuntimeCallStats::CompileIgnition);
182 TimerEventScope<TimerEventCompileIgnition> timer(info()->isolate());
183 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
184 info()->isolate(), &tracing::TraceEventStatsTable::CompileIgnition);
185
186 generator()->GenerateBytecode(stack_limit());
161 187
162 if (generator()->HasStackOverflow()) { 188 if (generator()->HasStackOverflow()) {
163 return FAILED; 189 return FAILED;
164 } 190 }
165 return SUCCEEDED; 191 return SUCCEEDED;
166 } 192 }
167 193
168 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() { 194 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
169 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate()); 195 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate());
170 if (generator()->HasStackOverflow()) { 196 if (generator()->HasStackOverflow()) {
171 return FAILED; 197 return FAILED;
172 } 198 }
173 199
174 if (FLAG_print_bytecode) { 200 if (FLAG_print_bytecode) {
175 OFStream os(stdout); 201 OFStream os(stdout);
176 bytecodes->Print(os); 202 bytecodes->Print(os);
177 os << std::flush; 203 os << std::flush;
178 } 204 }
179 205
180 info()->SetBytecodeArray(bytecodes); 206 info()->SetBytecodeArray(bytecodes);
181 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline()); 207 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline());
182 return SUCCEEDED; 208 return SUCCEEDED;
183 } 209 }
184 210
185 bool Interpreter::MakeBytecode(CompilationInfo* info) { 211 CompilationJob* Interpreter::NewCompilationJob(CompilationInfo* info) {
186 RuntimeCallTimerScope runtimeTimer(info->isolate(), 212 return new InterpreterCompilationJob(info);
187 &RuntimeCallStats::CompileIgnition);
188 TimerEventScope<TimerEventCompileIgnition> timer(info->isolate());
189 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
190 info->isolate(), &tracing::TraceEventStatsTable::CompileIgnition);
191
192 if (FLAG_print_bytecode || FLAG_print_ast) {
193 OFStream os(stdout);
194 std::unique_ptr<char[]> name = info->GetDebugName();
195 os << "[generating bytecode for function: " << info->GetDebugName().get()
196 << "]" << std::endl
197 << std::flush;
198 }
199
200 #ifdef DEBUG
201 if (info->parse_info() && FLAG_print_ast) {
202 OFStream os(stdout);
203 os << "--- AST ---" << std::endl
204 << AstPrinter(info->isolate()).PrintProgram(info->literal()) << std::endl
205 << std::flush;
206 }
207 #endif // DEBUG
208
209 InterpreterCompilationJob job(info);
210 if (job.PrepareJob() != CompilationJob::SUCCEEDED) return false;
211 if (job.ExecuteJob() != CompilationJob::SUCCEEDED) return false;
212 return job.FinalizeJob() == CompilationJob::SUCCEEDED;
213 } 213 }
214 214
215 bool Interpreter::IsDispatchTableInitialized() { 215 bool Interpreter::IsDispatchTableInitialized() {
216 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen || 216 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
217 FLAG_trace_ignition_dispatches) { 217 FLAG_trace_ignition_dispatches) {
218 // Regenerate table to add bytecode tracing operations, print the assembly 218 // Regenerate table to add bytecode tracing operations, print the assembly
219 // code generated by TurboFan or instrument handlers with dispatch counters. 219 // code generated by TurboFan or instrument handlers with dispatch counters.
220 return false; 220 return false;
221 } 221 }
222 return dispatch_table_[0] != nullptr; 222 return dispatch_table_[0] != nullptr;
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2332 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2333 __ SmiTag(new_state)); 2333 __ SmiTag(new_state));
2334 __ SetAccumulator(old_state); 2334 __ SetAccumulator(old_state);
2335 2335
2336 __ Dispatch(); 2336 __ Dispatch();
2337 } 2337 }
2338 2338
2339 } // namespace interpreter 2339 } // namespace interpreter
2340 } // namespace internal 2340 } // namespace internal
2341 } // namespace v8 2341 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698