Use the information from the last recorded safepoint for the padding after the deferr...
authorsgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 6 Jul 2011 09:28:07 +0000 (09:28 +0000)
committersgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 6 Jul 2011 09:28:07 +0000 (09:28 +0000)
R=kmillikin@chromium.org

BUG=none
TEST=none

Review URL: http://codereview.chromium.org//7248077

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8543 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/lithium-codegen-arm.cc
src/ia32/lithium-codegen-ia32.cc
src/ia32/lithium-codegen-ia32.h
src/x64/lithium-codegen-x64.cc

index 59fa3d6..ee36314 100644 (file)
@@ -257,29 +257,20 @@ LInstruction* LCodeGen::GetNextInstruction() {
 
 bool LCodeGen::GenerateDeferredCode() {
   ASSERT(is_generating());
-  Label last_jump;
   if (deferred_.length() > 0) {
     for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
       LDeferredCode* code = deferred_[i];
       __ bind(code->entry());
       code->Generate();
-#ifdef DEBUG
-      if (i == deferred_.length() - 1) {
-        __ bind(&last_jump);
-      }
-#endif
       __ jmp(code->exit());
     }
 
-    // Reserve some space to ensure that the last piece of deferred code
-    // have room for lazy bailout.
-    __ nop();
-    __ nop();
-
-    int code_generated =
-        masm_->InstructionsGeneratedSince(&last_jump) * Assembler::kInstrSize;
-    ASSERT(Deoptimizer::patch_size() <= code_generated);
-    USE(code_generated);
+    // Pad code to ensure that the last piece of deferred code have
+    // room for lazy bailout.
+    while ((masm()->pc_offset() - LastSafepointEnd())
+           < Deoptimizer::patch_size()) {
+      __ nop();
+    }
   }
 
   // Force constant pool emission at the end of the deferred code to make
index ab741b7..2f1b88e 100644 (file)
@@ -255,28 +255,20 @@ LInstruction* LCodeGen::GetNextInstruction() {
 
 bool LCodeGen::GenerateDeferredCode() {
   ASSERT(is_generating());
-  Label last_jump;
   if (deferred_.length() > 0) {
     for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
       LDeferredCode* code = deferred_[i];
       __ bind(code->entry());
       code->Generate();
-#ifdef DEBUG
-      if (i == deferred_.length() - 1) {
-        __ bind(&last_jump);
-      }
-#endif
       __ jmp(code->exit());
     }
 
-    // Reserve some space to ensure that the last piece of deferred code
-    // have room for lazy bailout.
-    __ nop();
-    __ nop();
-    __ nop();
-
-    ASSERT(Deoptimizer::patch_size() <=
-           masm_->SizeOfCodeGeneratedSince(&last_jump));
+    // Pad code to ensure that the last piece of deferred code have
+    // room for lazy bailout.
+    while ((masm()->pc_offset() - LastSafepointEnd())
+           < Deoptimizer::patch_size()) {
+      __ nop();
+    }
   }
 
   // Deferred code is the last part of the instruction sequence. Mark
index ecd2f51..7ab446d 100644 (file)
@@ -248,6 +248,9 @@ class LCodeGen BASE_EMBEDDED {
                                     int arguments,
                                     int deoptimization_index);
   void RecordPosition(int position);
+  int LastSafepointEnd() {
+    return static_cast<int>(safepoints_.GetPcAfterGap());
+  }
 
   static Condition TokenToCondition(Token::Value op, bool is_unsigned);
   void EmitGoto(int block);
index d8d7af6..3ebdc7c 100644 (file)
@@ -275,34 +275,25 @@ bool LCodeGen::GenerateJumpTable() {
 
 bool LCodeGen::GenerateDeferredCode() {
   ASSERT(is_generating());
-  Label last_jump;
   if (deferred_.length() > 0) {
     for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
       LDeferredCode* code = deferred_[i];
       __ bind(code->entry());
       code->Generate();
-#ifdef DEBUG
-      if (i == (deferred_.length() - 1)) {
-        __ bind(&last_jump);
-      }
-#endif
       __ jmp(code->exit());
     }
 
-    // Reserve some space to ensure that the last piece of deferred code
-    // have room for lazy bailout.
-    int padding =
-        Deoptimizer::patch_size() - masm_->SizeOfCodeGeneratedSince(&last_jump);
-    if (padding > 0) {
-      while (padding > 9) {
+    // Pad code to ensure that the last piece of deferred code have
+    // room for lazy bailout.
+    while ((masm()->pc_offset() - LastSafepointEnd())
+           < Deoptimizer::patch_size()) {
+      int padding = masm()->pc_offset() - LastSafepointEnd();
+      if (padding > 9) {
         __ nop(9);
-        padding -= 9;
+      } else {
+        __ nop(padding);
       }
-      __ nop(padding);
     }
-
-    ASSERT(Deoptimizer::patch_size() <=
-           masm_->SizeOfCodeGeneratedSince(&last_jump));
   }
 
   // Deferred code is the last part of the instruction sequence. Mark