Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: test/cctest/wasm/test-run-wasm-js.cc

Issue 1876783002: Move two test-internal functions up to header file (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@show-wasm-frames-1
Patch Set: update depends-on Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6d95d6e0fcdac0c791f94051e67a5f92d404efbe..aacf24e8c76802395a7a6b5032eb293a8341887b 100644
--- a/test/cctest/wasm/test-run-wasm-js.cc
+++ b/test/cctest/wasm/test-run-wasm-js.cc
@@ -49,22 +49,6 @@ class PredictableInputValues {
};
-uint32_t AddJsFunction(TestingModule* module, FunctionSig* sig,
- const char* source) {
- Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
- *v8::Local<v8::Function>::Cast(CompileRun(source))));
- module->AddFunction(sig, Handle<Code>::null());
- uint32_t index = static_cast<uint32_t>(module->module->functions.size() - 1);
- Isolate* isolate = CcTest::InitIsolateOnce();
- WasmName module_name = {"test", 4};
- WasmName function_name = {nullptr, 0};
- Handle<Code> code = CompileWasmToJSWrapper(isolate, module, jsfunc, sig,
- module_name, function_name);
- module->instance->function_code[index] = code;
- return index;
-}
-
-
uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) {
const int kMaxParams = 11;
static const char* formals[kMaxParams] = {"",
@@ -86,19 +70,7 @@ uint32_t AddJSSelector(TestingModule* module, FunctionSig* sig, int which) {
SNPrintF(source, "(function(%s) { return %c; })",
formals[sig->parameter_count()], param);
- return AddJsFunction(module, sig, source.start());
-}
-
-
-Handle<JSFunction> WrapCode(ModuleEnv* module, uint32_t index) {
- Isolate* isolate = module->module->shared_isolate;
- // Wrap the code so it can be called as a JS function.
- Handle<String> name = isolate->factory()->NewStringFromStaticChars("main");
- Handle<JSObject> module_object = Handle<JSObject>(0, isolate);
- Handle<Code> code = module->instance->function_code[index];
- WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context());
- return compiler::CompileJSToWasmWrapper(isolate, module, name, code,
- module_object, index);
+ return module->AddJsFunction(sig, source.start());
}
@@ -134,7 +106,7 @@ TEST(Run_Int32Sub_jswrapped) {
TestingModule module;
WasmFunctionCompiler t(sigs.i_ii(), &module);
BUILD(t, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
EXPECT_CALL(33, jsfunc, 44, 11);
EXPECT_CALL(-8723487, jsfunc, -8000000, 723487);
@@ -146,7 +118,7 @@ TEST(Run_Float32Div_jswrapped) {
TestingModule module;
WasmFunctionCompiler t(sigs.f_ff(), &module);
BUILD(t, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
EXPECT_CALL(92, jsfunc, 46, 0.5);
EXPECT_CALL(64, jsfunc, -16, -0.25);
@@ -158,7 +130,7 @@ TEST(Run_Float64Add_jswrapped) {
TestingModule module;
WasmFunctionCompiler t(sigs.d_dd(), &module);
BUILD(t, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
EXPECT_CALL(3, jsfunc, 2, 1);
EXPECT_CALL(-5.5, jsfunc, -5.25, -0.25);
@@ -170,13 +142,11 @@ TEST(Run_I32Popcount_jswrapped) {
TestingModule module;
WasmFunctionCompiler t(sigs.i_i(), &module);
BUILD(t, WASM_I32_POPCNT(WASM_GET_LOCAL(0)));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
EXPECT_CALL(2, jsfunc, 9, 0);
EXPECT_CALL(3, jsfunc, 11, 0);
EXPECT_CALL(6, jsfunc, 0x3F, 0);
-
- USE(AddJsFunction);
}
@@ -185,10 +155,10 @@ TEST(Run_CallJS_Add_jswrapped) {
TestingModule module;
WasmFunctionCompiler t(sigs.i_i(), &module);
uint32_t js_index =
- AddJsFunction(&module, sigs.i_i(), "(function(a) { return a + 99; })");
+ module.AddJsFunction(sigs.i_i(), "(function(a) { return a + 99; })");
BUILD(t, WASM_CALL_FUNCTION(js_index, WASM_GET_LOCAL(0)));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
EXPECT_CALL(101, jsfunc, 2, -8);
EXPECT_CALL(199, jsfunc, 100, -1);
@@ -223,7 +193,7 @@ void RunJSSelectTest(int which) {
t.Build(&code[0], &code[end]);
}
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
double expected = inputs.arg_d(which);
EXPECT_CALL(expected, jsfunc, 0.0, 0.0);
}
@@ -260,7 +230,7 @@ void RunWASMSelectTest(int which) {
TestingModule module;
WasmFunctionCompiler t(&sig, &module);
BUILD(t, WASM_GET_LOCAL(which));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
Handle<Object> args[] = {
isolate->factory()->NewNumber(inputs.arg_d(0)),
@@ -310,7 +280,7 @@ void RunWASMSelectAlignTest(int num_args, int num_params) {
TestingModule module;
WasmFunctionCompiler t(&sig, &module);
BUILD(t, WASM_GET_LOCAL(which));
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
Handle<Object> args[] = {isolate->factory()->NewNumber(inputs.arg_d(0)),
isolate->factory()->NewNumber(inputs.arg_d(1)),
@@ -418,7 +388,7 @@ void RunJSSelectAlignTest(int num_args, int num_params) {
WasmFunctionCompiler t(&sig, &module);
t.Build(&code[0], &code[end]);
- Handle<JSFunction> jsfunc = WrapCode(&module, t.CompileAndAdd());
+ Handle<JSFunction> jsfunc = module.WrapCode(t.CompileAndAdd());
Handle<Object> args[] = {
factory->NewNumber(inputs.arg_d(0)),
« no previous file with comments | « no previous file | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698