[debug] Introduce EphemeronHashTable root for locals block lists
This CL introduces a new root that is conceptually a WeakMap<ScopeInfo, Tuple2<ScopeInfo, StringSet>> Instead of storing the "locals block list" for debug-evaluate on the `ScopeInfo` object directly, we will store it instead in a global WeakMap. This enables us to re-use the "locals block lists" across multiple debug-evaluate invocations without having to modify the `ScopeInfo` of `SharedFunctionInfo`s. R=bmeurer@chromium.org Doc: https://bit.ly/chrome-devtools-debug-evaluate-design Bug: chromium:1363561 Change-Id: Ib52f9abd97cf1c8fa3053ff3c61a6062c4b814be Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3902041 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/main@{#83318}
This commit is contained in:
parent
f685fac31e
commit
0d25fc2c8e
@ -94,6 +94,7 @@
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/smi.h"
|
||||
#include "src/objects/source-text-module-inl.h"
|
||||
#include "src/objects/string-set-inl.h"
|
||||
#include "src/objects/visitors.h"
|
||||
#include "src/profiler/heap-profiler.h"
|
||||
#include "src/profiler/tracing-cpu-profiler.h"
|
||||
@ -6004,6 +6005,45 @@ ExternalPointerHandle Isolate::GetOrCreateWaiterQueueNodeExternalPointer() {
|
||||
}
|
||||
#endif // V8_COMPRESS_POINTERS
|
||||
|
||||
void Isolate::LocalsBlockListCacheSet(Handle<ScopeInfo> scope_info,
|
||||
Handle<ScopeInfo> outer_scope_info,
|
||||
Handle<StringSet> locals_blocklist) {
|
||||
Handle<EphemeronHashTable> cache;
|
||||
if (heap()->locals_block_list_cache().IsEphemeronHashTable()) {
|
||||
cache = handle(EphemeronHashTable::cast(heap()->locals_block_list_cache()),
|
||||
this);
|
||||
} else {
|
||||
CHECK(heap()->locals_block_list_cache().IsUndefined());
|
||||
constexpr int kInitialCapacity = 8;
|
||||
cache = EphemeronHashTable::New(this, kInitialCapacity);
|
||||
}
|
||||
DCHECK(cache->IsEphemeronHashTable());
|
||||
|
||||
Handle<Tuple2> outer_scope_info_and_locals = factory()->NewTuple2(
|
||||
outer_scope_info, locals_blocklist, AllocationType::kYoung);
|
||||
|
||||
cache =
|
||||
EphemeronHashTable::Put(cache, scope_info, outer_scope_info_and_locals);
|
||||
heap()->set_locals_block_list_cache(*cache);
|
||||
}
|
||||
|
||||
Object Isolate::LocalsBlockListCacheGet(Handle<ScopeInfo> scope_info) {
|
||||
DisallowGarbageCollection no_gc;
|
||||
|
||||
if (!heap()->locals_block_list_cache().IsEphemeronHashTable()) {
|
||||
return ReadOnlyRoots(this).the_hole_value();
|
||||
}
|
||||
|
||||
Object maybe_outer_scope_info_and_locals =
|
||||
EphemeronHashTable::cast(heap()->locals_block_list_cache())
|
||||
.Lookup(scope_info);
|
||||
if (maybe_outer_scope_info_and_locals.IsTheHole()) {
|
||||
return maybe_outer_scope_info_and_locals;
|
||||
}
|
||||
|
||||
return Tuple2::cast(maybe_outer_scope_info_and_locals).value2();
|
||||
}
|
||||
|
||||
namespace {
|
||||
class DefaultWasmAsyncResolvePromiseTask : public v8::Task {
|
||||
public:
|
||||
|
@ -2036,6 +2036,16 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
wasm::StackMemory*& wasm_stacks() { return wasm_stacks_; }
|
||||
#endif
|
||||
|
||||
// Access to the global "locals block list cache". Caches outer-stack
|
||||
// allocated variables per ScopeInfo for debug-evaluate.
|
||||
// We also store a strong reference to the outer ScopeInfo to keep all
|
||||
// blocklists along a scope chain alive.
|
||||
void LocalsBlockListCacheSet(Handle<ScopeInfo> scope_info,
|
||||
Handle<ScopeInfo> outer_scope_info,
|
||||
Handle<StringSet> locals_blocklist);
|
||||
// Returns either `TheHole` or `StringSet`.
|
||||
Object LocalsBlockListCacheGet(Handle<ScopeInfo> scope_info);
|
||||
|
||||
private:
|
||||
explicit Isolate(std::unique_ptr<IsolateAllocator> isolate_allocator,
|
||||
bool is_shared);
|
||||
|
@ -878,6 +878,7 @@ void Heap::CreateInitialObjects() {
|
||||
set_feedback_vectors_for_profiling_tools(roots.undefined_value());
|
||||
set_pending_optimize_for_test_bytecode(roots.undefined_value());
|
||||
set_shared_wasm_memories(roots.empty_weak_array_list());
|
||||
set_locals_block_list_cache(roots.undefined_value());
|
||||
#ifdef V8_ENABLE_WEBASSEMBLY
|
||||
set_active_continuation(roots.undefined_value());
|
||||
set_active_suspender(roots.undefined_value());
|
||||
|
@ -334,6 +334,8 @@ class Symbol;
|
||||
PendingOptimizeForTestBytecode) \
|
||||
V(ArrayList, basic_block_profiling_data, BasicBlockProfilingData) \
|
||||
V(WeakArrayList, shared_wasm_memories, SharedWasmMemories) \
|
||||
/* EphemeronHashTable for debug scopes (local debug evaluate) */ \
|
||||
V(HeapObject, locals_block_list_cache, DebugLocalsBlockListCache) \
|
||||
IF_WASM(V, HeapObject, active_continuation, ActiveContinuation) \
|
||||
IF_WASM(V, HeapObject, active_suspender, ActiveSuspender) \
|
||||
IF_WASM(V, WeakArrayList, js_to_wasm_wrappers, JSToWasmWrappers) \
|
||||
|
Loading…
Reference in New Issue
Block a user