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 const int transitions = 10 - 3; |
1589 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); | 1586 CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); |
1590 | 1587 |
1591 // Verify that prototype transitions array was compacted. | 1588 // Verify that prototype transitions array was compacted. |
1592 FixedArray* trans = baseObject->map()->prototype_transitions(); | 1589 FixedArray* trans = baseObject->map()->prototype_transitions(); |
1593 for (int i = 0; i < transitions; i++) { | 1590 for (int i = 0; i < transitions; i++) { |
1594 int j = Map::kProtoTransitionHeaderSize + | 1591 int j = Map::kProtoTransitionHeaderSize + |
1595 i * Map::kProtoTransitionElementsPerEntry; | 1592 i * Map::kProtoTransitionElementsPerEntry; |
1596 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); | 1593 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); |
1597 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); | 1594 Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset); |
1598 CHECK(proto->IsTheHole() || proto->IsJSObject()); | 1595 CHECK(proto->IsTheHole() || proto->IsJSObject()); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 | 1891 |
1895 Handle<JSObject> root = | 1892 Handle<JSObject> root = |
1896 v8::Utils::OpenHandle( | 1893 v8::Utils::OpenHandle( |
1897 *v8::Handle<v8::Object>::Cast( | 1894 *v8::Handle<v8::Object>::Cast( |
1898 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); | 1895 v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); |
1899 | 1896 |
1900 // The root object should be in a sane state. | 1897 // The root object should be in a sane state. |
1901 CHECK(root->IsJSObject()); | 1898 CHECK(root->IsJSObject()); |
1902 CHECK(root->map()->IsMap()); | 1899 CHECK(root->map()->IsMap()); |
1903 } | 1900 } |
OLD | NEW |