Reland "Retrieve native context from known fields"

This is a reland of commit be4d52e12f

Original change's description:
> Retrieve native context from known fields
>
> When using `typeof %LeakHole()` in testing code we would try to
> generate a stack trace via `Runtime_Abort()` without setting the
> native context on the Isolate. However, all the places that need the
> native context have it already available in some form. Fix these
> callsites.
>
> Bug: 345970375
> Change-Id: Idab1ba5416cb8e931056cb3f7aded1c526096e91
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5617530
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#94370}

Bug: 345970375
Change-Id: I3d2b50f70307dadedda54a1fdfd0dada0b793250
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5623373
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#94389}
This commit is contained in:
Michael Lippautz authored and V8 LUCI CQ committed 2024-06-12 09:10:36 +00:00
1 parent 196b18a7bc
commit e578e5adda
2 files changed
+13 -5

No files matched your search

+2 -1
View File
@@ -405,7 +405,8 @@ MaybeHandle<JSFunction> InstantiateFunction(
Handle<Object> protoype_provider_templ(
data->GetPrototypeProviderTemplate(), isolate);
if (IsUndefined(*protoype_provider_templ, isolate)) {
prototype = isolate->factory()->NewJSObject(isolate->object_function());
prototype = isolate->factory()->NewJSObject(
handle(native_context->object_function(), isolate));
} else {
ASSIGN_RETURN_ON_EXCEPTION(
isolate, prototype,
+11 -4
View File
@@ -1266,13 +1266,20 @@ Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map,
const char* reason) {
DCHECK(!fast_map->is_dictionary_map());
Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
isolate);
if (fast_map->is_prototype_map() || IsUndefined(*maybe_cache, isolate)) {
Tagged<Map> meta_map = fast_map->map();
if (fast_map->is_prototype_map()) {
use_cache = false;
}
Handle<NormalizedMapCache> cache;
if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache);
if (use_cache) {
Tagged<Object> normalized_map_cache =
meta_map->native_context()->normalized_map_cache();
use_cache = !IsUndefined(normalized_map_cache, isolate);
if (use_cache) {
cache = Handle<NormalizedMapCache>::cast(
handle(normalized_map_cache, isolate));
}
}
Handle<Map> new_map;
if (use_cache && cache