Skip to content

Commit de0f369

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm,dyn_modules] Avoid allocating large arrays in NewSpace
TEST=ci (co19/LibTest/collection/ListBase/ListBase_class_A01_t04) Change-Id: I763897e7e850e9e3f683bd88410311bb2d075a4e Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447760 Reviewed-by: Ryan Macnak <[email protected]> Reviewed-by: Tess Strickland <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 43ab48a commit de0f369

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

runtime/vm/interpreter.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ DART_FORCE_INLINE static bool TryAllocate(Thread* thread,
260260
ObjectPtr* result) {
261261
ASSERT(instance_size > 0);
262262
ASSERT(Utils::IsAligned(instance_size, kObjectAlignment));
263+
ASSERT(IsAllocatableInNewSpace(instance_size));
263264

264265
const uword top = thread->top();
265266
const intptr_t remaining = thread->end() - top;
@@ -1532,7 +1533,9 @@ bool Interpreter::AllocateArray(Thread* thread,
15321533
ObjectPtr* SP) {
15331534
if (LIKELY(!length_object->IsHeapObject())) {
15341535
const intptr_t length = Smi::Value(Smi::RawCast(length_object));
1535-
if (LIKELY(Array::IsValidLength(length))) {
1536+
if (LIKELY(static_cast<uintptr_t>(length) <=
1537+
static_cast<uintptr_t>(Array::kMaxNewSpaceElements))) {
1538+
ASSERT(Array::IsValidLength(length));
15361539
ArrayPtr result;
15371540
if (TryAllocate(thread, kArrayCid, Array::InstanceSize(length),
15381541
reinterpret_cast<ObjectPtr*>(&result))) {

0 commit comments

Comments
 (0)