OLD | NEW |
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 Loading... |
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 const int transitions = 11 - 3; |
| 1589 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); |
1586 | 1590 |
1587 // Verify that prototype transitions array was compacted. | 1591 // Verify that prototype transitions array was compacted. |
1588 FixedArray* trans = baseObject->map()->prototype_transitions(); | 1592 FixedArray* trans = baseObject->map()->prototype_transitions(); |
1589 for (int i = 0; i < 10 - 3; i++) { | 1593 for (int i = 0; i < transitions; i++) { |
1590 int j = Map::kProtoTransitionHeaderSize + | 1594 int j = Map::kProtoTransitionHeaderSize + |
1591 i * Map::kProtoTransitionElementsPerEntry; | 1595 i * Map::kProtoTransitionElementsPerEntry; |
1592 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); | 1596 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); |
1593 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); | 1597 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); |
| 1598 CHECK(proto->IsTheHole() || proto->IsJSObject()); |
1594 } | 1599 } |
1595 | 1600 |
1596 // Make sure next prototype is placed on an old-space evacuation candidate. | 1601 // Make sure next prototype is placed on an old-space evacuation candidate. |
1597 Handle<JSObject> prototype; | 1602 Handle<JSObject> prototype; |
1598 PagedSpace* space = HEAP->old_pointer_space(); | 1603 PagedSpace* space = HEAP->old_pointer_space(); |
1599 do { | 1604 do { |
1600 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 1605 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
1601 } while (space->FirstPage() == space->LastPage() || | 1606 } while (space->FirstPage() == space->LastPage() || |
1602 !space->LastPage()->Contains(prototype->address())); | 1607 !space->LastPage()->Contains(prototype->address())); |
1603 | 1608 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1894 |
1890 Handle<JSObject> root = | 1895 Handle<JSObject> root = |
1891 v8::Utils::OpenHandle( | 1896 v8::Utils::OpenHandle( |
1892 *v8::Handle<v8::Object>::Cast( | 1897 *v8::Handle<v8::Object>::Cast( |
1893 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); | 1898 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); |
1894 | 1899 |
1895 // The root object should be in a sane state. | 1900 // The root object should be in a sane state. |
1896 CHECK(root->IsJSObject()); | 1901 CHECK(root->IsJSObject()); |
1897 CHECK(root->map()->IsMap()); | 1902 CHECK(root->map()->IsMap()); |
1898 } | 1903 } |
OLD | NEW |