Reviewers: dehrenberg,

Description:
[simd.js] Set --harmony-simd flag in test config.
Adds the flag to the test configuration so we aren't just testing the
polyfill.
Fixes some number conversion in native fromFloat32x4 function that now
fails.

LOG=N
BUG=v8:4124

Please review this at https://codereview.chromium.org/1312703003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+20, -12 lines):
  M src/runtime/runtime-simd.cc
  M test/simdjs/testcfg.py


Index: src/runtime/runtime-simd.cc
diff --git a/src/runtime/runtime-simd.cc b/src/runtime/runtime-simd.cc
index ce9512e8da4b14c73469a879861efc2ca650ce46..e1d39798d09d3047bdeff820da43de91967a651c 100644
--- a/src/runtime/runtime-simd.cc
+++ b/src/runtime/runtime-simd.cc
@@ -21,6 +21,24 @@ namespace {

 // Functions to convert Numbers to SIMD component types.

+template <typename T, typename F>
+static bool CanCast(F from) {
+ // A float can't represent 2^31 - 1 or 2^32 - 1 exactly, so promote the limits + // to double. Otherwise, the limit is truncated and numbers like 2^31 or 2^32
+  // get through, causing any static_cast to be undefined.
+  return from >= static_cast<double>(std::numeric_limits<T>::min()) &&
+         from <= static_cast<double>(std::numeric_limits<T>::max());
+}
+
+
+// Explicitly specialize for conversions to float, which always succeed.
+template <>
+bool CanCast<float>(int32_t from) {
+  return true;
+}
+
+}  // namespace
+
 template <typename T>
 static T ConvertNumber(double number);

@@ -111,16 +129,6 @@ inline float MaxNumber(float a, float b) {
 }


-inline bool CanCast(int32_t a) { return true; }
-
-
-inline bool CanCast(float a) {
-  return a > std::numeric_limits<int32_t>::min() &&
-         a < std::numeric_limits<int32_t>::max();
-}
-
-}  // namespace
-
 //-------------------------------------------------------------------

 // SIMD helper functions.
@@ -759,7 +767,7 @@ SIMD_SELECT_TYPES(SIMD_SELECT_FUNCTION)
lane_type lanes[kLaneCount]; \ for (int i = 0; i < kLaneCount; i++) { \ from_ctype a_value = a->get_lane(i); \ - RUNTIME_ASSERT(CanCast(a_value)); \ + RUNTIME_ASSERT(CanCast<lane_type>(a_value)); \ lanes[i] = static_cast<lane_type>(a_value); \ } \ Handle<type> result = isolate->factory()->New##type(lanes); \
Index: test/simdjs/testcfg.py
diff --git a/test/simdjs/testcfg.py b/test/simdjs/testcfg.py
index cbe880d149dcbb94a8aca6add1879f791bb57a1e..afd366e5c0649b018a67cb1bab08d3ee9c773790 100644
--- a/test/simdjs/testcfg.py
+++ b/test/simdjs/testcfg.py
@@ -44,7 +44,7 @@ class SimdJsTestSuite(testsuite.TestSuite):
   def GetFlagsForTestCase(self, testcase, context):
     return (testcase.flags + context.mode_flags +
             [os.path.join(self.root, "harness-adapt.js"),
-             "--harmony",
+             "--harmony", "--harmony-simd",
              os.path.join(self.testroot, testcase.path + ".js"),
              os.path.join(self.root, "harness-finish.js")])



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to