| 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/base/atomic-utils.h" | 5 #include "src/base/atomic-utils.h" |
| 6 #include "src/macro-assembler.h" | 6 #include "src/macro-assembler.h" |
| 7 #include "src/objects.h" | 7 #include "src/objects.h" |
| 8 #include "src/property-descriptor.h" | 8 #include "src/property-descriptor.h" |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 code_size += code->body_size(); | 479 code_size += code->body_size(); |
| 480 reloc_size += code->relocation_info()->length(); | 480 reloc_size += code->relocation_info()->length(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 inline void Report() { | 483 inline void Report() { |
| 484 PrintF("Total generated wasm code: %zu bytes\n", code_size); | 484 PrintF("Total generated wasm code: %zu bytes\n", code_size); |
| 485 PrintF("Total generated wasm reloc: %zu bytes\n", reloc_size); | 485 PrintF("Total generated wasm reloc: %zu bytes\n", reloc_size); |
| 486 } | 486 } |
| 487 }; | 487 }; |
| 488 | 488 |
| 489 bool CompileWrappersToImportedFunctions(Isolate* isolate, | 489 bool CompileWrappersToImportedFunctions( |
| 490 const WasmModule* module, | 490 Isolate* isolate, const WasmModule* module, const Handle<JSReceiver> ffi, |
| 491 const Handle<JSReceiver> ffi, | 491 WasmModuleInstance* instance, ErrorThrower* thrower, Factory* factory) { |
| 492 WasmModuleInstance* instance, | |
| 493 ErrorThrower* thrower, Factory* factory, | |
| 494 ModuleEnv* module_env) { | |
| 495 if (module->import_table.size() > 0) { | 492 if (module->import_table.size() > 0) { |
| 496 instance->import_code.reserve(module->import_table.size()); | 493 instance->import_code.reserve(module->import_table.size()); |
| 497 for (uint32_t index = 0; index < module->import_table.size(); ++index) { | 494 for (uint32_t index = 0; index < module->import_table.size(); ++index) { |
| 498 const WasmImport& import = module->import_table[index]; | 495 const WasmImport& import = module->import_table[index]; |
| 499 WasmName module_name = module->GetNameOrNull(import.module_name_offset, | 496 WasmName module_name = module->GetNameOrNull(import.module_name_offset, |
| 500 import.module_name_length); | 497 import.module_name_length); |
| 501 WasmName function_name = module->GetNameOrNull( | 498 WasmName function_name = module->GetNameOrNull( |
| 502 import.function_name_offset, import.function_name_length); | 499 import.function_name_offset, import.function_name_length); |
| 503 MaybeHandle<JSFunction> function = LookupFunction( | 500 MaybeHandle<JSFunction> function = LookupFunction( |
| 504 *thrower, factory, ffi, index, module_name, function_name); | 501 *thrower, factory, ffi, index, module_name, function_name); |
| 505 if (function.is_null()) return false; | 502 if (function.is_null()) return false; |
| 506 | 503 |
| 507 Handle<Code> code = compiler::CompileWasmToJSWrapper( | 504 Handle<Code> code = compiler::CompileWasmToJSWrapper( |
| 508 isolate, module_env, function.ToHandleChecked(), import.sig, | 505 isolate, function.ToHandleChecked(), import.sig, module_name, |
| 509 module_name, function_name); | 506 function_name); |
| 510 instance->import_code[index] = code; | 507 instance->import_code[index] = code; |
| 511 } | 508 } |
| 512 } | 509 } |
| 513 return true; | 510 return true; |
| 514 } | 511 } |
| 515 | 512 |
| 516 void InitializeParallelCompilation( | 513 void InitializeParallelCompilation( |
| 517 Isolate* isolate, const std::vector<WasmFunction>& functions, | 514 Isolate* isolate, const std::vector<WasmFunction>& functions, |
| 518 std::vector<compiler::WasmCompilationUnit*>& compilation_units, | 515 std::vector<compiler::WasmCompilationUnit*>& compilation_units, |
| 519 ModuleEnv& module_env, ErrorThrower& thrower) { | 516 ModuleEnv& module_env, ErrorThrower& thrower) { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 827 |
| 831 ModuleEnv module_env; | 828 ModuleEnv module_env; |
| 832 module_env.module = this; | 829 module_env.module = this; |
| 833 module_env.instance = &instance; | 830 module_env.instance = &instance; |
| 834 module_env.origin = origin; | 831 module_env.origin = origin; |
| 835 | 832 |
| 836 //------------------------------------------------------------------------- | 833 //------------------------------------------------------------------------- |
| 837 // Compile wrappers to imported functions. | 834 // Compile wrappers to imported functions. |
| 838 //------------------------------------------------------------------------- | 835 //------------------------------------------------------------------------- |
| 839 if (!CompileWrappersToImportedFunctions(isolate, this, ffi, &instance, | 836 if (!CompileWrappersToImportedFunctions(isolate, this, ffi, &instance, |
| 840 &thrower, factory, &module_env)) { | 837 &thrower, factory)) { |
| 841 return MaybeHandle<JSObject>(); | 838 return MaybeHandle<JSObject>(); |
| 842 } | 839 } |
| 843 | 840 |
| 844 // If FLAG_print_wasm_code_size is set, this aggregates the sum of all code | 841 // If FLAG_print_wasm_code_size is set, this aggregates the sum of all code |
| 845 // objects created for this module. | 842 // objects created for this module. |
| 846 // TODO(titzer): switch this to TRACE_EVENT | 843 // TODO(titzer): switch this to TRACE_EVENT |
| 847 CodeStats code_stats; | 844 CodeStats code_stats; |
| 848 if (FLAG_print_wasm_code_size) { | 845 if (FLAG_print_wasm_code_size) { |
| 849 for (Handle<Code> c : instance.function_code) code_stats.Record(*c); | 846 for (Handle<Code> c : instance.function_code) code_stats.Record(*c); |
| 850 for (Handle<Code> c : instance.import_code) code_stats.Record(*c); | 847 for (Handle<Code> c : instance.import_code) code_stats.Record(*c); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 Object* info = wasm->GetInternalField(kWasmDebugInfo); | 1115 Object* info = wasm->GetInternalField(kWasmDebugInfo); |
| 1119 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info); | 1116 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info); |
| 1120 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm)); | 1117 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm)); |
| 1121 wasm->SetInternalField(kWasmDebugInfo, *new_info); | 1118 wasm->SetInternalField(kWasmDebugInfo, *new_info); |
| 1122 return *new_info; | 1119 return *new_info; |
| 1123 } | 1120 } |
| 1124 | 1121 |
| 1125 } // namespace wasm | 1122 } // namespace wasm |
| 1126 } // namespace internal | 1123 } // namespace internal |
| 1127 } // namespace v8 | 1124 } // namespace v8 |
| OLD | NEW |