Skip to content

Commit e48ce36

Browse files
verwaestV8 LUCI CQ
authored andcommitted
[api] Support Detached global in GetAlignedPointerFromEmbedderDataInCreationContextImpl
Otherwise we get nullptr ScriptState which isn't supported. We might want to look into a better solution long-term though Bug: 428451956 Change-Id: I5127d5f63078ec9afb41bd316850f43cec2c436d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6708443 Commit-Queue: Toon Verwaest <[email protected]> Commit-Queue: Michael Lippautz <[email protected]> Auto-Submit: Toon Verwaest <[email protected]> Reviewed-by: Michael Lippautz <[email protected]> Cr-Commit-Position: refs/heads/main@{#101290}
1 parent c8a27f0 commit e48ce36

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/api/api.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5202,12 +5202,25 @@ V8_INLINE void* GetAlignedPointerFromEmbedderDataInCreationContextImpl(
52025202
const char* location =
52035203
"v8::Object::GetAlignedPointerFromEmbedderDataInCreationContext()";
52045204
auto maybe_context = object->GetCreationContext();
5205-
if (!maybe_context.has_value()) return nullptr;
5205+
i::Tagged<i::NativeContext> native_context;
5206+
if (maybe_context.has_value()) {
5207+
native_context = maybe_context.value();
5208+
} else {
5209+
// This happens when we're accessing a global property but passed its (now
5210+
// detached) global proxy as holder. If the global proxy is detached because
5211+
// of navigation, it won't have a context-specific metamap anymore (it gets
5212+
// cleared on Detach to avoid leaks). Since we're doing a global proxy
5213+
// access though, the Isolate's current native context must be the native
5214+
// context we care about.
5215+
i::Isolate* isolate = i::Isolate::Current();
5216+
i::Tagged<i::Context> context = isolate->context();
5217+
CHECK_EQ(context->global_proxy(), *object);
5218+
native_context = context->native_context();
5219+
}
52065220

52075221
// The code below mostly mimics Context::GetAlignedPointerFromEmbedderData()
52085222
// but it doesn't try to expand the EmbedderDataArray instance.
52095223
i::DisallowGarbageCollection no_gc;
5210-
i::Tagged<i::NativeContext> native_context = maybe_context.value();
52115224

52125225
// This macro requires a real Isolate while |i_isolate_for_sandbox| might be
52135226
// nullptr if the V8 sandbox is not enabled.

0 commit comments

Comments
 (0)