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

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

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Restore signal mask at the right place Created 3 years, 10 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 3021fb55b9b67d917ae25093b62f298302c93779..a432286076fcfea86b293091f68d40d7628a4709 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/asmjs/asm-wasm-builder.h"
@@ -658,6 +659,18 @@ 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::ShouldEnableTrapHandler()) {
titzer 2017/02/20 09:50:08 Heads up that this code is going to move (see http
Eric Holk 2017/02/23 02:16:57 Acknowledged. (Interestingly, I didn't get any sig
+ 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);
+ code->set_trap_handler_index(Smi::FromInt(-1));
+ }
+ }
+ }
+
// 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.
@@ -1407,7 +1420,7 @@ class WasmInstanceBuilder {
//--------------------------------------------------------------------------
// Unpack and notify signal handler of protected instructions.
//--------------------------------------------------------------------------
- if (FLAG_wasm_trap_handler) {
+ if (trap_handler::ShouldEnableTrapHandler()) {
for (int i = 0; i < code_table->length(); ++i) {
Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i);
@@ -1428,8 +1441,15 @@ class WasmInstanceBuilder {
reinterpret_cast<intptr_t>(it.rinfo()->pc()) - base;
unpacked.emplace_back(data);
}
- // TODO(eholk): Register the protected instruction information once the
- // trap handler is in place.
+ if (unpacked.size() > 0) {
+ int size = code->CodeSize();
+ const int index =
+ RegisterHandlerData(reinterpret_cast<void*>(base), size,
+ unpacked.size(), &unpacked[0]);
+ // 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