Skip to content

ZJIT: Support lazy allocation of Array in stack maps #1046

Description

@k0kubun

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions