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

Side by Side Diff: test/cctest/test-heap.cc

Issue 10448011: Keep track of which maps are associated with prototype objects (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 7 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "execution.h" 7 #include "execution.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 #include "global-handles.h" 10 #include "global-handles.h"
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 " var prototype = {};" 1572 " var prototype = {};"
1573 " object.__proto__ = prototype;" 1573 " object.__proto__ = prototype;"
1574 " if (i >= 3) live.push(object, prototype);" 1574 " if (i >= 3) live.push(object, prototype);"
1575 "}"); 1575 "}");
1576 1576
1577 Handle<JSObject> baseObject = 1577 Handle<JSObject> baseObject =
1578 v8::Utils::OpenHandle( 1578 v8::Utils::OpenHandle(
1579 *v8::Handle<v8::Object>::Cast( 1579 *v8::Handle<v8::Object>::Cast(
1580 v8::Context::GetCurrent()->Global()->Get(v8_str("base")))); 1580 v8::Context::GetCurrent()->Global()->Get(v8_str("base"))));
1581 1581
1582 // Verify that only dead prototype transitions are cleared. 1582 // Verify that only dead prototype transitions are cleared. There is an
1583 CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions()); 1583 // extra, 11th, prototype transition on the Object map, which is the
1584 // transition to a map with the used_for_prototype flag set (the key is
1585 // the_hole).
1586 CHECK_EQ(11, baseObject->map()->NumberOfProtoTransitions());
1584 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1587 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1585 CHECK_EQ(10 - 3, baseObject->map()->NumberOfProtoTransitions()); 1588 CHECK_EQ(11 - 3, baseObject->map()->NumberOfProtoTransitions());
1586 1589
1587 // Verify that prototype transitions array was compacted. 1590 // Verify that prototype transitions array was compacted.
1588 FixedArray* trans = baseObject->map()->prototype_transitions(); 1591 FixedArray* trans = baseObject->map()->prototype_transitions();
1589 for (int i = 0; i < 10 - 3; i++) { 1592 for (int i = 0; i < 10 - 3; i++) {
Michael Starzinger 2012/05/30 14:08:03 The loop should also go to (11 - 3) ... better put
Erik Corry 2012/05/30 15:24:13 Done.
1590 int j = Map::kProtoTransitionHeaderSize + 1593 int j = Map::kProtoTransitionHeaderSize +
1591 i * Map::kProtoTransitionElementsPerEntry; 1594 i * Map::kProtoTransitionElementsPerEntry;
1592 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); 1595 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
1593 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); 1596 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset);
1597 CHECK(proto == trans->GetHeap()->the_hole_value() || proto->IsJSObject());
Michael Starzinger 2012/05/30 14:08:03 Can we just use proto->IsTheHole() here, that's mo
Erik Corry 2012/05/30 15:24:13 Done.
1594 } 1598 }
1595 1599
1596 // Make sure next prototype is placed on an old-space evacuation candidate. 1600 // Make sure next prototype is placed on an old-space evacuation candidate.
1597 Handle<JSObject> prototype; 1601 Handle<JSObject> prototype;
1598 PagedSpace* space = HEAP->old_pointer_space(); 1602 PagedSpace* space = HEAP->old_pointer_space();
1599 do { 1603 do {
1600 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); 1604 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
1601 } while (space->FirstPage() == space->LastPage() || 1605 } while (space->FirstPage() == space->LastPage() ||
1602 !space->LastPage()->Contains(prototype->address())); 1606 !space->LastPage()->Contains(prototype->address()));
1603 1607
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 CHECK(marking->IsComplete()); 1791 CHECK(marking->IsComplete());
1788 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1792 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1789 CHECK(marking->IsStopped()); 1793 CHECK(marking->IsStopped());
1790 1794
1791 // Count number of live transitions after marking. Note that one transition 1795 // Count number of live transitions after marking. Note that one transition
1792 // is left, because 'o' still holds an instance of one transition target. 1796 // is left, because 'o' still holds an instance of one transition target.
1793 int transitions_after = CountMapTransitions(root->map()); 1797 int transitions_after = CountMapTransitions(root->map());
1794 CompileRun("%DebugPrint(root);"); 1798 CompileRun("%DebugPrint(root);");
1795 CHECK_EQ(1, transitions_after); 1799 CHECK_EQ(1, transitions_after);
1796 } 1800 }
OLDNEW
« src/objects.cc ('K') | « src/runtime.cc ('k') | test/mjsunit/fast-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698