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

Side by Side Diff: src/mark-compact.cc

Issue 7074052: Fix traversal of the map transition tree to take the prototype (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 if (map->instance_type() < FIRST_JS_RECEIVER_TYPE) continue; 1528 if (map->instance_type() < FIRST_JS_RECEIVER_TYPE) continue;
1529 1529
1530 if (map->IsMarked() && map->attached_to_shared_function_info()) { 1530 if (map->IsMarked() && map->attached_to_shared_function_info()) {
1531 // This map is used for inobject slack tracking and has been detached 1531 // This map is used for inobject slack tracking and has been detached
1532 // from SharedFunctionInfo during the mark phase. 1532 // from SharedFunctionInfo during the mark phase.
1533 // Since it survived the GC, reattach it now. 1533 // Since it survived the GC, reattach it now.
1534 map->unchecked_constructor()->unchecked_shared()->AttachInitialMap(map); 1534 map->unchecked_constructor()->unchecked_shared()->AttachInitialMap(map);
1535 } 1535 }
1536 1536
1537 // Clear dead prototype transitions. 1537 // Clear dead prototype transitions.
1538 int number_of_transitions = map->NumberOfProtoTransitions();
1538 FixedArray* prototype_transitions = map->unchecked_prototype_transitions(); 1539 FixedArray* prototype_transitions = map->unchecked_prototype_transitions();
1539 if (prototype_transitions->length() > 0) { 1540 int new_number_of_transitions = 0;
1540 int finger = Smi::cast(prototype_transitions->get(0))->value(); 1541 const int header = Map::kProtoTransitionHeaderSize;
1541 int new_finger = 1; 1542 const int proto_offset =
1542 for (int i = 1; i < finger; i += 2) { 1543 header + Map::kProtoTransitionPrototypeOffset;
1543 Object* prototype = prototype_transitions->get(i); 1544 const int map_offset = header + Map::kProtoTransitionMapOffset;
1544 Object* cached_map = prototype_transitions->get(i + 1); 1545 const int step = Map::kProtoTransitionElementsPerEntry;
1545 if (HeapObject::cast(prototype)->IsMarked() && 1546 for (int i = 0; i < number_of_transitions; i++) {
1546 HeapObject::cast(cached_map)->IsMarked()) { 1547 Object* prototype = prototype_transitions->get(proto_offset + i * step);
1547 if (new_finger != i) { 1548 Object* cached_map = prototype_transitions->get(map_offset + i * step);
1548 prototype_transitions->set_unchecked(heap_, 1549 if (HeapObject::cast(prototype)->IsMarked() &&
1549 new_finger, 1550 HeapObject::cast(cached_map)->IsMarked()) {
1550 prototype, 1551 if (new_number_of_transitions != i) {
1551 UPDATE_WRITE_BARRIER); 1552 prototype_transitions->set_unchecked(
1552 prototype_transitions->set_unchecked(heap_, 1553 heap_,
1553 new_finger + 1, 1554 proto_offset + new_number_of_transitions * step,
1554 cached_map, 1555 prototype,
1555 SKIP_WRITE_BARRIER); 1556 UPDATE_WRITE_BARRIER);
1556 } 1557 prototype_transitions->set_unchecked(
1557 new_finger += 2; 1558 heap_,
1559 map_offset + new_number_of_transitions * step,
1560 cached_map,
1561 SKIP_WRITE_BARRIER);
1558 } 1562 }
1563 new_number_of_transitions++;
1559 } 1564 }
1560 1565
1561 // Fill slots that became free with undefined value. 1566 // Fill slots that became free with undefined value.
1562 Object* undefined = heap()->raw_unchecked_undefined_value(); 1567 Object* undefined = heap()->raw_unchecked_undefined_value();
1563 for (int i = new_finger; i < finger; i++) { 1568 for (int i = new_number_of_transitions * step;
1569 i < number_of_transitions * step;
1570 i++) {
1564 prototype_transitions->set_unchecked(heap_, 1571 prototype_transitions->set_unchecked(heap_,
1565 i, 1572 header + i,
1566 undefined, 1573 undefined,
1567 SKIP_WRITE_BARRIER); 1574 SKIP_WRITE_BARRIER);
1568 } 1575 }
1569 prototype_transitions->set_unchecked(0, Smi::FromInt(new_finger)); 1576 map->SetNumberOfProtoTransitions(new_number_of_transitions);
1570 } 1577 }
1571 1578
1572 // Follow the chain of back pointers to find the prototype. 1579 // Follow the chain of back pointers to find the prototype.
1573 Map* current = map; 1580 Map* current = map;
1574 while (SafeIsMap(current)) { 1581 while (SafeIsMap(current)) {
1575 current = reinterpret_cast<Map*>(current->prototype()); 1582 current = reinterpret_cast<Map*>(current->prototype());
1576 ASSERT(current->IsHeapObject()); 1583 ASSERT(current->IsHeapObject());
1577 } 1584 }
1578 Object* real_prototype = current; 1585 Object* real_prototype = current;
1579 1586
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 } 3144 }
3138 3145
3139 3146
3140 void MarkCompactCollector::Initialize() { 3147 void MarkCompactCollector::Initialize() {
3141 StaticPointersToNewGenUpdatingVisitor::Initialize(); 3148 StaticPointersToNewGenUpdatingVisitor::Initialize();
3142 StaticMarkingVisitor::Initialize(); 3149 StaticMarkingVisitor::Initialize();
3143 } 3150 }
3144 3151
3145 3152
3146 } } // namespace v8::internal 3153 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698