Skip to content

Commit fd3c238

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Shrink object store name metadata.
Saves 18k. TEST=ci Change-Id: Ie30eee4589f124e705bf922e5b6f8f8cedfdab25 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434240 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 05e6d48 commit fd3c238

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

runtime/vm/app_snapshot.cc

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7038,20 +7038,6 @@ class VMDeserializationRoots : public DeserializationRoots {
70387038
};
70397039

70407040
#if !defined(DART_PRECOMPILED_RUNTIME)
7041-
static const char* const kObjectStoreFieldNames[] = {
7042-
#define DECLARE_OBJECT_STORE_FIELD(Type, Name) #Name,
7043-
OBJECT_STORE_FIELD_LIST(DECLARE_OBJECT_STORE_FIELD,
7044-
DECLARE_OBJECT_STORE_FIELD,
7045-
DECLARE_OBJECT_STORE_FIELD,
7046-
DECLARE_OBJECT_STORE_FIELD,
7047-
DECLARE_OBJECT_STORE_FIELD,
7048-
DECLARE_OBJECT_STORE_FIELD,
7049-
DECLARE_OBJECT_STORE_FIELD,
7050-
DECLARE_OBJECT_STORE_FIELD,
7051-
DECLARE_OBJECT_STORE_FIELD)
7052-
#undef DECLARE_OBJECT_STORE_FIELD
7053-
};
7054-
70557041
class ProgramSerializationRoots : public SerializationRoots {
70567042
public:
70577043
#define RESET_ROOT_LIST(V) \
@@ -7157,8 +7143,19 @@ class ProgramSerializationRoots : public SerializationRoots {
71577143
void WriteRoots(Serializer* s) {
71587144
ObjectPtr* from = object_store_->from();
71597145
ObjectPtr* to = object_store_->to_snapshot(s->kind());
7146+
// A strtab is smaller than an array of strings.
7147+
static const char* const names = ""
7148+
#define EMIT_FIELD_NAME(type, name) #name "_\0"
7149+
OBJECT_STORE_FIELD_LIST(
7150+
EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME,
7151+
EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME,
7152+
EMIT_FIELD_NAME)
7153+
#undef EMIT_FIELD_NAME
7154+
; // NOLINT
7155+
const char* name = names;
71607156
for (ObjectPtr* p = from; p <= to; p++) {
7161-
s->WriteRootRef(*p, kObjectStoreFieldNames[p - from]);
7157+
s->WriteRootRef(*p, name);
7158+
name += strlen(name) + 1;
71627159
}
71637160

71647161
FieldTable* initial_field_table =

runtime/vm/object_store.cc

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,18 @@ void IsolateObjectStore::PrintToJSONObject(JSONObject* jsobj) {
3737
JSONObject fields(jsobj, "fields");
3838
Object& value = Object::Handle();
3939

40-
static const char* const names[] = {
41-
#define EMIT_FIELD_NAME(type, name) #name "_",
40+
// A strtab is smaller than an array of strings.
41+
static const char* const names = ""
42+
#define EMIT_FIELD_NAME(type, name) #name "_\0"
4243
ISOLATE_OBJECT_STORE_FIELD_LIST(EMIT_FIELD_NAME, EMIT_FIELD_NAME)
4344
#undef EMIT_FIELD_NAME
44-
};
45-
ObjectPtr* current = from();
46-
intptr_t i = 0;
47-
while (current <= to()) {
45+
; // NOLINT
46+
const char* name = names;
47+
for (ObjectPtr* current = from(); current <= to(); current++) {
4848
value = *current;
49-
fields.AddProperty(names[i], value);
50-
current++;
51-
i++;
49+
fields.AddProperty(name, value);
50+
name += strlen(name) + 1;
5251
}
53-
ASSERT(i == ARRAY_SIZE(names));
5452
}
5553
}
5654
#endif // !PRODUCT
@@ -109,23 +107,21 @@ void ObjectStore::PrintToJSONObject(JSONObject* jsobj) {
109107
{
110108
JSONObject fields(jsobj, "fields");
111109
Object& value = Object::Handle();
112-
static const char* const names[] = {
113-
#define EMIT_FIELD_NAME(type, name) #name "_",
110+
// A strtab is smaller than an array of strings.
111+
static const char* const names = ""
112+
#define EMIT_FIELD_NAME(type, name) #name "_\0"
114113
OBJECT_STORE_FIELD_LIST(
115114
EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME,
116115
EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME, EMIT_FIELD_NAME,
117116
EMIT_FIELD_NAME)
118117
#undef EMIT_FIELD_NAME
119-
};
120-
ObjectPtr* current = from();
121-
intptr_t i = 0;
122-
while (current <= to()) {
118+
; // NOLINT
119+
const char* name = names;
120+
for (ObjectPtr* current = from(); current <= to(); current++) {
123121
value = *current;
124-
fields.AddProperty(names[i], value);
125-
current++;
126-
i++;
122+
fields.AddProperty(name, value);
123+
name += strlen(name) + 1;
127124
}
128-
ASSERT(i == ARRAY_SIZE(names));
129125
}
130126
}
131127
#endif // !PRODUCT

0 commit comments

Comments
 (0)