Refactor embedded pointer visitors for the serializer

This patch continues the refactoring that started in r9597 and
extends it with support for the serializer.
This is required for MIPS support in the serializer.

Review URL: http://codereview.chromium.org/8467010
Patch from Gergely Kis <gergely@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9971 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 95eda367
...@@ -64,7 +64,9 @@ Address RelocInfo::target_address() { ...@@ -64,7 +64,9 @@ Address RelocInfo::target_address() {
Address RelocInfo::target_address_address() { Address RelocInfo::target_address_address() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
|| rmode_ == EMBEDDED_OBJECT
|| rmode_ == EXTERNAL_REFERENCE);
return reinterpret_cast<Address>(Assembler::target_address_address_at(pc_)); return reinterpret_cast<Address>(Assembler::target_address_address_at(pc_));
} }
...@@ -224,7 +226,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) { ...@@ -224,7 +226,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
visitor->VisitGlobalPropertyCell(this); visitor->VisitGlobalPropertyCell(this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
visitor->VisitExternalReference(target_reference_address()); visitor->VisitExternalReference(this);
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
// TODO(isolates): Get a cached isolate below. // TODO(isolates): Get a cached isolate below.
} else if (((RelocInfo::IsJSReturn(mode) && } else if (((RelocInfo::IsJSReturn(mode) &&
...@@ -250,7 +252,7 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -250,7 +252,7 @@ void RelocInfo::Visit(Heap* heap) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(heap, this); StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address()); StaticVisitor::VisitExternalReference(this);
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
} else if (heap->isolate()->debug()->has_break_points() && } else if (heap->isolate()->debug()->has_break_points() &&
((RelocInfo::IsJSReturn(mode) && ((RelocInfo::IsJSReturn(mode) &&
......
...@@ -78,7 +78,9 @@ Address RelocInfo::target_address() { ...@@ -78,7 +78,9 @@ Address RelocInfo::target_address() {
Address RelocInfo::target_address_address() { Address RelocInfo::target_address_address() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
|| rmode_ == EMBEDDED_OBJECT
|| rmode_ == EXTERNAL_REFERENCE);
return reinterpret_cast<Address>(pc_); return reinterpret_cast<Address>(pc_);
} }
...@@ -224,7 +226,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) { ...@@ -224,7 +226,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
visitor->VisitGlobalPropertyCell(this); visitor->VisitGlobalPropertyCell(this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
visitor->VisitExternalReference(target_reference_address()); visitor->VisitExternalReference(this);
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
// TODO(isolates): Get a cached isolate below. // TODO(isolates): Get a cached isolate below.
...@@ -252,7 +254,7 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -252,7 +254,7 @@ void RelocInfo::Visit(Heap* heap) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(heap, this); StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address()); StaticVisitor::VisitExternalReference(this);
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
} else if (heap->isolate()->debug()->has_break_points() && } else if (heap->isolate()->debug()->has_break_points() &&
......
...@@ -921,6 +921,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { ...@@ -921,6 +921,7 @@ class StaticMarkingVisitor : public StaticVisitorBase {
} }
static inline void VisitExternalReference(Address* p) { } static inline void VisitExternalReference(Address* p) { }
static inline void VisitExternalReference(RelocInfo* rinfo) { }
static inline void VisitRuntimeEntry(RelocInfo* rinfo) { } static inline void VisitRuntimeEntry(RelocInfo* rinfo) { }
private: private:
......
...@@ -7718,6 +7718,10 @@ void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) { ...@@ -7718,6 +7718,10 @@ void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) {
VisitPointer(rinfo->target_object_address()); VisitPointer(rinfo->target_object_address());
} }
void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) {
Address* p = rinfo->target_reference_address();
VisitExternalReferences(p, p + 1);
}
void Code::InvalidateRelocation() { void Code::InvalidateRelocation() {
set_relocation_info(GetHeap()->empty_byte_array()); set_relocation_info(GetHeap()->empty_byte_array());
......
...@@ -7810,6 +7810,8 @@ class ObjectVisitor BASE_EMBEDDED { ...@@ -7810,6 +7810,8 @@ class ObjectVisitor BASE_EMBEDDED {
// may be modified on return. // may be modified on return.
virtual void VisitExternalReferences(Address* start, Address* end) {} virtual void VisitExternalReferences(Address* start, Address* end) {}
virtual void VisitExternalReference(RelocInfo* rinfo);
inline void VisitExternalReference(Address* p) { inline void VisitExternalReference(Address* p) {
VisitExternalReferences(p, p + 1); VisitExternalReferences(p, p + 1);
} }
......
...@@ -1471,6 +1471,16 @@ void Serializer::ObjectSerializer::VisitPointers(Object** start, ...@@ -1471,6 +1471,16 @@ void Serializer::ObjectSerializer::VisitPointers(Object** start,
} }
void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) {
Object** current = rinfo->target_object_address();
OutputRawData(rinfo->target_address_address());
HowToCode representation = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
serializer_->SerializeObject(*current, representation, kStartOfObject);
bytes_processed_so_far_ += rinfo->target_address_size();
}
void Serializer::ObjectSerializer::VisitExternalReferences(Address* start, void Serializer::ObjectSerializer::VisitExternalReferences(Address* start,
Address* end) { Address* end) {
Address references_start = reinterpret_cast<Address>(start); Address references_start = reinterpret_cast<Address>(start);
...@@ -1485,6 +1495,20 @@ void Serializer::ObjectSerializer::VisitExternalReferences(Address* start, ...@@ -1485,6 +1495,20 @@ void Serializer::ObjectSerializer::VisitExternalReferences(Address* start,
} }
void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) {
Address references_start = rinfo->target_address_address();
OutputRawData(references_start);
Address* current = rinfo->target_reference_address();
int representation = rinfo->IsCodedSpecially() ?
kFromCode + kStartOfObject : kPlain + kStartOfObject;
sink_->Put(kExternalReference + representation, "ExternalRef");
int reference_id = serializer_->EncodeExternalReference(*current);
sink_->PutInt(reference_id, "reference id");
bytes_processed_so_far_ += rinfo->target_address_size();
}
void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) {
Address target_start = rinfo->target_address_address(); Address target_start = rinfo->target_address_address();
OutputRawData(target_start); OutputRawData(target_start);
......
...@@ -514,7 +514,9 @@ class Serializer : public SerializerDeserializer { ...@@ -514,7 +514,9 @@ class Serializer : public SerializerDeserializer {
bytes_processed_so_far_(0) { } bytes_processed_so_far_(0) { }
void Serialize(); void Serialize();
void VisitPointers(Object** start, Object** end); void VisitPointers(Object** start, Object** end);
void VisitEmbeddedPointer(RelocInfo* target);
void VisitExternalReferences(Address* start, Address* end); void VisitExternalReferences(Address* start, Address* end);
void VisitExternalReference(RelocInfo* rinfo);
void VisitCodeTarget(RelocInfo* target); void VisitCodeTarget(RelocInfo* target);
void VisitCodeEntry(Address entry_address); void VisitCodeEntry(Address entry_address);
void VisitGlobalPropertyCell(RelocInfo* rinfo); void VisitGlobalPropertyCell(RelocInfo* rinfo);
......
...@@ -224,7 +224,9 @@ Address RelocInfo::target_address() { ...@@ -224,7 +224,9 @@ Address RelocInfo::target_address() {
Address RelocInfo::target_address_address() { Address RelocInfo::target_address_address() {
ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
|| rmode_ == EMBEDDED_OBJECT
|| rmode_ == EXTERNAL_REFERENCE);
return reinterpret_cast<Address>(pc_); return reinterpret_cast<Address>(pc_);
} }
...@@ -399,7 +401,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) { ...@@ -399,7 +401,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
visitor->VisitGlobalPropertyCell(this); visitor->VisitGlobalPropertyCell(this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
visitor->VisitExternalReference(target_reference_address()); visitor->VisitExternalReference(this);
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
// TODO(isolates): Get a cached isolate below. // TODO(isolates): Get a cached isolate below.
...@@ -427,7 +429,7 @@ void RelocInfo::Visit(Heap* heap) { ...@@ -427,7 +429,7 @@ void RelocInfo::Visit(Heap* heap) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(heap, this); StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) { } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
StaticVisitor::VisitExternalReference(target_reference_address()); StaticVisitor::VisitExternalReference(this);
CPU::FlushICache(pc_, sizeof(Address)); CPU::FlushICache(pc_, sizeof(Address));
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
} else if (heap->isolate()->debug()->has_break_points() && } else if (heap->isolate()->debug()->has_break_points() &&
......
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