Skip to content

Valhalla LWVT: Add new bytecodes defaultvalue and withfield #1390

Closed

Description

@eric98zhang

Latest L-World proposal: http://cr.openjdk.java.net/~acorn/LWorldValueTypesFeb13.pdf
Latest rough draft JVMS: http://cr.openjdk.java.net/~fparain/L-world/L-World-JVMS-4b.pdf

defaultvalue

The defaultvalue bytecode pushes a reference to an instance of a value class onto the stack, initialized to the class' default values.

Stack:

... -->
..., valueref

The initial implementation should operate in the same way that the new bytecode does -- the instance should be allocated on the heap and a reference should be placed on the stack. A later version could consider value type buffering, where new instances are instead allocated in a valuebuffer pointed to from the Java stack, and which disappears when the stack frame is popped.

The default value for a value class is currently considered to be the same as for POJOs. That is zero for all scalars and NULL for all references.

withfield

The withfield bytecode pushes a new reference to a value class instance with an updated instance field.

Stack:

..., valueref, value -->
..., newvalueref

Note: This is NOT like putfield. An existing value type is not being updated. Rather, a new instance with an updated field is being created.

Again, the initial implementation should allocate new instances on the heap, and a later implementation should consider value type buffering.

Activity

  1. tajila commented on Feb 12, 2020

    @tajila
    Contributor

    default value full implementation (interpreter): #3575
    tests: #3682

  2. tajila commented on Feb 12, 2020

    @tajila
    Contributor

    With field support:
    #3760
    #3802
    #3925

  3. tajila commented on Feb 12, 2020

    @tajila
    Contributor
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions