[vm] Hoist allocation of sentinel et al.

These will be base objects even for kFullAOT and kFullJIT snapshots, so their allocation needs to be separated from the rest of Object::Init.

TEST=ci
Change-Id: I1ad03cf9900a925d3b084843206bba7f67c5daa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499083
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2026-04-29 08:06:40 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 8cbfb32907
commit 7012150dc7
2 changed files with 38 additions and 16 deletions
+33 -15
View File
@@ -544,6 +544,34 @@ void Object::InitNullAndBool(IsolateGroup* isolate_group) {
#endif
}
{
uword address =
heap->Allocate(thread, Sentinel::InstanceSize(), Heap::kOld);
Roots::set_sentinel_obj(static_cast<SentinelPtr>(address + kHeapObjectTag));
InitializeObject<Sentinel>(address);
}
{
uword address =
heap->Allocate(thread, Sentinel::InstanceSize(), Heap::kOld);
Roots::set_unknown_constant_obj(
static_cast<SentinelPtr>(address + kHeapObjectTag));
InitializeObject<Sentinel>(address);
}
{
uword address =
heap->Allocate(thread, Sentinel::InstanceSize(), Heap::kOld);
Roots::set_non_constant_obj(
static_cast<SentinelPtr>(address + kHeapObjectTag));
InitializeObject<Sentinel>(address);
}
{
uword address =
heap->Allocate(thread, Sentinel::InstanceSize(), Heap::kOld);
Roots::set_optimized_out_obj(
static_cast<SentinelPtr>(address + kHeapObjectTag));
InitializeObject<Sentinel>(address);
}
// Check that the objects have been allocated at appropriate addresses.
uword null_ = static_cast<uword>(Roots::null_obj());
uword true_ = static_cast<uword>(Roots::true_obj());
@@ -696,6 +724,10 @@ void Object::Init(IsolateGroup* isolate_group) {
Roots::null_compressed_stackmaps().initRO(CompressedStackMaps::null());
Roots::bool_true().initRO(Roots::true_obj());
Roots::bool_false().initRO(Roots::false_obj());
Roots::sentinel().initRO(Roots::sentinel_obj());
Roots::unknown_constant().initRO(Roots::unknown_constant_obj());
Roots::non_constant().initRO(Roots::non_constant_obj());
Roots::optimized_out().initRO(Roots::optimized_out_obj());
// Initialize the empty array and empty instantiations cache array handles to
// null_ in order to be able to check if the empty and zero arrays were
@@ -769,22 +801,8 @@ void Object::Init(IsolateGroup* isolate_group) {
cls.set_is_declaration_loaded();
cls.set_is_type_finalized();
// Allocate and initialize Sentinel class.
cls = Class::New<Sentinel, RTN::Sentinel>(isolate_group);
// Allocate and initialize the sentinel values.
{
Roots::sentinel().initRO(Sentinel::New());
}
// Allocate and initialize optimizing compiler constants.
{
Roots::unknown_constant().initRO(Sentinel::New());
Roots::non_constant().initRO(Sentinel::New());
Roots::optimized_out().initRO(Sentinel::New());
}
// Allocate the remaining VM internal classes.
cls = Class::New<Sentinel, RTN::Sentinel>(isolate_group);
cls = Class::New<TypeParameters, RTN::TypeParameters>(isolate_group);
cls = Class::New<TypeArguments, RTN::TypeArguments>(isolate_group);
cls = Class::New<PatchClass, RTN::PatchClass>(isolate_group);
+5 -1
View File
@@ -14,7 +14,11 @@ namespace dart {
#define RAW_ROOTS_LIST(V) \
V(ObjectPtr, null_obj) \
V(BoolPtr, true_obj) \
V(BoolPtr, false_obj)
V(BoolPtr, false_obj) \
V(SentinelPtr, sentinel_obj) \
V(SentinelPtr, unknown_constant_obj) \
V(SentinelPtr, non_constant_obj) \
V(SentinelPtr, optimized_out_obj)
#define HANDLE_ROOTS_LIST(V) \
V(Object, null_object) \