Index: test/cctest/wasm/test-run-wasm-js.cc |
diff --git a/test/cctest/wasm/test-run-wasm-js.cc b/test/cctest/wasm/test-run-wasm-js.cc |
index 87662897fc2da1a14bc1a20ed3f33a8b889716e7..4a74128f506a06038312626fee825489e4373a61 100644 |
--- a/test/cctest/wasm/test-run-wasm-js.cc |
+++ b/test/cctest/wasm/test-run-wasm-js.cc |
@@ -97,36 +97,48 @@ |
} // namespace |
TEST(Run_Int32Sub_jswrapped) { |
- WasmRunner<int, int, int> r(kExecuteCompiled); |
- BUILD(r, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); |
+ CcTest::InitializeVM(); |
+ TestSignatures sigs; |
+ TestingModule module; |
+ WasmFunctionCompiler t(sigs.i_ii(), &module); |
+ BUILD(t, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
EXPECT_CALL(33, jsfunc, 44, 11); |
EXPECT_CALL(-8723487, jsfunc, -8000000, 723487); |
} |
TEST(Run_Float32Div_jswrapped) { |
- WasmRunner<float, float, float> r(kExecuteCompiled); |
- BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); |
+ CcTest::InitializeVM(); |
+ TestSignatures sigs; |
+ TestingModule module; |
+ WasmFunctionCompiler t(sigs.f_ff(), &module); |
+ BUILD(t, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
EXPECT_CALL(92, jsfunc, 46, 0.5); |
EXPECT_CALL(64, jsfunc, -16, -0.25); |
} |
TEST(Run_Float64Add_jswrapped) { |
- WasmRunner<double, double, double> r(kExecuteCompiled); |
- BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); |
+ CcTest::InitializeVM(); |
+ TestSignatures sigs; |
+ TestingModule module; |
+ WasmFunctionCompiler t(sigs.d_dd(), &module); |
+ BUILD(t, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
EXPECT_CALL(3, jsfunc, 2, 1); |
EXPECT_CALL(-5.5, jsfunc, -5.25, -0.25); |
} |
TEST(Run_I32Popcount_jswrapped) { |
- WasmRunner<int, int> r(kExecuteCompiled); |
- BUILD(r, WASM_I32_POPCNT(WASM_GET_LOCAL(0))); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); |
+ CcTest::InitializeVM(); |
+ TestSignatures sigs; |
+ TestingModule module; |
+ WasmFunctionCompiler t(sigs.i_i(), &module); |
+ BUILD(t, WASM_I32_POPCNT(WASM_GET_LOCAL(0))); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
EXPECT_CALL(2, jsfunc, 9, 0); |
EXPECT_CALL(3, jsfunc, 11, 0); |
@@ -134,13 +146,15 @@ |
} |
TEST(Run_CallJS_Add_jswrapped) { |
- WasmRunner<int, int> r(kExecuteCompiled); |
+ CcTest::InitializeVM(); |
TestSignatures sigs; |
+ TestingModule module; |
+ WasmFunctionCompiler t(sigs.i_i(), &module); |
uint32_t js_index = |
- r.module().AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })"); |
- BUILD(r, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0))); |
- |
- Handle<JSFunction> jsfunc = r.module().WrapCode(r.function()->func_index); |
+ module.AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })"); |
+ BUILD(t, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0))); |
+ |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
EXPECT_CALL(101, jsfunc, 2, -8); |
EXPECT_CALL(199, jsfunc, 100, -1); |
@@ -157,9 +171,9 @@ |
HandleScope scope(CcTest::InitIsolateOnce()); |
FunctionSig sig(1, num_params, types); |
- WasmRunner<void> r(kExecuteCompiled); |
- uint32_t js_index = AddJSSelector(&r.module(), &sig, which); |
- WasmFunctionCompiler& t = r.NewFunction(&sig); |
+ TestingModule module; |
+ uint32_t js_index = AddJSSelector(&module, &sig, which); |
+ WasmFunctionCompiler t(&sig, &module); |
{ |
std::vector<byte> code; |
@@ -175,7 +189,7 @@ |
t.Build(&code[0], &code[end]); |
} |
- Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
double expected = inputs.arg_d(which); |
EXPECT_CALL(expected, jsfunc, 0.0, 0.0); |
} |
@@ -231,10 +245,10 @@ |
type, type, type, type}; |
FunctionSig sig(1, num_params, types); |
- WasmRunner<void> r(kExecuteCompiled); |
- WasmFunctionCompiler& t = r.NewFunction(&sig); |
+ TestingModule module; |
+ WasmFunctionCompiler t(&sig, &module); |
BUILD(t, WASM_GET_LOCAL(which)); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
Handle<Object> args[] = { |
isolate->factory()->NewNumber(inputs.arg_d(0)), |
@@ -303,10 +317,10 @@ |
FunctionSig sig(1, num_params, types); |
for (int which = 0; which < num_params; which++) { |
- WasmRunner<void> r(kExecuteCompiled); |
- WasmFunctionCompiler& t = r.NewFunction(&sig); |
+ TestingModule module; |
+ WasmFunctionCompiler t(&sig, &module); |
BUILD(t, WASM_GET_LOCAL(which)); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
Handle<Object> args[] = {isolate->factory()->NewNumber(inputs.arg_d(0)), |
isolate->factory()->NewNumber(inputs.arg_d(1)), |
@@ -397,8 +411,6 @@ |
LocalType types[kMaxParams + 1] = {type, type, type, type, type, type, |
type, type, type, type, type}; |
FunctionSig sig(1, num_params, types); |
- i::AccountingAllocator allocator; |
- Zone zone(&allocator, ZONE_NAME); |
// Build the calling code. |
std::vector<byte> code; |
@@ -407,21 +419,21 @@ |
ADD_CODE(code, WASM_GET_LOCAL(i)); |
} |
- uint8_t predicted_js_index = 1; |
- ADD_CODE(code, kExprCallFunction, predicted_js_index); |
+ ADD_CODE(code, kExprCallFunction, 0); |
size_t end = code.size(); |
code.push_back(0); |
// Call different select JS functions. |
for (int which = 0; which < num_params; which++) { |
- WasmRunner<void> r(kExecuteCompiled); |
- uint32_t js_index = AddJSSelector(&r.module(), &sig, which); |
- CHECK_EQ(predicted_js_index, js_index); |
- WasmFunctionCompiler& t = r.NewFunction(&sig); |
+ HandleScope scope(isolate); |
+ TestingModule module; |
+ uint32_t js_index = AddJSSelector(&module, &sig, which); |
+ CHECK_EQ(0u, js_index); |
+ WasmFunctionCompiler t(&sig, &module); |
t.Build(&code[0], &code[end]); |
- Handle<JSFunction> jsfunc = r.module().WrapCode(t.function_index()); |
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd()); |
Handle<Object> args[] = { |
factory->NewNumber(inputs.arg_d(0)), |