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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 64235409299198926d3453ee12f77e6216eced26..dccf9c09d86cd035a5ea5392bd7d9d78330aa872 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -239,32 +239,41 @@ TEST(SimdObjects) {
HandleScope sc(isolate);
- Handle<Object> value = factory->NewFloat32x4(1, 2, 3, 4);
+ 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.
+ CHECK(handle->IsFloat32x4());
+ CHECK(handle->BooleanValue()); // SIMD values map to true.
+
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.
+ Float32x4* value = *Handle<Float32x4>::cast(handle);
CHECK(value->IsFloat32x4());
- CHECK(value->BooleanValue()); // SIMD values map to true.
-
- Float32x4* float32x4 = *Handle<Float32x4>::cast(value);
- CheckSimdLanes<Float32x4, float, 4>(float32x4);
-
- // Check ToString for SIMD values.
- // TODO(bbudge): Switch to Check* style function to test ToString().
- value = factory->NewFloat32x4(1, 2, 3, 4);
- float32x4 = *Handle<Float32x4>::cast(value);
- std::ostringstream os;
- float32x4->Float32x4Print(os);
- CHECK_EQ("1, 2, 3, 4", os.str());
-
- // Check unusual lane values.
- float32x4->set_lane(0, 0);
- CHECK_EQ(0, float32x4->get_lane(0));
- float32x4->set_lane(1, -0.0);
- CHECK_EQ(-0.0, float32x4->get_lane(1));
+ CheckSimdLanes<Float32x4, float, 4>(value);
+
+ // Check all lanes, and special lane values.
+ value->set_lane(0, 0);
+ CHECK_EQ(0, value->get_lane(0));
+ value->set_lane(1, -0.0);
+ 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
float quiet_NaN = std::numeric_limits<float>::quiet_NaN();
float signaling_NaN = std::numeric_limits<float>::signaling_NaN();
- float32x4->set_lane(2, quiet_NaN);
- CHECK(std::isnan(float32x4->get_lane(2)));
- float32x4->set_lane(3, signaling_NaN);
- CHECK(std::isnan(float32x4->get_lane(3)));
+ value->set_lane(2, quiet_NaN);
+ CHECK(std::isnan(value->get_lane(2)));
+ value->set_lane(3, signaling_NaN);
+ CHECK(std::isnan(value->get_lane(3)));
+
+ // Check SIMD value to string conversions.
+ {
+ handle = factory->NewFloat32x4(1, 2, 3, 4);
+ value = *Handle<Float32x4>::cast(handle);
+ std::ostringstream os;
+ value->Float32x4Print(os);
+ CHECK_EQ("1, 2, 3, 4", os.str());
+ }
+ {
+ handle = factory->NewFloat32x4(0, -0.0, quiet_NaN, signaling_NaN);
+ value = *Handle<Float32x4>::cast(handle);
+ std::ostringstream os;
+ value->Float32x4Print(os);
+ CHECK_EQ("0, -0, nan, nan", os.str());
+ }
}

Powered by Google App Engine
This is Rietveld 408576698