Commit b111748d authored by Andreas Haas's avatar Andreas Haas Committed by V8 LUCI CQ

[wasm] Enter the native context when executing the start function

The wpt test external/wpt/wasm/jsapi/functions/entry.html failed
because the current context was entered when executing the start
function instead of the native context. The test crashed because in
GetEnteredOrMicrotaskContext a NativeContext is expected.

Bug: chromium:1098844
Change-Id: I52d50986c67a0a69c8d9e03756592dff670f83df
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3368107Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78652}
parent 4a082ecb
......@@ -316,6 +316,22 @@ inline bool V8_EXPORT TryToCopyAndConvertArrayToCppBuffer(Local<Array> src,
namespace internal {
void HandleScopeImplementer::EnterContext(Context context) {
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
DCHECK(context.IsNativeContext());
entered_contexts_.push_back(context);
is_microtask_context_.push_back(0);
}
void HandleScopeImplementer::EnterMicrotaskContext(Context context) {
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
DCHECK(context.IsNativeContext());
entered_contexts_.push_back(context);
is_microtask_context_.push_back(1);
}
Handle<Context> HandleScopeImplementer::LastEnteredContext() {
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
......
......@@ -467,13 +467,6 @@ bool HandleScopeImplementer::HasSavedContexts() {
return !saved_contexts_.empty();
}
void HandleScopeImplementer::EnterContext(Context context) {
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
entered_contexts_.push_back(context);
is_microtask_context_.push_back(0);
}
void HandleScopeImplementer::LeaveContext() {
DCHECK(!entered_contexts_.empty());
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
......@@ -486,13 +479,6 @@ bool HandleScopeImplementer::LastEnteredContextWas(Context context) {
return !entered_contexts_.empty() && entered_contexts_.back() == context;
}
void HandleScopeImplementer::EnterMicrotaskContext(Context context) {
DCHECK_EQ(entered_contexts_.capacity(), is_microtask_context_.capacity());
DCHECK_EQ(entered_contexts_.size(), is_microtask_context_.size());
entered_contexts_.push_back(context);
is_microtask_context_.push_back(1);
}
// If there's a spare block, use it for growing the current scope.
internal::Address* HandleScopeImplementer::GetSpareOrNewBlock() {
internal::Address* block =
......
......@@ -5,7 +5,7 @@
#include "src/codegen/external-reference.h"
#include "include/v8-fast-api-calls.h"
#include "src/api/api.h"
#include "src/api/api-inl.h"
#include "src/base/ieee754.h"
#include "src/codegen/cpu-features.h"
#include "src/common/globals.h"
......
......@@ -4,7 +4,7 @@
#include "src/wasm/module-instantiate.h"
#include "src/api/api.h"
#include "src/api/api-inl.h"
#include "src/asmjs/asm-js.h"
#include "src/base/atomicops.h"
#include "src/base/platform/wrappers.h"
......@@ -858,7 +858,7 @@ bool InstanceBuilder::ExecuteStartFunction() {
// v8::Context::Enter() and must happen in addition to the function call
// sequence doing the compiled version of "isolate->set_context(...)".
HandleScopeImplementer* hsi = isolate_->handle_scope_implementer();
hsi->EnterContext(start_function_->context());
hsi->EnterContext(start_function_->context().native_context());
// Call the JS function.
Handle<Object> undefined = isolate_->factory()->undefined_value();
......
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