[vm, dynamic modules] Bugfixes in the bytecode reader and interpreter runtime
* Never unbox fields loaded from bytecode as interpreter works with boxed fields only. * Ensure classes are allocate-finalized in AllocateObject runtime entry as interpreter may allocate instances of certain built-in classes (such as _Closure, _Double etc) without prior allocate-finalization. * Fix type arguments vector in constant instances when class doesn't have type parameters but extends a generic class (so its instances have type arguments vector). TEST=ci Change-Id: I488287f84572a79ca7f1fddbd53aed1c3a038cea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412981 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
409e103745
commit
22b26e5a29
@@ -1075,10 +1075,12 @@ ObjectPtr BytecodeReaderHelper::ReadConstObject(intptr_t tag) {
|
||||
const Type& type = Type::CheckedHandle(Z, ReadObject());
|
||||
const Class& cls = Class::Handle(Z, type.type_class());
|
||||
const Instance& obj = Instance::Handle(Z, Instance::New(cls, Heap::kOld));
|
||||
if (type.arguments() != TypeArguments::null()) {
|
||||
const TypeArguments& type_args =
|
||||
TypeArguments::Handle(Z, type.arguments());
|
||||
if (cls.NumTypeArguments() > 0) {
|
||||
auto& type_args = TypeArguments::Handle(Z, type.arguments());
|
||||
type_args = cls.GetInstanceTypeArguments(thread_, type_args);
|
||||
obj.SetTypeArguments(type_args);
|
||||
} else {
|
||||
ASSERT(type.arguments() == TypeArguments::null());
|
||||
}
|
||||
const intptr_t num_fields = reader_.ReadUInt();
|
||||
Field& field = Field::Handle(Z);
|
||||
@@ -1549,6 +1551,7 @@ void BytecodeReaderHelper::ReadFieldDeclarations(const Class& cls,
|
||||
(flags & kIsReflectableFlag) != 0, is_late, script_class,
|
||||
type, position, end_position);
|
||||
|
||||
field.set_is_unboxed(false);
|
||||
field.set_has_pragma(has_pragma);
|
||||
field.set_is_covariant((flags & kIsCovariantFlag) != 0);
|
||||
field.set_is_generic_covariant_impl((flags & kIsCovariantByClassFlag) != 0);
|
||||
|
||||
@@ -536,6 +536,16 @@ static void ThrowIfError(const Object& result) {
|
||||
// Return value: newly allocated object.
|
||||
DEFINE_RUNTIME_ENTRY(AllocateObject, 2) {
|
||||
const Class& cls = Class::CheckedHandle(zone, arguments.ArgAt(0));
|
||||
#if defined(DART_DYNAMIC_MODULES) && !defined(DART_PRECOMPILED_RUNTIME)
|
||||
if (!cls.is_allocate_finalized()) {
|
||||
const Error& error =
|
||||
Error::Handle(zone, cls.EnsureIsAllocateFinalized(thread));
|
||||
if (!error.IsNull()) {
|
||||
Exceptions::PropagateError(error);
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ASSERT(cls.is_allocate_finalized());
|
||||
const Instance& instance = Instance::Handle(
|
||||
zone, Instance::NewAlreadyFinalized(cls, SpaceForRuntimeAllocation()));
|
||||
|
||||
Reference in New Issue
Block a user