summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/wasm/test-c-wasm-entry.cc')
-rw-r--r--deps/v8/test/cctest/wasm/test-c-wasm-entry.cc42
1 files changed, 19 insertions, 23 deletions
diff --git a/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc b/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc
index 4224e51fde..6907b8381e 100644
--- a/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc
+++ b/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc
@@ -30,7 +30,7 @@ class CWasmEntryArgTester {
public:
CWasmEntryArgTester(std::initializer_list<uint8_t> wasm_function_bytes,
std::function<ReturnType(Args...)> expected_fn)
- : runner_(kExecuteCompiled),
+ : runner_(kExecuteTurbofan),
isolate_(runner_.main_isolate()),
expected_fn_(expected_fn),
sig_(runner_.template CreateSig<ReturnType, Args...>()) {
@@ -62,7 +62,12 @@ class CWasmEntryArgTester {
Handle<Object> buffer_obj(reinterpret_cast<Object*>(arg_buffer.data()),
isolate_);
CHECK(!buffer_obj->IsHeapObject());
- Handle<Object> call_args[]{wasm_code_, buffer_obj};
+ Handle<Object> call_args[]{
+ (FLAG_wasm_jit_to_native
+ ? Handle<Object>::cast(isolate_->factory()->NewForeign(
+ wasm_code_.GetWasmCode()->instructions().start(), TENURED))
+ : Handle<Object>::cast(wasm_code_.GetCode())),
+ buffer_obj};
static_assert(
arraysize(call_args) == compiler::CWasmEntryParameters::kNumParameters,
"adapt this test");
@@ -88,7 +93,7 @@ class CWasmEntryArgTester {
std::function<ReturnType(Args...)> expected_fn_;
FunctionSig* sig_;
Handle<JSFunction> c_wasm_entry_fn_;
- Handle<Code> wasm_code_;
+ WasmCodeWrapper wasm_code_;
};
} // namespace
@@ -100,8 +105,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 +115,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 +125,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 +137,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 +147,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 +171,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()));