Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/cctest/test-heap.cc

Issue 1153373003: Add new Float32x4 type for SIMD.js. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix int type mismatches. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 template <typename T, typename LANE_TYPE, int LANES>
218 static void CheckSimdLanes(T* value) {
219 // Get the original values, and check that all lanes can be set to new values
220 // without disturbing the other lanes.
221 LANE_TYPE lane_values[LANES];
222 for (int i = 0; i < LANES; i++) {
223 lane_values[i] = value->get_lane(i);
224 }
225 for (int i = 0; i < LANES; i++) {
226 lane_values[i] += 1;
227 value->set_lane(i, lane_values[i]);
228 for (int j = 0; j < LANES; j++) {
229 CHECK_EQ(lane_values[j], value->get_lane(j));
230 }
231 }
232 }
233
234
235 TEST(SimdObjects) {
236 CcTest::InitializeVM();
237 Isolate* isolate = CcTest::i_isolate();
238 Factory* factory = isolate->factory();
239
240 HandleScope sc(isolate);
241
242 Handle<Object> value = factory->NewFloat32x4(1, 2, 3, 4);
243 CHECK(value->IsFloat32x4());
244 CHECK(value->BooleanValue()); // SIMD values map to true.
245
246 Float32x4* float32x4 = *Handle<Float32x4>::cast(value);
247 CheckSimdLanes<Float32x4, float, 4>(float32x4);
248
249 // Check ToString for SIMD values.
250 // TODO(bbudge): Switch to Check* style function to test ToString().
251 value = factory->NewFloat32x4(1, 2, 3, 4);
252 float32x4 = *Handle<Float32x4>::cast(value);
253 std::ostringstream os;
254 float32x4->Float32x4Print(os);
255 CHECK_EQ("1, 2, 3, 4", os.str());
256
257 // Check unusual lane values.
258 float32x4->set_lane(0, 0);
259 CHECK_EQ(0, float32x4->get_lane(0));
260 float32x4->set_lane(1, -0.0);
261 CHECK_EQ(-0.0, float32x4->get_lane(1));
262 float quiet_NaN = std::numeric_limits<float>::quiet_NaN();
263 float signaling_NaN = std::numeric_limits<float>::signaling_NaN();
264 float32x4->set_lane(2, quiet_NaN);
265 CHECK(std::isnan(float32x4->get_lane(2)));
266 float32x4->set_lane(3, signaling_NaN);
267 CHECK(std::isnan(float32x4->get_lane(3)));
268 }
269
270
216 TEST(Tagging) { 271 TEST(Tagging) {
217 CcTest::InitializeVM(); 272 CcTest::InitializeVM();
218 int request = 24; 273 int request = 24;
219 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); 274 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request)));
220 CHECK(Smi::FromInt(42)->IsSmi()); 275 CHECK(Smi::FromInt(42)->IsSmi());
221 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); 276 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi());
222 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); 277 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi());
223 } 278 }
224 279
225 280
(...skipping 5672 matching lines...) Expand 10 before | Expand all | Expand 10 after
5898 size_t counter2 = 2000; 5953 size_t counter2 = 2000;
5899 tracer->SampleAllocation(time2, counter2, counter2); 5954 tracer->SampleAllocation(time2, counter2, counter2);
5900 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 5955 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5901 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 5956 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
5902 int time3 = 1000; 5957 int time3 = 1000;
5903 size_t counter3 = 30000; 5958 size_t counter3 = 30000;
5904 tracer->SampleAllocation(time3, counter3, counter3); 5959 tracer->SampleAllocation(time3, counter3, counter3);
5905 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 5960 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5906 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 5961 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
5907 } 5962 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698