Reviewers: titzer,

Description:
[turbofan] Turn JSIntrinsicLowering into an AdvancedReducer.

This in turn allows usage of AdvancedReducer::ReplaceWithValue which
has access to the underlying graph reducer. It will allow us to deal
with exception continuations correctly.

[email protected]

Please review this at https://codereview.chromium.org/1134663006/

Base URL: https://chromium.googlesource.com/v8/v8.git@local_graph-reducer-advanced-1

Affected files (+23, -21 lines):
  M src/compiler/js-intrinsic-lowering.h
  M src/compiler/js-intrinsic-lowering.cc
  M src/compiler/pipeline.cc
  M test/unittests/compiler/js-intrinsic-lowering-unittest.cc


Index: src/compiler/js-intrinsic-lowering.cc
diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc index 23b1f804a0f6f889724fd66a9bc18f6a03fb930f..5e063a7bff04f811175c940758a267d66b43367c 100644
--- a/src/compiler/js-intrinsic-lowering.cc
+++ b/src/compiler/js-intrinsic-lowering.cc
@@ -16,8 +16,10 @@ namespace v8 {
 namespace internal {
 namespace compiler {

-JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph)
-    : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
+JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph)
+    : AdvancedReducer(editor),
+      jsgraph_(jsgraph),
+      simplified_(jsgraph->zone()) {}


 Reduction JSIntrinsicLowering::Reduce(Node* node) {
@@ -95,7 +97,7 @@ Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { graph()->NewNode(machine()->Float64InsertLowWord32(),
                                         jsgraph()->Constant(0), low),
                        high);
-  NodeProperties::ReplaceWithValue(node, value);
+  ReplaceWithValue(node, value);
   return Replace(value);
 }

@@ -118,8 +120,7 @@ Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {

   // False branch - the original continuation.
   Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
- NodeProperties::ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect,
-                                   if_false);
+  ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect, if_false);

   // True branch: deopt.
   Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
@@ -209,7 +210,7 @@ Reduction JSIntrinsicLowering::ReduceIsInstanceType(

   // Replace all effect uses of {node} with the {ephi}.
Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
-  NodeProperties::ReplaceWithValue(node, node, ephi);
+  ReplaceWithValue(node, node, ephi);

   // Turn the {node} into a Phi.
   return Change(node, common()->Phi(type, 2), vtrue, vfalse, merge);
@@ -270,7 +271,7 @@ Reduction JSIntrinsicLowering::ReduceSeqStringGetChar(
   node->ReplaceInput(2, effect);
   node->ReplaceInput(3, control);
   node->TrimInputCount(4);
-  NodeProperties::ReplaceWithValue(node, node, node);
+  RelaxControls(node);
   return Changed(node);
 }

@@ -292,7 +293,7 @@ Reduction JSIntrinsicLowering::ReduceSeqStringSetChar(
   node->ReplaceInput(4, control);
   node->TrimInputCount(5);
   NodeProperties::RemoveBounds(node);
-  NodeProperties::ReplaceWithValue(node, string, node);
+  ReplaceWithValue(node, string, node);
   return Changed(node);
 }

@@ -325,7 +326,7 @@ Reduction JSIntrinsicLowering::ReduceUnLikely(Node* node, BranchHint hint) {
   }
// Apart from adding hints to branchs nodes, this is the identity function.
   Node* value = NodeProperties::GetValueInput(node, 0);
-  NodeProperties::ReplaceWithValue(node, value);
+  ReplaceWithValue(node, value);
   return Changed(value);
 }

@@ -386,7 +387,7 @@ Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) {

   // Replace all effect uses of {node} with the {ephi0}.
   Node* ephi0 = graph()->NewNode(ephi_op, etrue0, efalse0, merge0);
-  NodeProperties::ReplaceWithValue(node, node, ephi0);
+  ReplaceWithValue(node, node, ephi0);

   // Turn the {node} into a Phi.
   return Change(node, phi_op, vtrue0, vfalse0, merge0);
@@ -395,7 +396,7 @@ Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) {

 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op) {
   // Replace all effect uses of {node} with the effect dependency.
-  NodeProperties::ReplaceWithValue(node, node);
+  RelaxEffectsAndControls(node);
   // Remove the inputs corresponding to context, effect and control.
   NodeProperties::RemoveNonValueInputs(node);
   // Finally update the operator to the new one.
@@ -419,7 +420,7 @@ Reduction JSIntrinsicLowering::ReduceIsMinusZero(Node* node) {
       machine()->Word32Equal(), double_hi,
       jsgraph()->Int32Constant(static_cast<int32_t>(0x80000000)));

-  NodeProperties::ReplaceWithValue(node, node, effect);
+  ReplaceWithValue(node, node, effect);

Node* and_result = graph()->NewNode(machine()->Word32And(), check1, check2);

@@ -437,7 +438,7 @@ Reduction JSIntrinsicLowering::ReduceFixedArraySet(Node* node) {
   Node* store = (graph()->NewNode(
simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base,
       index, value, effect, control));
-  NodeProperties::ReplaceWithValue(node, value, store);
+  ReplaceWithValue(node, value, store);
   return Changed(store);
 }

@@ -460,7 +461,7 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
   node->ReplaceInput(0, a);
   node->ReplaceInput(1, b);
   node->TrimInputCount(2);
-  NodeProperties::ReplaceWithValue(node, node, node);
+  RelaxControls(node);
   return Changed(node);
 }

@@ -472,14 +473,13 @@ Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
   node->ReplaceInput(1, b);
   node->ReplaceInput(2, c);
   node->TrimInputCount(3);
-  NodeProperties::ReplaceWithValue(node, node, node);
+  RelaxControls(node);
   return Changed(node);
 }


Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) {
-  NodeProperties::ReplaceWithValue(node, jsgraph()->UndefinedConstant(),
-                                   effect);
+  ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect);
   return Changed(node);
 }

Index: src/compiler/js-intrinsic-lowering.h
diff --git a/src/compiler/js-intrinsic-lowering.h b/src/compiler/js-intrinsic-lowering.h index 7bb75ee40a488d224d39eaa5c2bcab7f6ea701ae..339000b2ba47ae9808adbf7d1ae4bb63cc9c8a76 100644
--- a/src/compiler/js-intrinsic-lowering.h
+++ b/src/compiler/js-intrinsic-lowering.h
@@ -20,9 +20,9 @@ class MachineOperatorBuilder;


 // Lowers certain JS-level runtime calls.
-class JSIntrinsicLowering final : public Reducer {
+class JSIntrinsicLowering final : public AdvancedReducer {
  public:
-  explicit JSIntrinsicLowering(JSGraph* jsgraph);
+  JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph);
   ~JSIntrinsicLowering() final {}

   Reduction Reduce(Node* node) final;
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index f7c5d43874c9ea664a0fe69e5b8a0218fe230b21..7387b46d2fb504cdff3a6d43ec235a41f450ecf2 100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -561,7 +561,7 @@ struct TypedLoweringPhase {
     LoadElimination load_elimination;
     JSBuiltinReducer builtin_reducer(data->jsgraph());
JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone);
-    JSIntrinsicLowering intrinsic_lowering(data->jsgraph());
+ JSIntrinsicLowering intrinsic_lowering(&graph_reducer, data->jsgraph());
     SimplifiedOperatorReducer simple_reducer(data->jsgraph());
     CommonOperatorReducer common_reducer(data->jsgraph());
     AddReducer(data, &graph_reducer, &builtin_reducer);
Index: test/unittests/compiler/js-intrinsic-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc index bc343060caa748453fca4974bd03df419942772f..7c561315b6485efa20a4cc1d790c9b0e50acae13 100644
--- a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
+++ b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
@@ -33,7 +33,9 @@ class JSIntrinsicLoweringTest : public GraphTest {
                                    MachineOperatorBuilder::kNoFlags) {
     MachineOperatorBuilder machine(zone(), kMachPtr, flags);
     JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine);
-    JSIntrinsicLowering reducer(&jsgraph);
+    // TODO(titzer): mock the GraphReducer here for better unit testing.
+    GraphReducer graph_reducer(graph(), zone());
+    JSIntrinsicLowering reducer(&graph_reducer, &jsgraph);
     return reducer.Reduce(node);
   }



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to