Revision: 10136
Author:   [email protected]
Date:     Fri Dec  2 03:41:29 2011
Log: Merge r10126 to 3.7 branch: Insert proper padding between lazy deoptimization points and safepoints.

Original CL: http://codereview.chromium.org/8775009/
Review URL: http://codereview.chromium.org/8773031
http://code.google.com/p/v8/source/detail?r=10136

Modified:
 /branches/3.7/src/version.cc
 /branches/3.7/src/x64/lithium-codegen-x64.cc
 /branches/3.7/src/x64/lithium-codegen-x64.h

=======================================
--- /branches/3.7/src/version.cc        Thu Dec  1 06:16:45 2011
+++ /branches/3.7/src/version.cc        Fri Dec  2 03:41:29 2011
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     7
 #define BUILD_NUMBER      12
-#define PATCH_LEVEL       1
+#define PATCH_LEVEL       2
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
=======================================
--- /branches/3.7/src/x64/lithium-codegen-x64.cc        Tue Nov 29 06:28:56 2011
+++ /branches/3.7/src/x64/lithium-codegen-x64.cc        Fri Dec  2 03:41:29 2011
@@ -49,7 +49,9 @@
         deopt_mode_(mode) { }
   virtual ~SafepointGenerator() { }

-  virtual void BeforeCall(int call_size) const { }
+  virtual void BeforeCall(int call_size) const {
+ codegen_->EnsureSpaceForLazyDeopt(Deoptimizer::patch_size() - call_size);
+  }

   virtual void AfterCall() const {
     codegen_->RecordSafepoint(pointers_, deopt_mode_);
@@ -241,7 +243,7 @@
       instr->CompileToNative(this);
     }
   }
-  EnsureSpaceForLazyDeopt();
+  EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
   return !is_aborted();
 }

@@ -439,6 +441,7 @@
                                LInstruction* instr,
                                SafepointMode safepoint_mode,
                                int argc) {
+ EnsureSpaceForLazyDeopt(Deoptimizer::patch_size() - masm()->CallSize(code));
   ASSERT(instr != NULL);
   LPointerMap* pointers = instr->pointer_map();
   RecordPosition(pointers->position());
@@ -4176,25 +4179,24 @@
 }


-void LCodeGen::EnsureSpaceForLazyDeopt() {
+void LCodeGen::EnsureSpaceForLazyDeopt(int space_needed) {
   // Ensure that we have enough space after the previous lazy-bailout
   // instruction for patching the code here.
   int current_pc = masm()->pc_offset();
-  int patch_size = Deoptimizer::patch_size();
-  if (current_pc < last_lazy_deopt_pc_ + patch_size) {
-    int padding_size = last_lazy_deopt_pc_ + patch_size - current_pc;
+  if (current_pc < last_lazy_deopt_pc_ + space_needed) {
+    int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
     while (padding_size > 0) {
       int nop_size = padding_size > 9 ? 9 : padding_size;
       __ nop(nop_size);
       padding_size -= nop_size;
     }
   }
-  last_lazy_deopt_pc_ = masm()->pc_offset();
 }


 void LCodeGen::DoLazyBailout(LLazyBailout* instr) {
-  EnsureSpaceForLazyDeopt();
+  EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
+  last_lazy_deopt_pc_ = masm()->pc_offset();
   ASSERT(instr->HasEnvironment());
   LEnvironment* env = instr->environment();
   RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt);
@@ -4272,7 +4274,8 @@
     __ j(above_equal, &done, Label::kNear);
     StackCheckStub stub;
     CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
-    EnsureSpaceForLazyDeopt();
+    EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
+    last_lazy_deopt_pc_ = masm()->pc_offset();
     __ bind(&done);
     RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt);
     safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index());
@@ -4283,7 +4286,8 @@
         new DeferredStackCheck(this, instr);
     __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
     __ j(below, deferred_stack_check->entry());
-    EnsureSpaceForLazyDeopt();
+    EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
+    last_lazy_deopt_pc_ = masm()->pc_offset();
     __ bind(instr->done_label());
     deferred_stack_check->SetExit(instr->done_label());
     RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt);
=======================================
--- /branches/3.7/src/x64/lithium-codegen-x64.h Tue Nov 29 06:28:56 2011
+++ /branches/3.7/src/x64/lithium-codegen-x64.h Fri Dec  2 03:41:29 2011
@@ -305,7 +305,7 @@
     Address address;
   };

-  void EnsureSpaceForLazyDeopt();
+  void EnsureSpaceForLazyDeopt(int space_needed);

   LChunk* const chunk_;
   MacroAssembler* const masm_;

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

Reply via email to