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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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<Float32x4> value = factory->NewFloat32x4(1, 2, 3, 4); | 242 Handle<Object> value = factory->NewFloat32x4(1, 2, 3, 4); |
243 CHECK(value->IsFloat32x4()); | 243 CHECK(value->IsFloat32x4()); |
244 CHECK(value->BooleanValue()); // SIMD values map to true. | 244 CHECK(value->BooleanValue()); // SIMD values map to true. |
245 CHECK_EQ(value->get_lane(0), 1); | |
246 CHECK_EQ(value->get_lane(1), 2); | |
247 CHECK_EQ(value->get_lane(2), 3); | |
248 CHECK_EQ(value->get_lane(3), 4); | |
249 | 245 |
250 CheckSimdLanes<Float32x4, float, 4>(*value); | 246 Float32x4* float32x4 = *Handle<Float32x4>::cast(value); |
| 247 CheckSimdLanes<Float32x4, float, 4>(float32x4); |
251 | 248 |
252 // Check all lanes, and special lane values. | 249 // Check ToString for SIMD values. |
253 value->set_lane(0, 0); | 250 // TODO(bbudge): Switch to Check* style function to test ToString(). |
254 CHECK_EQ(0, value->get_lane(0)); | 251 value = factory->NewFloat32x4(1, 2, 3, 4); |
255 value->set_lane(1, -0.0); | 252 float32x4 = *Handle<Float32x4>::cast(value); |
256 CHECK_EQ(-0.0, value->get_lane(1)); | 253 std::ostringstream os; |
257 CHECK(std::signbit(value->get_lane(1))); // Sign bit is preserved. | 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)); |
258 float quiet_NaN = std::numeric_limits<float>::quiet_NaN(); | 262 float quiet_NaN = std::numeric_limits<float>::quiet_NaN(); |
259 float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); | 263 float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); |
260 value->set_lane(2, quiet_NaN); | 264 float32x4->set_lane(2, quiet_NaN); |
261 CHECK(std::isnan(value->get_lane(2))); | 265 CHECK(std::isnan(float32x4->get_lane(2))); |
262 value->set_lane(3, signaling_NaN); | 266 float32x4->set_lane(3, signaling_NaN); |
263 CHECK(std::isnan(value->get_lane(3))); | 267 CHECK(std::isnan(float32x4->get_lane(3))); |
264 | |
265 // Check SIMD value printing. | |
266 { | |
267 value = factory->NewFloat32x4(1, 2, 3, 4); | |
268 std::ostringstream os; | |
269 value->Float32x4Print(os); | |
270 CHECK_EQ("1, 2, 3, 4", os.str()); | |
271 } | |
272 { | |
273 value = factory->NewFloat32x4(0, -0.0, quiet_NaN, signaling_NaN); | |
274 std::ostringstream os; | |
275 value->Float32x4Print(os); | |
276 // Value printing doesn't preserve signed zeroes. | |
277 CHECK_EQ("0, 0, NaN, NaN", os.str()); | |
278 } | |
279 } | 268 } |
280 | 269 |
281 | 270 |
282 TEST(Tagging) { | 271 TEST(Tagging) { |
283 CcTest::InitializeVM(); | 272 CcTest::InitializeVM(); |
284 int request = 24; | 273 int request = 24; |
285 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); | 274 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); |
286 CHECK(Smi::FromInt(42)->IsSmi()); | 275 CHECK(Smi::FromInt(42)->IsSmi()); |
287 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); | 276 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); |
288 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); | 277 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); |
(...skipping 5759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6048 array->address(), | 6037 array->address(), |
6049 array->address() + array->Size()); | 6038 array->address() + array->Size()); |
6050 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == | 6039 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
6051 HeapObject::RawField(heap->empty_fixed_array(), | 6040 HeapObject::RawField(heap->empty_fixed_array(), |
6052 FixedArrayBase::kLengthOffset)); | 6041 FixedArrayBase::kLengthOffset)); |
6053 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == | 6042 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
6054 HeapObject::RawField(heap->empty_fixed_array(), | 6043 HeapObject::RawField(heap->empty_fixed_array(), |
6055 FixedArrayBase::kLengthOffset)); | 6044 FixedArrayBase::kLengthOffset)); |
6056 delete buffer; | 6045 delete buffer; |
6057 } | 6046 } |
OLD | NEW |