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

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2723133003: Revert of [wasm] Initial signal handler (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/v8.gyp ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "src/assembler-inl.h" 7 #include "src/assembler-inl.h"
8 #include "src/base/adapters.h" 8 #include "src/base/adapters.h"
9 #include "src/base/atomic-utils.h" 9 #include "src/base/atomic-utils.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
11 #include "src/compiler/wasm-compiler.h" 11 #include "src/compiler/wasm-compiler.h"
12 #include "src/debug/interface-types.h" 12 #include "src/debug/interface-types.h"
13 #include "src/objects.h" 13 #include "src/objects.h"
14 #include "src/property-descriptor.h" 14 #include "src/property-descriptor.h"
15 #include "src/simulator.h" 15 #include "src/simulator.h"
16 #include "src/snapshot/snapshot.h" 16 #include "src/snapshot/snapshot.h"
17 #include "src/trap-handler/trap-handler.h"
18 #include "src/v8.h" 17 #include "src/v8.h"
19 18
20 #include "src/asmjs/asm-wasm-builder.h" 19 #include "src/asmjs/asm-wasm-builder.h"
21 #include "src/wasm/function-body-decoder.h" 20 #include "src/wasm/function-body-decoder.h"
22 #include "src/wasm/module-decoder.h" 21 #include "src/wasm/module-decoder.h"
23 #include "src/wasm/wasm-code-specialization.h" 22 #include "src/wasm/wasm-code-specialization.h"
24 #include "src/wasm/wasm-js.h" 23 #include "src/wasm/wasm-js.h"
25 #include "src/wasm/wasm-limits.h" 24 #include "src/wasm/wasm-limits.h"
26 #include "src/wasm/wasm-module.h" 25 #include "src/wasm/wasm-module.h"
27 #include "src/wasm/wasm-objects.h" 26 #include "src/wasm/wasm-objects.h"
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 WasmInstanceObject* owner = reinterpret_cast<WasmInstanceObject*>(*p); 663 WasmInstanceObject* owner = reinterpret_cast<WasmInstanceObject*>(*p);
665 Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate()); 664 Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
666 // If a link to shared memory instances exists, update the list of memory 665 // If a link to shared memory instances exists, update the list of memory
667 // instances before the instance is destroyed. 666 // instances before the instance is destroyed.
668 if (owner->has_instance_wrapper()) MemoryInstanceFinalizer(isolate, owner); 667 if (owner->has_instance_wrapper()) MemoryInstanceFinalizer(isolate, owner);
669 WasmCompiledModule* compiled_module = owner->compiled_module(); 668 WasmCompiledModule* compiled_module = owner->compiled_module();
670 TRACE("Finalizing %d {\n", compiled_module->instance_id()); 669 TRACE("Finalizing %d {\n", compiled_module->instance_id());
671 DCHECK(compiled_module->has_weak_wasm_module()); 670 DCHECK(compiled_module->has_weak_wasm_module());
672 WeakCell* weak_wasm_module = compiled_module->ptr_to_weak_wasm_module(); 671 WeakCell* weak_wasm_module = compiled_module->ptr_to_weak_wasm_module();
673 672
674 if (trap_handler::UseTrapHandler()) {
675 Handle<FixedArray> code_table = compiled_module->code_table();
676 for (int i = 0; i < code_table->length(); ++i) {
677 Handle<Code> code = code_table->GetValueChecked<Code>(isolate, i);
678 int index = code->trap_handler_index()->value();
679 if (index >= 0) {
680 trap_handler::ReleaseHandlerData(index);
681 code->set_trap_handler_index(Smi::FromInt(-1));
682 }
683 }
684 }
685
686 // weak_wasm_module may have been cleared, meaning the module object 673 // weak_wasm_module may have been cleared, meaning the module object
687 // was GC-ed. In that case, there won't be any new instances created, 674 // was GC-ed. In that case, there won't be any new instances created,
688 // and we don't need to maintain the links between instances. 675 // and we don't need to maintain the links between instances.
689 if (!weak_wasm_module->cleared()) { 676 if (!weak_wasm_module->cleared()) {
690 JSObject* wasm_module = JSObject::cast(weak_wasm_module->value()); 677 JSObject* wasm_module = JSObject::cast(weak_wasm_module->value());
691 WasmCompiledModule* current_template = 678 WasmCompiledModule* current_template =
692 WasmCompiledModule::cast(wasm_module->GetInternalField(0)); 679 WasmCompiledModule::cast(wasm_module->GetInternalField(0));
693 680
694 TRACE("chain before {\n"); 681 TRACE("chain before {\n");
695 TRACE_CHAIN(current_template); 682 TRACE_CHAIN(current_template);
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 { 1217 {
1231 code_specialization.RelocateDirectCalls(instance); 1218 code_specialization.RelocateDirectCalls(instance);
1232 code_specialization.ApplyToWholeInstance(*instance, SKIP_ICACHE_FLUSH); 1219 code_specialization.ApplyToWholeInstance(*instance, SKIP_ICACHE_FLUSH);
1233 } 1220 }
1234 1221
1235 FlushICache(isolate_, code_table); 1222 FlushICache(isolate_, code_table);
1236 1223
1237 //-------------------------------------------------------------------------- 1224 //--------------------------------------------------------------------------
1238 // Unpack and notify signal handler of protected instructions. 1225 // Unpack and notify signal handler of protected instructions.
1239 //-------------------------------------------------------------------------- 1226 //--------------------------------------------------------------------------
1240 if (trap_handler::UseTrapHandler()) { 1227 if (FLAG_wasm_trap_handler) {
1241 for (int i = 0; i < code_table->length(); ++i) { 1228 for (int i = 0; i < code_table->length(); ++i) {
1242 Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i); 1229 Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i);
1243 1230
1244 if (code->kind() != Code::WASM_FUNCTION) { 1231 if (code->kind() != Code::WASM_FUNCTION) {
1245 continue; 1232 continue;
1246 } 1233 }
1247 1234
1248 const intptr_t base = reinterpret_cast<intptr_t>(code->entry()); 1235 const intptr_t base = reinterpret_cast<intptr_t>(code->entry());
1249 1236
1250 Zone zone(isolate_->allocator(), "Wasm Module"); 1237 Zone zone(isolate_->allocator(), "Wasm Module");
1251 ZoneVector<trap_handler::ProtectedInstructionData> unpacked(&zone); 1238 ZoneVector<trap_handler::ProtectedInstructionData> unpacked(&zone);
1252 const int mode_mask = 1239 const int mode_mask =
1253 RelocInfo::ModeMask(RelocInfo::WASM_PROTECTED_INSTRUCTION_LANDING); 1240 RelocInfo::ModeMask(RelocInfo::WASM_PROTECTED_INSTRUCTION_LANDING);
1254 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { 1241 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
1255 trap_handler::ProtectedInstructionData data; 1242 trap_handler::ProtectedInstructionData data;
1256 data.instr_offset = it.rinfo()->data(); 1243 data.instr_offset = it.rinfo()->data();
1257 data.landing_offset = 1244 data.landing_offset =
1258 reinterpret_cast<intptr_t>(it.rinfo()->pc()) - base; 1245 reinterpret_cast<intptr_t>(it.rinfo()->pc()) - base;
1259 unpacked.emplace_back(data); 1246 unpacked.emplace_back(data);
1260 } 1247 }
1261 if (unpacked.size() > 0) { 1248 // TODO(eholk): Register the protected instruction information once the
1262 int size = code->CodeSize(); 1249 // trap handler is in place.
1263 const int index =
1264 RegisterHandlerData(reinterpret_cast<void*>(base), size,
1265 unpacked.size(), &unpacked[0]);
1266 // TODO(eholk): if index is negative, fail.
1267 DCHECK(index >= 0);
1268 code->set_trap_handler_index(Smi::FromInt(index));
1269 }
1270 } 1250 }
1271 } 1251 }
1272 1252
1273 //-------------------------------------------------------------------------- 1253 //--------------------------------------------------------------------------
1274 // Set up and link the new instance. 1254 // Set up and link the new instance.
1275 //-------------------------------------------------------------------------- 1255 //--------------------------------------------------------------------------
1276 { 1256 {
1277 Handle<Object> global_handle = 1257 Handle<Object> global_handle =
1278 isolate_->global_handles()->Create(*instance); 1258 isolate_->global_handles()->Create(*instance);
1279 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_); 1259 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_);
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 Handle<String> module_property_name = 2710 Handle<String> module_property_name =
2731 isolate->factory()->InternalizeUtf8String("module"); 2711 isolate->factory()->InternalizeUtf8String("module");
2732 Handle<String> instance_property_name = 2712 Handle<String> instance_property_name =
2733 isolate->factory()->InternalizeUtf8String("instance"); 2713 isolate->factory()->InternalizeUtf8String("instance");
2734 JSObject::AddProperty(ret, module_property_name, module, NONE); 2714 JSObject::AddProperty(ret, module_property_name, module, NONE);
2735 JSObject::AddProperty(ret, instance_property_name, 2715 JSObject::AddProperty(ret, instance_property_name,
2736 instance_object.ToHandleChecked(), NONE); 2716 instance_object.ToHandleChecked(), NONE);
2737 2717
2738 ResolvePromise(isolate, promise, ret); 2718 ResolvePromise(isolate, promise, ret);
2739 } 2719 }
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698