| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
| 8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
| 9 #include "src/base/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // patched at instantiation. | 535 // patched at instantiation. |
| 536 Handle<Code> init_builtin = lazy_compile | 536 Handle<Code> init_builtin = lazy_compile |
| 537 ? isolate_->builtins()->WasmCompileLazy() | 537 ? isolate_->builtins()->WasmCompileLazy() |
| 538 : isolate_->builtins()->Illegal(); | 538 : isolate_->builtins()->Illegal(); |
| 539 for (int i = 0, e = static_cast<int>(module_->functions.size()); i < e; | 539 for (int i = 0, e = static_cast<int>(module_->functions.size()); i < e; |
| 540 ++i) { | 540 ++i) { |
| 541 code_table->set(i, *init_builtin); | 541 code_table->set(i, *init_builtin); |
| 542 temp_instance.function_code[i] = init_builtin; | 542 temp_instance.function_code[i] = init_builtin; |
| 543 } | 543 } |
| 544 | 544 |
| 545 isolate_->counters()->wasm_functions_per_module()->AddSample( | 545 (module_->is_wasm() ? isolate_->counters()->wasm_functions_per_wasm_module() |
| 546 static_cast<int>(module_->functions.size())); | 546 : isolate_->counters()->wasm_functions_per_asm_module()) |
| 547 ->AddSample(static_cast<int>(module_->functions.size())); |
| 548 |
| 547 if (!lazy_compile) { | 549 if (!lazy_compile) { |
| 548 CompilationHelper helper(isolate_, module_); | 550 CompilationHelper helper(isolate_, module_); |
| 549 size_t funcs_to_compile = | 551 size_t funcs_to_compile = |
| 550 module_->functions.size() - module_->num_imported_functions; | 552 module_->functions.size() - module_->num_imported_functions; |
| 551 if (!FLAG_trace_wasm_decoder && FLAG_wasm_num_compilation_tasks != 0 && | 553 if (!FLAG_trace_wasm_decoder && FLAG_wasm_num_compilation_tasks != 0 && |
| 552 funcs_to_compile > 1) { | 554 funcs_to_compile > 1) { |
| 553 // Avoid a race condition by collecting results into a second vector. | 555 // Avoid a race condition by collecting results into a second vector. |
| 554 std::vector<Handle<Code>> results(temp_instance.function_code); | 556 std::vector<Handle<Code>> results(temp_instance.function_code); |
| 555 helper.CompileInParallel(&module_env, results, thrower); | 557 helper.CompileInParallel(&module_env, results, thrower); |
| 556 temp_instance.function_code.swap(results); | 558 temp_instance.function_code.swap(results); |
| (...skipping 2652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3209 callee_compiled->instruction_start()); | 3211 callee_compiled->instruction_start()); |
| 3210 } | 3212 } |
| 3211 DCHECK_EQ(non_compiled_functions.size(), idx); | 3213 DCHECK_EQ(non_compiled_functions.size(), idx); |
| 3212 } | 3214 } |
| 3213 | 3215 |
| 3214 Code* ret = | 3216 Code* ret = |
| 3215 Code::cast(compiled_module->code_table()->get(func_to_return_idx)); | 3217 Code::cast(compiled_module->code_table()->get(func_to_return_idx)); |
| 3216 DCHECK_EQ(Code::WASM_FUNCTION, ret->kind()); | 3218 DCHECK_EQ(Code::WASM_FUNCTION, ret->kind()); |
| 3217 return handle(ret, isolate); | 3219 return handle(ret, isolate); |
| 3218 } | 3220 } |
| OLD | NEW |