OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 value = Heap::NumberFromInt32(Smi::kMinValue); | 125 value = Heap::NumberFromInt32(Smi::kMinValue); |
126 CHECK(value->IsSmi()); | 126 CHECK(value->IsSmi()); |
127 CHECK(value->IsNumber()); | 127 CHECK(value->IsNumber()); |
128 CHECK_EQ(Smi::kMinValue, Smi::cast(value)->value()); | 128 CHECK_EQ(Smi::kMinValue, Smi::cast(value)->value()); |
129 | 129 |
130 value = Heap::NumberFromInt32(Smi::kMaxValue); | 130 value = Heap::NumberFromInt32(Smi::kMaxValue); |
131 CHECK(value->IsSmi()); | 131 CHECK(value->IsSmi()); |
132 CHECK(value->IsNumber()); | 132 CHECK(value->IsNumber()); |
133 CHECK_EQ(Smi::kMaxValue, Smi::cast(value)->value()); | 133 CHECK_EQ(Smi::kMaxValue, Smi::cast(value)->value()); |
134 | 134 |
| 135 #ifndef V8_LONG_SMI |
| 136 // TODO(lrn): We need a NumberFromIntptr function in order to test this. |
135 value = Heap::NumberFromInt32(Smi::kMinValue - 1); | 137 value = Heap::NumberFromInt32(Smi::kMinValue - 1); |
136 CHECK(value->IsHeapNumber()); | 138 CHECK(value->IsHeapNumber()); |
137 CHECK(value->IsNumber()); | 139 CHECK(value->IsNumber()); |
138 CHECK_EQ(static_cast<double>(Smi::kMinValue - 1), value->Number()); | 140 CHECK_EQ(static_cast<double>(Smi::kMinValue - 1), value->Number()); |
| 141 #endif |
139 | 142 |
140 value = Heap::NumberFromInt32(Smi::kMaxValue + 1); | 143 value = Heap::NumberFromUint32(static_cast<uint32_t>(Smi::kMaxValue) + 1); |
141 CHECK(value->IsHeapNumber()); | 144 CHECK(value->IsHeapNumber()); |
142 CHECK(value->IsNumber()); | 145 CHECK(value->IsNumber()); |
143 CHECK_EQ(static_cast<double>(Smi::kMaxValue + 1), value->Number()); | 146 CHECK_EQ(static_cast<double>(static_cast<uint32_t>(Smi::kMaxValue) + 1), |
| 147 value->Number()); |
144 | 148 |
145 // nan oddball checks | 149 // nan oddball checks |
146 CHECK(Heap::nan_value()->IsNumber()); | 150 CHECK(Heap::nan_value()->IsNumber()); |
147 CHECK(isnan(Heap::nan_value()->Number())); | 151 CHECK(isnan(Heap::nan_value()->Number())); |
148 | 152 |
149 Object* str = Heap::AllocateStringFromAscii(CStrVector("fisk hest ")); | 153 Object* str = Heap::AllocateStringFromAscii(CStrVector("fisk hest ")); |
150 if (!str->IsFailure()) { | 154 if (!str->IsFailure()) { |
151 String* s = String::cast(str); | 155 String* s = String::cast(str); |
152 CHECK(s->IsString()); | 156 CHECK(s->IsString()); |
153 CHECK_EQ(10, s->length()); | 157 CHECK_EQ(10, s->length()); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 // Set array length to 0. | 637 // Set array length to 0. |
634 array->SetElementsLength(Smi::FromInt(0)); | 638 array->SetElementsLength(Smi::FromInt(0)); |
635 CHECK_EQ(Smi::FromInt(0), array->length()); | 639 CHECK_EQ(Smi::FromInt(0), array->length()); |
636 CHECK(array->HasFastElements()); // Must be in fast mode. | 640 CHECK(array->HasFastElements()); // Must be in fast mode. |
637 | 641 |
638 // array[length] = name. | 642 // array[length] = name. |
639 array->SetElement(0, name); | 643 array->SetElement(0, name); |
640 CHECK_EQ(Smi::FromInt(1), array->length()); | 644 CHECK_EQ(Smi::FromInt(1), array->length()); |
641 CHECK_EQ(array->GetElement(0), name); | 645 CHECK_EQ(array->GetElement(0), name); |
642 | 646 |
643 // Set array length with larger than smi value. | 647 // Set array length with larger than smi value. |
644 Object* length = Heap::NumberFromInt32(Smi::kMaxValue + 1); | 648 Object* length = |
| 649 Heap::NumberFromUint32(static_cast<uint32_t>(Smi::kMaxValue) + 1); |
645 array->SetElementsLength(length); | 650 array->SetElementsLength(length); |
646 | 651 |
647 uint32_t int_length = 0; | 652 uint32_t int_length = 0; |
648 CHECK(Array::IndexFromObject(length, &int_length)); | 653 CHECK(Array::IndexFromObject(length, &int_length)); |
649 CHECK_EQ(length, array->length()); | 654 CHECK_EQ(length, array->length()); |
650 CHECK(array->HasDictionaryElements()); // Must be in slow mode. | 655 CHECK(array->HasDictionaryElements()); // Must be in slow mode. |
651 | 656 |
652 // array[length] = name. | 657 // array[length] = name. |
653 array->SetElement(int_length, name); | 658 array->SetElement(int_length, name); |
654 uint32_t new_int_length = 0; | 659 uint32_t new_int_length = 0; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 objs[next_objs_index++] = | 788 objs[next_objs_index++] = |
784 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 789 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
785 delete[] str; | 790 delete[] str; |
786 | 791 |
787 // Add a Map object to look for. | 792 // Add a Map object to look for. |
788 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 793 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
789 | 794 |
790 CHECK_EQ(objs_count, next_objs_index); | 795 CHECK_EQ(objs_count, next_objs_index); |
791 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 796 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
792 } | 797 } |
OLD | NEW |