Index: src/compiler/js-intrinsic-lowering.cc |
diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc |
index 7253aab787780acfd51268090ec36b81ce558165..71fd0e95734fdda8f7c7650ecb7da36e0de50286 100644 |
--- a/src/compiler/js-intrinsic-lowering.cc |
+++ b/src/compiler/js-intrinsic-lowering.cc |
@@ -5,6 +5,8 @@ |
#include "src/compiler/js-intrinsic-lowering.h" |
+#include <stack> |
+ |
#include "src/compiler/access-builder.h" |
#include "src/compiler/js-graph.h" |
#include "src/compiler/node-matchers.h" |
@@ -48,6 +50,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) { |
return ReduceIsSmi(node); |
case Runtime::kInlineJSValueGetValue: |
return ReduceJSValueGetValue(node); |
+ case Runtime::kInlineLikely: |
+ return ReduceUnLikely(node, BranchHint::kTrue); |
case Runtime::kInlineMapGetInstanceType: |
return ReduceMapGetInstanceType(node); |
case Runtime::kInlineMathClz32: |
@@ -66,6 +70,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) { |
return ReduceSeqStringGetChar(node, String::TWO_BYTE_ENCODING); |
case Runtime::kInlineTwoByteSeqStringSetChar: |
return ReduceSeqStringSetChar(node, String::TWO_BYTE_ENCODING); |
+ case Runtime::kInlineUnlikely: |
+ return ReduceUnLikely(node, BranchHint::kFalse); |
case Runtime::kInlineValueOf: |
return ReduceValueOf(node); |
default: |
@@ -293,6 +299,29 @@ Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { |
} |
+Reduction JSIntrinsicLowering::ReduceUnLikely(Node* node, BranchHint hint) { |
+ std::stack<Node*> nodes_to_visit; |
+ nodes_to_visit.push(node); |
+ while (!nodes_to_visit.empty()) { |
+ Node* current = nodes_to_visit.top(); |
+ nodes_to_visit.pop(); |
+ for (Node* use : current->uses()) { |
+ if (use->opcode() == IrOpcode::kJSToBoolean) { |
+ // We have to "look through" ToBoolean calls. |
+ nodes_to_visit.push(use); |
+ } else if (use->opcode() == IrOpcode::kBranch) { |
+ // Actually set the hint on any branch using the intrinsic node. |
+ use->set_op(common()->Branch(hint)); |
+ } |
+ } |
+ } |
+ // Apart from adding hints to branchs nodes, this is the identity function. |
+ Node* value = NodeProperties::GetValueInput(node, 0); |
+ NodeProperties::ReplaceWithValue(node, value); |
+ return Changed(value); |
+} |
+ |
+ |
Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { |
// if (%_IsSmi(value)) { |
// return value; |