OLD | NEW |
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 "src/wasm/wasm-objects.h" | 5 #include "src/wasm/wasm-objects.h" |
6 #include "src/utils.h" | 6 #include "src/utils.h" |
7 | 7 |
8 #include "src/base/iterator.h" | 8 #include "src/base/iterator.h" |
9 #include "src/debug/debug-interface.h" | 9 #include "src/debug/debug-interface.h" |
10 #include "src/wasm/module-decoder.h" | 10 #include "src/wasm/module-decoder.h" |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 return Handle<WasmSharedModuleData>::cast(arr); | 556 return Handle<WasmSharedModuleData>::cast(arr); |
557 } | 557 } |
558 | 558 |
559 bool WasmSharedModuleData::is_asm_js() { | 559 bool WasmSharedModuleData::is_asm_js() { |
560 bool asm_js = module()->origin == wasm::ModuleOrigin::kAsmJsOrigin; | 560 bool asm_js = module()->origin == wasm::ModuleOrigin::kAsmJsOrigin; |
561 DCHECK_EQ(asm_js, script()->type() == Script::TYPE_NORMAL); | 561 DCHECK_EQ(asm_js, script()->type() == Script::TYPE_NORMAL); |
562 DCHECK_EQ(asm_js, has_asm_js_offset_table()); | 562 DCHECK_EQ(asm_js, has_asm_js_offset_table()); |
563 return asm_js; | 563 return asm_js; |
564 } | 564 } |
565 | 565 |
566 void WasmSharedModuleData::RecreateModuleWrapper( | 566 void WasmSharedModuleData::ReinitializeAfterDeserialization( |
567 Isolate* isolate, Handle<WasmSharedModuleData> shared) { | 567 Isolate* isolate, Handle<WasmSharedModuleData> shared) { |
568 DCHECK(shared->get(kModuleWrapper)->IsUndefined(isolate)); | 568 DCHECK(shared->get(kModuleWrapper)->IsUndefined(isolate)); |
| 569 #ifdef DEBUG |
| 570 // No BreakpointInfo objects should survive deserialization. |
| 571 if (shared->has_breakpoint_infos()) { |
| 572 for (int i = 0, e = shared->breakpoint_infos()->length(); i < e; ++i) { |
| 573 DCHECK(shared->breakpoint_infos()->get(i)->IsUndefined(isolate)); |
| 574 } |
| 575 } |
| 576 #endif |
| 577 |
| 578 shared->set(kBreakPointInfos, isolate->heap()->undefined_value()); |
569 | 579 |
570 WasmModule* module = nullptr; | 580 WasmModule* module = nullptr; |
571 { | 581 { |
572 // We parse the module again directly from the module bytes, so | 582 // We parse the module again directly from the module bytes, so |
573 // the underlying storage must not be moved meanwhile. | 583 // the underlying storage must not be moved meanwhile. |
574 DisallowHeapAllocation no_allocation; | 584 DisallowHeapAllocation no_allocation; |
575 SeqOneByteString* module_bytes = shared->module_bytes(); | 585 SeqOneByteString* module_bytes = shared->module_bytes(); |
576 const byte* start = | 586 const byte* start = |
577 reinterpret_cast<const byte*>(module_bytes->GetCharsAddress()); | 587 reinterpret_cast<const byte*>(module_bytes->GetCharsAddress()); |
578 const byte* end = start + module_bytes->length(); | 588 const byte* end = start + module_bytes->length(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 PrintF("->%d", current->instance_id()); | 791 PrintF("->%d", current->instance_id()); |
782 if (!current->has_weak_next_instance()) break; | 792 if (!current->has_weak_next_instance()) break; |
783 CHECK(!current->ptr_to_weak_next_instance()->cleared()); | 793 CHECK(!current->ptr_to_weak_next_instance()->cleared()); |
784 current = | 794 current = |
785 WasmCompiledModule::cast(current->ptr_to_weak_next_instance()->value()); | 795 WasmCompiledModule::cast(current->ptr_to_weak_next_instance()->value()); |
786 } | 796 } |
787 PrintF("\n"); | 797 PrintF("\n"); |
788 #endif | 798 #endif |
789 } | 799 } |
790 | 800 |
791 void WasmCompiledModule::RecreateModuleWrapper( | 801 void WasmCompiledModule::ReinitializeAfterDeserialization( |
792 Isolate* isolate, Handle<WasmCompiledModule> compiled_module) { | 802 Isolate* isolate, Handle<WasmCompiledModule> compiled_module) { |
793 // This method must only be called immediately after deserialization. | 803 // This method must only be called immediately after deserialization. |
794 // At this point, no module wrapper exists, so the shared module data is | 804 // At this point, no module wrapper exists, so the shared module data is |
795 // incomplete. | 805 // incomplete. |
796 Handle<WasmSharedModuleData> shared( | 806 Handle<WasmSharedModuleData> shared( |
797 static_cast<WasmSharedModuleData*>(compiled_module->get(kID_shared)), | 807 static_cast<WasmSharedModuleData*>(compiled_module->get(kID_shared)), |
798 isolate); | 808 isolate); |
799 DCHECK(!WasmSharedModuleData::IsWasmSharedModuleData(*shared)); | 809 DCHECK(!WasmSharedModuleData::IsWasmSharedModuleData(*shared)); |
800 WasmSharedModuleData::RecreateModuleWrapper(isolate, shared); | 810 WasmSharedModuleData::ReinitializeAfterDeserialization(isolate, shared); |
801 DCHECK(WasmSharedModuleData::IsWasmSharedModuleData(*shared)); | 811 DCHECK(WasmSharedModuleData::IsWasmSharedModuleData(*shared)); |
802 } | 812 } |
803 | 813 |
804 uint32_t WasmCompiledModule::mem_size() const { | 814 uint32_t WasmCompiledModule::mem_size() const { |
805 return has_memory() ? memory()->byte_length()->Number() : default_mem_size(); | 815 return has_memory() ? memory()->byte_length()->Number() : default_mem_size(); |
806 } | 816 } |
807 | 817 |
808 uint32_t WasmCompiledModule::default_mem_size() const { | 818 uint32_t WasmCompiledModule::default_mem_size() const { |
809 return min_mem_pages() * WasmModule::kPageSize; | 819 return min_mem_pages() * WasmModule::kPageSize; |
810 } | 820 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 1171 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) |
1162 return false; | 1172 return false; |
1163 return true; | 1173 return true; |
1164 } | 1174 } |
1165 | 1175 |
1166 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, | 1176 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, |
1167 Isolate* isolate) { | 1177 Isolate* isolate) { |
1168 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); | 1178 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); |
1169 set(kWrapperInstanceObject, *cell); | 1179 set(kWrapperInstanceObject, *cell); |
1170 } | 1180 } |
OLD | NEW |