| 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/debug/debug-interface.h" | 8 #include "src/debug/debug-interface.h" |
| 9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
| 10 #include "src/wasm/wasm-module.h" | 10 #include "src/wasm/wasm-module.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 obj->GetInternalField(kCompiledModule))) { | 285 obj->GetInternalField(kCompiledModule))) { |
| 286 return false; | 286 return false; |
| 287 } | 287 } |
| 288 | 288 |
| 289 // All checks passed. | 289 // All checks passed. |
| 290 return true; | 290 return true; |
| 291 } | 291 } |
| 292 | 292 |
| 293 Handle<WasmInstanceObject> WasmInstanceObject::New( | 293 Handle<WasmInstanceObject> WasmInstanceObject::New( |
| 294 Isolate* isolate, Handle<WasmCompiledModule> compiled_module) { | 294 Isolate* isolate, Handle<WasmCompiledModule> compiled_module) { |
| 295 Handle<Map> map = isolate->factory()->NewMap( | 295 Handle<JSFunction> instance_cons( |
| 296 JS_OBJECT_TYPE, JSObject::kHeaderSize + kFieldCount * kPointerSize); | 296 isolate->native_context()->wasm_instance_constructor()); |
| 297 Handle<JSObject> instance_object = |
| 298 isolate->factory()->NewJSObject(instance_cons, TENURED); |
| 299 Handle<Symbol> instance_sym(isolate->native_context()->wasm_instance_sym()); |
| 300 Object::SetProperty(instance_object, instance_sym, instance_object, STRICT) |
| 301 .Check(); |
| 297 Handle<WasmInstanceObject> instance( | 302 Handle<WasmInstanceObject> instance( |
| 298 reinterpret_cast<WasmInstanceObject*>( | 303 reinterpret_cast<WasmInstanceObject*>(*instance_object), isolate); |
| 299 *isolate->factory()->NewJSObjectFromMap(map, TENURED)), | |
| 300 isolate); | |
| 301 | 304 |
| 302 instance->SetInternalField(kCompiledModule, *compiled_module); | 305 instance->SetInternalField(kCompiledModule, *compiled_module); |
| 303 instance->SetInternalField(kMemoryObject, isolate->heap()->undefined_value()); | 306 instance->SetInternalField(kMemoryObject, isolate->heap()->undefined_value()); |
| 304 Handle<WasmInstanceWrapper> instance_wrapper = | 307 Handle<WasmInstanceWrapper> instance_wrapper = |
| 305 WasmInstanceWrapper::New(isolate, instance); | 308 WasmInstanceWrapper::New(isolate, instance); |
| 306 instance->SetInternalField(kWasmMemInstanceWrapper, *instance_wrapper); | 309 instance->SetInternalField(kWasmMemInstanceWrapper, *instance_wrapper); |
| 307 return instance; | 310 return instance; |
| 308 } | 311 } |
| 309 | 312 |
| 310 WasmInstanceObject* WasmExportedFunction::instance() { | 313 WasmInstanceObject* WasmExportedFunction::instance() { |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) | 840 !array->get(kPreviousInstanceWrapper)->IsFixedArray()) |
| 838 return false; | 841 return false; |
| 839 return true; | 842 return true; |
| 840 } | 843 } |
| 841 | 844 |
| 842 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, | 845 void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance, |
| 843 Isolate* isolate) { | 846 Isolate* isolate) { |
| 844 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); | 847 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance); |
| 845 set(kWrapperInstanceObject, *cell); | 848 set(kWrapperInstanceObject, *cell); |
| 846 } | 849 } |
| OLD | NEW |