| 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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 int j = Map::kProtoTransitionHeaderSize + | 1573 int j = Map::kProtoTransitionHeaderSize + |
| 1572 i * Map::kProtoTransitionElementsPerEntry; | 1574 i * Map::kProtoTransitionElementsPerEntry; |
| 1573 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); | 1575 CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap()); |
| 1574 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); | 1576 CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject()); |
| 1575 } | 1577 } |
| 1576 | 1578 |
| 1577 // Make sure next prototype is placed on an old-space evacuation candidate. | 1579 // Make sure next prototype is placed on an old-space evacuation candidate. |
| 1578 Handle<JSObject> prototype; | 1580 Handle<JSObject> prototype; |
| 1579 PagedSpace* space = HEAP->old_pointer_space(); | 1581 PagedSpace* space = HEAP->old_pointer_space(); |
| 1580 do { | 1582 do { |
| 1581 prototype = FACTORY->NewJSArray(32 * KB, FAST_ELEMENTS, TENURED); | 1583 prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); |
| 1582 } while (space->FirstPage() == space->LastPage() || | 1584 } while (space->FirstPage() == space->LastPage() || |
| 1583 !space->LastPage()->Contains(prototype->address())); | 1585 !space->LastPage()->Contains(prototype->address())); |
| 1584 | 1586 |
| 1585 // Add a prototype on an evacuation candidate and verify that transition | 1587 // Add a prototype on an evacuation candidate and verify that transition |
| 1586 // clearing correctly records slots in prototype transition array. | 1588 // clearing correctly records slots in prototype transition array. |
| 1587 i::FLAG_always_compact = true; | 1589 i::FLAG_always_compact = true; |
| 1588 Handle<Map> map(baseObject->map()); | 1590 Handle<Map> map(baseObject->map()); |
| 1589 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); | 1591 CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address())); |
| 1590 CHECK(space->LastPage()->Contains(prototype->address())); | 1592 CHECK(space->LastPage()->Contains(prototype->address())); |
| 1591 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); | 1593 baseObject->SetPrototype(*prototype, false)->ToObjectChecked(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 "f(1); f(2); f(3);" | 1704 "f(1); f(2); f(3);" |
| 1703 "%OptimizeFunctionOnNextCall(f);" | 1705 "%OptimizeFunctionOnNextCall(f);" |
| 1704 "f(4);"); | 1706 "f(4);"); |
| 1705 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); | 1707 CHECK_EQ(4, res->ToObject()->GetRealNamedProperty(v8_str("x"))->Int32Value()); |
| 1706 | 1708 |
| 1707 Handle<JSObject> o = | 1709 Handle<JSObject> o = |
| 1708 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 1710 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 1709 | 1711 |
| 1710 CHECK(HEAP->InNewSpace(*o)); | 1712 CHECK(HEAP->InNewSpace(*o)); |
| 1711 } | 1713 } |
| OLD | NEW |