[test] Avoid unnecessary std::vector allocations
Instead of copying an array of fixed values into an std::vector for each usage of the FOR_INPUTS macro, just iterate the constant data directly. This also makes the <type>_vector() functions return {constexpr Vector} instead of {std::vector}. R=tebbi@chromium.org Change-Id: Ifc3e5509b2fbf5e383c967c2f46acf2b07f7b5b4 Reviewed-on: https://chromium-review.googlesource.com/725427 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#48688}
This commit is contained in:
parent
7f35aa6786
commit
e737b4ce0d
25
src/vector.h
25
src/vector.h
@ -19,14 +19,14 @@ namespace internal {
|
||||
template <typename T>
|
||||
class Vector {
|
||||
public:
|
||||
Vector() : start_(nullptr), length_(0) {}
|
||||
constexpr Vector() : start_(nullptr), length_(0) {}
|
||||
|
||||
Vector(T* data, size_t length) : start_(data), length_(length) {
|
||||
DCHECK(length == 0 || data != nullptr);
|
||||
}
|
||||
|
||||
template <int N>
|
||||
explicit Vector(T (&arr)[N]) : start_(arr), length_(N) {}
|
||||
explicit constexpr Vector(T (&arr)[N]) : start_(arr), length_(N) {}
|
||||
|
||||
static Vector<T> New(int length) {
|
||||
return Vector<T>(NewArray<T>(length), length);
|
||||
@ -47,13 +47,13 @@ class Vector {
|
||||
}
|
||||
|
||||
// Returns the length of the vector as a size_t.
|
||||
size_t size() const { return length_; }
|
||||
constexpr size_t size() const { return length_; }
|
||||
|
||||
// Returns whether or not the vector is empty.
|
||||
bool is_empty() const { return length_ == 0; }
|
||||
constexpr bool is_empty() const { return length_ == 0; }
|
||||
|
||||
// Returns the pointer to the start of the data in the vector.
|
||||
T* start() const { return start_; }
|
||||
constexpr T* start() const { return start_; }
|
||||
|
||||
// Access individual vector elements - checks bounds in debug mode.
|
||||
T& operator[](size_t index) const {
|
||||
@ -65,11 +65,14 @@ class Vector {
|
||||
|
||||
T& first() { return start_[0]; }
|
||||
|
||||
T& last() { return start_[length_ - 1]; }
|
||||
T& last() {
|
||||
DCHECK_LT(0, length_);
|
||||
return start_[length_ - 1];
|
||||
}
|
||||
|
||||
typedef T* iterator;
|
||||
inline iterator begin() const { return &start_[0]; }
|
||||
inline iterator end() const { return &start_[length_]; }
|
||||
constexpr iterator begin() const { return start_; }
|
||||
constexpr iterator end() const { return start_ + length_; }
|
||||
|
||||
// Returns a clone of this vector with a new backing store.
|
||||
Vector<T> Clone() const {
|
||||
@ -130,8 +133,8 @@ class Vector {
|
||||
// Factory method for creating empty vectors.
|
||||
static Vector<T> empty() { return Vector<T>(nullptr, 0); }
|
||||
|
||||
template<typename S>
|
||||
static Vector<T> cast(Vector<S> input) {
|
||||
template <typename S>
|
||||
static constexpr Vector<T> cast(Vector<S> input) {
|
||||
return Vector<T>(reinterpret_cast<T*>(input.start()),
|
||||
input.length() * sizeof(S) / sizeof(T));
|
||||
}
|
||||
@ -214,7 +217,7 @@ inline Vector<char> MutableCStrVector(char* data, int max) {
|
||||
}
|
||||
|
||||
template <typename T, int N>
|
||||
inline Vector<T> ArrayVector(T (&arr)[N]) {
|
||||
inline constexpr Vector<T> ArrayVector(T (&arr)[N]) {
|
||||
return Vector<T>(arr);
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,7 @@ v8_source_set("cctest_sources") {
|
||||
"compiler/test-run-unwinding-info.cc",
|
||||
"compiler/test-run-variables.cc",
|
||||
"compiler/test-run-wasm-machops.cc",
|
||||
"compiler/value-helper.cc",
|
||||
"compiler/value-helper.h",
|
||||
"expression-type-collector-macros.h",
|
||||
"gay-fixed.cc",
|
||||
|
@ -75,6 +75,7 @@
|
||||
'compiler/test-run-stubs.cc',
|
||||
'compiler/test-run-variables.cc',
|
||||
'compiler/test-run-wasm-machops.cc',
|
||||
'compiler/value-helper.cc',
|
||||
'compiler/value-helper.h',
|
||||
'cctest.cc',
|
||||
'cctest.h',
|
||||
|
@ -285,7 +285,7 @@ TEST(CompareWrapper) {
|
||||
|
||||
|
||||
void Int32BinopInputShapeTester::TestAllInputShapes() {
|
||||
std::vector<int32_t> inputs = ValueHelper::int32_vector();
|
||||
Vector<const int32_t> inputs = ValueHelper::int32_vector();
|
||||
int num_int_inputs = static_cast<int>(inputs.size());
|
||||
if (num_int_inputs > 16) num_int_inputs = 16; // limit to 16 inputs
|
||||
|
||||
|
21
test/cctest/compiler/value-helper.cc
Normal file
21
test/cctest/compiler/value-helper.cc
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "test/cctest/compiler/value-helper.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
// Define constexpr arrays of ValueHelper for external references.
|
||||
constexpr int8_t ValueHelper::int8_array[];
|
||||
constexpr int16_t ValueHelper::int16_array[];
|
||||
constexpr uint32_t ValueHelper::uint32_array[];
|
||||
constexpr uint64_t ValueHelper::uint64_array[];
|
||||
constexpr float ValueHelper::float32_array[];
|
||||
constexpr double ValueHelper::float64_array[];
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
@ -7,9 +7,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "src/base/template-utils.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
@ -60,283 +62,277 @@ class ValueHelper {
|
||||
CheckHeapConstant(isolate_->heap()->false_value(), node);
|
||||
}
|
||||
|
||||
static std::vector<float> float32_vector() {
|
||||
static const float nan = std::numeric_limits<float>::quiet_NaN();
|
||||
static const float kValues[] = {
|
||||
-std::numeric_limits<float>::infinity(),
|
||||
-2.70497e+38f,
|
||||
-1.4698e+37f,
|
||||
-1.22813e+35f,
|
||||
-1.20555e+35f,
|
||||
-1.34584e+34f,
|
||||
-1.0079e+32f,
|
||||
-6.49364e+26f,
|
||||
-3.06077e+25f,
|
||||
-1.46821e+25f,
|
||||
-1.17658e+23f,
|
||||
-1.9617e+22f,
|
||||
-2.7357e+20f,
|
||||
-9223372036854775808.0f, // INT64_MIN
|
||||
-1.48708e+13f,
|
||||
-1.89633e+12f,
|
||||
-4.66622e+11f,
|
||||
-2.22581e+11f,
|
||||
-1.45381e+10f,
|
||||
-2147483904.0f, // First float32 after INT32_MIN
|
||||
-2147483648.0f, // INT32_MIN
|
||||
-2147483520.0f, // Last float32 before INT32_MIN
|
||||
-1.3956e+09f,
|
||||
-1.32951e+09f,
|
||||
-1.30721e+09f,
|
||||
-1.19756e+09f,
|
||||
-9.26822e+08f,
|
||||
-6.35647e+08f,
|
||||
-4.00037e+08f,
|
||||
-1.81227e+08f,
|
||||
-5.09256e+07f,
|
||||
-964300.0f,
|
||||
-192446.0f,
|
||||
-28455.0f,
|
||||
-27194.0f,
|
||||
-26401.0f,
|
||||
-20575.0f,
|
||||
-17069.0f,
|
||||
-9167.0f,
|
||||
-960.178f,
|
||||
-113.0f,
|
||||
-62.0f,
|
||||
-15.0f,
|
||||
-7.0f,
|
||||
-1.0f,
|
||||
-0.0256635f,
|
||||
-4.60374e-07f,
|
||||
-3.63759e-10f,
|
||||
-4.30175e-14f,
|
||||
-5.27385e-15f,
|
||||
-1.5707963267948966f,
|
||||
-1.48084e-15f,
|
||||
-2.220446049250313e-16f,
|
||||
-1.05755e-19f,
|
||||
-3.2995e-21f,
|
||||
-1.67354e-23f,
|
||||
-1.11885e-23f,
|
||||
-1.78506e-30f,
|
||||
-5.07594e-31f,
|
||||
-3.65799e-31f,
|
||||
-1.43718e-34f,
|
||||
-1.27126e-38f,
|
||||
-0.0f,
|
||||
0.0f,
|
||||
1.17549e-38f,
|
||||
1.56657e-37f,
|
||||
4.08512e-29f,
|
||||
3.31357e-28f,
|
||||
6.25073e-22f,
|
||||
4.1723e-13f,
|
||||
1.44343e-09f,
|
||||
1.5707963267948966f,
|
||||
5.27004e-08f,
|
||||
9.48298e-08f,
|
||||
5.57888e-07f,
|
||||
4.89988e-05f,
|
||||
0.244326f,
|
||||
1.0f,
|
||||
12.4895f,
|
||||
19.0f,
|
||||
47.0f,
|
||||
106.0f,
|
||||
538.324f,
|
||||
564.536f,
|
||||
819.124f,
|
||||
7048.0f,
|
||||
12611.0f,
|
||||
19878.0f,
|
||||
20309.0f,
|
||||
797056.0f,
|
||||
1.77219e+09f,
|
||||
2147483648.0f, // INT32_MAX + 1
|
||||
4294967296.0f, // UINT32_MAX + 1
|
||||
1.51116e+11f,
|
||||
4.18193e+13f,
|
||||
3.59167e+16f,
|
||||
9223372036854775808.0f, // INT64_MAX + 1
|
||||
18446744073709551616.0f, // UINT64_MAX + 1
|
||||
3.38211e+19f,
|
||||
2.67488e+20f,
|
||||
1.78831e+21f,
|
||||
9.20914e+21f,
|
||||
8.35654e+23f,
|
||||
1.4495e+24f,
|
||||
5.94015e+25f,
|
||||
4.43608e+30f,
|
||||
2.44502e+33f,
|
||||
2.61152e+33f,
|
||||
1.38178e+37f,
|
||||
1.71306e+37f,
|
||||
3.31899e+38f,
|
||||
3.40282e+38f,
|
||||
std::numeric_limits<float>::infinity(),
|
||||
nan,
|
||||
-nan,
|
||||
};
|
||||
return std::vector<float>(&kValues[0], &kValues[arraysize(kValues)]);
|
||||
static constexpr float float32_array[] = {
|
||||
-std::numeric_limits<float>::infinity(),
|
||||
-2.70497e+38f,
|
||||
-1.4698e+37f,
|
||||
-1.22813e+35f,
|
||||
-1.20555e+35f,
|
||||
-1.34584e+34f,
|
||||
-1.0079e+32f,
|
||||
-6.49364e+26f,
|
||||
-3.06077e+25f,
|
||||
-1.46821e+25f,
|
||||
-1.17658e+23f,
|
||||
-1.9617e+22f,
|
||||
-2.7357e+20f,
|
||||
-9223372036854775808.0f, // INT64_MIN
|
||||
-1.48708e+13f,
|
||||
-1.89633e+12f,
|
||||
-4.66622e+11f,
|
||||
-2.22581e+11f,
|
||||
-1.45381e+10f,
|
||||
-2147483904.0f, // First float32 after INT32_MIN
|
||||
-2147483648.0f, // INT32_MIN
|
||||
-2147483520.0f, // Last float32 before INT32_MIN
|
||||
-1.3956e+09f,
|
||||
-1.32951e+09f,
|
||||
-1.30721e+09f,
|
||||
-1.19756e+09f,
|
||||
-9.26822e+08f,
|
||||
-6.35647e+08f,
|
||||
-4.00037e+08f,
|
||||
-1.81227e+08f,
|
||||
-5.09256e+07f,
|
||||
-964300.0f,
|
||||
-192446.0f,
|
||||
-28455.0f,
|
||||
-27194.0f,
|
||||
-26401.0f,
|
||||
-20575.0f,
|
||||
-17069.0f,
|
||||
-9167.0f,
|
||||
-960.178f,
|
||||
-113.0f,
|
||||
-62.0f,
|
||||
-15.0f,
|
||||
-7.0f,
|
||||
-1.0f,
|
||||
-0.0256635f,
|
||||
-4.60374e-07f,
|
||||
-3.63759e-10f,
|
||||
-4.30175e-14f,
|
||||
-5.27385e-15f,
|
||||
-1.5707963267948966f,
|
||||
-1.48084e-15f,
|
||||
-2.220446049250313e-16f,
|
||||
-1.05755e-19f,
|
||||
-3.2995e-21f,
|
||||
-1.67354e-23f,
|
||||
-1.11885e-23f,
|
||||
-1.78506e-30f,
|
||||
-5.07594e-31f,
|
||||
-3.65799e-31f,
|
||||
-1.43718e-34f,
|
||||
-1.27126e-38f,
|
||||
-0.0f,
|
||||
0.0f,
|
||||
1.17549e-38f,
|
||||
1.56657e-37f,
|
||||
4.08512e-29f,
|
||||
3.31357e-28f,
|
||||
6.25073e-22f,
|
||||
4.1723e-13f,
|
||||
1.44343e-09f,
|
||||
1.5707963267948966f,
|
||||
5.27004e-08f,
|
||||
9.48298e-08f,
|
||||
5.57888e-07f,
|
||||
4.89988e-05f,
|
||||
0.244326f,
|
||||
1.0f,
|
||||
12.4895f,
|
||||
19.0f,
|
||||
47.0f,
|
||||
106.0f,
|
||||
538.324f,
|
||||
564.536f,
|
||||
819.124f,
|
||||
7048.0f,
|
||||
12611.0f,
|
||||
19878.0f,
|
||||
20309.0f,
|
||||
797056.0f,
|
||||
1.77219e+09f,
|
||||
2147483648.0f, // INT32_MAX + 1
|
||||
4294967296.0f, // UINT32_MAX + 1
|
||||
1.51116e+11f,
|
||||
4.18193e+13f,
|
||||
3.59167e+16f,
|
||||
9223372036854775808.0f, // INT64_MAX + 1
|
||||
18446744073709551616.0f, // UINT64_MAX + 1
|
||||
3.38211e+19f,
|
||||
2.67488e+20f,
|
||||
1.78831e+21f,
|
||||
9.20914e+21f,
|
||||
8.35654e+23f,
|
||||
1.4495e+24f,
|
||||
5.94015e+25f,
|
||||
4.43608e+30f,
|
||||
2.44502e+33f,
|
||||
2.61152e+33f,
|
||||
1.38178e+37f,
|
||||
1.71306e+37f,
|
||||
3.31899e+38f,
|
||||
3.40282e+38f,
|
||||
std::numeric_limits<float>::infinity(),
|
||||
std::numeric_limits<float>::quiet_NaN(),
|
||||
-std::numeric_limits<float>::quiet_NaN()};
|
||||
|
||||
static constexpr Vector<const float> float32_vector() {
|
||||
return ArrayVector(float32_array);
|
||||
}
|
||||
|
||||
static std::vector<double> float64_vector() {
|
||||
static const double nan = std::numeric_limits<double>::quiet_NaN();
|
||||
static const double values[] = {-2e66,
|
||||
-2.220446049250313e-16,
|
||||
-9223373136366403584.0,
|
||||
-9223372036854775808.0, // INT64_MIN
|
||||
-2147483649.5,
|
||||
-2147483648.25,
|
||||
-2147483648.0,
|
||||
-2147483647.875,
|
||||
-2147483647.125,
|
||||
-2147483647.0,
|
||||
-999.75,
|
||||
-2e66,
|
||||
-1.75,
|
||||
-1.5707963267948966,
|
||||
-1.0,
|
||||
-0.5,
|
||||
-0.0,
|
||||
0.0,
|
||||
3e-88,
|
||||
0.125,
|
||||
0.25,
|
||||
0.375,
|
||||
0.5,
|
||||
1.0,
|
||||
1.17549e-38,
|
||||
1.56657e-37,
|
||||
1.0000001,
|
||||
1.25,
|
||||
1.5707963267948966,
|
||||
2,
|
||||
3.1e7,
|
||||
5.125,
|
||||
6.25,
|
||||
888,
|
||||
982983.25,
|
||||
2147483647.0,
|
||||
2147483647.375,
|
||||
2147483647.75,
|
||||
2147483648.0,
|
||||
2147483648.25,
|
||||
2147483649.25,
|
||||
9223372036854775808.0, // INT64_MAX + 1
|
||||
9223373136366403584.0,
|
||||
18446744073709551616.0, // UINT64_MAX + 1
|
||||
2e66,
|
||||
V8_INFINITY,
|
||||
-V8_INFINITY,
|
||||
-nan,
|
||||
nan};
|
||||
return std::vector<double>(&values[0], &values[arraysize(values)]);
|
||||
static constexpr double float64_array[] = {
|
||||
-2e66,
|
||||
-2.220446049250313e-16,
|
||||
-9223373136366403584.0,
|
||||
-9223372036854775808.0, // INT64_MIN
|
||||
-2147483649.5,
|
||||
-2147483648.25,
|
||||
-2147483648.0,
|
||||
-2147483647.875,
|
||||
-2147483647.125,
|
||||
-2147483647.0,
|
||||
-999.75,
|
||||
-2e66,
|
||||
-1.75,
|
||||
-1.5707963267948966,
|
||||
-1.0,
|
||||
-0.5,
|
||||
-0.0,
|
||||
0.0,
|
||||
3e-88,
|
||||
0.125,
|
||||
0.25,
|
||||
0.375,
|
||||
0.5,
|
||||
1.0,
|
||||
1.17549e-38,
|
||||
1.56657e-37,
|
||||
1.0000001,
|
||||
1.25,
|
||||
1.5707963267948966,
|
||||
2,
|
||||
3.1e7,
|
||||
5.125,
|
||||
6.25,
|
||||
888,
|
||||
982983.25,
|
||||
2147483647.0,
|
||||
2147483647.375,
|
||||
2147483647.75,
|
||||
2147483648.0,
|
||||
2147483648.25,
|
||||
2147483649.25,
|
||||
9223372036854775808.0, // INT64_MAX + 1
|
||||
9223373136366403584.0,
|
||||
18446744073709551616.0, // UINT64_MAX + 1
|
||||
2e66,
|
||||
V8_INFINITY,
|
||||
-V8_INFINITY,
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
-std::numeric_limits<double>::quiet_NaN()};
|
||||
|
||||
static constexpr Vector<const double> float64_vector() {
|
||||
return ArrayVector(float64_array);
|
||||
}
|
||||
|
||||
static const std::vector<int32_t> int32_vector() {
|
||||
std::vector<uint32_t> values = uint32_vector();
|
||||
return std::vector<int32_t>(values.begin(), values.end());
|
||||
static constexpr uint32_t uint32_array[] = {
|
||||
0x00000000, 0x00000001, 0xffffffff, 0x1b09788b, 0x04c5fce8, 0xcc0de5bf,
|
||||
// This row is useful for testing lea optimizations on intel.
|
||||
0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000008, 0x00000009,
|
||||
0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344,
|
||||
0x0000009e, 0x00000043, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c,
|
||||
0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00,
|
||||
0x761c4761, 0x80000000, 0x88888888, 0xa0000000, 0xdddddddd, 0xe0000000,
|
||||
0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff,
|
||||
0x000fffff, 0x0007ffff, 0x0003ffff, 0x0001ffff, 0x0000ffff, 0x00007fff,
|
||||
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff};
|
||||
|
||||
static constexpr Vector<const uint32_t> uint32_vector() {
|
||||
return ArrayVector(uint32_array);
|
||||
}
|
||||
|
||||
static const std::vector<uint32_t> uint32_vector() {
|
||||
static const uint32_t kValues[] = {
|
||||
0x00000000, 0x00000001, 0xffffffff, 0x1b09788b, 0x04c5fce8, 0xcc0de5bf,
|
||||
// This row is useful for testing lea optimizations on intel.
|
||||
0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000008, 0x00000009,
|
||||
0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344,
|
||||
0x0000009e, 0x00000043, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c,
|
||||
0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00,
|
||||
0x761c4761, 0x80000000, 0x88888888, 0xa0000000, 0xdddddddd, 0xe0000000,
|
||||
0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff,
|
||||
0x000fffff, 0x0007ffff, 0x0003ffff, 0x0001ffff, 0x0000ffff, 0x00007fff,
|
||||
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff};
|
||||
return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]);
|
||||
static constexpr Vector<const int32_t> int32_vector() {
|
||||
return Vector<const int32_t>::cast(uint32_vector());
|
||||
}
|
||||
|
||||
static const std::vector<int64_t> int64_vector() {
|
||||
std::vector<uint64_t> values = uint64_vector();
|
||||
return std::vector<int64_t>(values.begin(), values.end());
|
||||
static constexpr uint64_t uint64_array[] = {
|
||||
0x00000000, 0x00000001, 0xffffffff,
|
||||
0x1b09788b, 0x04c5fce8, 0xcc0de5bf,
|
||||
0x00000002, 0x00000003, 0x00000004,
|
||||
0x00000005, 0x00000008, 0x00000009,
|
||||
0xffffffffffffffff, 0xfffffffffffffffe, 0xfffffffffffffffd,
|
||||
0x0000000000000000, 0x0000000100000000, 0xffffffff00000000,
|
||||
0x1b09788b00000000, 0x04c5fce800000000, 0xcc0de5bf00000000,
|
||||
0x0000000200000000, 0x0000000300000000, 0x0000000400000000,
|
||||
0x0000000500000000, 0x0000000800000000, 0x0000000900000000,
|
||||
0x273a798e187937a3, 0xece3af835495a16b, 0x0b668ecc11223344,
|
||||
0x0000009e, 0x00000043, 0x0000af73,
|
||||
0x0000116b, 0x00658ecc, 0x002b3b4c,
|
||||
0x88776655, 0x70000000, 0x07200000,
|
||||
0x7fffffff, 0x56123761, 0x7fffff00,
|
||||
0x761c4761eeeeeeee, 0x80000000eeeeeeee, 0x88888888dddddddd,
|
||||
0xa0000000dddddddd, 0xddddddddaaaaaaaa, 0xe0000000aaaaaaaa,
|
||||
0xeeeeeeeeeeeeeeee, 0xfffffffdeeeeeeee, 0xf0000000dddddddd,
|
||||
0x007fffffdddddddd, 0x003fffffaaaaaaaa, 0x001fffffaaaaaaaa,
|
||||
0x000fffff, 0x0007ffff, 0x0003ffff,
|
||||
0x0001ffff, 0x0000ffff, 0x00007fff,
|
||||
0x00003fff, 0x00001fff, 0x00000fff,
|
||||
0x000007ff, 0x000003ff, 0x000001ff,
|
||||
0x00003fffffffffff, 0x00001fffffffffff, 0x00000fffffffffff,
|
||||
0x000007ffffffffff, 0x000003ffffffffff, 0x000001ffffffffff,
|
||||
0x8000008000000000, 0x8000008000000001, 0x8000000000000400,
|
||||
0x8000000000000401, 0x0000000000000020};
|
||||
|
||||
static constexpr Vector<const uint64_t> uint64_vector() {
|
||||
return ArrayVector(uint64_array);
|
||||
}
|
||||
|
||||
static const std::vector<uint64_t> uint64_vector() {
|
||||
static const uint64_t kValues[] = {
|
||||
0x00000000, 0x00000001, 0xffffffff,
|
||||
0x1b09788b, 0x04c5fce8, 0xcc0de5bf,
|
||||
0x00000002, 0x00000003, 0x00000004,
|
||||
0x00000005, 0x00000008, 0x00000009,
|
||||
0xffffffffffffffff, 0xfffffffffffffffe, 0xfffffffffffffffd,
|
||||
0x0000000000000000, 0x0000000100000000, 0xffffffff00000000,
|
||||
0x1b09788b00000000, 0x04c5fce800000000, 0xcc0de5bf00000000,
|
||||
0x0000000200000000, 0x0000000300000000, 0x0000000400000000,
|
||||
0x0000000500000000, 0x0000000800000000, 0x0000000900000000,
|
||||
0x273a798e187937a3, 0xece3af835495a16b, 0x0b668ecc11223344,
|
||||
0x0000009e, 0x00000043, 0x0000af73,
|
||||
0x0000116b, 0x00658ecc, 0x002b3b4c,
|
||||
0x88776655, 0x70000000, 0x07200000,
|
||||
0x7fffffff, 0x56123761, 0x7fffff00,
|
||||
0x761c4761eeeeeeee, 0x80000000eeeeeeee, 0x88888888dddddddd,
|
||||
0xa0000000dddddddd, 0xddddddddaaaaaaaa, 0xe0000000aaaaaaaa,
|
||||
0xeeeeeeeeeeeeeeee, 0xfffffffdeeeeeeee, 0xf0000000dddddddd,
|
||||
0x007fffffdddddddd, 0x003fffffaaaaaaaa, 0x001fffffaaaaaaaa,
|
||||
0x000fffff, 0x0007ffff, 0x0003ffff,
|
||||
0x0001ffff, 0x0000ffff, 0x00007fff,
|
||||
0x00003fff, 0x00001fff, 0x00000fff,
|
||||
0x000007ff, 0x000003ff, 0x000001ff,
|
||||
0x00003fffffffffff, 0x00001fffffffffff, 0x00000fffffffffff,
|
||||
0x000007ffffffffff, 0x000003ffffffffff, 0x000001ffffffffff,
|
||||
0x8000008000000000, 0x8000008000000001, 0x8000000000000400,
|
||||
0x8000000000000401, 0x0000000000000020};
|
||||
return std::vector<uint64_t>(&kValues[0], &kValues[arraysize(kValues)]);
|
||||
static constexpr Vector<const int64_t> int64_vector() {
|
||||
return Vector<const int64_t>::cast(uint64_vector());
|
||||
}
|
||||
|
||||
static const std::vector<double> nan_vector(size_t limit = 0) {
|
||||
static const double nan = std::numeric_limits<double>::quiet_NaN();
|
||||
static const double values[] = {-nan, -V8_INFINITY * -0.0,
|
||||
-V8_INFINITY * 0.0, V8_INFINITY * -0.0,
|
||||
V8_INFINITY * 0.0, nan};
|
||||
return std::vector<double>(&values[0], &values[arraysize(values)]);
|
||||
static constexpr int16_t int16_array[] = {
|
||||
0, 1, 2, INT16_MAX - 1, INT16_MAX, INT16_MIN, INT16_MIN + 1, -2, -1};
|
||||
|
||||
static constexpr Vector<const int16_t> int16_vector() {
|
||||
return ArrayVector(int16_array);
|
||||
}
|
||||
|
||||
static const std::vector<int16_t> int16_vector() {
|
||||
static const int16_t kValues[] = {
|
||||
0, 1, 2, INT16_MAX - 1, INT16_MAX, INT16_MIN, INT16_MIN + 1, -2, -1};
|
||||
return std::vector<int16_t>(&kValues[0], &kValues[arraysize(kValues)]);
|
||||
static constexpr Vector<const uint16_t> uint16_vector() {
|
||||
return Vector<const uint16_t>::cast(int16_vector());
|
||||
}
|
||||
|
||||
static const std::vector<uint16_t> uint16_vector() {
|
||||
std::vector<int16_t> values = int16_vector();
|
||||
return std::vector<uint16_t>(values.begin(), values.end());
|
||||
static constexpr int8_t int8_array[] = {
|
||||
0, 1, 2, INT8_MAX - 1, INT8_MAX, INT8_MIN, INT8_MIN + 1, -2, -1};
|
||||
|
||||
static constexpr Vector<const int8_t> int8_vector() {
|
||||
return ArrayVector(int8_array);
|
||||
}
|
||||
|
||||
static const std::vector<int8_t> int8_vector() {
|
||||
static const int8_t kValues[] = {
|
||||
0, 1, 2, INT8_MAX - 1, INT8_MAX, INT8_MIN, INT8_MIN + 1, -2, -1};
|
||||
return std::vector<int8_t>(&kValues[0], &kValues[arraysize(kValues)]);
|
||||
static constexpr Vector<const uint8_t> uint8_vector() {
|
||||
return Vector<const uint8_t>::cast(ArrayVector(int8_array));
|
||||
}
|
||||
|
||||
static const std::vector<uint8_t> uint8_vector() {
|
||||
std::vector<int8_t> values = int8_vector();
|
||||
return std::vector<uint8_t>(values.begin(), values.end());
|
||||
}
|
||||
static constexpr uint32_t ror_array[31] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
|
||||
static const std::vector<uint32_t> ror_vector() {
|
||||
static const uint32_t kValues[31] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]);
|
||||
static constexpr Vector<const uint32_t> ror_vector() {
|
||||
return ArrayVector(ror_array);
|
||||
}
|
||||
};
|
||||
|
||||
// Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... }
|
||||
// Watch out, these macros aren't hygenic; they pollute your scope. Thanks STL.
|
||||
#define FOR_INPUTS(ctype, itype, var) \
|
||||
std::vector<ctype> var##_vec = \
|
||||
::v8::internal::compiler::ValueHelper::itype##_vector(); \
|
||||
for (std::vector<ctype>::iterator var = var##_vec.begin(); \
|
||||
var != var##_vec.end(); ++var)
|
||||
#define FOR_INPUTS(ctype, itype, var) \
|
||||
Vector<const ctype> var##_vec = \
|
||||
::v8::internal::compiler::ValueHelper::itype##_vector(); \
|
||||
for (Vector<const ctype>::iterator var = var##_vec.begin(), \
|
||||
var##_end = var##_vec.end(); \
|
||||
var != var##_end; ++var)
|
||||
|
||||
#define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var)
|
||||
#define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var)
|
||||
|
@ -100,8 +100,7 @@ TEST(TestCWasmEntryArgPassing_int32) {
|
||||
WASM_I32_ADD(WASM_I32_MUL(WASM_I32V_1(2), WASM_GET_LOCAL(0)), WASM_ONE)},
|
||||
[](int32_t a) { return 2 * a + 1; });
|
||||
|
||||
std::vector<int32_t> test_values = compiler::ValueHelper::int32_vector();
|
||||
for (int32_t v : test_values) tester.CheckCall(v);
|
||||
FOR_INT32_INPUTS(v) { tester.CheckCall(*v); }
|
||||
}
|
||||
|
||||
// Pass int64_t, return double.
|
||||
@ -111,10 +110,7 @@ TEST(TestCWasmEntryArgPassing_double_int64) {
|
||||
WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))},
|
||||
[](int64_t a) { return static_cast<double>(a); });
|
||||
|
||||
std::vector<int64_t> test_values_i64 = compiler::ValueHelper::int64_vector();
|
||||
for (int64_t v : test_values_i64) {
|
||||
tester.CheckCall(v);
|
||||
}
|
||||
FOR_INT64_INPUTS(v) { tester.CheckCall(*v); }
|
||||
}
|
||||
|
||||
// Pass double, return int64_t.
|
||||
@ -124,9 +120,7 @@ TEST(TestCWasmEntryArgPassing_int64_double) {
|
||||
WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))},
|
||||
[](double d) { return static_cast<int64_t>(d); });
|
||||
|
||||
for (int64_t i : compiler::ValueHelper::int64_vector()) {
|
||||
tester.CheckCall(i);
|
||||
}
|
||||
FOR_INT64_INPUTS(i) { tester.CheckCall(*i); }
|
||||
}
|
||||
|
||||
// Pass float, return double.
|
||||
@ -138,8 +132,7 @@ TEST(TestCWasmEntryArgPassing_float_double) {
|
||||
WASM_F64(1))},
|
||||
[](float f) { return 2. * static_cast<double>(f) + 1.; });
|
||||
|
||||
std::vector<float> test_values = compiler::ValueHelper::float32_vector();
|
||||
for (float f : test_values) tester.CheckCall(f);
|
||||
FOR_FLOAT32_INPUTS(f) { tester.CheckCall(*f); }
|
||||
}
|
||||
|
||||
// Pass two doubles, return double.
|
||||
@ -149,11 +142,8 @@ TEST(TestCWasmEntryArgPassing_double_double) {
|
||||
WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))},
|
||||
[](double a, double b) { return a + b; });
|
||||
|
||||
std::vector<double> test_values = compiler::ValueHelper::float64_vector();
|
||||
for (double d1 : test_values) {
|
||||
for (double d2 : test_values) {
|
||||
tester.CheckCall(d1, d2);
|
||||
}
|
||||
FOR_FLOAT64_INPUTS(d1) {
|
||||
FOR_FLOAT64_INPUTS(d2) { tester.CheckCall(*d1, *d2); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,10 +166,11 @@ TEST(TestCWasmEntryArgPassing_AllTypes) {
|
||||
return 0. + a + b + c + d;
|
||||
});
|
||||
|
||||
std::vector<int32_t> test_values_i32 = compiler::ValueHelper::int32_vector();
|
||||
std::vector<int64_t> test_values_i64 = compiler::ValueHelper::int64_vector();
|
||||
std::vector<float> test_values_f32 = compiler::ValueHelper::float32_vector();
|
||||
std::vector<double> test_values_f64 = compiler::ValueHelper::float64_vector();
|
||||
Vector<const int32_t> test_values_i32 = compiler::ValueHelper::int32_vector();
|
||||
Vector<const int64_t> test_values_i64 = compiler::ValueHelper::int64_vector();
|
||||
Vector<const float> test_values_f32 = compiler::ValueHelper::float32_vector();
|
||||
Vector<const double> test_values_f64 =
|
||||
compiler::ValueHelper::float64_vector();
|
||||
size_t max_len =
|
||||
std::max(std::max(test_values_i32.size(), test_values_i64.size()),
|
||||
std::max(test_values_f32.size(), test_values_f64.size()));
|
||||
|
@ -101,8 +101,7 @@ TEST(TestArgumentPassing_int32) {
|
||||
WASM_GET_LOCAL(0), WASM_CALL_FUNCTION0(f2.function_index())},
|
||||
[](int32_t a) { return 2 * a + 1; });
|
||||
|
||||
std::vector<int32_t> test_values = compiler::ValueHelper::int32_vector();
|
||||
for (int32_t v : test_values) helper.CheckCall(v);
|
||||
FOR_INT32_INPUTS(v) { helper.CheckCall(*v); }
|
||||
}
|
||||
|
||||
// Pass int64_t, return double.
|
||||
@ -125,17 +124,13 @@ TEST(TestArgumentPassing_double_int64) {
|
||||
return static_cast<double>(a64 | b64);
|
||||
});
|
||||
|
||||
std::vector<int32_t> test_values_i32 = compiler::ValueHelper::int32_vector();
|
||||
for (int32_t v1 : test_values_i32) {
|
||||
for (int32_t v2 : test_values_i32) {
|
||||
helper.CheckCall(v1, v2);
|
||||
}
|
||||
FOR_INT32_INPUTS(v1) {
|
||||
FOR_INT32_INPUTS(v2) { helper.CheckCall(*v1, *v2); }
|
||||
}
|
||||
|
||||
std::vector<int64_t> test_values_i64 = compiler::ValueHelper::int64_vector();
|
||||
for (int64_t v : test_values_i64) {
|
||||
int32_t v1 = static_cast<int32_t>(v);
|
||||
int32_t v2 = static_cast<int32_t>(v >> 32);
|
||||
FOR_INT64_INPUTS(v) {
|
||||
int32_t v1 = static_cast<int32_t>(*v);
|
||||
int32_t v2 = static_cast<int32_t>(*v >> 32);
|
||||
helper.CheckCall(v1, v2);
|
||||
helper.CheckCall(v2, v1);
|
||||
}
|
||||
@ -176,8 +171,7 @@ TEST(TestArgumentPassing_float_double) {
|
||||
WASM_GET_LOCAL(0), WASM_CALL_FUNCTION0(f2.function_index())},
|
||||
[](float f) { return 2. * static_cast<double>(f) + 1.; });
|
||||
|
||||
std::vector<float> test_values = compiler::ValueHelper::float32_vector();
|
||||
for (float f : test_values) helper.CheckCall(f);
|
||||
FOR_FLOAT32_INPUTS(f) { helper.CheckCall(*f); }
|
||||
}
|
||||
|
||||
// Pass two doubles, return double.
|
||||
@ -193,11 +187,8 @@ TEST(TestArgumentPassing_double_double) {
|
||||
WASM_CALL_FUNCTION0(f2.function_index())},
|
||||
[](double a, double b) { return a + b; });
|
||||
|
||||
std::vector<double> test_values = compiler::ValueHelper::float64_vector();
|
||||
for (double d1 : test_values) {
|
||||
for (double d2 : test_values) {
|
||||
helper.CheckCall(d1, d2);
|
||||
}
|
||||
FOR_FLOAT64_INPUTS(d1) {
|
||||
FOR_FLOAT64_INPUTS(d2) { helper.CheckCall(*d1, *d2); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,10 +233,11 @@ TEST(TestArgumentPassing_AllTypes) {
|
||||
helper.CheckCall(a, b1, b0, c, d);
|
||||
};
|
||||
|
||||
std::vector<int32_t> test_values_i32 = compiler::ValueHelper::int32_vector();
|
||||
std::vector<int64_t> test_values_i64 = compiler::ValueHelper::int64_vector();
|
||||
std::vector<float> test_values_f32 = compiler::ValueHelper::float32_vector();
|
||||
std::vector<double> test_values_f64 = compiler::ValueHelper::float64_vector();
|
||||
Vector<const int32_t> test_values_i32 = compiler::ValueHelper::int32_vector();
|
||||
Vector<const int64_t> test_values_i64 = compiler::ValueHelper::int64_vector();
|
||||
Vector<const float> test_values_f32 = compiler::ValueHelper::float32_vector();
|
||||
Vector<const double> test_values_f64 =
|
||||
compiler::ValueHelper::float64_vector();
|
||||
size_t max_len =
|
||||
std::max(std::max(test_values_i32.size(), test_values_i64.size()),
|
||||
std::max(test_values_f32.size(), test_values_f64.size()));
|
||||
|
Loading…
Reference in New Issue
Block a user