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

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2413343002: [wasm] Use branch hint for the -1 check in I(32|64)Div. (Closed)
Patch Set: Use anonymous namespace. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/wasm/ast-decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index f3c1c5819bf606f97230ba1dc6983d66b31b94ee..b6dc62be9394dc3cd98372021721a3ab96853a1f 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -990,16 +990,36 @@ Node* WasmGraphBuilder::HeapConstant(Handle<HeapObject> value) {
return jsgraph()->HeapConstant(value);
}
-Node* WasmGraphBuilder::Branch(Node* cond, Node** true_node,
- Node** false_node) {
+namespace {
+Node* Branch(JSGraph* jsgraph, Node* cond, Node** true_node, Node** false_node,
+ Node* control, BranchHint hint) {
DCHECK_NOT_NULL(cond);
- DCHECK_NOT_NULL(*control_);
+ DCHECK_NOT_NULL(control);
Node* branch =
- graph()->NewNode(jsgraph()->common()->Branch(), cond, *control_);
- *true_node = graph()->NewNode(jsgraph()->common()->IfTrue(), branch);
- *false_node = graph()->NewNode(jsgraph()->common()->IfFalse(), branch);
+ jsgraph->graph()->NewNode(jsgraph->common()->Branch(hint), cond, control);
+ *true_node = jsgraph->graph()->NewNode(jsgraph->common()->IfTrue(), branch);
+ *false_node = jsgraph->graph()->NewNode(jsgraph->common()->IfFalse(), branch);
return branch;
}
+} // namespace
+
+Node* WasmGraphBuilder::BranchNoHint(Node* cond, Node** true_node,
+ Node** false_node) {
+ return Branch(jsgraph(), cond, true_node, false_node, *control_,
+ BranchHint::kNone);
+}
+
+Node* WasmGraphBuilder::BranchExpectTrue(Node* cond, Node** true_node,
+ Node** false_node) {
+ return Branch(jsgraph(), cond, true_node, false_node, *control_,
+ BranchHint::kTrue);
+}
+
+Node* WasmGraphBuilder::BranchExpectFalse(Node* cond, Node** true_node,
+ Node** false_node) {
+ return Branch(jsgraph(), cond, true_node, false_node, *control_,
+ BranchHint::kFalse);
+}
Node* WasmGraphBuilder::Switch(unsigned count, Node* key) {
return graph()->NewNode(jsgraph()->common()->Switch(count), key, *control_);
@@ -1758,7 +1778,7 @@ Node* WasmGraphBuilder::Catch(Node* input, wasm::WasmCodePosition position) {
Node* is_smi;
Node* is_heap;
- Branch(BuildTestNotSmi(value), &is_heap, &is_smi);
+ BranchExpectFalse(BuildTestNotSmi(value), &is_heap, &is_smi);
// is_smi
Node* smi_i32 = BuildChangeSmiToInt32(value);
@@ -1798,7 +1818,7 @@ Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
Node* before = *control_;
Node* denom_is_m1;
Node* denom_is_not_m1;
- Branch(
+ BranchExpectFalse(
graph()->NewNode(m->Word32Equal(), right, jsgraph()->Int32Constant(-1)),
&denom_is_m1, &denom_is_not_m1);
*control_ = denom_is_m1;
@@ -1940,9 +1960,9 @@ Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right,
Node* before = *control_;
Node* denom_is_m1;
Node* denom_is_not_m1;
- Branch(graph()->NewNode(jsgraph()->machine()->Word64Equal(), right,
- jsgraph()->Int64Constant(-1)),
- &denom_is_m1, &denom_is_not_m1);
+ BranchExpectFalse(graph()->NewNode(jsgraph()->machine()->Word64Equal(), right,
+ jsgraph()->Int64Constant(-1)),
+ &denom_is_m1, &denom_is_not_m1);
*control_ = denom_is_m1;
trap_->TrapIfEq64(wasm::kTrapDivUnrepresentable, left,
std::numeric_limits<int64_t>::min(), position);
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/wasm/ast-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698