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/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 return false; | 524 return false; |
525 return true; | 525 return true; |
526 } | 526 } |
527 | 527 |
528 WasmSharedModuleData* WasmSharedModuleData::cast(Object* object) { | 528 WasmSharedModuleData* WasmSharedModuleData::cast(Object* object) { |
529 DCHECK(IsWasmSharedModuleData(object)); | 529 DCHECK(IsWasmSharedModuleData(object)); |
530 return reinterpret_cast<WasmSharedModuleData*>(object); | 530 return reinterpret_cast<WasmSharedModuleData*>(object); |
531 } | 531 } |
532 | 532 |
533 wasm::WasmModule* WasmSharedModuleData::module() { | 533 wasm::WasmModule* WasmSharedModuleData::module() { |
534 return reinterpret_cast<WasmModuleWrapper*>(get(kModuleWrapper))->get(); | 534 // We populate the kModuleWrapper field with a Foreign holding the |
| 535 // address to the address of a WasmModule. This is because we can |
| 536 // handle both cases when the WasmModule's lifetime is managed through |
| 537 // a Managed<WasmModule> object, as well as cases when it's managed |
| 538 // by the embedder. CcTests fall into the latter case. |
| 539 return *(reinterpret_cast<wasm::WasmModule**>( |
| 540 Foreign::cast(get(kModuleWrapper))->foreign_address())); |
535 } | 541 } |
536 | 542 |
537 DEFINE_OPTIONAL_ARR_ACCESSORS(WasmSharedModuleData, module_bytes, kModuleBytes, | 543 DEFINE_OPTIONAL_ARR_ACCESSORS(WasmSharedModuleData, module_bytes, kModuleBytes, |
538 SeqOneByteString); | 544 SeqOneByteString); |
539 DEFINE_ARR_GETTER(WasmSharedModuleData, script, kScript, Script); | 545 DEFINE_ARR_GETTER(WasmSharedModuleData, script, kScript, Script); |
540 DEFINE_OPTIONAL_ARR_ACCESSORS(WasmSharedModuleData, asm_js_offset_table, | 546 DEFINE_OPTIONAL_ARR_ACCESSORS(WasmSharedModuleData, asm_js_offset_table, |
541 kAsmJsOffsetTable, ByteArray); | 547 kAsmJsOffsetTable, ByteArray); |
542 DEFINE_OPTIONAL_ARR_GETTER(WasmSharedModuleData, breakpoint_infos, | 548 DEFINE_OPTIONAL_ARR_GETTER(WasmSharedModuleData, breakpoint_infos, |
543 kBreakPointInfos, FixedArray); | 549 kBreakPointInfos, FixedArray); |
544 | 550 |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 1185 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) |
1180 return false; | 1186 return false; |
1181 return true; | 1187 return true; |
1182 } | 1188 } |
1183 | 1189 |
1184 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, | 1190 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, |
1185 Isolate* isolate) { | 1191 Isolate* isolate) { |
1186 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); | 1192 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); |
1187 set(kWrapperInstanceObject, *cell); | 1193 set(kWrapperInstanceObject, *cell); |
1188 } | 1194 } |
OLD | NEW |