Skip to content

Commit c9d187e

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm/bytecode] Finalize type parameters while reading bytecode
In bytecode we have enough information to "finalize" type parameters immediately while reading bytecode. Finalization of a type parameter is just calculating its index in type arguments vector. Change-Id: I6f47821b6ddb44441b3ca8c682262a38c454eeb7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117773 Reviewed-by: Régis Crelier <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 397c7e4 commit c9d187e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

runtime/vm/compiler/frontend/bytecode_reader.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,13 @@ void BytecodeReaderHelper::ReadTypeParametersDeclaration(
613613
const intptr_t num_type_params = reader_.ReadUInt();
614614
ASSERT(num_type_params > 0);
615615

616+
intptr_t offset;
617+
if (!parameterized_class.IsNull()) {
618+
offset = parameterized_class.NumTypeArguments() - num_type_params;
619+
} else {
620+
offset = parameterized_function.NumParentTypeParameters();
621+
}
622+
616623
// First setup the type parameters, so if any of the following code uses it
617624
// (in a recursive way) we're fine.
618625
//
@@ -628,6 +635,8 @@ void BytecodeReaderHelper::ReadTypeParametersDeclaration(
628635
parameter = TypeParameter::New(
629636
parameterized_class, parameterized_function, i, name, bound,
630637
/* is_generic_covariant_impl = */ false, TokenPosition::kNoSource);
638+
parameter.set_index(offset + i);
639+
parameter.SetIsFinalized();
631640
type_parameters.SetTypeAt(i, parameter);
632641
}
633642

@@ -1647,10 +1656,7 @@ RawObject* BytecodeReaderHelper::ReadType(intptr_t tag) {
16471656
} else {
16481657
UNREACHABLE();
16491658
}
1650-
AbstractType& type =
1651-
AbstractType::Handle(Z, type_parameters.TypeAt(index_in_parent));
1652-
// TODO(alexmarkov): skip type finalization
1653-
return ClassFinalizer::FinalizeType(*active_class_->klass, type);
1659+
return type_parameters.TypeAt(index_in_parent);
16541660
}
16551661
case kGenericType: {
16561662
const Class& cls = Class::CheckedHandle(Z, ReadObject());

0 commit comments

Comments
 (0)