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

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: Rebase 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
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 15c0ce8a09b24cf151d19d44e9fd86a291b32486..fe6030e5e9294cf6223715a0a948d211aab10c08 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_; }
+
+ BytecodeGenerator generator_;
+
+ DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob);
+};
+
Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
memset(dispatch_table_, 0, sizeof(dispatch_table_));
}
@@ -132,6 +149,39 @@ int Interpreter::InterruptBudget() {
return FLAG_interrupt_budget * kCodeSizeMultiplier;
}
+InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info)
+ : CompilationJob(info, "Ignition"), generator_(info) {}
+
+InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
+ return SUCCEEDED;
+}
+
+InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
+ generator()->GenerateBytecode();
+
+ if (generator()->HasStackOverflow()) {
+ return FAILED;
+ }
+ return SUCCEEDED;
+}
+
+InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
+ Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate());
+ 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 +206,10 @@ bool Interpreter::MakeBytecode(CompilationInfo* info) {
}
#endif // DEBUG
- BytecodeGenerator generator(info);
- Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info->isolate());
-
- 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() {
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698