Commit c93098f2 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by V8 LUCI CQ

[wasm] Simplify context-passing for stack-switching

Pass the context as an argument of the runtime function, instead
of using the stack frame iterator to find it.

R=jkummerow@chromium.org

Bug: v8:12191
Change-Id: I43c0cf74b1b83b9c1c63df99c3816bd3f3e94ebf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3562984Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79782}
parent f2579aac
...@@ -7070,13 +7070,16 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -7070,13 +7070,16 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
Node* suspender = gasm_->Load( Node* suspender = gasm_->Load(
MachineType::TaggedPointer(), api_function_ref, MachineType::TaggedPointer(), api_function_ref,
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kSuspenderOffset)); wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kSuspenderOffset));
Node* native_context = gasm_->Load(
MachineType::TaggedPointer(), api_function_ref,
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kNativeContextOffset));
auto* call_descriptor = GetBuiltinCallDescriptor( auto* call_descriptor = GetBuiltinCallDescriptor(
Builtin::kWasmSuspend, zone_, StubCallMode::kCallWasmRuntimeStub); Builtin::kWasmSuspend, zone_, StubCallMode::kCallWasmRuntimeStub);
Node* call_target = mcgraph()->RelocatableIntPtrConstant( Node* call_target = mcgraph()->RelocatableIntPtrConstant(
wasm::WasmCode::kWasmSuspend, RelocInfo::WASM_STUB_CALL); wasm::WasmCode::kWasmSuspend, RelocInfo::WASM_STUB_CALL);
Node* args[] = {value, suspender}; Node* args[] = {value, suspender};
Node* chained_promise = Node* chained_promise = BuildCallToRuntimeWithContext(
BuildCallToRuntime(Runtime::kWasmCreateResumePromise, args, 2); Runtime::kWasmCreateResumePromise, native_context, args, 2);
Node* resolved = Node* resolved =
gasm_->Call(call_descriptor, call_target, chained_promise, suspender); gasm_->Call(call_descriptor, call_target, chained_promise, suspender);
gasm_->Goto(&resume, resolved); gasm_->Goto(&resume, resolved);
......
...@@ -797,11 +797,6 @@ RUNTIME_FUNCTION(Runtime_WasmCreateResumePromise) { ...@@ -797,11 +797,6 @@ RUNTIME_FUNCTION(Runtime_WasmCreateResumePromise) {
Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo> shared =
isolate->factory()->NewSharedFunctionInfoForWasmOnFulfilled( isolate->factory()->NewSharedFunctionInfoForWasmOnFulfilled(
function_data); function_data);
Handle<WasmInstanceObject> instance(
GetWasmInstanceOnStackTop(isolate,
{StackFrame::EXIT, StackFrame::WASM_TO_JS}),
isolate);
isolate->set_context(instance->native_context());
Handle<Context> context(isolate->native_context()); Handle<Context> context(isolate->native_context());
Handle<Map> function_map = isolate->strict_function_map(); Handle<Map> function_map = isolate->strict_function_map();
Handle<JSObject> on_fulfilled = Handle<JSObject> on_fulfilled =
......
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