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

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

Issue 2964943002: [wasm] Introduce instance types for WebAssembly.* objects. (Closed)
Patch Set: Update v8heapconst.py again Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/module-compiler.h> 5 #include <src/wasm/module-compiler.h>
6 6
7 #include <atomic> 7 #include <atomic>
8 8
9 #include "src/asmjs/asm-js.h" 9 #include "src/asmjs/asm-js.h"
10 #include "src/assembler-inl.h" 10 #include "src/assembler-inl.h"
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 1011
1012 //-------------------------------------------------------------------------- 1012 //--------------------------------------------------------------------------
1013 // Set up the exports object for the new instance. 1013 // Set up the exports object for the new instance.
1014 //-------------------------------------------------------------------------- 1014 //--------------------------------------------------------------------------
1015 ProcessExports(code_table, instance, compiled_module_); 1015 ProcessExports(code_table, instance, compiled_module_);
1016 if (thrower_->error()) return {}; 1016 if (thrower_->error()) return {};
1017 1017
1018 //-------------------------------------------------------------------------- 1018 //--------------------------------------------------------------------------
1019 // Add instance to Memory object 1019 // Add instance to Memory object
1020 //-------------------------------------------------------------------------- 1020 //--------------------------------------------------------------------------
1021 DCHECK(wasm::IsWasmInstance(*instance)); 1021 DCHECK(instance->IsWasmInstanceObject());
1022 if (instance->has_memory_object()) { 1022 if (instance->has_memory_object()) {
1023 instance->memory_object()->AddInstance(isolate_, instance); 1023 instance->memory_object()->AddInstance(isolate_, instance);
1024 } 1024 }
1025 1025
1026 //-------------------------------------------------------------------------- 1026 //--------------------------------------------------------------------------
1027 // Initialize the indirect function tables. 1027 // Initialize the indirect function tables.
1028 //-------------------------------------------------------------------------- 1028 //--------------------------------------------------------------------------
1029 if (function_table_count > 0) LoadTableSegments(code_table, instance); 1029 if (function_table_count > 0) LoadTableSegments(code_table, instance);
1030 1030
1031 // Patch all code with the relocations registered in code_specialization. 1031 // Patch all code with the relocations registered in code_specialization.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 // Publish the new instance to the instances chain. 1063 // Publish the new instance to the instances chain.
1064 { 1064 {
1065 DisallowHeapAllocation no_gc; 1065 DisallowHeapAllocation no_gc;
1066 if (!link_to_original.is_null()) { 1066 if (!link_to_original.is_null()) {
1067 compiled_module_->set_weak_next_instance( 1067 compiled_module_->set_weak_next_instance(
1068 link_to_original.ToHandleChecked()); 1068 link_to_original.ToHandleChecked());
1069 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone); 1069 original.ToHandleChecked()->set_weak_prev_instance(link_to_clone);
1070 compiled_module_->set_weak_wasm_module( 1070 compiled_module_->set_weak_wasm_module(
1071 original.ToHandleChecked()->weak_wasm_module()); 1071 original.ToHandleChecked()->weak_wasm_module());
1072 } 1072 }
1073 module_object_->SetEmbedderField(0, *compiled_module_); 1073 module_object_->set_compiled_module(*compiled_module_);
1074 compiled_module_->set_weak_owning_instance(link_to_owning_instance); 1074 compiled_module_->set_weak_owning_instance(link_to_owning_instance);
1075 GlobalHandles::MakeWeak( 1075 GlobalHandles::MakeWeak(
1076 global_handle.location(), global_handle.location(), 1076 global_handle.location(), global_handle.location(),
1077 instance_finalizer_callback_, v8::WeakCallbackType::kFinalizer); 1077 instance_finalizer_callback_, v8::WeakCallbackType::kFinalizer);
1078 } 1078 }
1079 } 1079 }
1080 1080
1081 //-------------------------------------------------------------------------- 1081 //--------------------------------------------------------------------------
1082 // Debugging support. 1082 // Debugging support.
1083 //-------------------------------------------------------------------------- 1083 //--------------------------------------------------------------------------
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 // provided. 1387 // provided.
1388 DCHECK(!instance->has_memory_object()); 1388 DCHECK(!instance->has_memory_object());
1389 if (!WasmJs::IsWasmMemoryObject(isolate_, value)) { 1389 if (!WasmJs::IsWasmMemoryObject(isolate_, value)) {
1390 ReportLinkError("memory import must be a WebAssembly.Memory object", 1390 ReportLinkError("memory import must be a WebAssembly.Memory object",
1391 index, module_name, import_name); 1391 index, module_name, import_name);
1392 return -1; 1392 return -1;
1393 } 1393 }
1394 auto memory = Handle<WasmMemoryObject>::cast(value); 1394 auto memory = Handle<WasmMemoryObject>::cast(value);
1395 DCHECK(WasmJs::IsWasmMemoryObject(isolate_, memory)); 1395 DCHECK(WasmJs::IsWasmMemoryObject(isolate_, memory));
1396 instance->set_memory_object(*memory); 1396 instance->set_memory_object(*memory);
1397 memory_ = Handle<JSArrayBuffer>(memory->buffer(), isolate_); 1397 memory_ = Handle<JSArrayBuffer>(memory->array_buffer(), isolate_);
1398 uint32_t imported_cur_pages = static_cast<uint32_t>( 1398 uint32_t imported_cur_pages = static_cast<uint32_t>(
1399 memory_->byte_length()->Number() / WasmModule::kPageSize); 1399 memory_->byte_length()->Number() / WasmModule::kPageSize);
1400 if (imported_cur_pages < module_->min_mem_pages) { 1400 if (imported_cur_pages < module_->min_mem_pages) {
1401 thrower_->LinkError( 1401 thrower_->LinkError(
1402 "memory import %d is smaller than maximum %u, got %u", index, 1402 "memory import %d is smaller than maximum %u, got %u", index,
1403 module_->min_mem_pages, imported_cur_pages); 1403 module_->min_mem_pages, imported_cur_pages);
1404 } 1404 }
1405 int32_t imported_max_pages = memory->maximum_pages(); 1405 int32_t imported_max_pages = memory->maximum_pages();
1406 if (module_->has_max_mem) { 1406 if (module_->has_max_mem) {
1407 if (imported_max_pages < 0) { 1407 if (imported_max_pages < 0) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 memory_object = WasmMemoryObject::New( 1657 memory_object = WasmMemoryObject::New(
1658 isolate_, 1658 isolate_,
1659 (instance->has_memory_buffer()) 1659 (instance->has_memory_buffer())
1660 ? handle(instance->memory_buffer()) 1660 ? handle(instance->memory_buffer())
1661 : Handle<JSArrayBuffer>::null(), 1661 : Handle<JSArrayBuffer>::null(),
1662 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1); 1662 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1);
1663 instance->set_memory_object(*memory_object); 1663 instance->set_memory_object(*memory_object);
1664 } else { 1664 } else {
1665 memory_object = 1665 memory_object =
1666 Handle<WasmMemoryObject>(instance->memory_object(), isolate_); 1666 Handle<WasmMemoryObject>(instance->memory_object(), isolate_);
1667 DCHECK(WasmJs::IsWasmMemoryObject(isolate_, memory_object));
1668 memory_object->ResetInstancesLink(isolate_); 1667 memory_object->ResetInstancesLink(isolate_);
1669 } 1668 }
1670 1669
1671 desc.set_value(memory_object); 1670 desc.set_value(memory_object);
1672 break; 1671 break;
1673 } 1672 }
1674 case kExternalGlobal: { 1673 case kExternalGlobal: {
1675 // Export the value of the global variable as a number. 1674 // Export the value of the global variable as a number.
1676 WasmGlobal& global = module_->globals[exp.index]; 1675 WasmGlobal& global = module_->globals[exp.index];
1677 double num = 0; 1676 double num = 0;
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 HandleScope scope(job_->isolate_); 2350 HandleScope scope(job_->isolate_);
2352 Handle<WasmModuleObject> result = 2351 Handle<WasmModuleObject> result =
2353 WasmModuleObject::New(job_->isolate_, job_->compiled_module_); 2352 WasmModuleObject::New(job_->isolate_, job_->compiled_module_);
2354 // {job_} is deleted in AsyncCompileSucceeded, therefore the {return}. 2353 // {job_} is deleted in AsyncCompileSucceeded, therefore the {return}.
2355 return job_->AsyncCompileSucceeded(result); 2354 return job_->AsyncCompileSucceeded(result);
2356 } 2355 }
2357 }; 2356 };
2358 } // namespace wasm 2357 } // namespace wasm
2359 } // namespace internal 2358 } // namespace internal
2360 } // namespace v8 2359 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698