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

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

Issue 2446543002: [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Fix bugs Created 4 years, 1 month 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
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 <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 if (false) { 275 if (false) {
276 // End the control flow with a throw 276 // End the control flow with a throw
277 Node* thrw = 277 Node* thrw =
278 graph()->NewNode(common()->Throw(), jsgraph()->ZeroConstant(), 278 graph()->NewNode(common()->Throw(), jsgraph()->ZeroConstant(),
279 *effect_ptr, *control_ptr); 279 *effect_ptr, *control_ptr);
280 end = thrw; 280 end = thrw;
281 } else { 281 } else {
282 // End the control flow with returning 0xdeadbeef 282 // End the control flow with returning 0xdeadbeef
283 Node* ret_value = GetTrapValue(builder_->GetFunctionSignature()); 283 Node* ret_value = GetTrapValue(builder_->GetFunctionSignature());
284 end = graph()->NewNode(jsgraph()->common()->Return(), ret_value, 284 end = graph()->NewNode(jsgraph()->common()->Return(),
285 jsgraph()->Int32Constant(0), ret_value,
285 *effect_ptr, *control_ptr); 286 *effect_ptr, *control_ptr);
286 } 287 }
287 288
288 MergeControlToEnd(jsgraph(), end); 289 MergeControlToEnd(jsgraph(), end);
289 } 290 }
290 }; 291 };
291 292
292 WasmGraphBuilder::WasmGraphBuilder( 293 WasmGraphBuilder::WasmGraphBuilder(
293 Zone* zone, JSGraph* jsgraph, wasm::FunctionSig* function_signature, 294 Zone* zone, JSGraph* jsgraph, wasm::FunctionSig* function_signature,
294 compiler::SourcePositionTable* source_position_table) 295 compiler::SourcePositionTable* source_position_table)
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1034
1034 Node* WasmGraphBuilder::IfDefault(Node* sw) { 1035 Node* WasmGraphBuilder::IfDefault(Node* sw) {
1035 DCHECK_EQ(IrOpcode::kSwitch, sw->opcode()); 1036 DCHECK_EQ(IrOpcode::kSwitch, sw->opcode());
1036 return graph()->NewNode(jsgraph()->common()->IfDefault(), sw); 1037 return graph()->NewNode(jsgraph()->common()->IfDefault(), sw);
1037 } 1038 }
1038 1039
1039 Node* WasmGraphBuilder::Return(unsigned count, Node** vals) { 1040 Node* WasmGraphBuilder::Return(unsigned count, Node** vals) {
1040 DCHECK_NOT_NULL(*control_); 1041 DCHECK_NOT_NULL(*control_);
1041 DCHECK_NOT_NULL(*effect_); 1042 DCHECK_NOT_NULL(*effect_);
1042 1043
1043 Node** buf = Realloc(vals, count, count + 2); 1044 Node** buf = Realloc(vals, count, count + 3);
1044 buf[count] = *effect_; 1045 memmove(buf + 1, buf, sizeof(void*) * count);
1045 buf[count + 1] = *control_; 1046 buf[0] = jsgraph()->Int32Constant(0);
1047 buf[count + 1] = *effect_;
1048 buf[count + 2] = *control_;
1046 Node* ret = 1049 Node* ret =
1047 graph()->NewNode(jsgraph()->common()->Return(count), count + 2, vals); 1050 graph()->NewNode(jsgraph()->common()->Return(count), count + 3, buf);
1048 1051
1049 MergeControlToEnd(jsgraph(), ret); 1052 MergeControlToEnd(jsgraph(), ret);
1050 return ret; 1053 return ret;
1051 } 1054 }
1052 1055
1053 Node* WasmGraphBuilder::ReturnVoid() { return Return(0, Buffer(0)); } 1056 Node* WasmGraphBuilder::ReturnVoid() { return Return(0, Buffer(0)); }
1054 1057
1055 Node* WasmGraphBuilder::Unreachable(wasm::WasmCodePosition position) { 1058 Node* WasmGraphBuilder::Unreachable(wasm::WasmCodePosition position) {
1056 trap_->Unreachable(position); 1059 trap_->Unreachable(position);
1057 return nullptr; 1060 return nullptr;
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args); 2648 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args);
2646 Node* retval = call; 2649 Node* retval = call;
2647 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 && 2650 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 &&
2648 sig->GetReturn(0) == wasm::kAstI64) { 2651 sig->GetReturn(0) == wasm::kAstI64) {
2649 // The return values comes as two values, we pick the low word. 2652 // The return values comes as two values, we pick the low word.
2650 retval = graph()->NewNode(jsgraph()->common()->Projection(0), retval, 2653 retval = graph()->NewNode(jsgraph()->common()->Projection(0), retval,
2651 graph()->start()); 2654 graph()->start());
2652 } 2655 }
2653 Node* jsval = ToJS( 2656 Node* jsval = ToJS(
2654 retval, sig->return_count() == 0 ? wasm::kAstStmt : sig->GetReturn()); 2657 retval, sig->return_count() == 0 ? wasm::kAstStmt : sig->GetReturn());
2655 Node* ret = 2658 Node* ret = graph()->NewNode(jsgraph()->common()->Return(),
2656 graph()->NewNode(jsgraph()->common()->Return(), jsval, call, start); 2659 jsgraph()->Int32Constant(0), jsval, call, start);
2657 2660
2658 MergeControlToEnd(jsgraph(), ret); 2661 MergeControlToEnd(jsgraph(), ret);
2659 } 2662 }
2660 2663
2661 int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count, 2664 int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count,
2662 wasm::FunctionSig* sig) { 2665 wasm::FunctionSig* sig) {
2663 // Convert WASM numbers to JS values. 2666 // Convert WASM numbers to JS values.
2664 int param_index = 0; 2667 int param_index = 0;
2665 for (int i = 0; i < param_count; ++i) { 2668 for (int i = 0; i < param_count; ++i) {
2666 Node* param = graph()->NewNode( 2669 Node* param = graph()->NewNode(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 args[pos++] = *control_; 2760 args[pos++] = *control_;
2758 2761
2759 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args); 2762 call = graph()->NewNode(jsgraph()->common()->Call(desc), pos, args);
2760 } 2763 }
2761 2764
2762 // Convert the return value back. 2765 // Convert the return value back.
2763 Node* ret; 2766 Node* ret;
2764 Node* val = 2767 Node* val =
2765 FromJS(call, HeapConstant(isolate->native_context()), 2768 FromJS(call, HeapConstant(isolate->native_context()),
2766 sig->return_count() == 0 ? wasm::kAstStmt : sig->GetReturn()); 2769 sig->return_count() == 0 ? wasm::kAstStmt : sig->GetReturn());
2770 Node* pop_size = jsgraph()->Int32Constant(0);
2767 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 && 2771 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 &&
2768 sig->GetReturn() == wasm::kAstI64) { 2772 sig->GetReturn() == wasm::kAstI64) {
2769 ret = graph()->NewNode(jsgraph()->common()->Return(), val, 2773 ret = graph()->NewNode(jsgraph()->common()->Return(), pop_size, val,
2770 graph()->NewNode(jsgraph()->machine()->Word32Sar(), 2774 graph()->NewNode(jsgraph()->machine()->Word32Sar(),
2771 val, jsgraph()->Int32Constant(31)), 2775 val, jsgraph()->Int32Constant(31)),
2772 call, start); 2776 call, start);
2773 } else { 2777 } else {
2774 ret = graph()->NewNode(jsgraph()->common()->Return(), val, call, start); 2778 ret = graph()->NewNode(jsgraph()->common()->Return(), pop_size, val, call,
2779 start);
2775 } 2780 }
2776 2781
2777 MergeControlToEnd(jsgraph(), ret); 2782 MergeControlToEnd(jsgraph(), ret);
2778 } 2783 }
2779 2784
2780 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) { 2785 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) {
2781 DCHECK(module_ && module_->instance); 2786 DCHECK(module_ && module_->instance);
2782 if (offset == 0) { 2787 if (offset == 0) {
2783 if (!mem_buffer_) { 2788 if (!mem_buffer_) {
2784 mem_buffer_ = jsgraph()->RelocatableIntPtrConstant( 2789 mem_buffer_ = jsgraph()->RelocatableIntPtrConstant(
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3459 function_->code_start_offset), 3464 function_->code_start_offset),
3460 compile_ms); 3465 compile_ms);
3461 } 3466 }
3462 3467
3463 return code; 3468 return code;
3464 } 3469 }
3465 3470
3466 } // namespace compiler 3471 } // namespace compiler
3467 } // namespace internal 3472 } // namespace internal
3468 } // namespace v8 3473 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698