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

Unified Diff: test/cctest/wasm/wasm-run-utils.h

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 | « test/cctest/wasm/test-run-wasm-js.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/wasm-run-utils.h
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h
index 1e85f46887cb7783e6c30cef057a092295edb93d..87e4a0933a3c482a1b82f0861b406e4a9ad4f0e2 100644
--- a/test/cctest/wasm/wasm-run-utils.h
+++ b/test/cctest/wasm/wasm-run-utils.h
@@ -159,7 +159,7 @@ class TestingModule : public ModuleEnv {
rng.NextBytes(raw, end - raw);
}
- int AddFunction(FunctionSig* sig, Handle<Code> code) {
+ uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) {
if (module->functions.size() == 0) {
// TODO(titzer): Reserving space here to avoid the underlying WasmFunction
// structs from moving.
@@ -173,6 +173,30 @@ class TestingModule : public ModuleEnv {
return index;
}
+ uint32_t AddJsFunction(FunctionSig* sig, const char* source) {
+ Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
+ *v8::Local<v8::Function>::Cast(CompileRun(source))));
+ uint32_t index = AddFunction(sig, Handle<Code>::null());
+ Isolate* isolate = module->shared_isolate;
+ WasmName module_name = {"test", 4};
+ WasmName function_name = {nullptr, 0};
+ Handle<Code> code = CompileWasmToJSWrapper(isolate, this, jsfunc, sig,
+ module_name, function_name);
+ instance->function_code[index] = code;
+ return index;
+ }
+
+ Handle<JSFunction> WrapCode(uint32_t index) {
+ Isolate* isolate = 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 = instance->function_code[index];
+ WasmJs::InstallWasmFunctionMap(isolate, isolate->native_context());
+ return compiler::CompileJSToWasmWrapper(isolate, this, name, code,
+ module_object, index);
+ }
+
void SetFunctionCode(uint32_t index, Handle<Code> code) {
instance->function_code[index] = code;
}
« no previous file with comments | « test/cctest/wasm/test-run-wasm-js.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698