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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 // Allocate the object. | 666 // Allocate the object. |
667 Handle<JSObject> object = FACTORY->NewJSObject(function); | 667 Handle<JSObject> object = FACTORY->NewJSObject(function); |
668 Handle<JSArray> array = Handle<JSArray>::cast(object); | 668 Handle<JSArray> array = Handle<JSArray>::cast(object); |
669 // We just initialized the VM, no heap allocation failure yet. | 669 // We just initialized the VM, no heap allocation failure yet. |
670 array->Initialize(0)->ToObjectChecked(); | 670 array->Initialize(0)->ToObjectChecked(); |
671 | 671 |
672 // Set array length to 0. | 672 // Set array length to 0. |
673 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); | 673 array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); |
674 CHECK_EQ(Smi::FromInt(0), array->length()); | 674 CHECK_EQ(Smi::FromInt(0), array->length()); |
675 // Must be in fast mode. | 675 // Must be in fast mode. |
676 CHECK(array->HasFastTypeElements()); | 676 CHECK(array->HasFastSmiOrObjectElements()); |
677 | 677 |
678 // array[length] = name. | 678 // array[length] = name. |
679 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); | 679 array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); |
680 CHECK_EQ(Smi::FromInt(1), array->length()); | 680 CHECK_EQ(Smi::FromInt(1), array->length()); |
681 CHECK_EQ(array->GetElement(0), *name); | 681 CHECK_EQ(array->GetElement(0), *name); |
682 | 682 |
683 // Set array length with larger than smi value. | 683 // Set array length with larger than smi value. |
684 Handle<Object> length = | 684 Handle<Object> length = |
685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); | 685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); |
686 array->SetElementsLength(*length)->ToObjectChecked(); | 686 array->SetElementsLength(*length)->ToObjectChecked(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 InitializeVM(); | 804 InitializeVM(); |
805 v8::HandleScope scope; | 805 v8::HandleScope scope; |
806 | 806 |
807 // Array of objects to scan haep for. | 807 // Array of objects to scan haep for. |
808 const int objs_count = 6; | 808 const int objs_count = 6; |
809 Handle<Object> objs[objs_count]; | 809 Handle<Object> objs[objs_count]; |
810 int next_objs_index = 0; | 810 int next_objs_index = 0; |
811 | 811 |
812 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE | 812 // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE |
813 objs[next_objs_index++] = FACTORY->NewJSArray(10); | 813 objs[next_objs_index++] = FACTORY->NewJSArray(10); |
814 objs[next_objs_index++] = FACTORY->NewJSArray(10, FAST_ELEMENTS, TENURED); | 814 objs[next_objs_index++] = FACTORY->NewJSArray(10, |
| 815 FAST_HOLEY_ELEMENTS, |
| 816 TENURED); |
815 | 817 |
816 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE | 818 // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE |
817 objs[next_objs_index++] = | 819 objs[next_objs_index++] = |
818 FACTORY->NewStringFromAscii(CStrVector("abcdefghij")); | 820 FACTORY->NewStringFromAscii(CStrVector("abcdefghij")); |
819 objs[next_objs_index++] = | 821 objs[next_objs_index++] = |
820 FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED); | 822 FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED); |
821 | 823 |
822 // Allocate a large string (for large object space). | 824 // Allocate a large string (for large object space). |
823 int large_size = Page::kMaxNonCodeHeapObjectSize + 1; | 825 int large_size = Page::kMaxNonCodeHeapObjectSize + 1; |
824 char* str = new char[large_size]; | 826 char* str = new char[large_size]; |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 int j = Map::kProtoTransitionHeaderSize + | 1590 int j = Map::kProtoTransitionHeaderSize + |
1589 i * Map::kProtoTransitionElementsPerEntry; | 1591 i * Map::kProtoTransitionElementsPerEntry; |
1590 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); | 1592 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); |
1591 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); | 1593 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); |
1592 } | 1594 } |
1593 | 1595 |
1594 // 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. |
1595 Handle<JSObject> prototype; | 1597 Handle<JSObject> prototype; |
1596 PagedSpace* space = HEAP->old_pointer_space(); | 1598 PagedSpace* space = HEAP->old_pointer_space(); |
1597 do { | 1599 do { |
1598 prototype = FACTORY->NewJSArray(32 * KB, FAST_ELEMENTS, TENURED); | 1600 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
1599 } while (space->FirstPage() == space->LastPage() || | 1601 } while (space->FirstPage() == space->LastPage() || |
1600 !space->LastPage()->Contains(prototype->address())); | 1602 !space->LastPage()->Contains(prototype->address())); |
1601 | 1603 |
1602 // Add a prototype on an evacuation candidate and verify that transition | 1604 // Add a prototype on an evacuation candidate and verify that transition |
1603 // clearing correctly records slots in prototype transition array. | 1605 // clearing correctly records slots in prototype transition array. |
1604 i::FLAG_always_compact = true; | 1606 i::FLAG_always_compact = true; |
1605 Handle<Map> map(baseObject->map()); | 1607 Handle<Map> map(baseObject->map()); |
1606 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); | 1608 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); |
1607 CHECK(space->LastPage()->Contains(prototype->address())); | 1609 CHECK(space->LastPage()->Contains(prototype->address())); |
1608 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); | 1610 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 "f(1); f(2); f(3);" | 1730 "f(1); f(2); f(3);" |
1729 "%OptimizeFunctionOnNextCall(f);" | 1731 "%OptimizeFunctionOnNextCall(f);" |
1730 "f(4);"); | 1732 "f(4);"); |
1731 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); | 1733 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); |
1732 | 1734 |
1733 Handle<JSObject> o = | 1735 Handle<JSObject> o = |
1734 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 1736 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
1735 | 1737 |
1736 CHECK(HEAP->InNewSpace(*o)); | 1738 CHECK(HEAP->InNewSpace(*o)); |
1737 } | 1739 } |
OLD | NEW |