Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow
mov EAX,size ;
mul EAX,length ;
mov size,EAX ;
jc Loverflow ;
jnc Lcontinue ;
}
}
else version(D_InlineAsm_X86_64)
Expand All @@ -800,36 +800,35 @@ extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow
mov RAX,size ;
mul RAX,length ;
mov size,RAX ;
jc Loverflow ;
jnc Lcontinue ;
}
}
else
{
auto newsize = size * length;
if (newsize / length != size)
goto Loverflow;

size = newsize;
if (newsize / length == size)
{
size = newsize;
goto Lcontinue;
}
}
Loverflow:
onOutOfMemoryError();
assert(0);
Lcontinue:

// increase the size by the array pad.
auto pad = __arrayPad(size);
if (size + pad < size)
goto Loverflow;

{
auto info = GC.qalloc(size + pad, !(ti.next.flags & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
debug(PRINTF) printf(" p = %p\n", info.base);
// update the length of the array
auto arrstart = __arrayStart(info);
auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
__setArrayAllocLength(info, size, isshared);
return arrstart[0..length];
}

Loverflow:
onOutOfMemoryError();
assert(0);
}

/**
Expand Down