Refactored EXTERNAL_REFERENCE handling.

Previously, the result of target_reference_address() could only be
read, writing to it would have had an architecture-dependent effect,
e.g. writing into the code on ia32, a no-op on arm, etc.

This refactoring-only CL turns this into a simple getter, making it
impossible to use incorrectly.

More to come...

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/46583006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17467 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d3ad5be7
...@@ -160,10 +160,9 @@ void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { ...@@ -160,10 +160,9 @@ void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) {
} }
Address* RelocInfo::target_reference_address() { Address RelocInfo::target_reference() {
ASSERT(rmode_ == EXTERNAL_REFERENCE); ASSERT(rmode_ == EXTERNAL_REFERENCE);
reconstructed_adr_ptr_ = Assembler::target_address_at(pc_); return Assembler::target_address_at(pc_);
return &reconstructed_adr_ptr_;
} }
......
...@@ -819,8 +819,8 @@ void RelocInfo::Print(Isolate* isolate, FILE* out) { ...@@ -819,8 +819,8 @@ void RelocInfo::Print(Isolate* isolate, FILE* out) {
} else if (rmode_ == EXTERNAL_REFERENCE) { } else if (rmode_ == EXTERNAL_REFERENCE) {
ExternalReferenceEncoder ref_encoder(isolate); ExternalReferenceEncoder ref_encoder(isolate);
PrintF(out, " (%s) (%p)", PrintF(out, " (%s) (%p)",
ref_encoder.NameOfAddress(*target_reference_address()), ref_encoder.NameOfAddress(target_reference()),
*target_reference_address()); target_reference());
} else if (IsCodeTarget(rmode_)) { } else if (IsCodeTarget(rmode_)) {
Code* code = Code::GetCodeFromTargetAddress(target_address()); Code* code = Code::GetCodeFromTargetAddress(target_address());
PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()), PrintF(out, " (%s) (%p)", Code::Kind2String(code->kind()),
......
...@@ -425,7 +425,7 @@ class RelocInfo BASE_EMBEDDED { ...@@ -425,7 +425,7 @@ class RelocInfo BASE_EMBEDDED {
// Read/modify the reference in the instruction this relocation // Read/modify the reference in the instruction this relocation
// applies to; can only be called if rmode_ is external_reference // applies to; can only be called if rmode_ is external_reference
INLINE(Address* target_reference_address()); INLINE(Address target_reference());
// Read/modify the address of a call instruction. This is used to relocate // Read/modify the address of a call instruction. This is used to relocate
// the break points where straight-line code is patched with a call // the break points where straight-line code is patched with a call
......
...@@ -227,7 +227,7 @@ static int DecodeIt(Isolate* isolate, ...@@ -227,7 +227,7 @@ static int DecodeIt(Isolate* isolate,
out.AddFormatted(" ;; object: %s", *obj_name); out.AddFormatted(" ;; object: %s", *obj_name);
} else if (rmode == RelocInfo::EXTERNAL_REFERENCE) { } else if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
const char* reference_name = const char* reference_name =
ref_encoder.NameOfAddress(*relocinfo.target_reference_address()); ref_encoder.NameOfAddress(relocinfo.target_reference());
out.AddFormatted(" ;; external reference (%s)", reference_name); out.AddFormatted(" ;; external reference (%s)", reference_name);
} else if (RelocInfo::IsCodeTarget(rmode)) { } else if (RelocInfo::IsCodeTarget(rmode)) {
out.AddFormatted(" ;; code:"); out.AddFormatted(" ;; code:");
......
...@@ -145,9 +145,9 @@ void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { ...@@ -145,9 +145,9 @@ void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) {
} }
Address* RelocInfo::target_reference_address() { Address RelocInfo::target_reference() {
ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
return reinterpret_cast<Address*>(pc_); return Memory::Address_at(pc_);
} }
......
...@@ -213,10 +213,9 @@ void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { ...@@ -213,10 +213,9 @@ void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) {
} }
Address* RelocInfo::target_reference_address() { Address RelocInfo::target_reference() {
ASSERT(rmode_ == EXTERNAL_REFERENCE); ASSERT(rmode_ == EXTERNAL_REFERENCE);
reconstructed_adr_ptr_ = Assembler::target_address_at(pc_); return Assembler::target_address_at(pc_);
return &reconstructed_adr_ptr_;
} }
......
...@@ -10322,8 +10322,8 @@ void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) { ...@@ -10322,8 +10322,8 @@ void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) {
void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) { void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) {
Address* p = rinfo->target_reference_address(); Address p = rinfo->target_reference();
VisitExternalReference(p); VisitExternalReference(&p);
} }
......
...@@ -1694,12 +1694,12 @@ void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) { ...@@ -1694,12 +1694,12 @@ void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) {
Address references_start = rinfo->target_address_address(); Address references_start = rinfo->target_address_address();
int skip = OutputRawData(references_start, kCanReturnSkipInsteadOfSkipping); int skip = OutputRawData(references_start, kCanReturnSkipInsteadOfSkipping);
Address* current = rinfo->target_reference_address(); Address current = rinfo->target_reference();
int representation = rinfo->IsCodedSpecially() ? int representation = rinfo->IsCodedSpecially() ?
kFromCode + kStartOfObject : kPlain + kStartOfObject; kFromCode + kStartOfObject : kPlain + kStartOfObject;
sink_->Put(kExternalReference + representation, "ExternalRef"); sink_->Put(kExternalReference + representation, "ExternalRef");
sink_->PutInt(skip, "SkipB4ExternalRef"); sink_->PutInt(skip, "SkipB4ExternalRef");
int reference_id = serializer_->EncodeExternalReference(*current); int reference_id = serializer_->EncodeExternalReference(current);
sink_->PutInt(reference_id, "reference id"); sink_->PutInt(reference_id, "reference id");
bytes_processed_so_far_ += rinfo->target_address_size(); bytes_processed_so_far_ += rinfo->target_address_size();
} }
......
...@@ -309,9 +309,9 @@ Object** RelocInfo::target_object_address() { ...@@ -309,9 +309,9 @@ Object** RelocInfo::target_object_address() {
} }
Address* RelocInfo::target_reference_address() { Address RelocInfo::target_reference() {
ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
return reinterpret_cast<Address*>(pc_); return Memory::Address_at(pc_);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment