| 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<Object> value = factory->NewFloat32x4(1, 2, 3, 4); | 242 Handle<Float32x4> 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); |
| 245 | 249 |
| 246 Float32x4* float32x4 = *Handle<Float32x4>::cast(value); | 250 CheckSimdLanes<Float32x4, float, 4>(*value); |
| 247 CheckSimdLanes<Float32x4, float, 4>(float32x4); | |
| 248 | 251 |
| 249 // Check ToString for SIMD values. | 252 // Check all lanes, and special lane values. |
| 250 // TODO(bbudge): Switch to Check* style function to test ToString(). | 253 value->set_lane(0, 0); |
| 251 value = factory->NewFloat32x4(1, 2, 3, 4); | 254 CHECK_EQ(0, value->get_lane(0)); |
| 252 float32x4 = *Handle<Float32x4>::cast(value); | 255 value->set_lane(1, -0.0); |
| 253 std::ostringstream os; | 256 CHECK_EQ(-0.0, value->get_lane(1)); |
| 254 float32x4->Float32x4Print(os); | 257 CHECK(std::signbit(value->get_lane(1))); // Sign bit is preserved. |
| 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(); | 258 float quiet_NaN = std::numeric_limits<float>::quiet_NaN(); |
| 263 float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); | 259 float signaling_NaN = std::numeric_limits<float>::signaling_NaN(); |
| 264 float32x4->set_lane(2, quiet_NaN); | 260 value->set_lane(2, quiet_NaN); |
| 265 CHECK(std::isnan(float32x4->get_lane(2))); | 261 CHECK(std::isnan(value->get_lane(2))); |
| 266 float32x4->set_lane(3, signaling_NaN); | 262 value->set_lane(3, signaling_NaN); |
| 267 CHECK(std::isnan(float32x4->get_lane(3))); | 263 CHECK(std::isnan(value->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 } |
| 268 } | 279 } |
| 269 | 280 |
| 270 | 281 |
| 271 TEST(Tagging) { | 282 TEST(Tagging) { |
| 272 CcTest::InitializeVM(); | 283 CcTest::InitializeVM(); |
| 273 int request = 24; | 284 int request = 24; |
| 274 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); | 285 CHECK_EQ(request, static_cast<int>(OBJECT_POINTER_ALIGN(request))); |
| 275 CHECK(Smi::FromInt(42)->IsSmi()); | 286 CHECK(Smi::FromInt(42)->IsSmi()); |
| 276 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); | 287 CHECK(Smi::FromInt(Smi::kMinValue)->IsSmi()); |
| 277 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); | 288 CHECK(Smi::FromInt(Smi::kMaxValue)->IsSmi()); |
| (...skipping 5772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6050 HeapObject::RawField(*array, FixedArray::kHeaderSize)); | 6061 HeapObject::RawField(*array, FixedArray::kHeaderSize)); |
| 6051 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); | 6062 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); |
| 6052 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == | 6063 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
| 6053 HeapObject::RawField(heap->empty_fixed_array(), | 6064 HeapObject::RawField(heap->empty_fixed_array(), |
| 6054 FixedArrayBase::kLengthOffset)); | 6065 FixedArrayBase::kLengthOffset)); |
| 6055 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == | 6066 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
| 6056 HeapObject::RawField(heap->empty_fixed_array(), | 6067 HeapObject::RawField(heap->empty_fixed_array(), |
| 6057 FixedArrayBase::kLengthOffset)); | 6068 FixedArrayBase::kLengthOffset)); |
| 6058 delete buffer; | 6069 delete buffer; |
| 6059 } | 6070 } |
| OLD | NEW |