Commit 7a3a1eec authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [interpreter] Fix receiver on calling imports

When calling imported functions, we were always using the global object
as receiver. This is incorrect for strict functions, which should have
undefined as receiver.
This CL fixes this also for the interpreter, making us pass
test/mjsunit/wasm/receiver.js with --wasm-interpret-all.

R=ahaas@chromium.org
BUG=v8:5822
TEST=test/mjsunit/wasm/receiver

Change-Id: Ib7d637083245f67b668c11540e3c3473bc167129
Reviewed-on: https://chromium-review.googlesource.com/465986
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44346}
parent d38334c5
......@@ -2128,8 +2128,16 @@ class ThreadImpl {
signature->GetParam(i)));
}
MaybeHandle<Object> maybe_retval = Execution::Call(
isolate, target, isolate->global_proxy(), num_args, args.data());
// The receiver is the global proxy if in sloppy mode (default), undefined
// if in strict mode.
Handle<Object> receiver = isolate->global_proxy();
if (target->IsJSFunction() &&
is_strict(JSFunction::cast(*target)->shared()->language_mode())) {
receiver = isolate->factory()->undefined_value();
}
MaybeHandle<Object> maybe_retval =
Execution::Call(isolate, target, receiver, num_args, args.data());
if (maybe_retval.is_null()) return TryHandleException(isolate);
Handle<Object> retval = maybe_retval.ToHandleChecked();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment