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