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

Unified Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1048063002: Added %_Likely/%_Unlikely intrinsics (special cases of GCC's __builin_expect). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed feedback. Win fix. Created 5 years, 9 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/js-intrinsic-lowering.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698