Revision: 23449
Author:   [email protected]
Date:     Wed Aug 27 11:14:10 2014 UTC
Log: Remove old changes lowering code and convert test to use new changes lowering code.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/515433003
https://code.google.com/p/v8/source/detail?r=23449

Modified:
 /branches/bleeding_edge/src/compiler/simplified-lowering.cc
 /branches/bleeding_edge/src/compiler/simplified-lowering.h
 /branches/bleeding_edge/test/cctest/compiler/test-changes-lowering.cc

=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.cc Tue Aug 26 13:09:08 2014 UTC +++ /branches/bleeding_edge/src/compiler/simplified-lowering.cc Wed Aug 27 11:14:10 2014 UTC
@@ -726,10 +726,6 @@
                                 graph()->zone()->isolate());
   RepresentationSelector selector(jsgraph(), zone(), &changer);
   selector.Run(this);
-
-  GraphReducer graph_reducer(graph());
-  graph_reducer.AddReducer(this);
-  graph_reducer.ReduceGraph();
 }


@@ -750,157 +746,6 @@
 Node* SimplifiedLowering::OffsetMinusTagConstant(int32_t offset) {
   return jsgraph()->Int32Constant(offset - kHeapObjectTag);
 }
-
-
-static void UpdateControlSuccessors(Node* before, Node* node) {
-  DCHECK(IrOpcode::IsControlOpcode(before->opcode()));
-  UseIter iter = before->uses().begin();
-  while (iter != before->uses().end()) {
-    if (IrOpcode::IsControlOpcode((*iter)->opcode()) &&
-        NodeProperties::IsControlEdge(iter.edge())) {
-      iter = iter.UpdateToAndIncrement(node);
-      continue;
-    }
-    ++iter;
-  }
-}
-
-
-void SimplifiedLowering::DoChangeTaggedToUI32(Node* node, Node* effect,
- Node* control, bool is_signed) {
-  // if (IsTagged(val))
- // ConvertFloat64To(Int32|Uint32)(Load[kMachFloat64](input, #value_offset))
-  // else Untag(val)
-  Node* val = node->InputAt(0);
- Node* branch = graph()->NewNode(common()->Branch(), IsTagged(val), control);
-
-  // true branch.
-  Node* tbranch = graph()->NewNode(common()->IfTrue(), branch);
-  Node* loaded = graph()->NewNode(
-      machine()->Load(kMachFloat64), val,
-      OffsetMinusTagConstant(HeapNumber::kValueOffset), effect);
-  Operator* op = is_signed ? machine()->ChangeFloat64ToInt32()
-                           : machine()->ChangeFloat64ToUint32();
-  Node* converted = graph()->NewNode(op, loaded);
-
-  // false branch.
-  Node* fbranch = graph()->NewNode(common()->IfFalse(), branch);
-  Node* untagged = Untag(val);
-
-  // merge.
-  Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch);
- Node* phi = graph()->NewNode(common()->Phi(2), converted, untagged, merge);
-  UpdateControlSuccessors(control, merge);
-  branch->ReplaceInput(1, control);
-  node->ReplaceUses(phi);
-}
-
-
-void SimplifiedLowering::DoChangeTaggedToFloat64(Node* node, Node* effect,
-                                                 Node* control) {
-  // if (IsTagged(input)) Load[kMachFloat64](input, #value_offset)
-  // else ConvertFloat64(Untag(input))
-  Node* val = node->InputAt(0);
- Node* branch = graph()->NewNode(common()->Branch(), IsTagged(val), control);
-
-  // true branch.
-  Node* tbranch = graph()->NewNode(common()->IfTrue(), branch);
-  Node* loaded = graph()->NewNode(
-      machine()->Load(kMachFloat64), val,
-      OffsetMinusTagConstant(HeapNumber::kValueOffset), effect);
-
-  // false branch.
-  Node* fbranch = graph()->NewNode(common()->IfFalse(), branch);
-  Node* untagged = Untag(val);
-  Node* converted =
-      graph()->NewNode(machine()->ChangeInt32ToFloat64(), untagged);
-
-  // merge.
-  Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch);
-  Node* phi = graph()->NewNode(common()->Phi(2), loaded, converted, merge);
-  UpdateControlSuccessors(control, merge);
-  branch->ReplaceInput(1, control);
-  node->ReplaceUses(phi);
-}
-
-
-void SimplifiedLowering::DoChangeUI32ToTagged(Node* node, Node* effect,
- Node* control, bool is_signed) {
-  Node* val = node->InputAt(0);
-  Node* is_smi = NULL;
-  if (is_signed) {
-    if (SmiValuesAre32Bits()) {
-      // All int32s fit in this case.
-      DCHECK(kPointerSize == 8);
-      return node->ReplaceUses(SmiTag(val));
-    } else {
-      // TODO(turbofan): use an Int32AddWithOverflow to tag and check here.
-      Node* lt = graph()->NewNode(machine()->Int32LessThanOrEqual(), val,
- jsgraph()->Int32Constant(Smi::kMaxValue));
-      Node* gt =
-          graph()->NewNode(machine()->Int32LessThanOrEqual(),
-                           jsgraph()->Int32Constant(Smi::kMinValue), val);
-      is_smi = graph()->NewNode(machine()->Word32And(), lt, gt);
-    }
-  } else {
-    // Check if Uint32 value is in the smi range.
-    is_smi = graph()->NewNode(machine()->Uint32LessThanOrEqual(), val,
-                              jsgraph()->Int32Constant(Smi::kMaxValue));
-  }
-
-  // TODO(turbofan): fold smi test branch eagerly.
-  // if (IsSmi(input)) SmiTag(input);
-  // else InlineAllocAndInitHeapNumber(ConvertToFloat64(input)))
-  Node* branch = graph()->NewNode(common()->Branch(), is_smi, control);
-
-  // true branch.
-  Node* tbranch = graph()->NewNode(common()->IfTrue(), branch);
-  Node* smi_tagged = SmiTag(val);
-
-  // false branch.
-  Node* fbranch = graph()->NewNode(common()->IfFalse(), branch);
- Node* heap_num = jsgraph()->Constant(0.0); // TODO(titzer): alloc and init
-
-  // merge.
-  Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch);
- Node* phi = graph()->NewNode(common()->Phi(2), smi_tagged, heap_num, merge);
-  UpdateControlSuccessors(control, merge);
-  branch->ReplaceInput(1, control);
-  node->ReplaceUses(phi);
-}
-
-
-void SimplifiedLowering::DoChangeFloat64ToTagged(Node* node, Node* effect,
-                                                 Node* control) {
-  return;  // TODO(titzer): need to call runtime to allocate in one branch
-}
-
-
-void SimplifiedLowering::DoChangeBoolToBit(Node* node, Node* effect,
-                                           Node* control) {
-  Node* cmp = graph()->NewNode(machine()->WordEqual(), node->InputAt(0),
-                               jsgraph()->TrueConstant());
-  node->ReplaceUses(cmp);
-}
-
-
-void SimplifiedLowering::DoChangeBitToBool(Node* node, Node* effect,
-                                           Node* control) {
-  Node* val = node->InputAt(0);
-  Node* branch = graph()->NewNode(common()->Branch(), val, control);
-
-  // true branch.
-  Node* tbranch = graph()->NewNode(common()->IfTrue(), branch);
-  // false branch.
-  Node* fbranch = graph()->NewNode(common()->IfFalse(), branch);
-  // merge.
-  Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch);
-  Node* phi = graph()->NewNode(common()->Phi(2), jsgraph()->TrueConstant(),
-                               jsgraph()->FalseConstant(), merge);
-  UpdateControlSuccessors(control, merge);
-  branch->ReplaceInput(1, control);
-  node->ReplaceUses(phi);
-}


static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
@@ -963,41 +808,6 @@
   node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
 }

-
-Reduction SimplifiedLowering::Reduce(Node* node) { return NoChange(); }
-
-
-void SimplifiedLowering::LowerChange(Node* node, Node* effect, Node* control) {
-  switch (node->opcode()) {
-    case IrOpcode::kChangeTaggedToInt32:
-      DoChangeTaggedToUI32(node, effect, control, true);
-      break;
-    case IrOpcode::kChangeTaggedToUint32:
-      DoChangeTaggedToUI32(node, effect, control, false);
-      break;
-    case IrOpcode::kChangeTaggedToFloat64:
-      DoChangeTaggedToFloat64(node, effect, control);
-      break;
-    case IrOpcode::kChangeInt32ToTagged:
-      DoChangeUI32ToTagged(node, effect, control, true);
-      break;
-    case IrOpcode::kChangeUint32ToTagged:
-      DoChangeUI32ToTagged(node, effect, control, false);
-      break;
-    case IrOpcode::kChangeFloat64ToTagged:
-      DoChangeFloat64ToTagged(node, effect, control);
-      break;
-    case IrOpcode::kChangeBoolToBit:
-      DoChangeBoolToBit(node, effect, control);
-      break;
-    case IrOpcode::kChangeBitToBool:
-      DoChangeBitToBool(node, effect, control);
-      break;
-    default:
-      UNREACHABLE();
-      break;
-  }
-}

 }  // namespace compiler
 }  // namespace internal
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.h Thu Aug 14 12:24:37 2014 UTC +++ /branches/bleeding_edge/src/compiler/simplified-lowering.h Wed Aug 27 11:14:10 2014 UTC
@@ -5,7 +5,6 @@
 #ifndef V8_COMPILER_SIMPLIFIED_LOWERING_H_
 #define V8_COMPILER_SIMPLIFIED_LOWERING_H_

-#include "src/compiler/graph-reducer.h"
 #include "src/compiler/js-graph.h"
 #include "src/compiler/machine-operator.h"
 #include "src/compiler/node.h"
@@ -15,7 +14,7 @@
 namespace internal {
 namespace compiler {

-class SimplifiedLowering : public Reducer {
+class SimplifiedLowering {
  public:
   explicit SimplifiedLowering(JSGraph* jsgraph)
       : jsgraph_(jsgraph), machine_(jsgraph->zone()) {}
@@ -23,9 +22,6 @@

   void LowerAllNodes();

-  virtual Reduction Reduce(Node* node);
-  void LowerChange(Node* node, Node* effect, Node* control);
-
// TODO(titzer): These are exposed for direct testing. Use a friend class.
   void DoLoadField(Node* node);
   void DoStoreField(Node* node);
@@ -42,15 +38,6 @@
   Node* OffsetMinusTagConstant(int32_t offset);
   Node* ComputeIndex(const ElementAccess& access, Node* index);

-  void DoChangeTaggedToUI32(Node* node, Node* effect, Node* control,
-                            bool is_signed);
-  void DoChangeUI32ToTagged(Node* node, Node* effect, Node* control,
-                            bool is_signed);
-  void DoChangeTaggedToFloat64(Node* node, Node* effect, Node* control);
-  void DoChangeFloat64ToTagged(Node* node, Node* effect, Node* control);
-  void DoChangeBoolToBit(Node* node, Node* effect, Node* control);
-  void DoChangeBitToBool(Node* node, Node* effect, Node* control);
-
   friend class RepresentationSelector;

   Zone* zone() { return jsgraph_->zone(); }
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-changes-lowering.cc Tue Aug 19 11:24:24 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-changes-lowering.cc Wed Aug 27 11:14:10 2014 UTC
@@ -4,11 +4,12 @@

 #include <limits>

+#include "src/compiler/change-lowering.h"
 #include "src/compiler/control-builders.h"
 #include "src/compiler/generic-node-inl.h"
+#include "src/compiler/js-graph.h"
 #include "src/compiler/node-properties-inl.h"
 #include "src/compiler/pipeline.h"
-#include "src/compiler/simplified-lowering.h"
 #include "src/compiler/simplified-node-factory.h"
 #include "src/compiler/typer.h"
 #include "src/compiler/verifier.h"
@@ -31,12 +32,10 @@
       : GraphBuilderTester<ReturnType>(p0),
         typer(this->zone()),
         jsgraph(this->graph(), this->common(), &typer),
-        lowering(&jsgraph),
         function(Handle<JSFunction>::null()) {}

   Typer typer;
   JSGraph jsgraph;
-  SimplifiedLowering lowering;
   Handle<JSFunction> function;

   Node* start() { return this->graph()->start(); }
@@ -109,8 +108,7 @@
                                        this->start(), this->start());
     Node* end = this->graph()->NewNode(this->common()->End(), ret);
     this->graph()->SetEnd(end);
-    this->lowering.LowerChange(change, this->start(), this->start());
-    Verifier::Run(this->graph());
+    LowerChange(change);
   }

void BuildStoreAndLower(Operator* op, Operator* store_op, void* location) {
@@ -125,8 +123,7 @@
this->common()->Return(), this->Int32Constant(0), store, this->start());
     Node* end = this->graph()->NewNode(this->common()->End(), ret);
     this->graph()->SetEnd(end);
-    this->lowering.LowerChange(change, this->start(), this->start());
-    Verifier::Run(this->graph());
+    LowerChange(change);
   }

   void BuildLoadAndLower(Operator* op, Operator* load_op, void* location) {
@@ -140,7 +137,17 @@
                                        this->start(), this->start());
     Node* end = this->graph()->NewNode(this->common()->End(), ret);
     this->graph()->SetEnd(end);
-    this->lowering.LowerChange(change, this->start(), this->start());
+    LowerChange(change);
+  }
+
+  void LowerChange(Node* change) {
+    // Run the graph reducer with changes lowering on a single node.
+    CompilationInfo info(this->isolate(), this->zone());
+    Linkage linkage(&info);
+    ChangeLowering lowering(&jsgraph, &linkage, this->machine());
+    GraphReducer reducer(this->graph());
+    reducer.AddReducer(&lowering);
+    reducer.ReduceNode(change);
     Verifier::Run(this->graph());
   }

@@ -293,20 +300,6 @@
     CHECK_EQ(false_obj, result);
   }
 }
-
-
-bool TODO_INT32_TO_TAGGED_WILL_WORK(int32_t v) {
- // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation
-  // works.
-  return Smi::IsValid(v);
-}
-
-
-bool TODO_UINT32_TO_TAGGED_WILL_WORK(uint32_t v) {
- // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation
-  // works.
-  return v <= static_cast<uint32_t>(Smi::kMaxValue);
-}


 TEST(RunChangeInt32ToTagged) {
@@ -319,20 +312,16 @@
     FOR_INT32_INPUTS(i) {
       input = *i;
       Object* result = t.CallWithPotentialGC<Object>();
-      if (TODO_INT32_TO_TAGGED_WILL_WORK(input)) {
-        t.CheckNumber(static_cast<double>(input), result);
-      }
+      t.CheckNumber(static_cast<double>(input), result);
     }
   }

   if (Pipeline::SupportedTarget()) {
     FOR_INT32_INPUTS(i) {
       input = *i;
-      SimulateFullSpace(CcTest::heap()->new_space());
+      CcTest::heap()->DisableInlineAllocation();
       Object* result = t.CallWithPotentialGC<Object>();
-      if (TODO_INT32_TO_TAGGED_WILL_WORK(input)) {
-        t.CheckNumber(static_cast<double>(input), result);
-      }
+      t.CheckNumber(static_cast<double>(input), result);
     }
   }
 }
@@ -349,28 +338,21 @@
       input = *i;
       Object* result = t.CallWithPotentialGC<Object>();
       double expected = static_cast<double>(input);
-      if (TODO_UINT32_TO_TAGGED_WILL_WORK(input)) {
-        t.CheckNumber(expected, result);
-      }
+      t.CheckNumber(expected, result);
     }
   }

   if (Pipeline::SupportedTarget()) {
     FOR_UINT32_INPUTS(i) {
       input = *i;
-      SimulateFullSpace(CcTest::heap()->new_space());
+      CcTest::heap()->DisableInlineAllocation();
       Object* result = t.CallWithPotentialGC<Object>();
       double expected = static_cast<double>(static_cast<uint32_t>(input));
-      if (TODO_UINT32_TO_TAGGED_WILL_WORK(input)) {
-        t.CheckNumber(expected, result);
-      }
+      t.CheckNumber(expected, result);
     }
   }
 }

-
-// TODO(titzer): lowering of Float64->Tagged needs inline allocation.
-#define TODO_FLOAT64_TO_TAGGED false

 TEST(RunChangeFloat64ToTagged) {
   ChangesLoweringTester<Object*> t;
@@ -378,8 +360,7 @@
   t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(),
                       t.machine()->Load(kMachFloat64), &input);

-  // TODO(titzer): need inline allocation to change float to tagged.
-  if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) {
+  {
     FOR_FLOAT64_INPUTS(i) {
       input = *i;
       Object* result = t.CallWithPotentialGC<Object>();
@@ -387,10 +368,10 @@
     }
   }

-  if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) {
+  {
     FOR_FLOAT64_INPUTS(i) {
       input = *i;
-      SimulateFullSpace(CcTest::heap()->new_space());
+      CcTest::heap()->DisableInlineAllocation();
       Object* result = t.CallWithPotentialGC<Object>();
       t.CheckNumber(input, result);
     }

--
--
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