Reviewers: Erik Corry,
Description:
Fix two bugs in the code compaction:
1) Ensure that pc_to_code cache can iterate heap in the middle of
compaction.
2) Increase precision of code target patching write-barrier. We shoould
never
record reloc slots on white objects because they might die and evacuation
will
overwrite their contents invalidating collected reloc slots as their
positions
are not aligned in the code stream.
3) remove bogus assertion.
[email protected]
BUG=
TEST=
Please review this at http://codereview.chromium.org/7864025/
SVN Base: https://v8.googlecode.com/svn/branches/experimental/gc
Affected files:
M src/frames.cc
M src/heap.cc
M src/incremental-marking.cc
M src/mark-compact.cc
Index: src/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index
cc559cf7c9ef486928d7b1d9495eb438b01289fb..69ec4d4b33f63f979a124d61bc34e3cd265e65b0
100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -1162,6 +1162,14 @@ Code* PcToCodeCache::GcSafeCastToCode(HeapObject*
object, Address pc) {
}
+static int GcSafeSizeOfCodeSpaceObject(HeapObject* object) {
+ MapWord map_word = object->map_word();
+ Map* map = map_word.IsForwardingAddress() ?
+ map_word.ToForwardingAddress()->map() : map_word.ToMap();
+ return object->SizeFromMap(map);
+}
+
+
Code* PcToCodeCache::GcSafeFindCodeForPc(Address pc) {
Heap* heap = isolate_->heap();
// Check if the pc points into a large object chunk.
@@ -1171,7 +1179,7 @@ Code* PcToCodeCache::GcSafeFindCodeForPc(Address pc) {
// Iterate through the page until we reach the end or find an object
starting
// after the pc.
Page* page = Page::FromAddress(pc);
- HeapObjectIterator iterator(page, heap->GcSafeSizeOfOldObjectFunction());
+ HeapObjectIterator iterator(page, &GcSafeSizeOfCodeSpaceObject);
HeapObject* previous = NULL;
while (true) {
HeapObject* next = iterator.Next();
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
7503c0ad7369797c8eb46ca10789b693ac758a0c..2924a08190e0d9beca87dc0d14f5594a0d1a0e62
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4739,8 +4739,7 @@ void Heap::IterateStrongRoots(ObjectVisitor* v,
VisitMode mode) {
// Iterate over the builtin code objects and code stubs in the
// heap. Note that it is not necessary to iterate over code objects
// on scavenge collections.
- if (mode != VISIT_ALL_IN_SCAVENGE &&
- mode != VISIT_ALL_IN_SWEEP_NEWSPACE) {
+ if (mode != VISIT_ALL_IN_SCAVENGE) {
isolate_->builtins()->IterateBuiltins(v);
}
v->Synchronize("builtins");
Index: src/incremental-marking.cc
diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc
index
28b9485bc2825017bc9e215af0120dfe074af0a2..5e14baa9c557e905dd92451996d46835129309d7
100644
--- a/src/incremental-marking.cc
+++ b/src/incremental-marking.cc
@@ -86,20 +86,10 @@ void
IncrementalMarking::RecordWriteForEvacuationFromCode(HeapObject* obj,
void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject*
value) {
if (IsMarking()) {
- ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(value));
-
- MarkBit value_bit = Marking::MarkBitFrom(value);
- if (Marking::IsWhite(value_bit)) {
- WhiteToGreyAndPush(value, value_bit);
- RestartIfNotMarking();
- }
-
-
- if (is_compacting_) {
- RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, NULL, NULL);
- heap_->mark_compact_collector()->RecordRelocSlot(&rinfo,
- Code::cast(value));
- }
+ Code* host =
+ heap_->isolate()->pc_to_code_cache()->GcSafeFindCodeForPc(pc);
+ RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, NULL, host);
+ RecordWriteIntoCode(host, &rinfo, value);
}
}
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
c4ef923c108ee26f268839187a8ccdcf9279f292..176c9d906c5a3a937d19db67be61975e91b3efdb
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -2837,7 +2837,8 @@ void
MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
&UpdateReferenceInExternalStringTableEntry);
// Update JSFunction pointers from the runtime profiler.
- heap_->isolate()->runtime_profiler()->UpdateSamplesAfterScavenge();
+ heap()->isolate()->runtime_profiler()->UpdateSamplesAfterCompact(
+ &updating_visitor);
EvacuationWeakObjectRetainer evacuation_object_retainer;
heap()->ProcessWeakReferences(&evacuation_object_retainer);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev