| 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/wasm/wasm-module.h" | 6 #include "src/wasm/wasm-module.h" |
| 7 | 7 |
| 8 #define TRACE(...) \ | 8 #define TRACE(...) \ |
| 9 do { \ | 9 do { \ |
| 10 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ | 10 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 compiled_module->set_weak_wasm_module(link_to_module); | 90 compiled_module->set_weak_wasm_module(link_to_module); |
| 91 return Handle<WasmModuleObject>::cast(module_object); | 91 return Handle<WasmModuleObject>::cast(module_object); |
| 92 } | 92 } |
| 93 | 93 |
| 94 WasmModuleObject* WasmModuleObject::cast(Object* object) { | 94 WasmModuleObject* WasmModuleObject::cast(Object* object) { |
| 95 DCHECK(object->IsJSObject()); | 95 DCHECK(object->IsJSObject()); |
| 96 // TODO(titzer): brand check for WasmModuleObject. | 96 // TODO(titzer): brand check for WasmModuleObject. |
| 97 return reinterpret_cast<WasmModuleObject*>(object); | 97 return reinterpret_cast<WasmModuleObject*>(object); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool WasmModuleObject::IsWasmModuleObject(Object* object) { |
| 101 return object->IsJSObject() && |
| 102 JSObject::cast(object)->GetInternalFieldCount() == kFieldCount; |
| 103 } |
| 104 |
| 105 DEFINE_GETTER(WasmModuleObject, compiled_module, kCompiledModule, |
| 106 WasmCompiledModule) |
| 107 |
| 100 Handle<WasmTableObject> WasmTableObject::New(Isolate* isolate, uint32_t initial, | 108 Handle<WasmTableObject> WasmTableObject::New(Isolate* isolate, uint32_t initial, |
| 101 uint32_t maximum, | 109 uint32_t maximum, |
| 102 Handle<FixedArray>* js_functions) { | 110 Handle<FixedArray>* js_functions) { |
| 103 Handle<JSFunction> table_ctor( | 111 Handle<JSFunction> table_ctor( |
| 104 isolate->native_context()->wasm_table_constructor()); | 112 isolate->native_context()->wasm_table_constructor()); |
| 105 Handle<JSObject> table_obj = isolate->factory()->NewJSObject(table_ctor); | 113 Handle<JSObject> table_obj = isolate->factory()->NewJSObject(table_ctor); |
| 106 *js_functions = isolate->factory()->NewFixedArray(initial); | 114 *js_functions = isolate->factory()->NewFixedArray(initial); |
| 107 Object* null = isolate->heap()->null_value(); | 115 Object* null = isolate->heap()->null_value(); |
| 108 for (int i = 0; i < static_cast<int>(initial); ++i) { | 116 for (int i = 0; i < static_cast<int>(initial); ++i) { |
| 109 (*js_functions)->set(i, null); | 117 (*js_functions)->set(i, null); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 #endif | 358 #endif |
| 351 } | 359 } |
| 352 | 360 |
| 353 uint32_t WasmCompiledModule::mem_size() const { | 361 uint32_t WasmCompiledModule::mem_size() const { |
| 354 return has_memory() ? memory()->byte_length()->Number() : default_mem_size(); | 362 return has_memory() ? memory()->byte_length()->Number() : default_mem_size(); |
| 355 } | 363 } |
| 356 | 364 |
| 357 uint32_t WasmCompiledModule::default_mem_size() const { | 365 uint32_t WasmCompiledModule::default_mem_size() const { |
| 358 return min_mem_pages() * WasmModule::kPageSize; | 366 return min_mem_pages() * WasmModule::kPageSize; |
| 359 } | 367 } |
| OLD | NEW |