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 18 matching lines...) Expand all Loading... | |
29 CHECK_EQ(Heap::meta_map(), map->map()); | 29 CHECK_EQ(Heap::meta_map(), map->map()); |
30 CHECK_EQ(type, map->instance_type()); | 30 CHECK_EQ(type, map->instance_type()); |
31 CHECK_EQ(instance_size, map->instance_size()); | 31 CHECK_EQ(instance_size, map->instance_size()); |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 TEST(HeapMaps) { | 35 TEST(HeapMaps) { |
36 InitializeVM(); | 36 InitializeVM(); |
37 CheckMap(Heap::meta_map(), MAP_TYPE, Map::kSize); | 37 CheckMap(Heap::meta_map(), MAP_TYPE, Map::kSize); |
38 CheckMap(Heap::heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); | 38 CheckMap(Heap::heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); |
39 CheckMap(Heap::fixed_array_map(), FIXED_ARRAY_TYPE, Array::kHeaderSize); | 39 CheckMap(Heap::fixed_array_map(), FIXED_ARRAY_TYPE, Array::kAlignedSize); |
40 CheckMap(Heap::long_string_map(), LONG_STRING_TYPE, | 40 CheckMap(Heap::long_string_map(), LONG_STRING_TYPE, |
41 SeqTwoByteString::kHeaderSize); | 41 SeqTwoByteString::kAlignedSize); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 static void CheckOddball(Object* obj, const char* string) { | 45 static void CheckOddball(Object* obj, const char* string) { |
46 CHECK(obj->IsOddball()); | 46 CHECK(obj->IsOddball()); |
47 #ifndef V8_HOST_ARCH_64_BIT | |
48 // TODO(X64): Reenable when native builtins work. | |
47 bool exc; | 49 bool exc; |
48 Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc); | 50 Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc); |
49 CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string))); | 51 CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string))); |
52 #endif // V8_HOST_ARCH_64_BIT | |
50 } | 53 } |
51 | 54 |
52 | 55 |
53 static void CheckSmi(int value, const char* string) { | 56 static void CheckSmi(int value, const char* string) { |
57 #ifndef V8_HOST_ARCH_64_BIT | |
58 // TODO(X64): Reenable when native builtins work. | |
54 bool exc; | 59 bool exc; |
55 Object* print_string = | 60 Object* print_string = |
56 *Execution::ToString(Handle<Object>(Smi::FromInt(value)), &exc); | 61 *Execution::ToString(Handle<Object>(Smi::FromInt(value)), &exc); |
57 CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string))); | 62 CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string))); |
63 #endif // V8_HOST_ARCH_64_BIT | |
58 } | 64 } |
59 | 65 |
60 | 66 |
61 static void CheckNumber(double value, const char* string) { | 67 static void CheckNumber(double value, const char* string) { |
62 Object* obj = Heap::NumberFromDouble(value); | 68 Object* obj = Heap::NumberFromDouble(value); |
63 CHECK(obj->IsNumber()); | 69 CHECK(obj->IsNumber()); |
70 #ifndef V8_HOST_ARCH_64_BIT | |
71 // TODO(X64): Reenable when native builtins work. | |
64 bool exc; | 72 bool exc; |
65 Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc); | 73 Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc); |
66 CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string))); | 74 CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string))); |
75 #endif // V8_HOST_ARCH_64_BIT | |
67 } | 76 } |
68 | 77 |
69 | 78 |
70 static void CheckFindCodeObject() { | 79 static void CheckFindCodeObject() { |
71 // Test FindCodeObject | 80 // Test FindCodeObject |
72 #define __ assm. | 81 #define __ assm. |
73 | 82 |
74 Assembler assm(NULL, 0); | 83 Assembler assm(NULL, 0); |
75 | 84 |
76 __ nop(); // supported on all architectures | 85 __ nop(); // supported on all architectures |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 180 |
172 // Check ToString for Numbers | 181 // Check ToString for Numbers |
173 CheckNumber(1.1, "1.1"); | 182 CheckNumber(1.1, "1.1"); |
174 | 183 |
175 CheckFindCodeObject(); | 184 CheckFindCodeObject(); |
176 } | 185 } |
177 | 186 |
178 | 187 |
179 TEST(Tagging) { | 188 TEST(Tagging) { |
180 InitializeVM(); | 189 InitializeVM(); |
190 int request = 24; | |
191 ASSERT_EQ(request, OBJECT_SIZE_ALIGN(request)); | |
William Hesse
2009/05/22 12:21:13
Shouldn't this be CHECK_EQ? Otherwise, you could
Lasse Reichstein
2009/05/22 13:10:10
I couldn't decide. It's not a check in the same se
| |
181 CHECK(Smi::FromInt(42)->IsSmi()); | 192 CHECK(Smi::FromInt(42)->IsSmi()); |
182 CHECK(Failure::RetryAfterGC(12, NEW_SPACE)->IsFailure()); | 193 CHECK(Failure::RetryAfterGC(request, NEW_SPACE)->IsFailure()); |
183 CHECK_EQ(12, Failure::RetryAfterGC(12, NEW_SPACE)->requested()); | 194 CHECK_EQ(request, Failure::RetryAfterGC(request, NEW_SPACE)->requested()); |
184 CHECK_EQ(NEW_SPACE, Failure::RetryAfterGC(12, NEW_SPACE)->allocation_space()); | 195 CHECK_EQ(NEW_SPACE, |
196 Failure::RetryAfterGC(request, NEW_SPACE)->allocation_space()); | |
185 CHECK_EQ(OLD_POINTER_SPACE, | 197 CHECK_EQ(OLD_POINTER_SPACE, |
186 Failure::RetryAfterGC(12, OLD_POINTER_SPACE)->allocation_space()); | 198 Failure::RetryAfterGC(request, |
199 OLD_POINTER_SPACE)->allocation_space()); | |
187 CHECK(Failure::Exception()->IsFailure()); | 200 CHECK(Failure::Exception()->IsFailure()); |
188 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); | 201 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); |
189 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); | 202 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); |
190 } | 203 } |
191 | 204 |
192 | 205 |
193 TEST(GarbageCollection) { | 206 TEST(GarbageCollection) { |
194 InitializeVM(); | 207 InitializeVM(); |
195 | 208 |
196 v8::HandleScope sc; | 209 v8::HandleScope sc; |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 objs[next_objs_index++] = | 789 objs[next_objs_index++] = |
777 Factory::NewStringFromAscii(CStrVector(str), TENURED); | 790 Factory::NewStringFromAscii(CStrVector(str), TENURED); |
778 delete[] str; | 791 delete[] str; |
779 | 792 |
780 // Add a Map object to look for. | 793 // Add a Map object to look for. |
781 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); | 794 objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); |
782 | 795 |
783 CHECK_EQ(objs_count, next_objs_index); | 796 CHECK_EQ(objs_count, next_objs_index); |
784 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); | 797 CHECK_EQ(objs_count, ObjectsFoundInHeap(objs, objs_count)); |
785 } | 798 } |
OLD | NEW |