v8/v8
0
Files
v8/bazel
Nikolaos Papaspyrou e1649301df [handles] Introduce v8::LocalVector
According to V8's public API documentation, local handles (i.e.,
objects of type v8::Local<T>) "should never be allocated on the heap".
This disallows heap-allocated data structures containing instances of
v8::Local, like std::vector<v8::Local<v8::String>>. It is unfortunate
that the V8 API itself requires the usage of such data structures.

This CL introduces a compile-time flag v8_enable_local_off_stack_check
which enforces a run-time DCHECK, that all v8::Local<T> objects are
indeed stack-allocated. The check is disabled by default. It will
fail for all heap data structures containing local handles.

The CL also introduces v8::LocalVector<T> as an intended replacement
for std::vector<v8::Local<T>>. This class implements correctly
heap-allocated vectors of local handles. The backing store of such
vectors does not trigger the off-stack check. Furthermore, if direct
locals are used, the backing store is also registered as a strong
roots region.

Additionally, the CL modifies root visitors so that, when direct
locals are used, they bypass slots containing kTaggedNullPointer.
In the direct local configuration, this value is used to represent
"empty handles" and is expected to be found in the backing stores
of v8::LocalVector<T>, for default-constructed elements.

Bug: v8:13257
Bug: v8:13270
Bug: chromium:1454114
Change-Id: I1fa6277eab95fa3609d840fca211e2531592e657
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4905902
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#90335}
2023-10-10 12:58:37 +00:00
..
2023-10-10 12:58:37 +00:00
2022-02-16 08:16:04 +00:00