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

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

Issue 2413343002: [wasm] Use branch hint for the -1 check in I(32|64)Div. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | 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 <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 *control_ = merge; 1789 *control_ = merge;
1790 *effect_ = effect_merge; 1790 *effect_ = effect_merge;
1791 return value_i32; 1791 return value_i32;
1792 } 1792 }
1793 1793
1794 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, 1794 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
1795 wasm::WasmCodePosition position) { 1795 wasm::WasmCodePosition position) {
1796 MachineOperatorBuilder* m = jsgraph()->machine(); 1796 MachineOperatorBuilder* m = jsgraph()->machine();
1797 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position); 1797 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position);
1798 Node* before = *control_; 1798 Node* before = *control_;
1799 Node* denom_is_m1; 1799 Node* is_denom_m1 =
titzer 2016/10/17 13:44:16 Can you add a branch hint to the old method so tha
1800 Node* denom_is_not_m1; 1800 graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1));
1801 Branch( 1801 Node* branch = graph()->NewNode(
1802 graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)), 1802 jsgraph()->common()->Branch(BranchHint::kFalse), is_denom_m1, *control_);
1803 &denom_is_m1, &denom_is_not_m1); 1803 Node* denom_is_m1 = graph()->NewNode(jsgraph()->common()->IfTrue(), branch);
1804 Node* denom_is_not_m1 =
1805 graph()->NewNode(jsgraph()->common()->IfFalse(), branch);
1804 *control_ = denom_is_m1; 1806 *control_ = denom_is_m1;
1805 trap_->TrapIfEq32(wasm::kTrapDivUnrepresentable, left, kMinInt, position); 1807 trap_->TrapIfEq32(wasm::kTrapDivUnrepresentable, left, kMinInt, position);
1806 if (*control_ != denom_is_m1) { 1808 if (*control_ != denom_is_m1) {
1807 *control_ = graph()->NewNode(jsgraph()->common()->Merge(2), denom_is_not_m1, 1809 *control_ = graph()->NewNode(jsgraph()->common()->Merge(2), denom_is_not_m1,
1808 *control_); 1810 *control_);
1809 } else { 1811 } else {
1810 *control_ = before; 1812 *control_ = before;
1811 } 1813 }
1812 return graph()->NewNode(m->Int32Div(), left, right, *control_); 1814 return graph()->NewNode(m->Int32Div(), left, right, *control_);
1813 } 1815 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 BranchHint::kFalse); 1926 BranchHint::kFalse);
1925 1927
1926 Node* rem = graph()->NewNode(jsgraph()->machine()->Uint32Mod(), left, right, 1928 Node* rem = graph()->NewNode(jsgraph()->machine()->Uint32Mod(), left, right,
1927 z.if_false); 1929 z.if_false);
1928 return z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0), 1930 return z.Phi(MachineRepresentation::kWord32, jsgraph()->Int32Constant(0),
1929 rem); 1931 rem);
1930 } 1932 }
1931 1933
1932 Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right, 1934 Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right,
1933 wasm::WasmCodePosition position) { 1935 wasm::WasmCodePosition position) {
1934 if (jsgraph()->machine()->Is32()) { 1936 MachineOperatorBuilder* m = jsgraph()->machine();
1937 if (m->Is32()) {
1935 return BuildDiv64Call( 1938 return BuildDiv64Call(
1936 left, right, ExternalReference::wasm_int64_div(jsgraph()->isolate()), 1939 left, right, ExternalReference::wasm_int64_div(jsgraph()->isolate()),
1937 MachineType::Int64(), wasm::kTrapDivByZero, position); 1940 MachineType::Int64(), wasm::kTrapDivByZero, position);
1938 } 1941 }
1939 trap_->ZeroCheck64(wasm::kTrapDivByZero, right, position); 1942 trap_->ZeroCheck64(wasm::kTrapDivByZero, right, position);
1940 Node* before = *control_; 1943 Node* before = *control_;
1941 Node* denom_is_m1; 1944 Node* is_denom_m1 =
1942 Node* denom_is_not_m1; 1945 graph()->NewNode(m->Word64Equal(), right, jsgraph()->Int64Constant(-1));
1943 Branch(graph()->NewNode(jsgraph()->machine()->Word64Equal(), right, 1946 Node* branch = graph()->NewNode(
1944 jsgraph()->Int64Constant(-1)), 1947 jsgraph()->common()->Branch(BranchHint::kFalse), is_denom_m1, *control_);
1945 &denom_is_m1, &denom_is_not_m1); 1948 Node* denom_is_m1 = graph()->NewNode(jsgraph()->common()->IfTrue(), branch);
1949 Node* denom_is_not_m1 =
1950 graph()->NewNode(jsgraph()->common()->IfFalse(), branch);
1946 *control_ = denom_is_m1; 1951 *control_ = denom_is_m1;
1947 trap_->TrapIfEq64(wasm::kTrapDivUnrepresentable, left, 1952 trap_->TrapIfEq64(wasm::kTrapDivUnrepresentable, left,
1948 std::numeric_limits<int64_t>::min(), position); 1953 std::numeric_limits<int64_t>::min(), position);
1949 if (*control_ != denom_is_m1) { 1954 if (*control_ != denom_is_m1) {
1950 *control_ = graph()->NewNode(jsgraph()->common()->Merge(2), denom_is_not_m1, 1955 *control_ = graph()->NewNode(jsgraph()->common()->Merge(2), denom_is_not_m1,
1951 *control_); 1956 *control_);
1952 } else { 1957 } else {
1953 *control_ = before; 1958 *control_ = before;
1954 } 1959 }
1955 return graph()->NewNode(jsgraph()->machine()->Int64Div(), left, right, 1960 return graph()->NewNode(jsgraph()->machine()->Int64Div(), left, right,
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 function_->code_start_offset), 3421 function_->code_start_offset),
3417 compile_ms); 3422 compile_ms);
3418 } 3423 }
3419 3424
3420 return code; 3425 return code;
3421 } 3426 }
3422 3427
3423 } // namespace compiler 3428 } // namespace compiler
3424 } // namespace internal 3429 } // namespace internal
3425 } // namespace v8 3430 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698