Avoiding the assumption that the pc pointer of RelocInfo points to the word containin...
authorolehougaard <olehougaard@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 13 Jan 2009 14:38:12 +0000 (14:38 +0000)
committerolehougaard <olehougaard@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 13 Jan 2009 14:38:12 +0000 (14:38 +0000)
Review URL: http://codereview.chromium.org/17376

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

src/assembler-arm-inl.h
src/assembler-ia32-inl.h
src/assembler.h
src/serialize.cc
test/cctest/test-serialize.cc

index fbe37d7a20025376cfe04bc47970f7c36b8c0dc3..5a64d0136181d6bb24df6c470d877135537476ff 100644 (file)
@@ -61,13 +61,19 @@ void RelocInfo::apply(int delta) {
 
 
 Address RelocInfo::target_address() {
-  ASSERT(IsCodeTarget(rmode_));
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
   return Assembler::target_address_at(pc_);
 }
 
 
+Address RelocInfo::target_address_address() {
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  return reinterpret_cast<Address>(Assembler::target_address_address_at(pc_));
+}
+
+
 void RelocInfo::set_target_address(Address target) {
-  ASSERT(IsCodeTarget(rmode_));
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
   Assembler::set_target_address_at(pc_, target);
 }
 
@@ -92,7 +98,7 @@ void RelocInfo::set_target_object(Object* target) {
 
 Address* RelocInfo::target_reference_address() {
   ASSERT(rmode_ == EXTERNAL_REFERENCE);
-  return reinterpret_cast<Address*>(pc_);
+  return reinterpret_cast<Address*>(Assembler::target_address_address_at(pc_));
 }
 
 
index aee847dc1331b5a59b13ddb5e0e2002f689d6cb4..8b5fc6452aa95855a1932a78b4a92ec298e3c20e 100644 (file)
@@ -70,6 +70,12 @@ Address RelocInfo::target_address() {
 }
 
 
+Address RelocInfo::target_address_address() {
+  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  return reinterpret_cast<Address>(pc_);
+}
+
+
 void RelocInfo::set_target_address(Address target) {
   ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
   Assembler::set_target_address_at(pc_, target);
index 097bc84d2764ced6f4c202cb05d5fa87addc28d1..62ef9dc782c6e39bbcf8f6a58fb3ae11449a2473 100644 (file)
@@ -230,14 +230,19 @@ class RelocInfo BASE_EMBEDDED {
   // Apply a relocation by delta bytes
   INLINE(void apply(int delta));
 
-  // Read/modify the code target in the branch/call instruction this relocation
-  // applies to; can only be called if IsCodeTarget(rmode_)
+  // Read/modify the code target in the branch/call instruction
+  // this relocation applies to;
+  // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
   INLINE(Address target_address());
   INLINE(void set_target_address(Address target));
   INLINE(Object* target_object());
   INLINE(Object** target_object_address());
   INLINE(void set_target_object(Object* target));
 
+  // Read the address of the word containing the target_address. Can only
+  // be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY.
+  INLINE(Address target_address_address());
+
   // Read/modify the reference in the instruction this relocation
   // applies to; can only be called if rmode_ is external_reference
   INLINE(Address* target_reference_address());
index 4ecb2a5ad01a75b265196bda264fa3e92056f663..557e6334832dc90ca60732333946081dd4aa83f3 100644 (file)
@@ -586,29 +586,33 @@ ExternalReferenceTable::ExternalReferenceTable() : refs_(64) {
       UNCLASSIFIED,
       3,
       "StackGuard::address_of_limit()");
-  Add(ExternalReference::debug_break().address(),
+  Add(ExternalReference::address_of_regexp_stack_limit().address(),
       UNCLASSIFIED,
       4,
+      "RegExpStack::limit_address()");
+  Add(ExternalReference::debug_break().address(),
+      UNCLASSIFIED,
+      5,
       "Debug::Break()");
   Add(ExternalReference::new_space_start().address(),
       UNCLASSIFIED,
-      5,
+      6,
       "Heap::NewSpaceStart()");
   Add(ExternalReference::heap_always_allocate_scope_depth().address(),
       UNCLASSIFIED,
-      6,
+      7,
       "Heap::always_allocate_scope_depth()");
   Add(ExternalReference::new_space_allocation_limit_address().address(),
       UNCLASSIFIED,
-      7,
+      8,
       "Heap::NewSpaceAllocationLimitAddress()");
   Add(ExternalReference::new_space_allocation_top_address().address(),
       UNCLASSIFIED,
-      8,
+      9,
       "Heap::NewSpaceAllocationTopAddress()");
   Add(ExternalReference::debug_step_in_fp_address().address(),
       UNCLASSIFIED,
-      9,
+      10,
       "Debug::step_in_fp_addr()");
 }
 
@@ -804,7 +808,7 @@ class ReferenceUpdater: public ObjectVisitor {
     Address target = rinfo->target_address();
     uint32_t encoding = reference_encoder_->Encode(target);
     CHECK(target == NULL ? encoding == 0 : encoding != 0);
-    offsets_.Add(reinterpret_cast<Address>(rinfo->pc()) - obj_address_);
+    offsets_.Add(rinfo->target_address_address() - obj_address_);
     addresses_.Add(reinterpret_cast<Address>(encoding));
   }
 
@@ -1269,7 +1273,7 @@ void Deserializer::VisitExternalReferences(Address* start, Address* end) {
 
 
 void Deserializer::VisitRuntimeEntry(RelocInfo* rinfo) {
-  uint32_t* pc = reinterpret_cast<uint32_t*>(rinfo->pc());
+  uint32_t* pc = reinterpret_cast<uint32_t*>(rinfo->target_address_address());
   uint32_t encoding = *pc;
   Address target = reference_decoder_->Decode(encoding);
   rinfo->set_target_address(target);
index c7dd222af0a84d51c6c37fcaa3792fc4f5387ef5..03765a873ef695062164223dd23b9c16e26311cf 100644 (file)
@@ -109,9 +109,9 @@ TEST(ExternalReferenceEncoder) {
       ExternalReference::address_of_stack_guard_limit();
   CHECK_EQ(make_code(UNCLASSIFIED, 3),
            encoder.Encode(stack_guard_limit_address.address()));
-  CHECK_EQ(make_code(UNCLASSIFIED, 4),
-           encoder.Encode(ExternalReference::debug_break().address()));
   CHECK_EQ(make_code(UNCLASSIFIED, 5),
+           encoder.Encode(ExternalReference::debug_break().address()));
+  CHECK_EQ(make_code(UNCLASSIFIED, 6),
            encoder.Encode(ExternalReference::new_space_start().address()));
 }
 
@@ -141,9 +141,9 @@ TEST(ExternalReferenceDecoder) {
   CHECK_EQ(ExternalReference::address_of_stack_guard_limit().address(),
            decoder.Decode(make_code(UNCLASSIFIED, 3)));
   CHECK_EQ(ExternalReference::debug_break().address(),
-           decoder.Decode(make_code(UNCLASSIFIED, 4)));
-  CHECK_EQ(ExternalReference::new_space_start().address(),
            decoder.Decode(make_code(UNCLASSIFIED, 5)));
+  CHECK_EQ(ExternalReference::new_space_start().address(),
+           decoder.Decode(make_code(UNCLASSIFIED, 6)));
 }