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

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

Issue 1886173003: [wasm] Remove the use of JSOperatorBuilder.ToNumber to avoid JSGenericLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 case wasm::kAstF64: 2093 case wasm::kAstF64:
2094 return graph()->NewNode(simplified.ChangeFloat64ToTagged(), node); 2094 return graph()->NewNode(simplified.ChangeFloat64ToTagged(), node);
2095 case wasm::kAstStmt: 2095 case wasm::kAstStmt:
2096 return jsgraph()->UndefinedConstant(); 2096 return jsgraph()->UndefinedConstant();
2097 default: 2097 default:
2098 UNREACHABLE(); 2098 UNREACHABLE();
2099 return nullptr; 2099 return nullptr;
2100 } 2100 }
2101 } 2101 }
2102 2102
2103 Node* WasmGraphBuilder::BuildJavaScriptToNumber(Node* node, Node* context,
2104 Node* effect, Node* control) {
2105 Callable callable = CodeFactory::ToNumber(jsgraph()->isolate());
2106 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
2107 jsgraph()->isolate(), jsgraph()->zone(), callable.descriptor(), 0,
2108 CallDescriptor::kNeedsFrameState, Operator::kNoProperties);
2109 Node* stub_code = jsgraph()->HeapConstant(callable.code());
2110
2111 Node* result =
2112 graph()->NewNode(jsgraph()->common()->Call(desc), stub_code, node,
2113 context, jsgraph()->EmptyFrameState(), effect, control);
2114
2115 *control_ = result;
2116 *effect_ = result;
2117
2118 return result;
2119 }
2103 2120
2104 Node* WasmGraphBuilder::FromJS(Node* node, Node* context, 2121 Node* WasmGraphBuilder::FromJS(Node* node, Node* context,
2105 wasm::LocalType type) { 2122 wasm::LocalType type) {
2106 // Do a JavaScript ToNumber. 2123 // Do a JavaScript ToNumber.
2107 Node* num = 2124 Node* num = BuildJavaScriptToNumber(node, context, *effect_, *control_);
2108 graph()->NewNode(jsgraph()->javascript()->ToNumber(), node, context,
2109 jsgraph()->EmptyFrameState(), *effect_, *control_);
2110 *control_ = num;
2111 *effect_ = num;
2112 2125
2113 // Change representation. 2126 // Change representation.
2114 SimplifiedOperatorBuilder simplified(jsgraph()->zone()); 2127 SimplifiedOperatorBuilder simplified(jsgraph()->zone());
2115 num = graph()->NewNode(simplified.ChangeTaggedToFloat64(), num); 2128 num = graph()->NewNode(simplified.ChangeTaggedToFloat64(), num);
2116 2129
2117 switch (type) { 2130 switch (type) {
2118 case wasm::kAstI32: { 2131 case wasm::kAstI32: {
2119 num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToInt32( 2132 num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToInt32(
2120 TruncationMode::kJavaScript), 2133 TruncationMode::kJavaScript),
2121 num); 2134 num);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 isolate->wasm_function_map(), name, MaybeHandle<Code>()); 2514 isolate->wasm_function_map(), name, MaybeHandle<Code>());
2502 function->SetInternalField(0, *module_object); 2515 function->SetInternalField(0, *module_object);
2503 function->set_shared(*shared); 2516 function->set_shared(*shared);
2504 2517
2505 //---------------------------------------------------------------------------- 2518 //----------------------------------------------------------------------------
2506 // Create the Graph 2519 // Create the Graph
2507 //---------------------------------------------------------------------------- 2520 //----------------------------------------------------------------------------
2508 Zone zone(isolate->allocator()); 2521 Zone zone(isolate->allocator());
2509 Graph graph(&zone); 2522 Graph graph(&zone);
2510 CommonOperatorBuilder common(&zone); 2523 CommonOperatorBuilder common(&zone);
2511 JSOperatorBuilder javascript(&zone);
2512 MachineOperatorBuilder machine(&zone); 2524 MachineOperatorBuilder machine(&zone);
2513 JSGraph jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine); 2525 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
2514 2526
2515 Node* control = nullptr; 2527 Node* control = nullptr;
2516 Node* effect = nullptr; 2528 Node* effect = nullptr;
2517 2529
2518 WasmGraphBuilder builder(&zone, &jsgraph, func->sig); 2530 WasmGraphBuilder builder(&zone, &jsgraph, func->sig);
2519 builder.set_control_ptr(&control); 2531 builder.set_control_ptr(&control);
2520 builder.set_effect_ptr(&effect); 2532 builder.set_effect_ptr(&effect);
2521 builder.set_module(module); 2533 builder.set_module(module);
2522 builder.BuildJSToWasmWrapper(wasm_code, func->sig); 2534 builder.BuildJSToWasmWrapper(wasm_code, func->sig);
2523 2535
2524 //---------------------------------------------------------------------------- 2536 //----------------------------------------------------------------------------
2525 // Run the compilation pipeline. 2537 // Run the compilation pipeline.
2526 //---------------------------------------------------------------------------- 2538 //----------------------------------------------------------------------------
2527 { 2539 {
2528 // Changes lowering requires types. 2540 // Changes lowering requires types.
2529 Typer typer(isolate, &graph); 2541 Typer typer(isolate, &graph);
2530 NodeVector roots(&zone); 2542 NodeVector roots(&zone);
2531 jsgraph.GetCachedNodes(&roots); 2543 jsgraph.GetCachedNodes(&roots);
2532 typer.Run(roots); 2544 typer.Run(roots);
2533 2545
2534 // Run generic and change lowering. 2546 // Run generic and change lowering.
2535 JSGenericLowering generic(&jsgraph);
2536 ChangeLowering changes(&jsgraph); 2547 ChangeLowering changes(&jsgraph);
2537 GraphReducer graph_reducer(&zone, &graph, jsgraph.Dead()); 2548 GraphReducer graph_reducer(&zone, &graph, jsgraph.Dead());
2538 graph_reducer.AddReducer(&changes); 2549 graph_reducer.AddReducer(&changes);
2539 graph_reducer.AddReducer(&generic);
2540 graph_reducer.ReduceGraph(); 2550 graph_reducer.ReduceGraph();
2541 2551
2542 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 2552 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
2543 OFStream os(stdout); 2553 OFStream os(stdout);
2544 os << "-- Graph after change lowering -- " << std::endl; 2554 os << "-- Graph after change lowering -- " << std::endl;
2545 os << AsRPO(graph); 2555 os << AsRPO(graph);
2546 } 2556 }
2547 2557
2548 // Schedule and compile to machine code. 2558 // Schedule and compile to machine code.
2549 int params = static_cast<int>( 2559 int params = static_cast<int>(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 Handle<JSFunction> function, 2603 Handle<JSFunction> function,
2594 wasm::FunctionSig* sig, 2604 wasm::FunctionSig* sig,
2595 wasm::WasmName module_name, 2605 wasm::WasmName module_name,
2596 wasm::WasmName function_name) { 2606 wasm::WasmName function_name) {
2597 //---------------------------------------------------------------------------- 2607 //----------------------------------------------------------------------------
2598 // Create the Graph 2608 // Create the Graph
2599 //---------------------------------------------------------------------------- 2609 //----------------------------------------------------------------------------
2600 Zone zone(isolate->allocator()); 2610 Zone zone(isolate->allocator());
2601 Graph graph(&zone); 2611 Graph graph(&zone);
2602 CommonOperatorBuilder common(&zone); 2612 CommonOperatorBuilder common(&zone);
2603 JSOperatorBuilder javascript(&zone);
2604 MachineOperatorBuilder machine(&zone); 2613 MachineOperatorBuilder machine(&zone);
2605 JSGraph jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine); 2614 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
2606 2615
2607 Node* control = nullptr; 2616 Node* control = nullptr;
2608 Node* effect = nullptr; 2617 Node* effect = nullptr;
2609 2618
2610 WasmGraphBuilder builder(&zone, &jsgraph, sig); 2619 WasmGraphBuilder builder(&zone, &jsgraph, sig);
2611 builder.set_control_ptr(&control); 2620 builder.set_control_ptr(&control);
2612 builder.set_effect_ptr(&effect); 2621 builder.set_effect_ptr(&effect);
2613 builder.set_module(module); 2622 builder.set_module(module);
2614 builder.BuildWasmToJSWrapper(function, sig); 2623 builder.BuildWasmToJSWrapper(function, sig);
2615 2624
2616 Handle<Code> code = Handle<Code>::null(); 2625 Handle<Code> code = Handle<Code>::null();
2617 { 2626 {
2618 // Changes lowering requires types. 2627 // Changes lowering requires types.
2619 Typer typer(isolate, &graph); 2628 Typer typer(isolate, &graph);
2620 NodeVector roots(&zone); 2629 NodeVector roots(&zone);
2621 jsgraph.GetCachedNodes(&roots); 2630 jsgraph.GetCachedNodes(&roots);
2622 typer.Run(roots); 2631 typer.Run(roots);
2623 2632
2624 // Run generic and change lowering. 2633 // Run generic and change lowering.
2625 JSGenericLowering generic(&jsgraph);
2626 ChangeLowering changes(&jsgraph); 2634 ChangeLowering changes(&jsgraph);
2627 GraphReducer graph_reducer(&zone, &graph, jsgraph.Dead()); 2635 GraphReducer graph_reducer(&zone, &graph, jsgraph.Dead());
2628 graph_reducer.AddReducer(&changes); 2636 graph_reducer.AddReducer(&changes);
2629 graph_reducer.AddReducer(&generic);
2630 graph_reducer.ReduceGraph(); 2637 graph_reducer.ReduceGraph();
2631 2638
2632 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 2639 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
2633 OFStream os(stdout); 2640 OFStream os(stdout);
2634 os << "-- Graph after change lowering -- " << std::endl; 2641 os << "-- Graph after change lowering -- " << std::endl;
2635 os << AsRPO(graph); 2642 os << AsRPO(graph);
2636 } 2643 }
2637 2644
2638 // Schedule and compile to machine code. 2645 // Schedule and compile to machine code.
2639 CallDescriptor* incoming = 2646 CallDescriptor* incoming =
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 // TODO(bradnelson): Improve histogram handling of size_t. 2792 // TODO(bradnelson): Improve histogram handling of size_t.
2786 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( 2793 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
2787 static_cast<int>(zone.allocation_size())); 2794 static_cast<int>(zone.allocation_size()));
2788 return code; 2795 return code;
2789 } 2796 }
2790 2797
2791 2798
2792 } // namespace compiler 2799 } // namespace compiler
2793 } // namespace internal 2800 } // namespace internal
2794 } // namespace v8 2801 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698