[wasm] Make an "incumbent context" available for module instantiation
A Wasm module's start function might be imported from JavaScript, and as such might contain calls to Blink. For such a case, we must make sure that an "incumbent context" is available. See microtask queue handling for a similar example. Bug: chromium:1096558 Change-Id: I2e3c0fc20d4e3581e490822c3ac63ce2c5e1e990 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2284982 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#68760}
This commit is contained in:
parent
01e59c4bd9
commit
8ba517e194
@ -4,6 +4,7 @@
|
||||
|
||||
#include "src/wasm/module-instantiate.h"
|
||||
|
||||
#include "src/api/api.h"
|
||||
#include "src/asmjs/asm-js.h"
|
||||
#include "src/logging/counters.h"
|
||||
#include "src/numbers/conversions-inl.h"
|
||||
@ -641,10 +642,15 @@ bool InstanceBuilder::ExecuteStartFunction() {
|
||||
if (start_function_.is_null()) return true; // No start function.
|
||||
|
||||
HandleScope scope(isolate_);
|
||||
// We have to make sure that an "incumbent context" is available in case
|
||||
// the start function calls out to Blink.
|
||||
HandleScopeImplementer* hsi = isolate_->handle_scope_implementer();
|
||||
hsi->EnterContext(isolate_->context());
|
||||
// Call the JS function.
|
||||
Handle<Object> undefined = isolate_->factory()->undefined_value();
|
||||
MaybeHandle<Object> retval =
|
||||
Execution::Call(isolate_, start_function_, undefined, 0, nullptr);
|
||||
hsi->LeaveContext();
|
||||
|
||||
if (retval.is_null()) {
|
||||
DCHECK(isolate_->has_pending_exception());
|
||||
|
Loading…
Reference in New Issue
Block a user