[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: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44346}
This commit is contained in:
Clemens Hammacher 2017-04-03 10:25:59 +02:00 committed by Commit Bot
parent d38334c575
commit 7a3a1eec12

View File

@ -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();