• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. Valhalla
  4. L-World

Page History

Versions Compared

Old Version 14

changes.mady.by.user David Simms

Saved on Oct 18, 2018

compared with

New Version 15

changes.mady.by.user David Simms

Saved on Jun 27, 2019

  • Previous Change: Difference between versions 13 and 14
  • Next Change: Difference between versions 15 and 16
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Welcome to the L-World Value Types early adopter's project !

Table of Contents

What are

...

Inline Types?

  • Formerly known as "Value Types", renamed "inline-types" (discussion here)
  • Inline Types are small, immutable, identity-less types
  • User model: "codes like a class, works like an int"
  • Use cases: Numerics, algebraic data types, tuples, cursors, ...
  • Removing identity commitment enables optimizations such as
    • flattening of value inline types in containers such as fields or arrays
      • reducing cost of indirection and locality of reference with attendant cache miss penalties
      • reducing memory footprint and load on garbage collectors
  • Combining Immutability and no identity commitment allows value inline types to be stored in registers or stack or passed by value

What is the L-World

...

project?

The L-World Value Types project is a series of early prototypes for Value Typesbring Inline Types to the language and JDK.

    • builds on work of the previous Minimal Values Types prototype (MVT)
      • provides a new type which is: immutable, identity-agnostic, non-nullable, non-synchronizable, final
      • Value Inline Types contained in References, other Value Inline Types or in Arrays are flatten-able
      • Value Types Inline Types can contain primitives or references
      • JVMS class file model for MVT: 
        • Separate descriptors to distinguish value inline types from object types using "Q" signatures (Q-Types) similar to how Object descriptors begin with "L" (L-Types).
        • Separate bytecodes, starting with "v", called "v-bytecodes" to distinguish from reference "a-bytecodes".
    • MVT limitations:
      • No direct support for methods
      • No compatibility with existing Objects and Interfaces
    • Enabled exploration of  potential maximum optimizations for value inline types with minimal impact on existing objects (object identity types)

"L-World"

To maximize backward compatibility with existing Objects and interfaces, i.e. existing L-Types, the current prototype incorporates value inline types into the L-Type system or "L-World".

  • Value Inline Types may be referred to by the same "L-Type" descriptors the VM has always operated on:
    • May implement interfaces with value inline types
    • May pass a value inline type as a java.lang.Object, or an interface through existing APIs
  • Value Inline Type characteristics:
    • immutable: unmodifiable instance fields
      • may contain primitives, other value inline types, references to mutable objects
    • identity-less: 
      • synchronization including use of wait(*), notify*()  will fail with exception: IllegalMonitorStateException
      • reference equality with "==" (if_acmp<eq|ne>) always returns false, value equality requires using the performs a substitutability test, comparing each field (much like carry out "equals()" method)
      • freely substitutable when equal, no visible change in behavior if equals()
    • final
  • JVMS class file model for "LWorld"
    • Re-uses "L" descriptors
    • Re-uses "a-bytecodes"
    • There are only two new byte-codes, otherwise existing byte-codes have been engineered to accept and maintain value inline type characteristics (identity-less, flattenable, pass by value):
      • "defaultdefaultvalue" - will create a new default valueinline type
      • "withfield"- allows updating value inline type fields via a copy-on-write semantic, i.e. new value based on the old value combined with new field value.

Recognize that the path to Valhalla is long, there are number of open issues facing value inline types. We wish to solve these incrementally. Fully generic specialization of value inline types with clear and sensible migration rules are going to take more than a single prototype.

"LW1" - Minimal L-World

LW1 initial prototype is intended to get this into your hands as early as possible so you can provide us with feedback. 

...

  • Generated class files require ValueTypes attribute, and will throw IncompatibleClassChangeError if value types are used which are not in the attribute
  • IllegalMonitorException thrown on attempts to synchronize or call wait(*) or notify*() on a value type
  • ClassCircularityError thrown if loading an instance field of a value type which declares its own type either directly or indirectly

Limitations for LW1

  • platforms: x64 Linux, x64 Mac OS X, Windows
  • no support for value class with no instance fields
  • no support for atomic fields containing value types
  • no support for @Contended value type fields
  • static fields are not flattenable
  • no AOT, CDS, ZGC, serviceability agent
  • -Xint and C2 only, no C1, no tiered-compilation, no Graal
  • unsafe field and array accessor APIs are not supported for value types
    • VarHandles support value types
      • however: they do not enforce immutability  or non-nullability for value types
        • note that immutable types can be copied, so updates may not be seen
    • low-level unsafe APIs are UNSAFE and will not be changed to support value types
    • risks: If a value type has been flattened in a container, unsafe does not know the layout
      • getObject could return the first flattened element rather than the expected reference
  • interpreter is not optimized, focus is on JIT optimization
  • Please provide additional USE CASES for optimizations
  • Working on additional test cases

Future Possibilities

  • LW1 updates: 
    • fix bugs, add optimizations and support for additional minor features
  • LWX:
    • Addition of significant feature support
    • Addition of language level syntax and semantics
    • Eventually a preview with an openjdk release
    • Expect specialized generics and support for primitives as value types will have their own early access cycles 

How to Try L-World Value Types

Target Audience

  • Power users  - Java/JVM Language, Framework, Library authors/experts
    • who are comfortable with early experimental software
    • who recognize that everything in the experiment - the model, the classfile extensions, the byte codes is likely to change
    • who want to contribute to early exploration of Value Types
    • who will not build any products based on these prototypes
  • Who are willing to provide feedback to the developers on a subset of Value Type features
  • Who will provide use cases for the development team to experiment with optimizations

Early Access Binaries

http://jdk.java.net/valhalla/

Repository and Build Instructions

To create a new local repository, based on "lworld" branch:

...

Note: Valhalla is a child of the jdk/jdk repository, to keep current with latest OpenJDK development.

Programming Model

CMH: Example code

Sample JMH benchmarks: http://mail.openjdk.java.net/pipermail/valhalla-dev/2018-June/004380.html

Run Experimental L-World

  • java -XX:+EnableValhalla <Test>
  • Further experimental flags can be found here

Helpful Feedback Please

This is intended as an early prototype to give you a chance to experiment and provide feedback on the currently supported features.

...

  • Use cases that worked for you, including any positive performance or footprint information
  • Bugs or questions about surprise behavior
  • Use cases that you would like to see optimized PLEASE

Too Early for Feedback

This is intended as an early prototype to give you a chance to experiment and provide feedback on the currently supported features.

...

  • Language syntax
  • Problems already listed under Limitations

References

  • Draft Java Virtual Machine Specification Value Type changes
  • http://cr.openjdk.java.net/~chegar/docs/sandbox.html  (instructions for working with branch repositories)

...

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.21
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 312, "requestCorrelationId": "401f92fff7d26530"}