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/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include "src/isolate-inl.h" | 7 #include "src/isolate-inl.h" |
8 | 8 |
9 #include "src/base/platform/elapsed-timer.h" | 9 #include "src/base/platform/elapsed-timer.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 shared->set_length(params); | 2523 shared->set_length(params); |
2524 shared->set_internal_formal_parameter_count(params); | 2524 shared->set_internal_formal_parameter_count(params); |
2525 Handle<JSFunction> function = isolate->factory()->NewFunction( | 2525 Handle<JSFunction> function = isolate->factory()->NewFunction( |
2526 isolate->wasm_function_map(), name, MaybeHandle<Code>()); | 2526 isolate->wasm_function_map(), name, MaybeHandle<Code>()); |
2527 function->SetInternalField(0, *module_object); | 2527 function->SetInternalField(0, *module_object); |
2528 function->set_shared(*shared); | 2528 function->set_shared(*shared); |
2529 | 2529 |
2530 //---------------------------------------------------------------------------- | 2530 //---------------------------------------------------------------------------- |
2531 // Create the Graph | 2531 // Create the Graph |
2532 //---------------------------------------------------------------------------- | 2532 //---------------------------------------------------------------------------- |
2533 Zone zone; | 2533 Zone zone(isolate->allocator()); |
2534 Graph graph(&zone); | 2534 Graph graph(&zone); |
2535 CommonOperatorBuilder common(&zone); | 2535 CommonOperatorBuilder common(&zone); |
2536 JSOperatorBuilder javascript(&zone); | 2536 JSOperatorBuilder javascript(&zone); |
2537 MachineOperatorBuilder machine(&zone); | 2537 MachineOperatorBuilder machine(&zone); |
2538 JSGraph jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine); | 2538 JSGraph jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine); |
2539 | 2539 |
2540 Node* control = nullptr; | 2540 Node* control = nullptr; |
2541 Node* effect = nullptr; | 2541 Node* effect = nullptr; |
2542 | 2542 |
2543 WasmGraphBuilder builder(&zone, &jsgraph, func->sig); | 2543 WasmGraphBuilder builder(&zone, &jsgraph, func->sig); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2615 } | 2615 } |
2616 | 2616 |
2617 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, | 2617 Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module, |
2618 Handle<JSFunction> function, | 2618 Handle<JSFunction> function, |
2619 wasm::FunctionSig* sig, | 2619 wasm::FunctionSig* sig, |
2620 wasm::WasmName module_name, | 2620 wasm::WasmName module_name, |
2621 wasm::WasmName function_name) { | 2621 wasm::WasmName function_name) { |
2622 //---------------------------------------------------------------------------- | 2622 //---------------------------------------------------------------------------- |
2623 // Create the Graph | 2623 // Create the Graph |
2624 //---------------------------------------------------------------------------- | 2624 //---------------------------------------------------------------------------- |
2625 Zone zone; | 2625 Zone zone(isolate->allocator()); |
2626 Graph graph(&zone); | 2626 Graph graph(&zone); |
2627 CommonOperatorBuilder common(&zone); | 2627 CommonOperatorBuilder common(&zone); |
2628 JSOperatorBuilder javascript(&zone); | 2628 JSOperatorBuilder javascript(&zone); |
2629 MachineOperatorBuilder machine(&zone); | 2629 MachineOperatorBuilder machine(&zone); |
2630 JSGraph jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine); | 2630 JSGraph jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine); |
2631 | 2631 |
2632 Node* control = nullptr; | 2632 Node* control = nullptr; |
2633 Node* effect = nullptr; | 2633 Node* effect = nullptr; |
2634 | 2634 |
2635 WasmGraphBuilder builder(&zone, &jsgraph, sig); | 2635 WasmGraphBuilder builder(&zone, &jsgraph, sig); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 os << std::endl; | 2709 os << std::endl; |
2710 } | 2710 } |
2711 | 2711 |
2712 double decode_ms = 0; | 2712 double decode_ms = 0; |
2713 base::ElapsedTimer decode_timer; | 2713 base::ElapsedTimer decode_timer; |
2714 if (FLAG_trace_wasm_decode_time) { | 2714 if (FLAG_trace_wasm_decode_time) { |
2715 decode_timer.Start(); | 2715 decode_timer.Start(); |
2716 } | 2716 } |
2717 | 2717 |
2718 // Create a TF graph during decoding. | 2718 // Create a TF graph during decoding. |
2719 Zone zone; | 2719 Zone zone(isolate->allocator()); |
2720 Graph graph(&zone); | 2720 Graph graph(&zone); |
2721 CommonOperatorBuilder common(&zone); | 2721 CommonOperatorBuilder common(&zone); |
2722 MachineOperatorBuilder machine( | 2722 MachineOperatorBuilder machine( |
2723 &zone, MachineType::PointerRepresentation(), | 2723 &zone, MachineType::PointerRepresentation(), |
2724 InstructionSelector::SupportedMachineOperatorFlags()); | 2724 InstructionSelector::SupportedMachineOperatorFlags()); |
2725 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); | 2725 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); |
2726 WasmGraphBuilder builder(&zone, &jsgraph, function.sig); | 2726 WasmGraphBuilder builder(&zone, &jsgraph, function.sig); |
2727 wasm::FunctionBody body = { | 2727 wasm::FunctionBody body = { |
2728 module_env, function.sig, module_env->module->module_start, | 2728 module_env, function.sig, module_env->module->module_start, |
2729 module_env->module->module_start + function.code_start_offset, | 2729 module_env->module->module_start + function.code_start_offset, |
2730 module_env->module->module_start + function.code_end_offset}; | 2730 module_env->module->module_start + function.code_end_offset}; |
2731 wasm::TreeResult result = wasm::BuildTFGraph(&builder, body); | 2731 wasm::TreeResult result = |
| 2732 wasm::BuildTFGraph(isolate->allocator(), &builder, body); |
2732 | 2733 |
2733 if (result.failed()) { | 2734 if (result.failed()) { |
2734 if (FLAG_trace_wasm_compiler) { | 2735 if (FLAG_trace_wasm_compiler) { |
2735 OFStream os(stdout); | 2736 OFStream os(stdout); |
2736 os << "Compilation failed: " << result << std::endl; | 2737 os << "Compilation failed: " << result << std::endl; |
2737 } | 2738 } |
2738 // Add the function as another context for the exception | 2739 // Add the function as another context for the exception |
2739 ScopedVector<char> buffer(128); | 2740 ScopedVector<char> buffer(128); |
2740 wasm::WasmName name = | 2741 wasm::WasmName name = |
2741 module_env->module->GetName(function.name_offset, function.name_length); | 2742 module_env->module->GetName(function.name_offset, function.name_length); |
2742 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", | 2743 SNPrintF(buffer, "Compiling WASM function #%d:%.*s failed:", |
2743 function.func_index, name.length, name.name); | 2744 function.func_index, name.length, name.name); |
2744 thrower.Failed(buffer.start(), result); | 2745 thrower.Failed(buffer.start(), result); |
2745 return Handle<Code>::null(); | 2746 return Handle<Code>::null(); |
2746 } | 2747 } |
2747 | 2748 |
2748 int index = static_cast<int>(function.func_index); | 2749 int index = static_cast<int>(function.func_index); |
2749 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { | 2750 if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { |
2750 PrintAst(body); | 2751 PrintAst(isolate->allocator(), body); |
2751 } | 2752 } |
2752 | 2753 |
2753 if (FLAG_trace_wasm_decode_time) { | 2754 if (FLAG_trace_wasm_decode_time) { |
2754 decode_ms = decode_timer.Elapsed().InMillisecondsF(); | 2755 decode_ms = decode_timer.Elapsed().InMillisecondsF(); |
2755 } | 2756 } |
2756 | 2757 |
2757 base::ElapsedTimer compile_timer; | 2758 base::ElapsedTimer compile_timer; |
2758 if (FLAG_trace_wasm_decode_time) { | 2759 if (FLAG_trace_wasm_decode_time) { |
2759 compile_timer.Start(); | 2760 compile_timer.Start(); |
2760 } | 2761 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2804 static_cast<int>(function.code_end_offset - function.code_start_offset), | 2805 static_cast<int>(function.code_end_offset - function.code_start_offset), |
2805 decode_ms, static_cast<int>(graph.NodeCount()), compile_ms); | 2806 decode_ms, static_cast<int>(graph.NodeCount()), compile_ms); |
2806 } | 2807 } |
2807 return code; | 2808 return code; |
2808 } | 2809 } |
2809 | 2810 |
2810 | 2811 |
2811 } // namespace compiler | 2812 } // namespace compiler |
2812 } // namespace internal | 2813 } // namespace internal |
2813 } // namespace v8 | 2814 } // namespace v8 |
OLD | NEW |