Skip to content

Commit d76f568

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm,dynamic_modules] Fix object allocation/initialization in interpreter in compressed pointers mode
Fix initialization of a newly allocated Closure object when compressed pointers are used. Also, fix how instance size is calculated when allocating an object with instance type arguments. Fixes b/383719624. TEST=tools/test.py -n vm-aot-dyn-linux-debug-x64c language corelib Change-Id: I4bf848ac9b9c9c76d069d1861683cb6dc626ceb9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400400 Commit-Queue: Slava Egorov <[email protected]> Auto-Submit: Alexander Markov <[email protected]> Reviewed-by: Slava Egorov <[email protected]>
1 parent 2b5b316 commit d76f568

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

runtime/vm/interpreter.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,11 +1525,10 @@ bool Interpreter::AllocateClosure(Thread* thread,
15251525
if (TryAllocate(thread, kClosureCid, instance_size,
15261526
reinterpret_cast<ObjectPtr*>(&result))) {
15271527
uword start = UntaggedObject::ToAddr(result);
1528-
ObjectPtr null_value = Object::null();
1529-
for (intptr_t offset = sizeof(UntaggedInstance); offset < instance_size;
1530-
offset += kWordSize) {
1531-
*reinterpret_cast<ObjectPtr*>(start + offset) = null_value;
1532-
}
1528+
Object::InitializeObject(start, kClosureCid, instance_size,
1529+
Closure::ContainsCompressedPointers(),
1530+
Object::from_offset<Closure>(),
1531+
Object::to_offset<Closure>());
15331532
SP[0] = result;
15341533
return true;
15351534
} else {
@@ -2472,8 +2471,8 @@ ObjectPtr Interpreter::Run(Thread* thread,
24722471
TypeArgumentsPtr type_args = TypeArguments::RawCast(SP[-1]);
24732472
if (LIKELY(InterpreterHelpers::IsAllocateFinalized(cls))) {
24742473
const intptr_t class_id = cls->untag()->id_;
2475-
const intptr_t instance_size = cls->untag()->host_instance_size_in_words_
2476-
<< kWordSizeLog2;
2474+
const intptr_t instance_size =
2475+
cls->untag()->host_instance_size_in_words_ * kCompressedWordSize;
24772476
ObjectPtr result;
24782477
if (TryAllocate(thread, class_id, instance_size, &result)) {
24792478
uword start = UntaggedObject::ToAddr(result);

0 commit comments

Comments
 (0)