20DEFINE_FLAG(
bool, print_class_table,
false,
"Print initial class table.");
23 : allocator_(allocator),
25 top_level_classes_(allocator) {
32 vm_class_table->classes_.capacity());
34 const auto copy_info_for_cid = [&](intptr_t
cid) {
35 classes_.At<kClassIndex>(
cid) = vm_class_table->
At(
cid);
36 classes_.At<kSizeIndex>(
cid) = vm_class_table->
SizeAt(
cid);
45 copy_info_for_cid(kTypeArgumentsCid);
55#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
56 for (intptr_t
i = 1;
i < classes_.num_cids();
i++) {
58 if (
name !=
nullptr) {
59 free(
const_cast<char*
>(
name));
68 bool did_grow =
false;
73 const intptr_t instance_size =
77 classes_.At<kClassIndex>(
cid) = cls.
ptr();
78 classes_.At<kSizeIndex>(
cid) =
static_cast<int32_t
>(instance_size);
79#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
80 classes_.At<kClassNameIndex>(
cid) =
nullptr;
85 classes_.GetColumn<kClassIndex>());
88 std::atomic_thread_fence(std::memory_order_release);
96 bool did_grow =
false;
97 const intptr_t index = top_level_classes_.
AddRow(&did_grow);
99 top_level_classes_.
At<kClassIndex>(index) = cls.
ptr();
103 bool did_grow =
false;
109 classes_.AllocateIndex(index, &did_grow);
119 top_level_classes_.
At<kClassIndex>(tlc_index) =
nullptr;
124 classes_.Remap(old_to_new_cid);
128 ASSERT(visitor !=
nullptr);
131 const auto visit = [&](ClassPtr* table, intptr_t num_cids) {
140 visit(classes_.GetColumn<kClassIndex>(), classes_.num_cids());
141 visit(top_level_classes_.
GetColumn<kClassIndex>(),
148 for (intptr_t
i = 1;
i < classes_.num_cids();
i++) {
161 classes_.At<kClassIndex>(
cid) = raw_cls;
167 const intptr_t
size =
169 classes_.At<kSizeIndex>(
cid) =
static_cast<int32_t
>(
size);
185#if defined(DART_PRECOMPILER)
201 for (intptr_t
i = 1;
i < classes_.num_cids();
i++) {
206 if (cls.
ptr() !=
nullptr) {
213#if defined(DART_PRECOMPILER)
214void ClassTable::PrintObjectLayout(
const char* filename) {
221 for (intptr_t
i = ClassId::kObjectCid;
i < classes_.num_cids();
i++) {
233 js.OpenArray(
"fields");
236 for (intptr_t
i = 0, n = fields.
Length();
i < n; ++
i) {
237 field ^= fields.
At(
i);
241 js.PrintPropertyBool(
"static",
true);
256 if ((file_open ==
nullptr) || (file_write ==
nullptr) ||
257 (file_close ==
nullptr)) {
258 OS::PrintErr(
"warning: Could not access file callbacks.");
262 void*
file = file_open(filename,
true);
263 if (
file ==
nullptr) {
264 OS::PrintErr(
"warning: Failed to write object layout: %s\n", filename);
269 intptr_t output_length = 0;
277#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
280 for (intptr_t
i = 0;
i < classes_.num_cids(); ++
i) {
293 object->AddProperty(
"type",
"ClassList");
296 for (intptr_t
i = ClassId::kObjectCid;
i < classes_.num_cids();
i++) {
307 ASSERT(isolate !=
nullptr);
308 auto isolate_group = isolate->
group();
309 Heap* heap = isolate_group->heap();
313 if (isolate_group->last_allocationprofile_accumulator_reset_timestamp() !=
316 "dateLastAccumulatorReset",
"%" Pd64 "",
317 isolate_group->last_allocationprofile_accumulator_reset_timestamp());
319 if (isolate_group->last_allocationprofile_gc_timestamp() != 0) {
321 isolate_group->last_allocationprofile_gc_timestamp());
342 CountObjectsVisitor visitor(thread,
NumCids());
352 for (intptr_t
i = 3;
i < classes_.num_cids();
i++) {
356 if (cls.
IsNull())
continue;
361 intptr_t
count = visitor.new_count_[
i] + visitor.old_count_[
i];
362 intptr_t
size = visitor.new_size_[
i] + visitor.old_size_[
i];
371 new_stats.
AddValue(visitor.new_count_[
i]);
372 new_stats.
AddValue(visitor.new_size_[
i]);
373 new_stats.
AddValue(visitor.new_external_size_[
i]);
377 old_stats.
AddValue(visitor.old_count_[
i]);
378 old_stats.
AddValue(visitor.old_size_[
i]);
379 old_stats.
AddValue(visitor.old_external_size_[
i]);
392 delete pending_freed_;
396 if (ptr !=
nullptr) {
397 pending_freed_->
Add(std::make_pair(
398 ptr, [](
void* ptr) {
delete static_cast<ClassTable*
>(ptr); }));
403 if (ptr !=
nullptr) {
404 pending_freed_->
Add(std::make_pair(ptr,
nullptr));
409 while (!pending_freed_->
is_empty()) {
410 auto [ptr, deleter] = pending_freed_->
RemoveLast();
411 if (deleter ==
nullptr) {
ObjectPtr At(intptr_t index) const
intptr_t num_cids() const
intptr_t AddRow(bool *did_grow)
void AllocateIndex(intptr_t index, bool *did_grow)
void Free(ClassTable *table)
void Register(const Class &cls)
void CopySizesFromClassObjects()
ClassPtr At(intptr_t cid) const
void SetAt(intptr_t index, ClassPtr raw_cls)
static intptr_t CidFromTopLevelIndex(intptr_t index)
void UpdateCachedAllocationTracingStateTablePointer()
void AllocationProfilePrintJSON(JSONStream *stream, bool internal)
void UnregisterTopLevel(intptr_t index)
int32_t SizeAt(intptr_t index) const
void VisitObjectPointers(ObjectPointerVisitor *visitor)
void UpdateClassSize(intptr_t cid, ClassPtr raw_cls)
void Remap(intptr_t *old_to_new_cids)
void RegisterTopLevel(const Class &cls)
bool HasValidClassAt(intptr_t cid) const
void PopulateUserVisibleNames()
void AllocateIndex(intptr_t index)
ClassTable(ClassTableAllocator *allocator)
static intptr_t IndexFromTopLevelCid(intptr_t cid)
static bool IsTopLevelCid(intptr_t cid)
void PrintToJSONObject(JSONObject *object)
const char * UserVisibleNameFor(intptr_t cid)
intptr_t target_instance_size() const
void SetUserVisibleNameInClassTable()
intptr_t host_instance_size() const
void set_id(intptr_t value) const
const char * UserVisibleNameCString() const
bool is_finalized() const
static Dart_FileWriteCallback file_write_callback()
static IsolateGroup * vm_isolate_group()
static Dart_FileOpenCallback file_open_callback()
static Isolate * vm_isolate()
static Dart_FileCloseCallback file_close_callback()
const char * UserVisibleNameCString() const
intptr_t TargetOffset() const
void IterateObjects(ObjectVisitor *visitor) const
void PrintMemoryUsageJSON(JSONStream *stream) const
void PrintToJSONObject(Space space, JSONObject *object) const
void set_cached_class_table_table(ClassPtr *cached_class_table_table)
static IsolateGroup * Current()
ClassTable * class_table() const
void VisitWeakPersistentHandles(HandleVisitor *visitor)
static Isolate * Current()
IsolateGroup * group() const
void AddValue(bool b) const
void AddProperty64(const char *name, int64_t i) const
void AddProperty(const char *name, bool b) const
void AddPropertyF(const char *name, const char *format,...) const PRINTF_ATTRIBUTE(3
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
void clear_gc_root_type()
void set_gc_root_type(const char *gc_root_type)
virtual void VisitPointers(ObjectPtr *first, ObjectPtr *last)=0
static Thread * Current()
constexpr intptr_t kFirstInternalOnlyCid
DEFINE_FLAG(bool, print_cluster_information, false, "Print information about clusters written to snapshot")
COMPILE_ASSERT(kUnreachableReference==WeakTable::kNoValue)
constexpr intptr_t kLastInternalOnlyCid
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size