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

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: Back out changes to include/v8.h 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-heap-profiler.cc » ('j') | 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 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<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 5759 matching lines...) Expand 10 before | Expand all | Expand 10 after
6037 array->address(), 6048 array->address(),
6038 array->address() + array->Size()); 6049 array->address() + array->Size());
6039 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == 6050 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) ==
6040 HeapObject::RawField(heap->empty_fixed_array(), 6051 HeapObject::RawField(heap->empty_fixed_array(),
6041 FixedArrayBase::kLengthOffset)); 6052 FixedArrayBase::kLengthOffset));
6042 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == 6053 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) ==
6043 HeapObject::RawField(heap->empty_fixed_array(), 6054 HeapObject::RawField(heap->empty_fixed_array(),
6044 FixedArrayBase::kLengthOffset)); 6055 FixedArrayBase::kLengthOffset));
6045 delete buffer; 6056 delete buffer;
6046 } 6057 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698