Revision: 9597
Author: [email protected]
Date: Wed Oct 12 08:43:41 2011
Log: Refactor how embedded pointers are visited.
This refactoring (almost) gets rid of the requirement to get the target
object address for an object pointer embedded in code objects. This is
not possible on MIPS as pointers are encoded using two instructions. All
usages of RelocInfo::target_object_address() are (almost) obsoleted by
this change. The serializer still uses it, so MIPS will not yet work
with snapshots turned on.
[email protected],[email protected]
Review URL: http://codereview.chromium.org/8245007
http://code.google.com/p/v8/source/detail?r=9597
Modified:
/branches/bleeding_edge/src/arm/assembler-arm-inl.h
/branches/bleeding_edge/src/assembler.h
/branches/bleeding_edge/src/ia32/assembler-ia32-inl.h
/branches/bleeding_edge/src/incremental-marking.cc
/branches/bleeding_edge/src/mark-compact.cc
/branches/bleeding_edge/src/mark-compact.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/x64/assembler-x64-inl.h
=======================================
--- /branches/bleeding_edge/src/arm/assembler-arm-inl.h Wed Sep 28 10:45:58
2011
+++ /branches/bleeding_edge/src/arm/assembler-arm-inl.h Wed Oct 12 08:43:41
2011
@@ -215,7 +215,7 @@
void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- visitor->VisitEmbeddedPointer(host(), target_object_address());
+ visitor->VisitEmbeddedPointer(this);
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
@@ -241,7 +241,7 @@
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitEmbeddedPointer(heap, host(),
target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, this);
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
=======================================
--- /branches/bleeding_edge/src/assembler.h Tue Oct 4 02:07:50 2011
+++ /branches/bleeding_edge/src/assembler.h Wed Oct 12 08:43:41 2011
@@ -230,6 +230,9 @@
static inline bool IsCodeTarget(Mode mode) {
return mode <= LAST_CODE_ENUM;
}
+ static inline bool IsEmbeddedObject(Mode mode) {
+ return mode == EMBEDDED_OBJECT;
+ }
// Is the relocation mode affected by GC?
static inline bool IsGCRelocMode(Mode mode) {
return mode <= LAST_GCED_ENUM;
=======================================
--- /branches/bleeding_edge/src/ia32/assembler-ia32-inl.h Wed Sep 28
10:45:58 2011
+++ /branches/bleeding_edge/src/ia32/assembler-ia32-inl.h Wed Oct 12
08:43:41 2011
@@ -214,7 +214,7 @@
void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- visitor->VisitEmbeddedPointer(host(), target_object_address());
+ visitor->VisitEmbeddedPointer(this);
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
@@ -242,7 +242,7 @@
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitEmbeddedPointer(heap, host(),
target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, this);
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
=======================================
--- /branches/bleeding_edge/src/incremental-marking.cc Tue Oct 11 09:50:58
2011
+++ /branches/bleeding_edge/src/incremental-marking.cc Wed Oct 12 08:43:41
2011
@@ -117,14 +117,12 @@
incremental_marking_(incremental_marking) {
}
- void VisitEmbeddedPointer(Code* host, Object** p) {
- Object* obj = *p;
- if (obj->NonFailureIsHeapObject()) {
- heap_->mark_compact_collector()->RecordSlot(
- reinterpret_cast<Object**>(host),
- p,
- obj);
- MarkObject(obj);
+ void VisitEmbeddedPointer(RelocInfo* rinfo) {
+ ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
+ Object* target = rinfo->target_object();
+ if (target->NonFailureIsHeapObject()) {
+ heap_->mark_compact_collector()->RecordRelocSlot(rinfo, target);
+ MarkObject(target);
}
}
=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Tue Oct 11 08:52:15 2011
+++ /branches/bleeding_edge/src/mark-compact.cc Wed Oct 12 08:43:41 2011
@@ -847,10 +847,14 @@
heap->mark_compact_collector()->MarkObject(cell, mark);
}
- static inline void VisitEmbeddedPointer(Heap* heap, Code* host, Object**
p) {
- MarkObjectByPointer(heap->mark_compact_collector(),
- reinterpret_cast<Object**>(host),
- p);
+ static inline void VisitEmbeddedPointer(Heap* heap, RelocInfo* rinfo) {
+ ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
+ // TODO(mstarzinger): We do not short-circuit cons strings here, verify
+ // that there can be no such embedded pointers and add assertion here.
+ HeapObject* object = HeapObject::cast(rinfo->target_object());
+ heap->mark_compact_collector()->RecordRelocSlot(rinfo, object);
+ MarkBit mark = Marking::MarkBitFrom(object);
+ heap->mark_compact_collector()->MarkObject(object, mark);
}
static inline void VisitCodeTarget(Heap* heap, RelocInfo* rinfo) {
@@ -2458,8 +2462,11 @@
for (Object** p = start; p < end; p++) UpdatePointer(p);
}
- void VisitEmbeddedPointer(Code* host, Object** p) {
- UpdatePointer(p);
+ void VisitEmbeddedPointer(RelocInfo* rinfo) {
+ ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
+ Object* target = rinfo->target_object();
+ VisitPointer(&target);
+ rinfo->set_target_object(target);
}
void VisitCodeTarget(RelocInfo* rinfo) {
@@ -2773,6 +2780,11 @@
if (rinfo.IsPatchedReturnSequence()) rinfo.Visit(v);
break;
}
+ case SlotsBuffer::EMBEDDED_OBJECT_SLOT: {
+ RelocInfo rinfo(addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL);
+ rinfo.Visit(v);
+ break;
+ }
default:
UNREACHABLE();
break;
@@ -3706,6 +3718,8 @@
static inline SlotsBuffer::SlotType SlotTypeForRMode(RelocInfo::Mode
rmode) {
if (RelocInfo::IsCodeTarget(rmode)) {
return SlotsBuffer::CODE_TARGET_SLOT;
+ } else if (RelocInfo::IsEmbeddedObject(rmode)) {
+ return SlotsBuffer::EMBEDDED_OBJECT_SLOT;
} else if (RelocInfo::IsDebugBreakSlot(rmode)) {
return SlotsBuffer::DEBUG_TARGET_SLOT;
} else if (RelocInfo::IsJSReturn(rmode)) {
@@ -3716,9 +3730,8 @@
}
-void MarkCompactCollector::RecordRelocSlot(RelocInfo* rinfo, Code* target)
{
- Page* target_page = Page::FromAddress(
- reinterpret_cast<Address>(target));
+void MarkCompactCollector::RecordRelocSlot(RelocInfo* rinfo, Object*
target) {
+ Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target));
if (target_page->IsEvacuationCandidate() &&
(rinfo->host() == NULL ||
!ShouldSkipEvacuationSlotRecording(rinfo->host()))) {
@@ -3734,8 +3747,7 @@
void MarkCompactCollector::RecordCodeEntrySlot(Address slot, Code* target)
{
- Page* target_page = Page::FromAddress(
- reinterpret_cast<Address>(target));
+ Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target));
if (target_page->IsEvacuationCandidate() &&
!ShouldSkipEvacuationSlotRecording(reinterpret_cast<Object**>(slot)))
{
if (!SlotsBuffer::AddTo(&slots_buffer_allocator_,
=======================================
--- /branches/bleeding_edge/src/mark-compact.h Wed Oct 5 02:42:20 2011
+++ /branches/bleeding_edge/src/mark-compact.h Wed Oct 12 08:43:41 2011
@@ -315,6 +315,7 @@
}
enum SlotType {
+ EMBEDDED_OBJECT_SLOT,
RELOCATED_CODE_OBJECT,
CODE_TARGET_SLOT,
CODE_ENTRY_SLOT,
@@ -538,7 +539,7 @@
}
}
- void RecordRelocSlot(RelocInfo* rinfo, Code* target);
+ void RecordRelocSlot(RelocInfo* rinfo, Object* target);
void RecordCodeEntrySlot(Address slot, Code* target);
INLINE(void RecordSlot(Object** anchor_slot, Object** slot, Object*
object));
=======================================
--- /branches/bleeding_edge/src/objects.cc Tue Oct 11 09:02:45 2011
+++ /branches/bleeding_edge/src/objects.cc Wed Oct 12 08:43:41 2011
@@ -7369,6 +7369,12 @@
VisitPointer(&target);
CHECK_EQ(target, old_target); // VisitPointer doesn't change Code*
*target.
}
+
+
+void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) {
+ ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
+ VisitPointer(rinfo->target_object_address());
+}
void Code::InvalidateRelocation() {
=======================================
--- /branches/bleeding_edge/src/objects.h Tue Oct 11 09:02:45 2011
+++ /branches/bleeding_edge/src/objects.h Wed Oct 12 08:43:41 2011
@@ -7534,11 +7534,7 @@
virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); }
// Visit pointer embedded into a code object.
- virtual void VisitEmbeddedPointer(Code* host, Object** p) {
- // Default implementation for the convenience of users that do
- // not care about the host object.
- VisitPointer(p);
- }
+ virtual void VisitEmbeddedPointer(RelocInfo* rinfo);
// Visits a contiguous arrays of external references (references to the
C++
// heap) in the half-open range [start, end). Any or all of the values
=======================================
--- /branches/bleeding_edge/src/x64/assembler-x64-inl.h Wed Sep 28 10:45:58
2011
+++ /branches/bleeding_edge/src/x64/assembler-x64-inl.h Wed Oct 12 08:43:41
2011
@@ -388,7 +388,7 @@
void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- visitor->VisitEmbeddedPointer(host(), target_object_address());
+ visitor->VisitEmbeddedPointer(this);
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
@@ -416,7 +416,7 @@
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitEmbeddedPointer(heap, host(),
target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, this);
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev