OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 665 |
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 Object* ok = array->Initialize(0)->ToObjectChecked(); | 670 Object* ok = array->Initialize(0)->ToObjectChecked(); |
671 | 671 |
672 // Set array length to 0. | 672 // Set array length to 0. |
673 ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); | 673 ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); |
674 CHECK_EQ(Smi::FromInt(0), array->length()); | 674 CHECK_EQ(Smi::FromInt(0), array->length()); |
675 CHECK(array->HasFastElements()); // Must be in fast mode. | 675 // Must be in fast mode. |
| 676 CHECK(array->HasFastTypeElements()); |
676 | 677 |
677 // array[length] = name. | 678 // array[length] = name. |
678 ok = array->SetElement(0, *name, kNonStrictMode, true)->ToObjectChecked(); | 679 ok = array->SetElement(0, *name, kNonStrictMode, true)->ToObjectChecked(); |
679 CHECK_EQ(Smi::FromInt(1), array->length()); | 680 CHECK_EQ(Smi::FromInt(1), array->length()); |
680 CHECK_EQ(array->GetElement(0), *name); | 681 CHECK_EQ(array->GetElement(0), *name); |
681 | 682 |
682 // Set array length with larger than smi value. | 683 // Set array length with larger than smi value. |
683 Handle<Object> length = | 684 Handle<Object> length = |
684 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); | 685 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); |
685 ok = array->SetElementsLength(*length)->ToObjectChecked(); | 686 ok = array->SetElementsLength(*length)->ToObjectChecked(); |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 ASSERT_EQ(old_capacity, 2 * new_capacity); | 1256 ASSERT_EQ(old_capacity, 2 * new_capacity); |
1256 | 1257 |
1257 // Consecutive shrinking should not affect space capacity. | 1258 // Consecutive shrinking should not affect space capacity. |
1258 old_capacity = new_space->Capacity(); | 1259 old_capacity = new_space->Capacity(); |
1259 new_space->Shrink(); | 1260 new_space->Shrink(); |
1260 new_space->Shrink(); | 1261 new_space->Shrink(); |
1261 new_space->Shrink(); | 1262 new_space->Shrink(); |
1262 new_capacity = new_space->Capacity(); | 1263 new_capacity = new_space->Capacity(); |
1263 ASSERT_EQ(old_capacity, new_capacity); | 1264 ASSERT_EQ(old_capacity, new_capacity); |
1264 } | 1265 } |
OLD | NEW |