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

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

Issue 2404253002: [wasm] Provide better stack traces for asm.js code (Closed)
Patch Set: Address titzer's comments Created 4 years, 2 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/wasm/wasm-module.h ('k') | src/wasm/wasm-module-builder.h » ('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/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 code->instruction_size()); 653 code->instruction_size());
654 } 654 }
655 } 655 }
656 } 656 }
657 compiled_module->reset_heap(); 657 compiled_module->reset_heap();
658 } 658 }
659 659
660 static void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) { 660 static void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) {
661 JSObject** p = reinterpret_cast<JSObject**>(data.GetParameter()); 661 JSObject** p = reinterpret_cast<JSObject**>(data.GetParameter());
662 JSObject* owner = *p; 662 JSObject* owner = *p;
663 WasmCompiledModule* compiled_module = 663 WasmCompiledModule* compiled_module = GetCompiledModule(owner);
664 WasmCompiledModule::cast(owner->GetInternalField(kWasmCompiledModule));
665 TRACE("Finalizing %d {\n", compiled_module->instance_id()); 664 TRACE("Finalizing %d {\n", compiled_module->instance_id());
666 Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate()); 665 Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
667 DCHECK(compiled_module->has_weak_module_object()); 666 DCHECK(compiled_module->has_weak_module_object());
668 WeakCell* weak_module_obj = compiled_module->ptr_to_weak_module_object(); 667 WeakCell* weak_module_obj = compiled_module->ptr_to_weak_module_object();
669 668
670 // weak_module_obj may have been cleared, meaning the module object 669 // weak_module_obj may have been cleared, meaning the module object
671 // was GC-ed. In that case, there won't be any new instances created, 670 // was GC-ed. In that case, there won't be any new instances created,
672 // and we don't need to maintain the links between instances. 671 // and we don't need to maintain the links between instances.
673 if (!weak_module_obj->cleared()) { 672 if (!weak_module_obj->cleared()) {
674 JSObject* module_obj = JSObject::cast(weak_module_obj->value()); 673 JSObject* module_obj = JSObject::cast(weak_module_obj->value());
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 DCHECK(deopt_data->length() == 2); 853 DCHECK(deopt_data->length() == 2);
855 Object* weak_link = deopt_data->get(0); 854 Object* weak_link = deopt_data->get(0);
856 if (!weak_link->IsWeakCell()) return nullptr; 855 if (!weak_link->IsWeakCell()) return nullptr;
857 WeakCell* cell = WeakCell::cast(weak_link); 856 WeakCell* cell = WeakCell::cast(weak_link);
858 return cell->value(); 857 return cell->value();
859 } 858 }
860 859
861 int GetNumImportedFunctions(Handle<JSObject> wasm_object) { 860 int GetNumImportedFunctions(Handle<JSObject> wasm_object) {
862 // TODO(wasm): Cache this number if it ever becomes a performance problem. 861 // TODO(wasm): Cache this number if it ever becomes a performance problem.
863 DCHECK(IsWasmObject(*wasm_object)); 862 DCHECK(IsWasmObject(*wasm_object));
864 Object* compiled_module = wasm_object->GetInternalField(kWasmCompiledModule); 863 WasmCompiledModule* compiled_module = GetCompiledModule(*wasm_object);
865 Handle<FixedArray> imports = 864 Handle<FixedArray> imports =
866 WasmCompiledModule::cast(compiled_module)->imports(); 865 WasmCompiledModule::cast(compiled_module)->imports();
867 int num_imports = imports->length(); 866 int num_imports = imports->length();
868 int num_imported_functions = 0; 867 int num_imported_functions = 0;
869 for (int i = 0; i < num_imports; ++i) { 868 for (int i = 0; i < num_imports; ++i) {
870 FixedArray* encoded_import = FixedArray::cast(imports->get(i)); 869 FixedArray* encoded_import = FixedArray::cast(imports->get(i));
871 int kind = Smi::cast(encoded_import->get(kImportKind))->value(); 870 int kind = Smi::cast(encoded_import->get(kImportKind))->value();
872 if (kind == kExternalFunction) ++num_imported_functions; 871 if (kind == kExternalFunction) ++num_imported_functions;
873 } 872 }
874 return num_imported_functions; 873 return num_imported_functions;
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_); 1417 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_);
1419 Handle<WeakCell> link_to_owning_instance = factory->NewWeakCell(instance); 1418 Handle<WeakCell> link_to_owning_instance = factory->NewWeakCell(instance);
1420 MaybeHandle<WeakCell> link_to_original; 1419 MaybeHandle<WeakCell> link_to_original;
1421 MaybeHandle<WasmCompiledModule> original; 1420 MaybeHandle<WasmCompiledModule> original;
1422 if (!owner.is_null()) { 1421 if (!owner.is_null()) {
1423 // prepare the data needed for publishing in a chain, but don't link 1422 // prepare the data needed for publishing in a chain, but don't link
1424 // just yet, because 1423 // just yet, because
1425 // we want all the publishing to happen free from GC interruptions, and 1424 // we want all the publishing to happen free from GC interruptions, and
1426 // so we do it in 1425 // so we do it in
1427 // one GC-free scope afterwards. 1426 // one GC-free scope afterwards.
1428 original = handle(WasmCompiledModule::cast( 1427 original = handle(GetCompiledModule(*owner.ToHandleChecked()));
1429 owner.ToHandleChecked()->GetInternalField(kWasmCompiledModule)));
1430 link_to_original = factory->NewWeakCell(original.ToHandleChecked()); 1428 link_to_original = factory->NewWeakCell(original.ToHandleChecked());
1431 } 1429 }
1432 // Publish the new instance to the instances chain. 1430 // Publish the new instance to the instances chain.
1433 { 1431 {
1434 DisallowHeapAllocation no_gc; 1432 DisallowHeapAllocation no_gc;
1435 if (!link_to_original.is_null()) { 1433 if (!link_to_original.is_null()) {
1436 compiled_module_->set_weak_next_instance( 1434 compiled_module_->set_weak_next_instance(
1437 link_to_original.ToHandleChecked()); 1435 link_to_original.ToHandleChecked());
1438 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone); 1436 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone);
1439 compiled_module_->set_weak_module_object( 1437 compiled_module_->set_weak_module_object(
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 WasmCompiledModule::cast(current->ptr_to_weak_next_instance()->value()); 1949 WasmCompiledModule::cast(current->ptr_to_weak_next_instance()->value());
1952 } 1950 }
1953 PrintF("\n"); 1951 PrintF("\n");
1954 #endif 1952 #endif
1955 } 1953 }
1956 1954
1957 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm, 1955 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm,
1958 uint32_t func_index) { 1956 uint32_t func_index) {
1959 if (!wasm->IsUndefined(isolate)) { 1957 if (!wasm->IsUndefined(isolate)) {
1960 DCHECK(IsWasmObject(*wasm)); 1958 DCHECK(IsWasmObject(*wasm));
1961 WasmCompiledModule* compiled_module = WasmCompiledModule::cast( 1959 WasmCompiledModule* compiled_module =
1962 Handle<JSObject>::cast(wasm)->GetInternalField(kWasmCompiledModule)); 1960 GetCompiledModule(JSObject::cast(*wasm));
1963 Handle<ByteArray> func_names = compiled_module->function_names(); 1961 Handle<ByteArray> func_names = compiled_module->function_names();
1964 // TODO(clemens): Extract this from the module bytes; skip whole function 1962 // TODO(clemens): Extract this from the module bytes; skip whole function
1965 // name table. 1963 // name table.
1966 Handle<Object> name; 1964 Handle<Object> name;
1967 if (GetWasmFunctionNameFromTable(func_names, func_index).ToHandle(&name)) { 1965 if (GetWasmFunctionNameFromTable(func_names, func_index).ToHandle(&name)) {
1968 return name; 1966 return name;
1969 } 1967 }
1970 } 1968 }
1971 return isolate->factory()->null_value(); 1969 return isolate->factory()->null_value();
1972 } 1970 }
(...skipping 22 matching lines...) Expand all
1995 !(mem->IsUndefined(isolate) || mem->IsJSArrayBuffer()) || 1993 !(mem->IsUndefined(isolate) || mem->IsJSArrayBuffer()) ||
1996 !WasmCompiledModule::IsWasmCompiledModule( 1994 !WasmCompiledModule::IsWasmCompiledModule(
1997 obj->GetInternalField(kWasmCompiledModule))) { 1995 obj->GetInternalField(kWasmCompiledModule))) {
1998 return false; 1996 return false;
1999 } 1997 }
2000 1998
2001 // All checks passed. 1999 // All checks passed.
2002 return true; 2000 return true;
2003 } 2001 }
2004 2002
2003 WasmCompiledModule* GetCompiledModule(JSObject* wasm) {
2004 return WasmCompiledModule::cast(wasm->GetInternalField(kWasmCompiledModule));
2005 }
2006
2007 bool WasmIsAsmJs(Object* wasm, Isolate* isolate) {
2008 if (wasm->IsUndefined(isolate)) return false;
2009 DCHECK(IsWasmObject(wasm));
2010 WasmCompiledModule* compiled_module = GetCompiledModule(JSObject::cast(wasm));
2011 return compiled_module->has_asm_js_script();
2012 }
2013
2014 Handle<Script> GetAsmWasmScript(Handle<JSObject> wasm) {
2015 DCHECK(IsWasmObject(*wasm));
2016 WasmCompiledModule* compiled_module = GetCompiledModule(*wasm);
2017 return compiled_module->asm_js_script();
2018 }
2019
2020 int GetAsmWasmSourcePosition(Handle<JSObject> wasm, int func_index,
2021 int byte_offset) {
2022 return WasmDebugInfo::GetAsmJsSourcePosition(GetDebugInfo(wasm), func_index,
2023 byte_offset);
2024 }
2025
2005 Handle<SeqOneByteString> GetWasmBytes(Handle<JSObject> wasm) { 2026 Handle<SeqOneByteString> GetWasmBytes(Handle<JSObject> wasm) {
2006 DCHECK(IsWasmObject(*wasm)); 2027 DCHECK(IsWasmObject(*wasm));
2007 Object* compiled_module = wasm->GetInternalField(kWasmCompiledModule); 2028 WasmCompiledModule* compiled_module = GetCompiledModule(*wasm);
2008 return WasmCompiledModule::cast(compiled_module)->module_bytes(); 2029 return compiled_module->module_bytes();
2009 } 2030 }
2010 2031
2011 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm) { 2032 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm) {
2012 Handle<Object> info(wasm->GetInternalField(kWasmDebugInfo), 2033 Handle<Object> info(wasm->GetInternalField(kWasmDebugInfo),
2013 wasm->GetIsolate()); 2034 wasm->GetIsolate());
2014 if (!info->IsUndefined(wasm->GetIsolate())) 2035 if (!info->IsUndefined(wasm->GetIsolate()))
2015 return Handle<WasmDebugInfo>::cast(info); 2036 return Handle<WasmDebugInfo>::cast(info);
2016 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(wasm); 2037 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(wasm);
2017 wasm->SetInternalField(kWasmDebugInfo, *new_info); 2038 wasm->SetInternalField(kWasmDebugInfo, *new_info);
2018 return new_info; 2039 return new_info;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 for (uint32_t i = max_size; i < max_size + table_size; ++i) { 2102 for (uint32_t i = max_size; i < max_size + table_size; ++i) {
2082 int index = Smi::cast(table->get(static_cast<int>(i)))->value(); 2103 int index = Smi::cast(table->get(static_cast<int>(i)))->value();
2083 DCHECK_GE(index, 0); 2104 DCHECK_GE(index, 0);
2084 DCHECK_LT(static_cast<size_t>(index), code_table->size()); 2105 DCHECK_LT(static_cast<size_t>(index), code_table->size());
2085 table->set(static_cast<int>(i), *(*code_table)[index]); 2106 table->set(static_cast<int>(i), *(*code_table)[index]);
2086 } 2107 }
2087 } 2108 }
2088 2109
2089 int GetNumberOfFunctions(Handle<JSObject> wasm) { 2110 int GetNumberOfFunctions(Handle<JSObject> wasm) {
2090 DCHECK(IsWasmObject(*wasm)); 2111 DCHECK(IsWasmObject(*wasm));
2091 WasmCompiledModule* compiled_module = 2112 WasmCompiledModule* compiled_module = GetCompiledModule(*wasm);
2092 WasmCompiledModule::cast(wasm->GetInternalField(kWasmCompiledModule));
2093 ByteArray* func_names_arr = compiled_module->ptr_to_function_names(); 2113 ByteArray* func_names_arr = compiled_module->ptr_to_function_names();
2094 // TODO(clemensh): this looks inside an array constructed elsewhere. Refactor. 2114 // TODO(clemensh): this looks inside an array constructed elsewhere. Refactor.
2095 return func_names_arr->get_int(0); 2115 return func_names_arr->get_int(0);
2096 } 2116 }
2097 2117
2098 Handle<JSObject> CreateCompiledModuleObject( 2118 Handle<JSObject> CreateCompiledModuleObject(
2099 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 2119 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
2100 ModuleOrigin origin) { 2120 ModuleOrigin origin) {
2101 Handle<JSObject> module_obj; 2121 Handle<JSObject> module_obj;
2102 if (origin == ModuleOrigin::kWasmOrigin) { 2122 if (origin == ModuleOrigin::kWasmOrigin) {
2103 Handle<JSFunction> module_cons( 2123 Handle<JSFunction> module_cons(
2104 isolate->native_context()->wasm_module_constructor()); 2124 isolate->native_context()->wasm_module_constructor());
2105 module_obj = isolate->factory()->NewJSObject(module_cons); 2125 module_obj = isolate->factory()->NewJSObject(module_cons);
2106 } else { 2126 } else {
2107 DCHECK(origin == ModuleOrigin::kAsmJsOrigin); 2127 DCHECK(origin == ModuleOrigin::kAsmJsOrigin);
2108 Handle<Map> map = isolate->factory()->NewMap( 2128 Handle<Map> map = isolate->factory()->NewMap(
2109 JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize); 2129 JS_OBJECT_TYPE, JSObject::kHeaderSize + kPointerSize);
2110 module_obj = isolate->factory()->NewJSObjectFromMap(map, TENURED); 2130 module_obj = isolate->factory()->NewJSObjectFromMap(map, TENURED);
2111 } 2131 }
2112 module_obj->SetInternalField(0, *compiled_module); 2132 module_obj->SetInternalField(0, *compiled_module);
2113 if (origin == ModuleOrigin::kWasmOrigin) { 2133 if (origin == ModuleOrigin::kWasmOrigin) {
2114 Handle<Symbol> module_sym(isolate->native_context()->wasm_module_sym()); 2134 Handle<Symbol> module_sym(isolate->native_context()->wasm_module_sym());
2115 Object::SetProperty(module_obj, module_sym, module_obj, STRICT).Check(); 2135 Object::SetProperty(module_obj, module_sym, module_obj, STRICT).Check();
2116 } 2136 }
2117 Handle<WeakCell> link_to_module = isolate->factory()->NewWeakCell(module_obj); 2137 Handle<WeakCell> link_to_module = isolate->factory()->NewWeakCell(module_obj);
2118 compiled_module->set_weak_module_object(link_to_module); 2138 compiled_module->set_weak_module_object(link_to_module);
2119 return module_obj; 2139 return module_obj;
2120 } 2140 }
2121 2141
2122 MaybeHandle<JSObject> CreateModuleObjectFromBytes(Isolate* isolate, 2142 // TODO(clemensh): origin can be inferred from asm_js_script; remove it.
2123 const byte* start, 2143 MaybeHandle<JSObject> CreateModuleObjectFromBytes(
2124 const byte* end, 2144 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower,
2125 ErrorThrower* thrower, 2145 ModuleOrigin origin, Handle<Script> asm_js_script,
2126 ModuleOrigin origin) { 2146 const byte* asm_js_offset_tables_start,
2147 const byte* asm_js_offset_tables_end) {
2127 MaybeHandle<JSObject> nothing; 2148 MaybeHandle<JSObject> nothing;
2128 Zone zone(isolate->allocator()); 2149 Zone zone(isolate->allocator());
2129 ModuleResult result = 2150 ModuleResult result =
2130 DecodeWasmModule(isolate, &zone, start, end, false, origin); 2151 DecodeWasmModule(isolate, &zone, start, end, false, origin);
2131 std::unique_ptr<const WasmModule> decoded_module(result.val); 2152 std::unique_ptr<const WasmModule> decoded_module(result.val);
2132 if (result.failed()) { 2153 if (result.failed()) {
2133 thrower->Failed("Wasm decoding failed", result); 2154 thrower->Failed("Wasm decoding failed", result);
2134 return nothing; 2155 return nothing;
2135 } 2156 }
2136 MaybeHandle<WasmCompiledModule> compiled_module = 2157 MaybeHandle<WasmCompiledModule> maybe_compiled_module =
2137 decoded_module->CompileFunctions(isolate, thrower); 2158 decoded_module->CompileFunctions(isolate, thrower);
2138 if (compiled_module.is_null()) return nothing; 2159 if (maybe_compiled_module.is_null()) return nothing;
2160 Handle<WasmCompiledModule> compiled_module =
2161 maybe_compiled_module.ToHandleChecked();
2139 2162
2140 return CreateCompiledModuleObject(isolate, compiled_module.ToHandleChecked(), 2163 DCHECK_EQ(origin == kAsmJsOrigin, !asm_js_script.is_null());
2141 origin); 2164 DCHECK(!compiled_module->has_asm_js_script());
2165 DCHECK(!compiled_module->has_asm_js_offset_tables());
2166 if (origin == kAsmJsOrigin) {
2167 compiled_module->set_asm_js_script(asm_js_script);
2168 size_t offset_tables_len =
2169 asm_js_offset_tables_end - asm_js_offset_tables_start;
2170 DCHECK_GE(static_cast<size_t>(kMaxInt), offset_tables_len);
2171 Handle<ByteArray> offset_tables =
2172 isolate->factory()->NewByteArray(static_cast<int>(offset_tables_len));
2173 memcpy(offset_tables->GetDataStartAddress(), asm_js_offset_tables_start,
2174 offset_tables_len);
2175 compiled_module->set_asm_js_offset_tables(offset_tables);
2176 }
2177
2178 return CreateCompiledModuleObject(isolate, compiled_module, origin);
2142 } 2179 }
2143 2180
2144 bool ValidateModuleBytes(Isolate* isolate, const byte* start, const byte* end, 2181 bool ValidateModuleBytes(Isolate* isolate, const byte* start, const byte* end,
2145 ErrorThrower* thrower, ModuleOrigin origin) { 2182 ErrorThrower* thrower, ModuleOrigin origin) {
2146 Zone zone(isolate->allocator()); 2183 Zone zone(isolate->allocator());
2147 ModuleResult result = 2184 ModuleResult result =
2148 DecodeWasmModule(isolate, &zone, start, end, false, origin); 2185 DecodeWasmModule(isolate, &zone, start, end, false, origin);
2149 if (result.ok()) { 2186 if (result.ok()) {
2150 DCHECK_NOT_NULL(result.val); 2187 DCHECK_NOT_NULL(result.val);
2151 delete result.val; 2188 delete result.val;
2152 return true; 2189 return true;
2153 } 2190 }
2154 return false; 2191 return false;
2155 } 2192 }
2156 2193
2157 MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate, 2194 MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate,
2158 Handle<JSObject> instance) { 2195 Handle<JSObject> instance) {
2159 Object* mem = instance->GetInternalField(kWasmMemArrayBuffer); 2196 Object* mem = instance->GetInternalField(kWasmMemArrayBuffer);
2160 DCHECK(IsWasmObject(*instance)); 2197 DCHECK(IsWasmObject(*instance));
2161 if (mem->IsUndefined(isolate)) return MaybeHandle<JSArrayBuffer>(); 2198 if (mem->IsUndefined(isolate)) return MaybeHandle<JSArrayBuffer>();
2162 return Handle<JSArrayBuffer>(JSArrayBuffer::cast(mem)); 2199 return Handle<JSArrayBuffer>(JSArrayBuffer::cast(mem));
2163 } 2200 }
2164 2201
2165 void SetInstanceMemory(Handle<JSObject> instance, JSArrayBuffer* buffer) { 2202 void SetInstanceMemory(Handle<JSObject> instance, JSArrayBuffer* buffer) {
2166 DisallowHeapAllocation no_gc; 2203 DisallowHeapAllocation no_gc;
2167 DCHECK(IsWasmObject(*instance)); 2204 DCHECK(IsWasmObject(*instance));
2168 instance->SetInternalField(kWasmMemArrayBuffer, buffer); 2205 instance->SetInternalField(kWasmMemArrayBuffer, buffer);
2169 WasmCompiledModule* module = 2206 WasmCompiledModule* compiled_module = GetCompiledModule(*instance);
2170 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule)); 2207 compiled_module->set_ptr_to_heap(buffer);
2171 module->set_ptr_to_heap(buffer);
2172 } 2208 }
2173 2209
2174 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance) { 2210 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance) {
2175 MaybeHandle<JSArrayBuffer> maybe_mem_buffer = 2211 MaybeHandle<JSArrayBuffer> maybe_mem_buffer =
2176 GetInstanceMemory(isolate, instance); 2212 GetInstanceMemory(isolate, instance);
2177 Handle<JSArrayBuffer> buffer; 2213 Handle<JSArrayBuffer> buffer;
2178 if (!maybe_mem_buffer.ToHandle(&buffer)) { 2214 if (!maybe_mem_buffer.ToHandle(&buffer)) {
2179 return 0; 2215 return 0;
2180 } else { 2216 } else {
2181 return buffer->byte_length()->Number() / WasmModule::kPageSize; 2217 return buffer->byte_length()->Number() / WasmModule::kPageSize;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 CHECK(compiled_module->has_weak_module_object()); 2304 CHECK(compiled_module->has_weak_module_object());
2269 CHECK_EQ(compiled_module->ptr_to_weak_module_object()->value(), *module_obj); 2305 CHECK_EQ(compiled_module->ptr_to_weak_module_object()->value(), *module_obj);
2270 CHECK(!compiled_module->has_weak_prev_instance()); 2306 CHECK(!compiled_module->has_weak_prev_instance());
2271 CHECK(!compiled_module->has_weak_next_instance()); 2307 CHECK(!compiled_module->has_weak_next_instance());
2272 CHECK(!compiled_module->has_weak_owning_instance()); 2308 CHECK(!compiled_module->has_weak_owning_instance());
2273 } 2309 }
2274 2310
2275 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance) { 2311 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance) {
2276 DisallowHeapAllocation no_gc; 2312 DisallowHeapAllocation no_gc;
2277 CHECK(IsWasmObject(*instance)); 2313 CHECK(IsWasmObject(*instance));
2278 WasmCompiledModule* compiled_module = 2314 WasmCompiledModule* compiled_module = GetCompiledModule(*instance);
2279 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule));
2280 CHECK(compiled_module->has_weak_module_object()); 2315 CHECK(compiled_module->has_weak_module_object());
2281 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); 2316 CHECK(compiled_module->ptr_to_weak_module_object()->cleared());
2282 } 2317 }
2283 2318
2284 } // namespace testing 2319 } // namespace testing
2285 } // namespace wasm 2320 } // namespace wasm
2286 } // namespace internal 2321 } // namespace internal
2287 } // namespace v8 2322 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-module-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698