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

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

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Addressing some of Jochen's feedback Created 3 years, 12 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/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 40aec7ad33d0fed98c4fac593a6140e71b97a64b..c7d67c31f5ea6a764331f510dec51426a3c357a5 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -14,6 +14,7 @@
#include "src/property-descriptor.h"
#include "src/simulator.h"
#include "src/snapshot/snapshot.h"
+#include "src/trap-handler/trap-handler.h"
#include "src/v8.h"
#include "src/wasm/function-body-decoder.h"
@@ -600,6 +601,17 @@ static void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) {
DCHECK(compiled_module->has_weak_wasm_module());
WeakCell* weak_wasm_module = compiled_module->ptr_to_weak_wasm_module();
+ if (trap_handler::EnableTrapHandler()) {
+ Handle<FixedArray> code_table = compiled_module->code_table();
+ for (int i = 0; i < code_table->length(); ++i) {
+ Handle<Code> code = code_table->GetValueChecked<Code>(isolate, i);
+ int index = code->trap_handler_index()->value();
+ if (index >= 0) {
+ trap_handler::ReleaseHandlerData(index);
+ }
+ }
+ }
+
// weak_wasm_module may have been cleared, meaning the module object
// was GC-ed. In that case, there won't be any new instances created,
// and we don't need to maintain the links between instances.
@@ -1332,8 +1344,18 @@ class WasmInstanceBuilder {
->value();
unpacked.emplace_back(data);
}
- // TODO(eholk): Register the protected instruction information once the
- // trap handler is in place.
+ if (unpacked.size() > 0) {
+ Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i);
+ byte* base = code->entry();
+ int size = code->CodeSize();
+ trap_handler::CodeObjectData* handler_data =
titzer 2017/01/09 09:26:56 Is it possible to hide this data structure altoget
Eric Holk 2017/01/10 23:10:48 Yes. Originally I was thinking keeping them separa
+ CreateHandlerData(reinterpret_cast<void*>(base), size,
+ unpacked.size(), &unpacked[0]);
+ const int index = RegisterHandlerData(handler_data);
+ // TODO(eholk): if index is negative, fail.
+ DCHECK(index >= 0);
+ code->set_trap_handler_index(Smi::FromInt(index));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698