Skip to content

Commit 5167ec9

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm] Remove Class::NumOwnTypeArguments()
Calculation of Class::NumTypeArguments() is reimplemented so that it does no require separate calculation of Class::NumOwnTypeArguments(). Number of own type arguments is no longer stored in Class, and has_pragma bit is moved into state_bits. This simplifies overall calculation and does not require to keep both num_type_arguments and num_own_type_arguments. This also allows us to add up to 15 more flag bits to Class. Change-Id: Iac7a751145fea7adb673ab9369eeb8eea5c5794d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105544 Reviewed-by: Régis Crelier <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent aa246f6 commit 5167ec9

File tree

5 files changed

+67
-156
lines changed

5 files changed

+67
-156
lines changed

runtime/vm/class_finalizer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,6 @@ void ClassFinalizer::FinalizeTypeArguments(const Class& cls,
557557
const Class& super_class = Class::Handle(super_type.type_class());
558558
const intptr_t num_super_type_params = super_class.NumTypeParameters();
559559
const intptr_t num_super_type_args = super_class.NumTypeArguments();
560-
ASSERT(num_super_type_args ==
561-
(cls.NumTypeArguments() - cls.NumOwnTypeArguments()));
562560
if (!super_type.IsFinalized() && !super_type.IsBeingFinalized()) {
563561
super_type = FinalizeType(cls, super_type, kFinalize, pending_types);
564562
cls.set_super_type(super_type);
@@ -1384,7 +1382,7 @@ void ClassFinalizer::VerifyImplicitFieldOffsets() {
13841382
cls = class_table.At(kFfiPointerCid);
13851383
error = cls.EnsureIsFinalized(thread);
13861384
ASSERT(error.IsNull());
1387-
ASSERT(cls.NumOwnTypeArguments() == 1);
1385+
ASSERT(cls.NumTypeParameters() == 1);
13881386
type_param ^= TypeParameter::RawCast(
13891387
TypeArguments::Handle(cls.type_parameters()).TypeAt(0));
13901388
ASSERT(Pointer::kNativeTypeArgPos == type_param.index());

runtime/vm/clustered_snapshot.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,10 @@ class ClassSerializationCluster : public SerializationCluster {
182182
s->Write<int32_t>(cls->ptr()->instance_size_in_words_);
183183
s->Write<int32_t>(cls->ptr()->next_field_offset_in_words_);
184184
s->Write<int32_t>(cls->ptr()->type_arguments_field_offset_in_words_);
185-
s->Write<uint16_t>(cls->ptr()->num_type_arguments_);
186-
s->Write<uint16_t>(cls->ptr()->has_pragma_and_num_own_type_arguments_);
185+
s->Write<int16_t>(cls->ptr()->num_type_arguments_);
187186
s->Write<uint16_t>(cls->ptr()->num_native_fields_);
188187
s->WriteTokenPosition(cls->ptr()->token_pos_);
189-
s->Write<uint16_t>(cls->ptr()->state_bits_);
188+
s->Write<uint32_t>(cls->ptr()->state_bits_);
190189
}
191190

192191
private:
@@ -244,11 +243,10 @@ class ClassDeserializationCluster : public DeserializationCluster {
244243
d->Read<int32_t>(); // Skip.
245244
}
246245
cls->ptr()->type_arguments_field_offset_in_words_ = d->Read<int32_t>();
247-
cls->ptr()->num_type_arguments_ = d->Read<uint16_t>();
248-
cls->ptr()->has_pragma_and_num_own_type_arguments_ = d->Read<uint16_t>();
246+
cls->ptr()->num_type_arguments_ = d->Read<int16_t>();
249247
cls->ptr()->num_native_fields_ = d->Read<uint16_t>();
250248
cls->ptr()->token_pos_ = d->ReadTokenPosition();
251-
cls->ptr()->state_bits_ = d->Read<uint16_t>();
249+
cls->ptr()->state_bits_ = d->Read<uint32_t>();
252250
}
253251

254252
for (intptr_t id = start_index_; id < stop_index_; id++) {
@@ -271,11 +269,10 @@ class ClassDeserializationCluster : public DeserializationCluster {
271269
cls->ptr()->instance_size_in_words_ = d->Read<int32_t>();
272270
cls->ptr()->next_field_offset_in_words_ = d->Read<int32_t>();
273271
cls->ptr()->type_arguments_field_offset_in_words_ = d->Read<int32_t>();
274-
cls->ptr()->num_type_arguments_ = d->Read<uint16_t>();
275-
cls->ptr()->has_pragma_and_num_own_type_arguments_ = d->Read<uint16_t>();
272+
cls->ptr()->num_type_arguments_ = d->Read<int16_t>();
276273
cls->ptr()->num_native_fields_ = d->Read<uint16_t>();
277274
cls->ptr()->token_pos_ = d->ReadTokenPosition();
278-
cls->ptr()->state_bits_ = d->Read<uint16_t>();
275+
cls->ptr()->state_bits_ = d->Read<uint32_t>();
279276

280277
table->AllocateIndex(class_id);
281278
table->SetAt(class_id, cls);

0 commit comments

Comments
 (0)