Commit 2090c08d authored by bbudge's avatar bbudge Committed by Commit bot

[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

Review URL: https://codereview.chromium.org/1312703003

Cr-Commit-Position: refs/heads/master@{#30341}
parent 45e2628d
......@@ -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); \
......
......@@ -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")])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment