OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 CHECK_EQ(type, map->instance_type()); | 52 CHECK_EQ(type, map->instance_type()); |
53 CHECK_EQ(instance_size, map->instance_size()); | 53 CHECK_EQ(instance_size, map->instance_size()); |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 TEST(HeapMaps) { | 57 TEST(HeapMaps) { |
58 CcTest::InitializeVM(); | 58 CcTest::InitializeVM(); |
59 Heap* heap = CcTest::heap(); | 59 Heap* heap = CcTest::heap(); |
60 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); | 60 CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); |
61 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); | 61 CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); |
62 CheckMap(heap->float32x4_map(), FLOAT32X4_TYPE, Float32x4::kSize); | |
62 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 63 CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
63 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); | 64 CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); |
64 } | 65 } |
65 | 66 |
66 | 67 |
67 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { | 68 static void CheckOddball(Isolate* isolate, Object* obj, const char* string) { |
68 CHECK(obj->IsOddball()); | 69 CHECK(obj->IsOddball()); |
69 Handle<Object> handle(obj, isolate); | 70 Handle<Object> handle(obj, isolate); |
70 Object* print_string = | 71 Object* print_string = |
71 *Execution::ToString(isolate, handle).ToHandleChecked(); | 72 *Execution::ToString(isolate, handle).ToHandleChecked(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 CheckSmi(isolate, 42, "42"); | 207 CheckSmi(isolate, 42, "42"); |
207 CheckSmi(isolate, -42, "-42"); | 208 CheckSmi(isolate, -42, "-42"); |
208 | 209 |
209 // Check ToString for Numbers | 210 // Check ToString for Numbers |
210 CheckNumber(isolate, 1.1, "1.1"); | 211 CheckNumber(isolate, 1.1, "1.1"); |
211 | 212 |
212 CheckFindCodeObject(isolate); | 213 CheckFindCodeObject(isolate); |
213 } | 214 } |
214 | 215 |
215 | 216 |
217 TEST(SimdObjects) { | |
218 CcTest::InitializeVM(); | |
219 Isolate* isolate = CcTest::i_isolate(); | |
220 Factory* factory = isolate->factory(); | |
221 | |
222 HandleScope sc(isolate); | |
223 | |
224 Handle<Object> value = factory->NewFloat32x4(1, 2, 3, 4); | |
225 CHECK(value->IsFloat32x4()); | |
226 CHECK(value->BooleanValue()); // SIMD values map to true. | |
227 Float32x4* float32x4 = *Handle<Float32x4>::cast(value); | |
228 CHECK_EQ(1, float32x4->get_lane(0)); | |
229 CHECK_EQ(2, float32x4->get_lane(1)); | |
230 CHECK_EQ(3, float32x4->get_lane(2)); | |
231 CHECK_EQ(4, float32x4->get_lane(3)); | |
232 float32x4->set_lane(3, 5); | |
233 CHECK_EQ(5, float32x4->get_lane(3)); | |
234 | |
235 // Check ToString for SIMD values. | |
236 // TODO(bbudge): Switch to Check* style function to test ToString(). | |
237 std::ostringstream os; | |
238 float32x4->Float32x4Print(os); | |
239 CHECK_EQ("1, 2, 3, 5", os.str()); | |
240 | |
241 float32x4->set_lane(0, -0.0); | |
242 CHECK_EQ(-0.0, float32x4->get_lane(0)); | |
243 float quiet_NaN = std::numeric_limits<float>::quiet_NaN(); | |
244 float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); | |
245 float32x4->set_lane(1, quiet_NaN); | |
246 CHECK(std::isnan(float32x4->get_lane(1))); | |
247 float32x4->set_lane(2, signaling_NaN); | |
248 CHECK(std::isnan(float32x4->get_lane(2))); | |
titzer
2015/06/03 20:34:40
Can we also check that writing to one lane doesn't
bbudge
2015/06/03 21:32:52
Done. I added a templated function to do the lane
| |
249 } | |
250 | |
251 | |
216 TEST(Tagging) { | 252 TEST(Tagging) { |
217 CcTest::InitializeVM(); | 253 CcTest::InitializeVM(); |
218 int request = 24; | 254 int request = 24; |
219 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); | 255 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); |
220 CHECK(Smi::FromInt(42)->IsSmi()); | 256 CHECK(Smi::FromInt(42)->IsSmi()); |
221 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); | 257 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); |
222 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); | 258 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); |
223 } | 259 } |
224 | 260 |
225 | 261 |
(...skipping 5672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5898 size_t counter2 = 2000; | 5934 size_t counter2 = 2000; |
5899 tracer->SampleAllocation(time2, counter2, counter2); | 5935 tracer->SampleAllocation(time2, counter2, counter2); |
5900 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5936 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
5901 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); | 5937 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); |
5902 int time3 = 1000; | 5938 int time3 = 1000; |
5903 size_t counter3 = 30000; | 5939 size_t counter3 = 30000; |
5904 tracer->SampleAllocation(time3, counter3, counter3); | 5940 tracer->SampleAllocation(time3, counter3, counter3); |
5905 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5941 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
5906 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); | 5942 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); |
5907 } | 5943 } |
OLD | NEW |