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

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: Created 4 years, 4 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_() {} 153 : CompilationJob(info, "Ignition"), generator_() {}
154 154
155 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() { 155 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
156 generator_.reset(new BytecodeGenerator(info())); 156 generator_.reset(new BytecodeGenerator(info()));
157
158 if (FLAG_print_bytecode || FLAG_print_ast) {
159 OFStream os(stdout);
160 std::unique_ptr<char[]> name = info()->GetDebugName();
161 os << "[generating bytecode for function: " << info()->GetDebugName().get()
162 << "]" << std::endl
163 << std::flush;
164 }
165
166 #ifdef DEBUG
167 if (info()->parse_info() && FLAG_print_ast) {
168 OFStream os(stdout);
169 os << "--- AST ---" << std::endl
170 << AstPrinter(info()->isolate()).PrintProgram(info()->literal())
171 << std::endl
172 << std::flush;
173 }
174 #endif // DEBUG
175
157 return SUCCEEDED; 176 return SUCCEEDED;
158 } 177 }
159 178
160 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() { 179 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
180 // TODO(5203): These timers aren't thread safe, move to using the CompilerJob
181 // timers.
182 RuntimeCallTimerScope runtimeTimer(info()->isolate(),
183 &RuntimeCallStats::CompileIgnition);
184 TimerEventScope<TimerEventCompileIgnition> timer(info()->isolate());
185 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
186 info()->isolate(), &tracing::TraceEventStatsTable::CompileIgnition);
187
161 generator()->GenerateBytecode(); 188 generator()->GenerateBytecode();
162 189
163 if (generator()->HasStackOverflow()) { 190 if (generator()->HasStackOverflow()) {
164 return FAILED; 191 return FAILED;
165 } 192 }
166 return SUCCEEDED; 193 return SUCCEEDED;
167 } 194 }
168 195
169 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() { 196 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
170 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(); 197 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode();
171 if (generator()->HasStackOverflow()) { 198 if (generator()->HasStackOverflow()) {
172 return FAILED; 199 return FAILED;
173 } 200 }
174 201
175 if (FLAG_print_bytecode) { 202 if (FLAG_print_bytecode) {
176 OFStream os(stdout); 203 OFStream os(stdout);
177 bytecodes->Print(os); 204 bytecodes->Print(os);
178 os << std::flush; 205 os << std::flush;
179 } 206 }
180 207
181 info()->SetBytecodeArray(bytecodes); 208 info()->SetBytecodeArray(bytecodes);
182 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline()); 209 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline());
183 return SUCCEEDED; 210 return SUCCEEDED;
184 } 211 }
185 212
186 bool Interpreter::MakeBytecode(CompilationInfo* info) { 213 CompilationJob* Interpreter::NewCompilationJob(CompilationInfo* info) {
187 RuntimeCallTimerScope runtimeTimer(info->isolate(), 214 return new InterpreterCompilationJob(info);
188 &RuntimeCallStats::CompileIgnition);
189 TimerEventScope<TimerEventCompileIgnition> timer(info->isolate());
190 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
191 info->isolate(), &tracing::TraceEventStatsTable::CompileIgnition);
192
193 if (FLAG_print_bytecode || FLAG_print_ast) {
194 OFStream os(stdout);
195 std::unique_ptr<char[]> name = info->GetDebugName();
196 os << "[generating bytecode for function: " << info->GetDebugName().get()
197 << "]" << std::endl
198 << std::flush;
199 }
200
201 #ifdef DEBUG
202 if (info->parse_info() && FLAG_print_ast) {
203 OFStream os(stdout);
204 os << "--- AST ---" << std::endl
205 << AstPrinter(info->isolate()).PrintProgram(info->literal()) << std::endl
206 << std::flush;
207 }
208 #endif // DEBUG
209
210 InterpreterCompilationJob job(info);
211 if (job.PrepareJob() != CompilationJob::SUCCEEDED) return false;
212 if (job.ExecuteJob() != CompilationJob::SUCCEEDED) return false;
213 return job.FinalizeJob() == CompilationJob::SUCCEEDED;
214 } 215 }
215 216
216 bool Interpreter::IsDispatchTableInitialized() { 217 bool Interpreter::IsDispatchTableInitialized() {
217 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen || 218 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
218 FLAG_trace_ignition_dispatches) { 219 FLAG_trace_ignition_dispatches) {
219 // Regenerate table to add bytecode tracing operations, print the assembly 220 // Regenerate table to add bytecode tracing operations, print the assembly
220 // code generated by TurboFan or instrument handlers with dispatch counters. 221 // code generated by TurboFan or instrument handlers with dispatch counters.
221 return false; 222 return false;
222 } 223 }
223 return dispatch_table_[0] != nullptr; 224 return dispatch_table_[0] != nullptr;
(...skipping 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2205 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2205 __ SmiTag(new_state)); 2206 __ SmiTag(new_state));
2206 __ SetAccumulator(old_state); 2207 __ SetAccumulator(old_state);
2207 2208
2208 __ Dispatch(); 2209 __ Dispatch();
2209 } 2210 }
2210 2211
2211 } // namespace interpreter 2212 } // namespace interpreter
2212 } // namespace internal 2213 } // namespace internal
2213 } // namespace v8 2214 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698