Reviewers: Vitaly Repeshko, Sven,

Message:
This is an attempt to fix the safepoint problem with the ToBoolean stub. It
would be nice to have a regression test, but I fear, it may not easy to create
one.

Description:
Record safepoint at calls ToBooleanStub.

This fixes the issues when GC happens when invoking
ToBooleanStub.

Please review this at http://codereview.chromium.org/7465066/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/arm/lithium-arm.cc
  M     src/arm/lithium-codegen-arm.cc
  M     src/ia32/lithium-codegen-ia32.cc
  M     src/ia32/lithium-ia32.cc
  M     src/x64/lithium-codegen-x64.cc
  M     src/x64/lithium-x64.cc


Index: src/arm/lithium-arm.cc
===================================================================
--- src/arm/lithium-arm.cc      (revision 8745)
+++ src/arm/lithium-arm.cc      (working copy)
@@ -1039,7 +1039,7 @@
         : instr->SecondSuccessor();
     return new LGoto(successor->block_id());
   }
-  return new LBranch(UseRegisterAtStart(v));
+  return AssignPointerMap(new LBranch(UseRegisterAtStart(v)));
 }


Index: src/arm/lithium-codegen-arm.cc
===================================================================
--- src/arm/lithium-codegen-arm.cc      (revision 8745)
+++ src/arm/lithium-codegen-arm.cc      (working copy)
@@ -1600,13 +1600,14 @@
       __ b(ne, false_label);
       __ b(true_label);

-      // The conversion stub doesn't cause garbage collections so it's
-      // safe to not record a safepoint after the call.
       __ bind(&call_stub);
       ToBooleanStub stub(reg);
       RegList saved_regs = kJSCallerSaved | kCalleeSaved;
       __ stm(db_w, sp, saved_regs);
       __ CallStub(&stub);
+ // Record safepoint with registers saved and no arguments on the stack.
+      RecordSafepointWithRegisters(
+          instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
       __ cmp(reg, Operand(0));
       __ ldm(ia_w, sp, saved_regs);
       EmitBranch(true_block, false_block, ne);
Index: src/ia32/lithium-codegen-ia32.cc
===================================================================
--- src/ia32/lithium-codegen-ia32.cc    (revision 8745)
+++ src/ia32/lithium-codegen-ia32.cc    (working copy)
@@ -1421,13 +1421,14 @@
       __ j(zero, false_label);
       __ jmp(true_label);

-      // The conversion stub doesn't cause garbage collections so it's
-      // safe to not record a safepoint after the call.
       __ bind(&call_stub);
       ToBooleanStub stub(eax);
       __ pushad();
       __ push(reg);
       __ CallStub(&stub);
+      // Record safepoint with registers saved and one argument.
+      RecordSafepointWithRegisters(
+          instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex);
       __ test(eax, Operand(eax));
       __ popad();
       EmitBranch(true_block, false_block, not_zero);
Index: src/ia32/lithium-ia32.cc
===================================================================
--- src/ia32/lithium-ia32.cc    (revision 8745)
+++ src/ia32/lithium-ia32.cc    (working copy)
@@ -1041,7 +1041,7 @@
         : instr->SecondSuccessor();
     return new LGoto(successor->block_id());
   }
-  return new LBranch(UseRegisterAtStart(v));
+  return AssignPointerMap(new LBranch(UseRegisterAtStart(v)));
 }


Index: src/x64/lithium-codegen-x64.cc
===================================================================
--- src/x64/lithium-codegen-x64.cc      (revision 8745)
+++ src/x64/lithium-codegen-x64.cc      (working copy)
@@ -1425,13 +1425,14 @@
       __ j(zero, false_label);
       __ jmp(true_label);

-      // The conversion stub doesn't cause garbage collections so it's
-      // safe to not record a safepoint after the call.
       __ bind(&call_stub);
       ToBooleanStub stub(rax);
       __ Pushad();
       __ push(reg);
       __ CallStub(&stub);
+      // Record safepoint with registers saved and one argument.
+      RecordSafepointWithRegisters(
+          instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex);
       __ testq(rax, rax);
       __ Popad();
       EmitBranch(true_block, false_block, not_zero);
Index: src/x64/lithium-x64.cc
===================================================================
--- src/x64/lithium-x64.cc      (revision 8745)
+++ src/x64/lithium-x64.cc      (working copy)
@@ -1036,7 +1036,7 @@
         : instr->SecondSuccessor();
     return new LGoto(successor->block_id());
   }
-  return new LBranch(UseRegisterAtStart(v));
+  return AssignPointerMap(new LBranch(UseRegisterAtStart(v)));
 }




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

Reply via email to