OLD | NEW |
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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 | 1015 |
1016 //-------------------------------------------------------------------------- | 1016 //-------------------------------------------------------------------------- |
1017 // Set up the exports object for the new instance. | 1017 // Set up the exports object for the new instance. |
1018 //-------------------------------------------------------------------------- | 1018 //-------------------------------------------------------------------------- |
1019 ProcessExports(code_table, instance, compiled_module_); | 1019 ProcessExports(code_table, instance, compiled_module_); |
1020 if (thrower_->error()) return {}; | 1020 if (thrower_->error()) return {}; |
1021 | 1021 |
1022 //-------------------------------------------------------------------------- | 1022 //-------------------------------------------------------------------------- |
1023 // Add instance to Memory object | 1023 // Add instance to Memory object |
1024 //-------------------------------------------------------------------------- | 1024 //-------------------------------------------------------------------------- |
1025 DCHECK(instance->IsWasmInstanceObject()); | |
1026 if (instance->has_memory_object()) { | 1025 if (instance->has_memory_object()) { |
1027 instance->memory_object()->AddInstance(isolate_, instance); | 1026 Handle<WasmMemoryObject> memory(instance->memory_object(), isolate_); |
| 1027 WasmMemoryObject::AddInstance(isolate_, memory, instance); |
1028 } | 1028 } |
1029 | 1029 |
1030 //-------------------------------------------------------------------------- | 1030 //-------------------------------------------------------------------------- |
1031 // Initialize the indirect function tables. | 1031 // Initialize the indirect function tables. |
1032 //-------------------------------------------------------------------------- | 1032 //-------------------------------------------------------------------------- |
1033 if (function_table_count > 0) LoadTableSegments(code_table, instance); | 1033 if (function_table_count > 0) LoadTableSegments(code_table, instance); |
1034 | 1034 |
1035 // Patch all code with the relocations registered in code_specialization. | 1035 // Patch all code with the relocations registered in code_specialization. |
1036 code_specialization.RelocateDirectCalls(instance); | 1036 code_specialization.RelocateDirectCalls(instance); |
1037 code_specialization.ApplyToWholeInstance(*instance, SKIP_ICACHE_FLUSH); | 1037 code_specialization.ApplyToWholeInstance(*instance, SKIP_ICACHE_FLUSH); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 memory_object = WasmMemoryObject::New( | 1660 memory_object = WasmMemoryObject::New( |
1661 isolate_, | 1661 isolate_, |
1662 (instance->has_memory_buffer()) | 1662 (instance->has_memory_buffer()) |
1663 ? handle(instance->memory_buffer()) | 1663 ? handle(instance->memory_buffer()) |
1664 : Handle<JSArrayBuffer>::null(), | 1664 : Handle<JSArrayBuffer>::null(), |
1665 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1); | 1665 (module_->max_mem_pages != 0) ? module_->max_mem_pages : -1); |
1666 instance->set_memory_object(*memory_object); | 1666 instance->set_memory_object(*memory_object); |
1667 } else { | 1667 } else { |
1668 memory_object = | 1668 memory_object = |
1669 Handle<WasmMemoryObject>(instance->memory_object(), isolate_); | 1669 Handle<WasmMemoryObject>(instance->memory_object(), isolate_); |
1670 memory_object->ResetInstancesLink(isolate_); | |
1671 } | 1670 } |
1672 | 1671 |
1673 desc.set_value(memory_object); | 1672 desc.set_value(memory_object); |
1674 break; | 1673 break; |
1675 } | 1674 } |
1676 case kExternalGlobal: { | 1675 case kExternalGlobal: { |
1677 // Export the value of the global variable as a number. | 1676 // Export the value of the global variable as a number. |
1678 WasmGlobal& global = module_->globals[exp.index]; | 1677 WasmGlobal& global = module_->globals[exp.index]; |
1679 double num = 0; | 1678 double num = 0; |
1680 switch (global.type) { | 1679 switch (global.type) { |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2354 HandleScope scope(job_->isolate_); | 2353 HandleScope scope(job_->isolate_); |
2355 Handle<WasmModuleObject> result = | 2354 Handle<WasmModuleObject> result = |
2356 WasmModuleObject::New(job_->isolate_, job_->compiled_module_); | 2355 WasmModuleObject::New(job_->isolate_, job_->compiled_module_); |
2357 // {job_} is deleted in AsyncCompileSucceeded, therefore the {return}. | 2356 // {job_} is deleted in AsyncCompileSucceeded, therefore the {return}. |
2358 return job_->AsyncCompileSucceeded(result); | 2357 return job_->AsyncCompileSucceeded(result); |
2359 } | 2358 } |
2360 }; | 2359 }; |
2361 } // namespace wasm | 2360 } // namespace wasm |
2362 } // namespace internal | 2361 } // namespace internal |
2363 } // namespace v8 | 2362 } // namespace v8 |
OLD | NEW |