Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
dart::MegamorphicCacheTable Class Reference

#include <megamorphic_cache_table.h>

Inheritance diagram for dart::MegamorphicCacheTable:
dart::AllStatic

Static Public Member Functions

static MegamorphicCachePtr Lookup (Thread *thread, const String &name, const Array &descriptor)
 
static void PrintSizes (Thread *thread)
 

Detailed Description

Definition at line 17 of file megamorphic_cache_table.h.

Member Function Documentation

◆ Lookup()

MegamorphicCachePtr dart::MegamorphicCacheTable::Lookup ( Thread thread,
const String name,
const Array descriptor 
)
static

Definition at line 16 of file megamorphic_cache_table.cc.

18 {
19 auto object_store = thread->isolate_group()->object_store();
20 SafepointMutexLocker ml(thread->isolate_group()->megamorphic_table_mutex());
21
22 ASSERT(name.IsSymbol());
23 // TODO(rmacnak): ASSERT(descriptor.IsCanonical());
24
25 // TODO(rmacnak): Make a proper hashtable a la symbol table.
26 auto& table =
27 GrowableObjectArray::Handle(object_store->megamorphic_cache_table());
28 MegamorphicCache& cache = MegamorphicCache::Handle();
29 if (table.IsNull()) {
31 object_store->set_megamorphic_cache_table(table);
32 } else {
33 for (intptr_t i = 0; i < table.Length(); i++) {
34 cache ^= table.At(i);
35 if ((cache.target_name() == name.ptr()) &&
36 (cache.arguments_descriptor() == descriptor.ptr())) {
37 return cache.ptr();
38 }
39 }
40 }
41
42 cache = MegamorphicCache::New(name, descriptor);
43 table.Add(cache, Heap::kOld);
44 return cache.ptr();
45}
SI F table(const skcms_Curve *curve, F v)
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition object.h:11118
@ kOld
Definition heap.h:39
static Object & Handle()
Definition object.h:407
#define ASSERT(E)
const char *const name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition switches.h:191

◆ PrintSizes()

void dart::MegamorphicCacheTable::PrintSizes ( Thread thread)
static

Definition at line 47 of file megamorphic_cache_table.cc.

47 {
48 auto isolate_group = thread->isolate_group();
49 SafepointMutexLocker ml(isolate_group->megamorphic_table_mutex());
50
51 StackZone zone(thread);
52 intptr_t size = 0;
53 MegamorphicCache& cache = MegamorphicCache::Handle();
54 Array& buckets = Array::Handle();
55 const GrowableObjectArray& table = GrowableObjectArray::Handle(
56 isolate_group->object_store()->megamorphic_cache_table());
57 if (table.IsNull()) return;
58 intptr_t max_size = 0;
59 for (intptr_t i = 0; i < table.Length(); i++) {
60 cache ^= table.At(i);
61 buckets = cache.buckets();
63 size += Array::InstanceSize(buckets.Length());
64 if (buckets.Length() > max_size) {
65 max_size = buckets.Length();
66 }
67 }
68 OS::PrintErr("%" Pd " megamorphic caches using %" Pd "KB.\n", table.Length(),
69 size / 1024);
70
71 intptr_t* probe_counts = new intptr_t[max_size];
72 intptr_t entry_count = 0;
73 intptr_t max_probe_count = 0;
74 for (intptr_t i = 0; i < max_size; i++) {
75 probe_counts[i] = 0;
76 }
77 for (intptr_t i = 0; i < table.Length(); i++) {
78 cache ^= table.At(i);
79 buckets = cache.buckets();
80 intptr_t mask = cache.mask();
81 intptr_t capacity = mask + 1;
82 for (intptr_t j = 0; j < capacity; j++) {
83 intptr_t class_id =
84 Smi::Value(Smi::RawCast(cache.GetClassId(buckets, j)));
85 if (class_id != kIllegalCid) {
86 intptr_t probe_count = 0;
87 intptr_t probe_index =
88 (class_id * MegamorphicCache::kSpreadFactor) & mask;
89 intptr_t probe_cid;
90 while (true) {
91 probe_count++;
92 probe_cid =
93 Smi::Value(Smi::RawCast(cache.GetClassId(buckets, probe_index)));
94 if (probe_cid == class_id) {
95 break;
96 }
97 probe_index = (probe_index + 1) & mask;
98 }
99 probe_counts[probe_count]++;
100 if (probe_count > max_probe_count) {
101 max_probe_count = probe_count;
102 }
103 entry_count++;
104 }
105 }
106 }
107 intptr_t cumulative_entries = 0;
108 for (intptr_t i = 0; i <= max_probe_count; i++) {
109 cumulative_entries += probe_counts[i];
110 OS::PrintErr("Megamorphic probe %" Pd ": %" Pd " (%lf)\n", i,
111 probe_counts[i],
112 static_cast<double>(cumulative_entries) /
113 static_cast<double>(entry_count));
114 }
115 delete[] probe_counts;
116}
static intptr_t InstanceSize()
Definition object.h:10910
static constexpr intptr_t kSpreadFactor
Definition object.h:7571
static intptr_t InstanceSize()
Definition object.h:7605
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
intptr_t Value() const
Definition object.h:9969
@ kIllegalCid
Definition class_id.h:214
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
Definition switches.h:259
#define Pd
Definition globals.h:408

The documentation for this class was generated from the following files: