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

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

Issue 2339053003: [V8][Wasm] Wasm throws. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addresses comments. Created 4 years, 3 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') | src/runtime/runtime.h » ('j') | 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 <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 Node* result = BuildChangeSmiToInt32(call); 1696 Node* result = BuildChangeSmiToInt32(call);
1697 1697
1698 result = check_input_range.Phi(MachineRepresentation::kWord32, result, 1698 result = check_input_range.Phi(MachineRepresentation::kWord32, result,
1699 jsgraph()->Int32Constant(-1)); 1699 jsgraph()->Int32Constant(-1));
1700 *effect_ = graph()->NewNode(jsgraph()->common()->EffectPhi(2), call, *effect_, 1700 *effect_ = graph()->NewNode(jsgraph()->common()->EffectPhi(2), call, *effect_,
1701 check_input_range.merge); 1701 check_input_range.merge);
1702 *control_ = check_input_range.merge; 1702 *control_ = check_input_range.merge;
1703 return result; 1703 return result;
1704 } 1704 }
1705 1705
1706 Node* WasmGraphBuilder::Throw(Node* input) {
1707 MachineOperatorBuilder* machine = jsgraph()->machine();
1708
1709 // Pass the thrown value as two SMIs:
1710 //
1711 // upper = static_cast<uint32_t>(input) >> 16;
1712 // lower = input & 0xFFFF;
1713 //
1714 // This is needed because we can't safely call BuildChangeInt32ToTagged from
1715 // this method.
1716 //
1717 // TODO(wasm): figure out how to properly pass this to the runtime function.
1718 Node* upper = BuildChangeInt32ToSmi(
1719 graph()->NewNode(machine->Word32Shr(), input, Int32Constant(16)));
1720 Node* lower = BuildChangeInt32ToSmi(
1721 graph()->NewNode(machine->Word32And(), input, Int32Constant(0xFFFFu)));
1722
1723 Node* parameters[] = {lower, upper}; // thrown value
1724 return BuildCallToRuntime(Runtime::kWasmThrow, jsgraph(),
1725 module_->instance->context, parameters,
1726 arraysize(parameters), effect_, *control_);
1727 }
1728
1706 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, 1729 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
1707 wasm::WasmCodePosition position) { 1730 wasm::WasmCodePosition position) {
1708 MachineOperatorBuilder* m = jsgraph()->machine(); 1731 MachineOperatorBuilder* m = jsgraph()->machine();
1709 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position); 1732 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position);
1710 Node* before = *control_; 1733 Node* before = *control_;
1711 Node* denom_is_m1; 1734 Node* denom_is_m1;
1712 Node* denom_is_not_m1; 1735 Node* denom_is_not_m1;
1713 Branch( 1736 Branch(
1714 graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)), 1737 graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)),
1715 &denom_is_m1, &denom_is_not_m1); 1738 &denom_is_m1, &denom_is_not_m1);
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 function_->code_start_offset), 3302 function_->code_start_offset),
3280 compile_ms); 3303 compile_ms);
3281 } 3304 }
3282 3305
3283 return code; 3306 return code;
3284 } 3307 }
3285 3308
3286 } // namespace compiler 3309 } // namespace compiler
3287 } // namespace internal 3310 } // namespace internal
3288 } // namespace v8 3311 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698