Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: src/objects-visiting-inl.h

Issue 11575007: Make embedded maps in optimized code weak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix skipping of maps in visitors. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/objects.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-visiting-inl.h
diff --git a/src/objects-visiting-inl.h b/src/objects-visiting-inl.h
index 925b2562f292558687716cc6be8c0b618d1f7f04..65a46dcc229baec0b5f6f97d8a4911a75ec94996 100644
--- a/src/objects-visiting-inl.h
+++ b/src/objects-visiting-inl.h
@@ -261,12 +261,9 @@ void StaticMarkingVisitor<StaticVisitor>::VisitMap(
map_object->ClearCodeCache(heap);
}
- // When map collection is enabled we have to mark through map's
- // transitions and back pointers in a special way to make these links
- // weak. Only maps for subclasses of JSReceiver can have transitions.
- STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
- if (FLAG_collect_maps &&
- map_object->instance_type() >= FIRST_JS_RECEIVER_TYPE) {
+ // When map collection is enabled we have to mark through map's transitions
+ // and back pointers in a special way to make these links weak.
+ if (FLAG_collect_maps && map_object->CanTransition()) {
MarkMapContents(heap, map_object);
} else {
StaticVisitor::VisitPointers(heap,
@@ -287,7 +284,7 @@ void StaticMarkingVisitor<StaticVisitor>::VisitCode(
if (FLAG_age_code && !Serializer::enabled()) {
code->MakeOlder(heap->mark_compact_collector()->marking_parity());
}
- code->CodeIterateBody<StaticVisitor>(heap);
+ code->CodeIterateBody<StaticVisitor, Code::SKIP_EMBEDDED_MAPS>(heap);
}
@@ -394,6 +391,15 @@ void StaticMarkingVisitor<StaticVisitor>::MarkMapContents(
ASSERT(transitions->IsMap() || transitions->IsUndefined());
}
+ // Mark prototype dependent codes array but do not push it onto marking
+ // stack, this will make references from it weak. We will clean dead
Michael Starzinger 2013/01/21 10:31:48 One "dead" oughta be enough. :)
ulan 2013/01/21 13:11:57 Done.
+ // dead codes when we iterate over maps in ClearNonLiveTransitions.
+ Object** slot = HeapObject::RawField(reinterpret_cast<HeapObject*>(map),
Michael Starzinger 2013/01/21 10:31:48 The reinterpret_cast shouldn't be necessary, a Map
ulan 2013/01/21 13:11:57 Done.
+ Map::kDependentCodesOffset);
+ HeapObject* obj = HeapObject::cast(*slot);
+ heap->mark_compact_collector()->RecordSlot(slot, slot, obj);
+ StaticVisitor::MarkObjectWithoutPush(heap, obj);
+
// Mark the pointer fields of the Map. Since the transitions array has
// been marked already, it is fine that one of these fields contains a
// pointer to it.
@@ -637,8 +643,13 @@ void Code::CodeIterateBody(ObjectVisitor* v) {
RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) |
RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
- // There are two places where we iterate code bodies: here and the
- // templated CodeIterateBody (below). They should be kept in sync.
+ // There are two places where we iterate code bodies: here and the non-
+ // templated CodeIterateBody (above). They should be kept in sync. The only
+ // difference between the two versions is in handling of embedded maps.
+ // Static marking visitors do not visit embedded maps, but most of the non-
+ // static visitors need to visit embedded maps. Non-static visitor can skip
+ // embedded maps by overriding VisitEmbeddedPointer, like
+ // VerifyMarkingVisitor does.
IteratePointer(v, kRelocationInfoOffset);
IteratePointer(v, kHandlerTableOffset);
IteratePointer(v, kDeoptimizationDataOffset);
@@ -651,7 +662,7 @@ void Code::CodeIterateBody(ObjectVisitor* v) {
}
-template<typename StaticVisitor>
+template<typename StaticVisitor, Code::EmbeddedMapVisitMode map_visit_mode>
void Code::CodeIterateBody(Heap* heap) {
int mode_mask = RelocInfo::kCodeTargetMask |
RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
@@ -661,8 +672,13 @@ void Code::CodeIterateBody(Heap* heap) {
RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) |
RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
- // There are two places where we iterate code bodies: here and the
- // non-templated CodeIterateBody (above). They should be kept in sync.
+ // There are two places where we iterate code bodies: here and the non-
+ // templated CodeIterateBody (above). They should be kept in sync. The only
+ // difference between the two versions is in handling of embedded maps.
+ // Static marking visitors do not visit embedded maps, but most of the non-
+ // static visitors need to visit embedded maps. Non-static visitor can skip
+ // embedded maps by overriding VisitEmbeddedPointer, like
+ // VerifyMarkingVisitor does.
StaticVisitor::VisitPointer(
heap,
reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset));
@@ -677,8 +693,20 @@ void Code::CodeIterateBody(Heap* heap) {
reinterpret_cast<Object**>(this->address() + kTypeFeedbackInfoOffset));
RelocIterator it(this, mode_mask);
- for (; !it.done(); it.next()) {
- it.rinfo()->template Visit<StaticVisitor>(heap);
+ if (map_visit_mode == SKIP_EMBEDDED_MAPS && kind() == OPTIMIZED_FUNCTION) {
ulan 2013/01/17 09:35:10 Maybe I should just move this to VisitEmbeddedPoin
Michael Starzinger 2013/01/21 10:31:48 Yes, good idea, I am very much in favor of this su
ulan 2013/01/21 13:11:57 Done.
+ // Treat embedded maps in optimized code as weak.
+ for (; !it.done(); it.next()) {
+ RelocInfo* info = it.rinfo();
+ if (!RelocInfo::IsEmbeddedObject(info->rmode()) ||
+ !info->target_object()->IsMap() ||
+ !Map::cast(info->target_object())->CanTransition()) {
+ it.rinfo()->template Visit<StaticVisitor>(heap);
+ }
+ }
+ } else {
+ for (; !it.done(); it.next()) {
+ it.rinfo()->template Visit<StaticVisitor>(heap);
+ }
}
}
« src/objects.cc ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698