There are multiple cases where we'd like to elide Array allocations, e.g. rest to splat forwarding (discovered in #1020, also mentioned in #1004), newarray to expandarray assignment (a, b = c, d), or newarray == newarray #770.
One could run escape analysis, or just check for effectful instructions to support simple cases, to figure out what could be optimized away. However, in many cases, FrameState still refers to an allocated array for side exits and/or PatchPoints.
I'll survey what existing compilers do about it, but one idea I have been thinking of is to introduce a new kind of stack map entry that lazily allocates a new array out of elements. That way, the array allocation would be sunk to side exits and we should be unblocked from optimizing away array allocations.
There are multiple cases where we'd like to elide Array allocations, e.g. rest to splat forwarding (discovered in #1020, also mentioned in #1004), newarray to expandarray assignment (
a, b = c, d), or newarray == newarray #770.One could run escape analysis, or just check for effectful instructions to support simple cases, to figure out what could be optimized away. However, in many cases,
FrameStatestill refers to an allocated array for side exits and/or PatchPoints.I'll survey what existing compilers do about it, but one idea I have been thinking of is to introduce a new kind of stack map entry that lazily allocates a new array out of elements. That way, the array allocation would be sunk to side exits and we should be unblocked from optimizing away array allocations.