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

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2500443004: [wasm] OOB traps: build protected instruction list during codegen (Closed)
Patch Set: Merging with master Created 4 years, 1 month 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/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index eaa5b6fec6e2202b476c299589bb5a6863e24c94..fc20b77aa602a29fdf393020535383309a84103c 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -3430,7 +3430,8 @@ void WasmCompilationUnit::ExecuteCompilation() {
module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor);
}
job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(),
- descriptor, source_positions));
+ descriptor, source_positions,
+ &protected_instructions_));
ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED;
// TODO(bradnelson): Improve histogram handling of size_t.
// TODO(ahaas): The counters are not thread-safe at the moment.
@@ -3490,9 +3491,26 @@ Handle<Code> WasmCompilationUnit::FinishCompilation() {
compile_ms);
}
+ Handle<FixedArray> protected_instructions = PackProtectedInstructions();
+ code->set_protected_instructions(*protected_instructions);
+
return code;
}
+Handle<FixedArray> WasmCompilationUnit::PackProtectedInstructions() const {
+ const int num_instructions = static_cast<int>(protected_instructions_.size());
+ Handle<FixedArray> fn_protected = isolate_->factory()->NewFixedArray(
+ num_instructions * wasm::kTrapDataSize, TENURED);
+ for (unsigned i = 0; i < protected_instructions_.size(); ++i) {
+ const ProtectedInstructionData& instruction = protected_instructions_[i];
+ fn_protected->set(wasm::kTrapDataSize * i + wasm::kTrapCodeOffset,
+ Smi::FromInt(instruction.instr_offset));
+ fn_protected->set(wasm::kTrapDataSize * i + wasm::kTrapLandingOffset,
+ Smi::FromInt(instruction.landing_offset));
+ }
+ return fn_protected;
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698