mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
[vm] Add flag to investigate array serialization optimizations.
TEST=--print_array_optimization_candidates Bug: https://github.com/dart-lang/sdk/issues/48910 Change-Id: I6e5031ce9cca4128b8fb75dd5c9e43ad57e7013c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243527 Reviewed-by: Dan Field <dnfield@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
74dd509610
commit
caf220432f
1 changed files with 62 additions and 0 deletions
|
@ -53,6 +53,11 @@ DEFINE_FLAG(charp,
|
|||
write_v8_snapshot_profile_to,
|
||||
NULL,
|
||||
"Write a snapshot profile in V8 format to a file.");
|
||||
DEFINE_FLAG(bool,
|
||||
print_array_optimization_candidates,
|
||||
false,
|
||||
"Print information about how many array are candidates for Smi and "
|
||||
"ROData optimizations.");
|
||||
#endif // defined(DART_PRECOMPILER)
|
||||
|
||||
namespace {
|
||||
|
@ -5401,7 +5406,64 @@ class ArraySerializationCluster : public SerializationCluster {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(DART_PRECOMPILER)
|
||||
static bool IsReadOnlyCid(intptr_t cid) {
|
||||
switch (cid) {
|
||||
case kPcDescriptorsCid:
|
||||
case kCodeSourceMapCid:
|
||||
case kCompressedStackMapsCid:
|
||||
case kOneByteStringCid:
|
||||
case kTwoByteStringCid:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // defined(DART_PRECOMPILER)
|
||||
|
||||
void WriteAlloc(Serializer* s) {
|
||||
#if defined(DART_PRECOMPILER)
|
||||
if (FLAG_print_array_optimization_candidates) {
|
||||
intptr_t array_count = objects_.length();
|
||||
intptr_t array_count_allsmi = 0;
|
||||
intptr_t array_count_allro = 0;
|
||||
intptr_t array_count_empty = 0;
|
||||
intptr_t element_count = 0;
|
||||
intptr_t element_count_allsmi = 0;
|
||||
intptr_t element_count_allro = 0;
|
||||
for (intptr_t i = 0; i < array_count; i++) {
|
||||
ArrayPtr array = objects_[i];
|
||||
bool allsmi = true;
|
||||
bool allro = true;
|
||||
const intptr_t length = Smi::Value(array->untag()->length());
|
||||
for (intptr_t i = 0; i < length; i++) {
|
||||
ObjectPtr element = array->untag()->element(i);
|
||||
intptr_t cid = element->GetClassIdMayBeSmi();
|
||||
if (!IsReadOnlyCid(cid)) allro = false;
|
||||
if (cid != kSmiCid) allsmi = false;
|
||||
}
|
||||
element_count += length;
|
||||
if (length == 0) {
|
||||
array_count_empty++;
|
||||
} else if (allsmi) {
|
||||
array_count_allsmi++;
|
||||
element_count_allsmi += length;
|
||||
} else if (allro) {
|
||||
array_count_allro++;
|
||||
element_count_allro += length;
|
||||
}
|
||||
}
|
||||
OS::PrintErr("Arrays\n");
|
||||
OS::PrintErr(" total: %" Pd ", % " Pd " elements\n", array_count,
|
||||
element_count);
|
||||
OS::PrintErr(" smi-only:%" Pd ", % " Pd " elements\n",
|
||||
array_count_allsmi, element_count_allsmi);
|
||||
OS::PrintErr(" ro-only:%" Pd " , % " Pd " elements\n", array_count_allro,
|
||||
element_count_allro);
|
||||
OS::PrintErr(" empty:%" Pd "\n", array_count_empty);
|
||||
}
|
||||
#endif // defined(DART_PRECOMPILER)
|
||||
|
||||
const intptr_t count = objects_.length();
|
||||
s->WriteUnsigned(count);
|
||||
for (intptr_t i = 0; i < count; i++) {
|
||||
|
|
Loading…
Reference in a new issue