Reviewers: danno, rossberg, Paul Lind,

Message:
From the source codes and discussion with danno, RUNTIME_ENTRY is a special
external reference. It does not move and is the target of relative
jump/branch/call instructions. Because the relative jump/branch/call
instructions might be moved by GC, RUNTIME_ENTRY needs to be relocated.

It seems that current ARM and MIPS does not use relative jump/branch/call
instructions when using RUNTIME_ENTRY (for deoptimization entries), we should be able to replace RUNTIME_ENTRY with EXTERNAL_REFERENCE. In the future if ARM and
MIPS use CodeRange, we could use RUNTIME_ENTRY again as for X64
(https://codereview.chromium.org/11574027/).

Upstream MIPS could not be compiled, so I verified this patch set by using
https://github.com/paul99/v8m-rb for MIPS.

Description:
Use EXTERNAL_REFERENCE instead of RUNTIME_ENTRY for deoptimization entries
for ARM and MIPS

Please review this at https://codereview.chromium.org/12213080/

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

Affected files:
  M     src/arm/assembler-arm-inl.h
  M     src/arm/lithium-codegen-arm.cc
  M     src/assembler.h
  M     src/assembler.cc
  M     src/disassembler.cc
  M     src/mips/assembler-mips-inl.h
  M     src/mips/lithium-codegen-mips.cc
  M     src/objects.cc


Index: src/arm/assembler-arm-inl.h
===================================================================
--- src/arm/assembler-arm-inl.h (revision 13624)
+++ src/arm/assembler-arm-inl.h (working copy)
@@ -107,14 +107,13 @@


 Address RelocInfo::target_address() {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EXTERNAL_REFERENCE);
   return Assembler::target_address_at(pc_);
 }


 Address RelocInfo::target_address_address() {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
-                              || rmode_ == EMBEDDED_OBJECT
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT
                               || rmode_ == EXTERNAL_REFERENCE);
return reinterpret_cast<Address>(Assembler::target_pointer_address_at(pc_));
 }
@@ -126,7 +125,7 @@


 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EXTERNAL_REFERENCE);
   Assembler::set_target_address_at(pc_, target);
if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) {
     Object* target_code = Code::GetCodeFromTargetAddress(target);
@@ -309,6 +308,7 @@
     visitor->VisitDebugTarget(this);
 #endif
   } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+    UNREACHABLE();
     visitor->VisitRuntimeEntry(this);
   }
 }
@@ -336,6 +336,7 @@
     StaticVisitor::VisitDebugTarget(heap, this);
 #endif
   } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+    UNREACHABLE();
     StaticVisitor::VisitRuntimeEntry(this);
   }
 }
Index: src/arm/lithium-codegen-arm.cc
===================================================================
--- src/arm/lithium-codegen-arm.cc      (revision 13624)
+++ src/arm/lithium-codegen-arm.cc      (working copy)
@@ -834,7 +834,7 @@
ASSERT(FLAG_deopt_every_n_times < 2); // Other values not supported on ARM.

   if (FLAG_deopt_every_n_times == 1 && info_->opt_count() == id) {
-    __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
+    __ Jump(entry, RelocInfo::EXTERNAL_REFERENCE);
     return;
   }

@@ -843,7 +843,7 @@
   bool needs_lazy_deopt = info()->IsStub();
   ASSERT(info()->IsStub() || frame_is_built_);
   if (cc == al && !needs_lazy_deopt) {
-    __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
+    __ Jump(entry, RelocInfo::EXTERNAL_REFERENCE);
   } else {
     // We often have several deopts to the same entry, reuse the last
     // jump entry if this is the case.
Index: src/assembler.cc
===================================================================
--- src/assembler.cc    (revision 13624)
+++ src/assembler.cc    (working copy)
@@ -766,7 +766,8 @@
     }
   } else if (IsPosition(rmode_)) {
     PrintF(out, "  (%" V8_PTR_PREFIX "d)", data());
-  } else if (rmode_ == RelocInfo::RUNTIME_ENTRY &&
+  } else if ((rmode_ == RelocInfo::RUNTIME_ENTRY ||
+              rmode_ == RelocInfo::EXTERNAL_REFERENCE) &&
              Isolate::Current()->deoptimizer_data() != NULL) {
     // Depotimization bailouts are stored as runtime entries.
     int id = Deoptimizer::GetDeoptimizationId(
Index: src/assembler.h
===================================================================
--- src/assembler.h     (revision 13624)
+++ src/assembler.h     (working copy)
@@ -345,7 +345,8 @@

   // Read/modify the code target in the branch/call instruction
   // this relocation applies to;
-  // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
+ // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY ||
+  // rmode_ == EXTERNAL_REFERENCE
   INLINE(Address target_address());
   INLINE(void set_target_address(Address target,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER));
Index: src/disassembler.cc
===================================================================
--- src/disassembler.cc (revision 13624)
+++ src/disassembler.cc (working copy)
@@ -281,7 +281,8 @@
         if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
out.AddFormatted(" (id = %d)", static_cast<int>(relocinfo.data()));
         }
-      } else if (rmode == RelocInfo::RUNTIME_ENTRY &&
+      } else if ((rmode == RelocInfo::RUNTIME_ENTRY ||
+                  rmode == RelocInfo::EXTERNAL_REFERENCE) &&
                  Isolate::Current()->deoptimizer_data() != NULL) {
         // A runtime entry reloinfo might be a deoptimization bailout.
         Address addr = relocinfo.target_address();
Index: src/mips/assembler-mips-inl.h
===================================================================
--- src/mips/assembler-mips-inl.h       (revision 13624)
+++ src/mips/assembler-mips-inl.h       (working copy)
@@ -139,14 +139,13 @@


 Address RelocInfo::target_address() {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EXTERNAL_REFERENCE);
   return Assembler::target_address_at(pc_);
 }


 Address RelocInfo::target_address_address() {
   ASSERT(IsCodeTarget(rmode_) ||
-         rmode_ == RUNTIME_ENTRY ||
          rmode_ == EMBEDDED_OBJECT ||
          rmode_ == EXTERNAL_REFERENCE);
   // Read the address of the word containing the target_address in an
@@ -174,7 +173,7 @@


 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == EXTERNAL_REFERENCE);
   Assembler::set_target_address_at(pc_, target);
if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) {
     Object* target_code = Code::GetCodeFromTargetAddress(target);
@@ -360,6 +359,7 @@
     visitor->VisitDebugTarget(this);
 #endif
   } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+    UNREACHABLE();
     visitor->VisitRuntimeEntry(this);
   }
 }
@@ -387,6 +387,7 @@
     StaticVisitor::VisitDebugTarget(heap, this);
 #endif
   } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+    UNREACHABLE();
     StaticVisitor::VisitRuntimeEntry(this);
   }
 }
Index: src/mips/lithium-codegen-mips.cc
===================================================================
--- src/mips/lithium-codegen-mips.cc    (revision 13624)
+++ src/mips/lithium-codegen-mips.cc    (working copy)
@@ -785,7 +785,7 @@
ASSERT(FLAG_deopt_every_n_times < 2); // Other values not supported on MIPS.

   if (FLAG_deopt_every_n_times == 1 && info_->opt_count() == id) {
-    __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
+    __ Jump(entry, RelocInfo::EXTERNAL_REFERENCE);
     return;
   }

@@ -801,7 +801,7 @@
   bool needs_lazy_deopt = info()->IsStub();
   ASSERT(info()->IsStub() || frame_is_built_);
   if (cc == al && !needs_lazy_deopt) {
-    __ Jump(entry, RelocInfo::RUNTIME_ENTRY, cc, src1, src2);
+    __ Jump(entry, RelocInfo::EXTERNAL_REFERENCE, cc, src1, src2);
   } else {
     // We often have several deopts to the same entry, reuse the last
     // jump entry if this is the case.
Index: src/objects.cc
===================================================================
--- src/objects.cc      (revision 13624)
+++ src/objects.cc      (working copy)
@@ -8830,7 +8830,8 @@
 void Code::PrintDeoptLocation(int bailout_id) {
   const char* last_comment = NULL;
   int mask = RelocInfo::ModeMask(RelocInfo::COMMENT)
-      | RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
+      | RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY)
+      | RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE);
   for (RelocIterator it(this, mask); !it.done(); it.next()) {
     RelocInfo* info = it.rinfo();
     if (info->rmode() == RelocInfo::COMMENT) {
@@ -8838,7 +8839,8 @@
     } else if (last_comment != NULL &&
                bailout_id == Deoptimizer::GetDeoptimizationId(
                    info->target_address(), Deoptimizer::EAGER)) {
-      CHECK(info->rmode() == RelocInfo::RUNTIME_ENTRY);
+      CHECK(info->rmode() == RelocInfo::RUNTIME_ENTRY ||
+            info->rmode() == RelocInfo::EXTERNAL_REFERENCE);
       PrintF("            %s\n", last_comment);
       return;
     }


--
--
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