Revision: 17299
Author:   [email protected]
Date:     Mon Oct 21 14:09:32 2013 UTC
Log: Allow constants to be deleted by reinserting them into the graph as needed.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/31943002
http://code.google.com/p/v8/source/detail?r=17299

Modified:
 /branches/bleeding_edge/src/code-stubs-hydrogen.cc
 /branches/bleeding_edge/src/hydrogen-dce.cc
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h

=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Mon Oct 21 13:35:48 2013 UTC +++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Mon Oct 21 14:09:32 2013 UTC
@@ -150,10 +150,6 @@
   next_block->SetJoinId(BailoutId::StubEntry());
   set_current_block(next_block);

-  HConstant* undefined_constant =
-      Add<HConstant>(isolate()->factory()->undefined_value());
-  graph()->set_undefined_constant(undefined_constant);
-
   for (int i = 0; i < param_count; ++i) {
     HParameter* param =
         Add<HParameter>(i, HParameter::REGISTER_PARAMETER);
=======================================
--- /branches/bleeding_edge/src/hydrogen-dce.cc Wed Oct 16 13:19:46 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-dce.cc Mon Oct 21 14:09:32 2013 UTC
@@ -98,11 +98,7 @@
       HInstruction* instr = it.Current();
       if (!instr->CheckFlag(HValue::kIsLive)) {
         // Instruction has not been marked live, so remove it.
-        if (!instr->IsConstant() || instr->block()->block_id() != 0) {
-          // TODO(titzer): Some global constants in block 0 can be used
-          // again later, and can't currently be removed. Fix that.
-          instr->DeleteAndReplaceWith(NULL);
-        }
+        instr->DeleteAndReplaceWith(NULL);
       } else {
// Clear the liveness flag to leave the graph clean for the next DCE.
         instr->ClearFlag(HValue::kIsLive);
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Oct 21 13:35:48 2013 UTC +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Oct 21 14:09:32 2013 UTC
@@ -2576,6 +2576,7 @@
   ASSERT(IsLinked());
   if (block()->graph()->has_osr() &&
       block()->graph()->IsStandardConstant(this)) {
+ // TODO(titzer): this seems like a hack that should be fixed by custom OSR.
     return true;
   }
   if (UseCount() == 0) return true;
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Mon Oct 21 13:35:48 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc     Mon Oct 21 14:09:32 2013 UTC
@@ -648,10 +648,21 @@
     // Can't pass GetInvalidContext() to HConstant::New, because that will
     // recursively call GetConstant
     HConstant* constant = HConstant::New(zone(), NULL, value);
-    constant->InsertAfter(GetConstantUndefined());
+    constant->InsertAfter(entry_block()->first());
     pointer->set(constant);
+    return constant;
+  }
+  return ReinsertConstantIfNecessary(pointer->get());
+}
+
+
+HConstant* HGraph::ReinsertConstantIfNecessary(HConstant* constant) {
+  if (!constant->IsLinked()) {
+    // The constant was removed from the graph. Reinsert.
+    constant->ClearFlag(HValue::kIsDead);
+    constant->InsertAfter(entry_block()->first());
   }
-  return pointer->get();
+  return constant;
 }


@@ -681,13 +692,14 @@
true, \ false, \ boolean_value); \ - constant->InsertAfter(GetConstantUndefined()); \ + constant->InsertAfter(entry_block()->first()); \ constant_##name##_.set(constant); \ } \ - return constant_##name##_.get(); \ + return ReinsertConstantIfNecessary(constant_##name##_.get()); \
 }


+DEFINE_GET_CONSTANT(Undefined, undefined, HType::Tagged(), false)
 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true)
 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false)
 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false)
@@ -3233,10 +3245,6 @@
   HInstruction* context = Add<HContext>();
   environment()->BindContext(context);

-  HConstant* undefined_constant = HConstant::cast(Add<HConstant>(
-      isolate()->factory()->undefined_value()));
-  graph()->set_undefined_constant(undefined_constant);
-
   // Create an arguments object containing the initial parameters.  Set the
// initial values of parameters including "this" having parameter index 0.
   ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count());
@@ -3250,6 +3258,7 @@
   AddInstruction(arguments_object);
   graph()->SetArgumentsObject(arguments_object);

+  HConstant* undefined_constant = graph()->GetConstantUndefined();
   // Initialize specials and locals to undefined.
   for (int i = environment()->parameter_count() + 1;
        i < environment()->length();
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Mon Oct 21 13:35:48 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.h      Mon Oct 21 14:09:32 2013 UTC
@@ -342,10 +342,7 @@

   void CollectPhis();

-  void set_undefined_constant(HConstant* constant) {
-    undefined_constant_.set(constant);
-  }
- HConstant* GetConstantUndefined() const { return undefined_constant_.get(); }
+  HConstant* GetConstantUndefined();
   HConstant* GetConstant0();
   HConstant* GetConstant1();
   HConstant* GetConstantMinus1();
@@ -460,6 +457,7 @@
bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_
0; }

  private:
+  HConstant* ReinsertConstantIfNecessary(HConstant* constant);
   HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
                          int32_t integer_value);

@@ -479,7 +477,7 @@
   ZoneList<HValue*> values_;
   ZoneList<HPhi*>* phi_list_;
   ZoneList<HInstruction*>* uint32_instructions_;
-  SetOncePointer<HConstant> undefined_constant_;
+  SetOncePointer<HConstant> constant_undefined_;
   SetOncePointer<HConstant> constant_0_;
   SetOncePointer<HConstant> constant_1_;
   SetOncePointer<HConstant> constant_minus1_;

--
--
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/groups/opt_out.

Reply via email to