Commit 89270b1e authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[GetIsolate] Inline GetIsolate into ScopeInfo::ContextSlotIndex

We want to remove GetIsolate calls, but this particular one is safe
and necessary to avoid either storing the isolate in the parser/scopes,
or passing it through as a parameter throughout the parser.

Bug: v8:7786
Change-Id: I07765f5c20b2c9925bb0b980bc9fe850c91d7811
Reviewed-on: https://chromium-review.googlesource.com/1104685Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53822}
parent ee9c34c5
......@@ -690,8 +690,21 @@ int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
if (scope_info->length() == 0) return -1;
ContextSlotCache* context_slot_cache =
scope_info->GetIsolate()->context_slot_cache();
// Inline a GetIsolate-style call here.
//
// Ideally we'd pass Isolate* through to this function, however this is mostly
// called from the parser, which is otherwise isolate independent. We can't
// assume that all scope infos are never RO space (like we can with JSReceiver
// or Context), but we can assume that *non-empty* scope infos are.
//
// So, we take the least-ugly approach of manually getting the isolate to be
// able to remove GetIsolate from ScopeInfo in the general case, while
// allowing it in this one particular case.
MemoryChunk* scope_info_chunk = MemoryChunk::FromHeapObject(*scope_info);
DCHECK_NE(scope_info_chunk->owner()->identity(), RO_SPACE);
Isolate* isolate = scope_info_chunk->heap()->isolate();
ContextSlotCache* context_slot_cache = isolate->context_slot_cache();
int result = context_slot_cache->Lookup(*scope_info, *name, mode, init_flag,
maybe_assigned_flag);
if (result != ContextSlotCache::kNotFound) {
......
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