Commit 67709e53 authored by vegorov@chromium.org's avatar vegorov@chromium.org

Fix bug in prototype transitions cache clearing introduced by r8165.

Invalid loop nesting causes full cleanup of the prototype transitions cache on every GC.

R=ager@chromium.org

Review URL: http://codereview.chromium.org/7354020

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8634 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent be1eee70
...@@ -1661,31 +1661,33 @@ void MarkCompactCollector::ClearNonLiveTransitions() { ...@@ -1661,31 +1661,33 @@ void MarkCompactCollector::ClearNonLiveTransitions() {
// Clear dead prototype transitions. // Clear dead prototype transitions.
int number_of_transitions = map->NumberOfProtoTransitions(); int number_of_transitions = map->NumberOfProtoTransitions();
FixedArray* prototype_transitions = map->unchecked_prototype_transitions(); if (number_of_transitions > 0) {
int new_number_of_transitions = 0; FixedArray* prototype_transitions = map->unchecked_prototype_transitions();
const int header = Map::kProtoTransitionHeaderSize; int new_number_of_transitions = 0;
const int proto_offset = const int header = Map::kProtoTransitionHeaderSize;
header + Map::kProtoTransitionPrototypeOffset; const int proto_offset =
const int map_offset = header + Map::kProtoTransitionMapOffset; header + Map::kProtoTransitionPrototypeOffset;
const int step = Map::kProtoTransitionElementsPerEntry; const int map_offset = header + Map::kProtoTransitionMapOffset;
for (int i = 0; i < number_of_transitions; i++) { const int step = Map::kProtoTransitionElementsPerEntry;
Object* prototype = prototype_transitions->get(proto_offset + i * step); for (int i = 0; i < number_of_transitions; i++) {
Object* cached_map = prototype_transitions->get(map_offset + i * step); Object* prototype = prototype_transitions->get(proto_offset + i * step);
if (HeapObject::cast(prototype)->IsMarked() && Object* cached_map = prototype_transitions->get(map_offset + i * step);
HeapObject::cast(cached_map)->IsMarked()) { if (HeapObject::cast(prototype)->IsMarked() &&
if (new_number_of_transitions != i) { HeapObject::cast(cached_map)->IsMarked()) {
prototype_transitions->set_unchecked( if (new_number_of_transitions != i) {
heap_, prototype_transitions->set_unchecked(
proto_offset + new_number_of_transitions * step, heap_,
prototype, proto_offset + new_number_of_transitions * step,
UPDATE_WRITE_BARRIER); prototype,
prototype_transitions->set_unchecked( UPDATE_WRITE_BARRIER);
heap_, prototype_transitions->set_unchecked(
map_offset + new_number_of_transitions * step, heap_,
cached_map, map_offset + new_number_of_transitions * step,
SKIP_WRITE_BARRIER); cached_map,
SKIP_WRITE_BARRIER);
}
new_number_of_transitions++;
} }
new_number_of_transitions++;
} }
// Fill slots that became free with undefined value. // Fill slots that became free with undefined value.
......
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