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

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

Issue 1219943002: Expose SIMD.Float32x4 type to Javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 234
235 TEST(SimdObjects) { 235 TEST(SimdObjects) {
236 CcTest::InitializeVM(); 236 CcTest::InitializeVM();
237 Isolate* isolate = CcTest::i_isolate(); 237 Isolate* isolate = CcTest::i_isolate();
238 Factory* factory = isolate->factory(); 238 Factory* factory = isolate->factory();
239 239
240 HandleScope sc(isolate); 240 HandleScope sc(isolate);
241 241
242 Handle<Object> value = factory->NewFloat32x4(1, 2, 3, 4); 242 Handle<Object> handle = factory->NewFloat32x4(1, 2, 3, 4);
rossberg 2015/07/02 13:35:43 Type this as Handle<Float32x4> and get rid of the
bbudge 2015/07/06 23:59:05 Done.
243 CHECK(handle->IsFloat32x4());
244 CHECK(handle->BooleanValue()); // SIMD values map to true.
245
rossberg 2015/07/02 13:35:43 Also check that the lanes have the values passed t
bbudge 2015/07/06 23:59:05 Done.
246 Float32x4* value = *Handle<Float32x4>::cast(handle);
243 CHECK(value->IsFloat32x4()); 247 CHECK(value->IsFloat32x4());
244 CHECK(value->BooleanValue()); // SIMD values map to true. 248 CheckSimdLanes<Float32x4, float, 4>(value);
245 249
246 Float32x4* float32x4 = *Handle<Float32x4>::cast(value); 250 // Check all lanes, and special lane values.
247 CheckSimdLanes<Float32x4, float, 4>(float32x4); 251 value->set_lane(0, 0);
248 252 CHECK_EQ(0, value->get_lane(0));
249 // Check ToString for SIMD values. 253 value->set_lane(1, -0.0);
250 // TODO(bbudge): Switch to Check* style function to test ToString(). 254 CHECK_EQ(-0.0, value->get_lane(1));
rossberg 2015/07/02 13:35:43 Does CHECK_EQ actually distinguish -0.0 from +0.0?
bbudge 2015/07/06 23:59:05 Good point - probably not. I added a test for the
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(); 255 float quiet_NaN = std::numeric_limits<float>::quiet_NaN();
263 float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); 256 float signaling_NaN = std::numeric_limits<float>::signaling_NaN();
264 float32x4->set_lane(2, quiet_NaN); 257 value->set_lane(2, quiet_NaN);
265 CHECK(std::isnan(float32x4->get_lane(2))); 258 CHECK(std::isnan(value->get_lane(2)));
266 float32x4->set_lane(3, signaling_NaN); 259 value->set_lane(3, signaling_NaN);
267 CHECK(std::isnan(float32x4->get_lane(3))); 260 CHECK(std::isnan(value->get_lane(3)));
261
262 // Check SIMD value to string conversions.
263 {
264 handle = factory->NewFloat32x4(1, 2, 3, 4);
265 value = *Handle<Float32x4>::cast(handle);
266 std::ostringstream os;
267 value->Float32x4Print(os);
268 CHECK_EQ("1, 2, 3, 4", os.str());
269 }
270 {
271 handle = factory->NewFloat32x4(0, -0.0, quiet_NaN, signaling_NaN);
272 value = *Handle<Float32x4>::cast(handle);
273 std::ostringstream os;
274 value->Float32x4Print(os);
275 CHECK_EQ("0, -0, nan, nan", os.str());
276 }
268 } 277 }
269 278
270 279
271 TEST(Tagging) { 280 TEST(Tagging) {
272 CcTest::InitializeVM(); 281 CcTest::InitializeVM();
273 int request = 24; 282 int request = 24;
274 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); 283 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request)));
275 CHECK(Smi::FromInt(42)->IsSmi()); 284 CHECK(Smi::FromInt(42)->IsSmi());
276 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); 285 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi());
277 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); 286 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi());
(...skipping 5772 matching lines...) Expand 10 before | Expand all | Expand 10 after
6050 HeapObject::RawField(*array, FixedArray::kHeaderSize)); 6059 HeapObject::RawField(*array, FixedArray::kHeaderSize));
6051 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); 6060 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array);
6052 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == 6061 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6053 HeapObject::RawField(heap->empty_fixed_array(), 6062 HeapObject::RawField(heap->empty_fixed_array(),
6054 FixedArrayBase::kLengthOffset)); 6063 FixedArrayBase::kLengthOffset));
6055 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == 6064 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6056 HeapObject::RawField(heap->empty_fixed_array(), 6065 HeapObject::RawField(heap->empty_fixed_array(),
6057 FixedArrayBase::kLengthOffset)); 6066 FixedArrayBase::kLengthOffset));
6058 delete buffer; 6067 delete buffer;
6059 } 6068 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698