Revision: 6479
Author: [email protected]
Date: Wed Jan 26 00:03:48 2011
Log: Revert r6543 and r6441.

This fixes a crash in the code generator.

BUG=1074

Review URL: http://codereview.chromium.org/6258020
http://code.google.com/p/v8/source/detail?r=6479

Modified:
 /branches/bleeding_edge/src/arm/lithium-arm.cc
 /branches/bleeding_edge/src/arm/lithium-arm.h
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.h
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc      Tue Jan 25 06:52:35 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc      Wed Jan 26 00:03:48 2011
@@ -651,6 +651,22 @@
   instr->set_environment(CreateEnvironment(hydrogen_env));
   return instr;
 }
+
+
+LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment(
+    LInstruction* instr, int ast_id) {
+  ASSERT(instructions_pending_deoptimization_environment_ == NULL);
+  ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
+  instructions_pending_deoptimization_environment_ = instr;
+  pending_deoptimization_ast_id_ = ast_id;
+  return instr;
+}
+
+
+void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() {
+  instructions_pending_deoptimization_environment_ = NULL;
+  pending_deoptimization_ast_id_ = AstNode::kNoNumber;
+}


 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
@@ -662,8 +678,8 @@
   if (hinstr->HasSideEffects()) {
     ASSERT(hinstr->next()->IsSimulate());
     HSimulate* sim = HSimulate::cast(hinstr->next());
-    ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
-    pending_deoptimization_ast_id_ = sim->ast_id();
+    instr = SetInstructionPendingDeoptimizationEnvironment(
+        instr, sim->ast_id());
   }

   // If instruction does not have side-effects lazy deoptimization
@@ -1811,11 +1827,12 @@

   // If there is an instruction pending deoptimization environment create a
   // lazy bailout instruction to capture the environment.
-  if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) {
-    ASSERT(pending_deoptimization_ast_id_ == instr->ast_id());
-    LInstruction* lazy_bailout = new LLazyBailout;
-    LInstruction* result = AssignEnvironment(lazy_bailout);
-    pending_deoptimization_ast_id_ = AstNode::kNoNumber;
+  if (pending_deoptimization_ast_id_ == instr->ast_id()) {
+    LInstruction* result = new LLazyBailout;
+    result = AssignEnvironment(result);
+    instructions_pending_deoptimization_environment_->
+        set_deoptimization_environment(result->environment());
+    ClearInstructionPendingDeoptimizationEnvironment();
     return result;
   }

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h       Tue Jan 25 02:35:57 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h       Wed Jan 26 00:03:48 2011
@@ -319,11 +319,22 @@

   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
   HValue* hydrogen_value() const { return hydrogen_value_; }
+
+  void set_deoptimization_environment(LEnvironment* env) {
+    deoptimization_environment_.set(env);
+  }
+  LEnvironment* deoptimization_environment() const {
+    return deoptimization_environment_.get();
+  }
+  bool HasDeoptimizationEnvironment() const {
+    return deoptimization_environment_.is_set();
+  }

  private:
   SetOncePointer<LEnvironment> environment_;
   SetOncePointer<LPointerMap> pointer_map_;
   HValue* hydrogen_value_;
+  SetOncePointer<LEnvironment> deoptimization_environment_;
 };


@@ -1952,6 +1963,10 @@
       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
   LInstruction* MarkAsSaveDoubles(LInstruction* instr);

+  LInstruction* SetInstructionPendingDeoptimizationEnvironment(
+      LInstruction* instr, int ast_id);
+  void ClearInstructionPendingDeoptimizationEnvironment();
+
   LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env);

   void VisitInstruction(HInstruction* current);
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Jan 25 23:44:45 2011 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed Jan 26 00:03:48 2011
@@ -601,20 +601,16 @@
   // Create the environment to bailout to. If the call has side effects
// execution has to continue after the call otherwise execution can continue
   // from a previous bailout point repeating the call.
-  LEnvironment* lazy_deoptimization_environment;
-  ASSERT(!instr->IsControl());
-  ASSERT(instructions_->at(current_instruction_ + 1)->IsGap());
-  LInstruction* next_instr = instructions_->at(current_instruction_ + 2);
-  if (next_instr->IsLazyBailout()) {
-    ASSERT(next_instr->HasEnvironment());
-    lazy_deoptimization_environment = next_instr->environment();
+  LEnvironment* deoptimization_environment;
+  if (instr->HasDeoptimizationEnvironment()) {
+    deoptimization_environment = instr->deoptimization_environment();
   } else {
-    lazy_deoptimization_environment = instr->environment();
+    deoptimization_environment = instr->environment();
   }

-  RegisterEnvironmentForDeoptimization(lazy_deoptimization_environment);
+  RegisterEnvironmentForDeoptimization(deoptimization_environment);
   RecordSafepoint(instr->pointer_map(),
-                  lazy_deoptimization_environment->deoptimization_index());
+                  deoptimization_environment->deoptimization_index());
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon Jan 24 05:29:39 2011 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Wed Jan 26 00:03:48 2011
@@ -414,20 +414,16 @@
   // Create the environment to bailout to. If the call has side effects
// execution has to continue after the call otherwise execution can continue
   // from a previous bailout point repeating the call.
-  LEnvironment* lazy_deoptimization_environment;
-  ASSERT(!instr->IsControl());
-  ASSERT(instructions_->at(current_instruction_ + 1)->IsGap());
-  LInstruction* next_instr = instructions_->at(current_instruction_ + 2);
-  if (next_instr->IsLazyBailout()) {
-    ASSERT(next_instr->HasEnvironment());
-    lazy_deoptimization_environment = next_instr->environment();
+  LEnvironment* deoptimization_environment;
+  if (instr->HasDeoptimizationEnvironment()) {
+    deoptimization_environment = instr->deoptimization_environment();
   } else {
-    lazy_deoptimization_environment = instr->environment();
+    deoptimization_environment = instr->environment();
   }

-  RegisterEnvironmentForDeoptimization(lazy_deoptimization_environment);
+  RegisterEnvironmentForDeoptimization(deoptimization_environment);
   RecordSafepoint(instr->pointer_map(),
-                  lazy_deoptimization_environment->deoptimization_index());
+                  deoptimization_environment->deoptimization_index());
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Jan 25 04:17:02 2011 +++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed Jan 26 00:03:48 2011
@@ -654,6 +654,22 @@
   instr->set_environment(CreateEnvironment(hydrogen_env));
   return instr;
 }
+
+
+LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment(
+    LInstruction* instr, int ast_id) {
+  ASSERT(instructions_pending_deoptimization_environment_ == NULL);
+  ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
+  instructions_pending_deoptimization_environment_ = instr;
+  pending_deoptimization_ast_id_ = ast_id;
+  return instr;
+}
+
+
+void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() {
+  instructions_pending_deoptimization_environment_ = NULL;
+  pending_deoptimization_ast_id_ = AstNode::kNoNumber;
+}


 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
@@ -665,8 +681,8 @@
   if (hinstr->HasSideEffects()) {
     ASSERT(hinstr->next()->IsSimulate());
     HSimulate* sim = HSimulate::cast(hinstr->next());
-    ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
-    pending_deoptimization_ast_id_ = sim->ast_id();
+    instr = SetInstructionPendingDeoptimizationEnvironment(
+        instr, sim->ast_id());
   }

   // If instruction does not have side-effects lazy deoptimization
@@ -1858,11 +1874,12 @@

   // If there is an instruction pending deoptimization environment create a
   // lazy bailout instruction to capture the environment.
-  if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) {
-    ASSERT(pending_deoptimization_ast_id_ == instr->ast_id());
+  if (pending_deoptimization_ast_id_ == instr->ast_id()) {
     LLazyBailout* lazy_bailout = new LLazyBailout;
     LInstruction* result = AssignEnvironment(lazy_bailout);
-    pending_deoptimization_ast_id_ = AstNode::kNoNumber;
+    instructions_pending_deoptimization_environment_->
+        set_deoptimization_environment(result->environment());
+    ClearInstructionPendingDeoptimizationEnvironment();
     return result;
   }

=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h     Mon Jan 24 05:29:39 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h     Wed Jan 26 00:03:48 2011
@@ -320,11 +320,22 @@

   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
   HValue* hydrogen_value() const { return hydrogen_value_; }
+
+  void set_deoptimization_environment(LEnvironment* env) {
+    deoptimization_environment_.set(env);
+  }
+  LEnvironment* deoptimization_environment() const {
+    return deoptimization_environment_.get();
+  }
+  bool HasDeoptimizationEnvironment() const {
+    return deoptimization_environment_.is_set();
+  }

  private:
   SetOncePointer<LEnvironment> environment_;
   SetOncePointer<LPointerMap> pointer_map_;
   HValue* hydrogen_value_;
+  SetOncePointer<LEnvironment> deoptimization_environment_;
 };


@@ -1870,6 +1881,7 @@
         argument_count_(0),
         allocator_(allocator),
         position_(RelocInfo::kNoPosition),
+        instructions_pending_deoptimization_environment_(NULL),
         pending_deoptimization_ast_id_(AstNode::kNoNumber) { }

   // Build the sequence for the graph.
@@ -1978,6 +1990,10 @@
       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
   LInstruction* MarkAsSaveDoubles(LInstruction* instr);

+  LInstruction* SetInstructionPendingDeoptimizationEnvironment(
+      LInstruction* instr, int ast_id);
+  void ClearInstructionPendingDeoptimizationEnvironment();
+
   LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env);

   void VisitInstruction(HInstruction* current);
@@ -1999,6 +2015,7 @@
   int argument_count_;
   LAllocator* allocator_;
   int position_;
+  LInstruction* instructions_pending_deoptimization_environment_;
   int pending_deoptimization_ast_id_;

   DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Jan 25 08:37:18 2011 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Wed Jan 26 00:03:48 2011
@@ -374,20 +374,16 @@
   // Create the environment to bailout to. If the call has side effects
// execution has to continue after the call otherwise execution can continue
   // from a previous bailout point repeating the call.
-  LEnvironment* lazy_deoptimization_environment;
-  ASSERT(!instr->IsControl());
-  ASSERT(instructions_->at(current_instruction_ + 1)->IsGap());
-  LInstruction* next_instr = instructions_->at(current_instruction_ + 2);
-  if (next_instr->IsLazyBailout()) {
-    ASSERT(next_instr->HasEnvironment());
-    lazy_deoptimization_environment = next_instr->environment();
+  LEnvironment* deoptimization_environment;
+  if (instr->HasDeoptimizationEnvironment()) {
+    deoptimization_environment = instr->deoptimization_environment();
   } else {
-    lazy_deoptimization_environment = instr->environment();
+    deoptimization_environment = instr->environment();
   }

-  RegisterEnvironmentForDeoptimization(lazy_deoptimization_environment);
+  RegisterEnvironmentForDeoptimization(deoptimization_environment);
   RecordSafepoint(instr->pointer_map(),
-                  lazy_deoptimization_environment->deoptimization_index());
+                  deoptimization_environment->deoptimization_index());
 }


=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc      Tue Jan 25 08:37:18 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc      Wed Jan 26 00:03:48 2011
@@ -649,6 +649,22 @@
   instr->set_environment(CreateEnvironment(hydrogen_env));
   return instr;
 }
+
+
+LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment(
+    LInstruction* instr, int ast_id) {
+  ASSERT(instructions_pending_deoptimization_environment_ == NULL);
+  ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
+  instructions_pending_deoptimization_environment_ = instr;
+  pending_deoptimization_ast_id_ = ast_id;
+  return instr;
+}
+
+
+void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() {
+  instructions_pending_deoptimization_environment_ = NULL;
+  pending_deoptimization_ast_id_ = AstNode::kNoNumber;
+}


 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
@@ -660,8 +676,8 @@
   if (hinstr->HasSideEffects()) {
     ASSERT(hinstr->next()->IsSimulate());
     HSimulate* sim = HSimulate::cast(hinstr->next());
-    ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
-    pending_deoptimization_ast_id_ = sim->ast_id();
+    instr = SetInstructionPendingDeoptimizationEnvironment(
+        instr, sim->ast_id());
   }

   // If instruction does not have side-effects lazy deoptimization
@@ -1625,11 +1641,12 @@

   // If there is an instruction pending deoptimization environment create a
   // lazy bailout instruction to capture the environment.
-  if (pending_deoptimization_ast_id_ != AstNode::kNoNumber) {
-    ASSERT(pending_deoptimization_ast_id_ == instr->ast_id());
+  if (pending_deoptimization_ast_id_ == instr->ast_id()) {
     LLazyBailout* lazy_bailout = new LLazyBailout;
     LInstruction* result = AssignEnvironment(lazy_bailout);
-    pending_deoptimization_ast_id_ = AstNode::kNoNumber;
+    instructions_pending_deoptimization_environment_->
+        set_deoptimization_environment(result->environment());
+    ClearInstructionPendingDeoptimizationEnvironment();
     return result;
   }

=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h       Tue Jan 25 03:30:47 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.h       Wed Jan 26 00:03:48 2011
@@ -316,11 +316,22 @@

   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
   HValue* hydrogen_value() const { return hydrogen_value_; }
+
+  void set_deoptimization_environment(LEnvironment* env) {
+    deoptimization_environment_.set(env);
+  }
+  LEnvironment* deoptimization_environment() const {
+    return deoptimization_environment_.get();
+  }
+  bool HasDeoptimizationEnvironment() const {
+    return deoptimization_environment_.is_set();
+  }

  private:
   SetOncePointer<LEnvironment> environment_;
   SetOncePointer<LPointerMap> pointer_map_;
   HValue* hydrogen_value_;
+  SetOncePointer<LEnvironment> deoptimization_environment_;
 };


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to