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

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

Issue 2500443004: [wasm] OOB traps: build protected instruction list during codegen (Closed)
Patch Set: Fixing Windows better 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/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 865fc260e38eda4c72733cbec63ac303d0454de0..124ce8786d21060ed78c3f77797dcdd077638891 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -801,9 +801,37 @@ MaybeHandle<WasmCompiledModule> WasmModule::CompileFunctions(
ret->set_module_bytes(Handle<SeqOneByteString>::cast(module_bytes_string));
}
+ Handle<FixedArray> protected_instructions =
+ PackProtectedInstructions(temp_instance.protected_instructions, factory);
+ ret->set_protected_instructions(protected_instructions);
+
return ret;
}
+Handle<FixedArray> WasmModule::PackProtectedInstructions(
titzer 2016/11/16 18:06:47 I think this can also move into the compiler.
Eric Holk 2016/11/18 02:19:46 Done.
+ const std::vector<ProtectedInstructionList>& protected_instructions,
+ Factory* factory) const {
+ const int num_instructions = static_cast<int>(protected_instructions.size());
+ Handle<FixedArray> all_protected =
+ factory->NewFixedArray(num_instructions, TENURED);
+ for (int j = 0; j < num_instructions; ++j) {
+ const ProtectedInstructionList& func = protected_instructions[j];
+ const int func_instructions = static_cast<int>(func.size());
+ Handle<FixedArray> fn_protected =
+ factory->NewFixedArray(func_instructions * kTrapDataSize, TENURED);
+ for (unsigned i = 0; i < func.size(); ++i) {
+ const ProtectedInstructionData& instruction = func[i];
+ fn_protected->set(kTrapDataSize * i + kTrapCodeOffset,
+ Smi::FromInt(instruction.instr_offset));
+ fn_protected->set(kTrapDataSize * i + kTrapLandingOffset,
+ Smi::FromInt(instruction.landing_offset));
+ }
+
+ all_protected->set(j, *fn_protected);
+ }
+ return all_protected;
+}
+
static WasmFunction* GetWasmFunctionForImportWrapper(Isolate* isolate,
Handle<Object> target) {
if (target->IsJSFunction()) {
@@ -1117,6 +1145,36 @@ class WasmInstanceBuilder {
FlushICache(isolate_, code_table);
//--------------------------------------------------------------------------
+ // Unpack and notify signal handler of protected instructions.
+ //--------------------------------------------------------------------------
+ {
+ Handle<FixedArray> protected_instructions =
+ compiled_module_->protected_instructions();
+
+ for (int i = 0; i < protected_instructions->length(); ++i) {
+ Handle<FixedArray> fn_protect =
+ protected_instructions->GetValueChecked<FixedArray>(isolate_, i);
+
+ ProtectedInstructionList unpacked;
+ for (int i = 0; i < fn_protect->length();
+ i += WasmModule::kTrapDataSize) {
+ ProtectedInstructionData data;
+ data.instr_offset = fn_protect
+ ->GetValueChecked<Smi>(
+ isolate_, i + WasmModule::kTrapCodeOffset)
+ ->value();
+ data.landing_offset =
+ fn_protect
+ ->GetValueChecked<Smi>(isolate_,
+ i + WasmModule::kTrapLandingOffset)
+ ->value();
+ unpacked.push_back(data);
+ }
+ // TODO(eholk): Register the protected instruction information once the
+ // trap handler is in place.
+ }
+ }
+
// Set up and link the new instance.
//--------------------------------------------------------------------------
{
« src/wasm/wasm-module.h ('K') | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698