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

Unified Diff: src/interpreter/interpreter.cc

Issue 2240463002: [Interpreter] Introduce InterpreterCompilationJob (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_peekhole
Patch Set: DISALLOW_COPY_AND_ASSIGN 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 side-by-side diff with in-line comments
Download patch
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index acc69c43967019bac0b29301ed753a55330c5c41..f39910356a967a3299438f2c1bb702588fc257dc 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -30,6 +30,23 @@ typedef InterpreterAssembler::Arg Arg;
#define __ assembler->
+class InterpreterCompilationJob final : public CompilationJob {
+ public:
+ explicit InterpreterCompilationJob(CompilationInfo* info);
+
+ protected:
+ Status PrepareJobImpl() final;
+ Status ExecuteJobImpl() final;
+ Status FinalizeJobImpl() final;
+
+ private:
+ BytecodeGenerator* generator() { return generator_.get(); }
+
+ std::unique_ptr<BytecodeGenerator> generator_;
Michael Starzinger 2016/08/16 08:46:40 Would it be possible to just have BytecodeGenerato
rmcilroy 2016/08/16 11:10:44 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob);
+};
+
Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
memset(dispatch_table_, 0, sizeof(dispatch_table_));
}
@@ -132,6 +149,40 @@ int Interpreter::InterruptBudget() {
return FLAG_interrupt_budget * kCodeSizeMultiplier;
}
+InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info)
+ : CompilationJob(info, "Ignition"), generator_() {}
+
+InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
+ generator_.reset(new BytecodeGenerator(info()));
+ return SUCCEEDED;
+}
+
+InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
+ generator()->GenerateBytecode();
+
+ if (generator()->HasStackOverflow()) {
+ return FAILED;
+ }
+ return SUCCEEDED;
+}
+
+InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
+ Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode();
+ if (generator()->HasStackOverflow()) {
+ return FAILED;
+ }
+
+ if (FLAG_print_bytecode) {
+ OFStream os(stdout);
+ bytecodes->Print(os);
+ os << std::flush;
+ }
+
+ info()->SetBytecodeArray(bytecodes);
+ info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline());
+ return SUCCEEDED;
+}
+
bool Interpreter::MakeBytecode(CompilationInfo* info) {
RuntimeCallTimerScope runtimeTimer(info->isolate(),
&RuntimeCallStats::CompileIgnition);
@@ -156,20 +207,10 @@ bool Interpreter::MakeBytecode(CompilationInfo* info) {
}
#endif // DEBUG
- BytecodeGenerator generator(info);
- Handle<BytecodeArray> bytecodes = generator.MakeBytecode();
-
- if (generator.HasStackOverflow()) return false;
-
- if (FLAG_print_bytecode) {
- OFStream os(stdout);
- bytecodes->Print(os);
- os << std::flush;
- }
-
- info->SetBytecodeArray(bytecodes);
- info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline());
- return true;
+ InterpreterCompilationJob job(info);
+ if (job.PrepareJob() != CompilationJob::SUCCEEDED) return false;
+ if (job.ExecuteJob() != CompilationJob::SUCCEEDED) return false;
+ return job.FinalizeJob() == CompilationJob::SUCCEEDED;
}
bool Interpreter::IsDispatchTableInitialized() {

Powered by Google App Engine
This is Rietveld 408576698