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

Unified Diff: src/runtime/runtime-test.cc

Issue 2204703002: [wasm] Get rid of extra wrappers when import another wasm export (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make test case code more clean Created 4 years, 4 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 | « src/runtime/runtime.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-test.cc
diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc
index 2232b190599a2b1a3025ea72bb44ef23596130ce..2e934403d9521e3fc385d118d0ae49437cd8f365 100644
--- a/src/runtime/runtime-test.cc
+++ b/src/runtime/runtime-test.cc
@@ -282,6 +282,70 @@ RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) {
return isolate->heap()->undefined_value();
}
+RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
+ // This only supports the case where the function being exported
+ // calls an intermediate function, and the intermediate function
+ // calls exactly one imported function
+ HandleScope scope(isolate);
+ CHECK(args.length() == 2);
+ // It takes two parameters, the first one is the JSFunction,
+ // The second one is the type
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
+ // If type is 0, it means that it is supposed to be a direct call into a WASM
+ // function
+ // If type is 1, it means that it is supposed to have wrappers
+ CONVERT_ARG_HANDLE_CHECKED(Smi, type, 1);
+ Handle<Code> export_code = handle(function->code());
+ CHECK(export_code->kind() == Code::JS_TO_WASM_FUNCTION);
+ int const mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
+ // check the type of the $export_fct
+ Handle<Code> export_fct;
+ int count = 0;
+ for (RelocIterator it(*export_code, mask); !it.done(); it.next()) {
+ RelocInfo* rinfo = it.rinfo();
+ Address target_address = rinfo->target_address();
+ Code* target = Code::GetCodeFromTargetAddress(target_address);
+ if (target->kind() == Code::WASM_FUNCTION) {
+ ++count;
+ export_fct = handle(target);
+ }
+ }
+ CHECK(count == 1);
+ // check the type of the intermediate_fct
+ Handle<Code> intermediate_fct;
+ count = 0;
+ for (RelocIterator it(*export_fct, mask); !it.done(); it.next()) {
+ RelocInfo* rinfo = it.rinfo();
+ Address target_address = rinfo->target_address();
+ Code* target = Code::GetCodeFromTargetAddress(target_address);
+ if (target->kind() == Code::WASM_FUNCTION) {
+ ++count;
+ intermediate_fct = handle(target);
+ }
+ }
+ CHECK(count == 1);
+ // check the type of the imported exported function, it should be also a WASM
+ // function in our case
+ Handle<Code> imported_fct;
+ Code::Kind target_kind;
+ if (type->value() == 0) {
+ target_kind = Code::WASM_FUNCTION;
+ } else if (type->value() == 1) {
+ target_kind = Code::WASM_TO_JS_FUNCTION;
+ }
+ count = 0;
+ for (RelocIterator it(*intermediate_fct, mask); !it.done(); it.next()) {
+ RelocInfo* rinfo = it.rinfo();
+ Address target_address = rinfo->target_address();
+ Code* target = Code::GetCodeFromTargetAddress(target_address);
+ if (target->kind() == target_kind) {
+ ++count;
+ imported_fct = handle(target);
+ }
+ }
+ CHECK_LE(count, 1);
+ return isolate->heap()->ToBoolean(count == 1);
+}
RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
HandleScope scope(isolate);
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698