Slide 1

Slide 1 text

Project Valhalla Update JVM Language Summit Feedback #JVMLS_jp

Slide 2

Slide 2 text

Agenda

Slide 3

Slide 3 text

Project Valhalla

Slide 4

Slide 4 text

Project Valhalla - Reboot JVM relationship with data in memory

Slide 5

Slide 5 text

Project Valhalla - Reboot JVM relationship with data in memory  Value Types  Generic Specialization

Slide 6

Slide 6 text

Will be discussed in JVMLS 2020...

Slide 7

Slide 7 text

Why are flatter and denser memory layouts required? e.g. Intel Broadwell-EP L1 L2 Main Memory Intel® 64 and IA-32 Architectures Optimization Reference Manual https://software.intel.com/sites/default/files/managed/9e/bc/64-ia-32-architectures-optimization-manual.pdf L3 Cache

Slide 8

Slide 8 text

For example... class Point { int x; int y; } public class App { ... Point[] points = new Point[5]; points[0] = new Point(); ... }

Slide 9

Slide 9 text

As is... header x y header x y header x y header x y header x y header

Slide 10

Slide 10 text

To be... header x y header x y header x y header x y header x y header header x y x y x y x y x y

Slide 11

Slide 11 text

Who cares about project Valhalla?

Slide 12

Slide 12 text

Value Type is available in CLR System.ValueType https://docs.microsoft.com/ja-jp/dotnet/csharp/language-reference/keywords/value-types

Slide 13

Slide 13 text

What the project has done

Slide 14

Slide 14 text

Drilling from JVM side and programming model side L World Early prototypes (M1-M3) Compiler-only Exploring language side • Specialized generics, wildcards • Informed VM requirements • Many of these problems still require considerable work “MVT” prototype VM-only Exploring the “Q-World” model For more detail, check the JVMLS 2018 video! Current prototype VM and compiler support No support yet for specialized generics or migration Still drilling...

Slide 15

Slide 15 text

Q World Q qload

Slide 16

Slide 16 text

Worked, but...

Slide 17

Slide 17 text

L World a*

Slide 18

Slide 18 text

L World benefits

Slide 19

Slide 19 text

L World costs

Slide 20

Slide 20 text

Project status

Slide 21

Slide 21 text

Milestone L2 (LW2) https://wiki.openjdk.java.net/display/valhalla/LW2

Slide 22

Slide 22 text

LW2 prototype binary http://jdk.java.net/valhalla/

Slide 23

Slide 23 text

Inline class value class Point { int x; int y; } inline class Point { int x; int y; }

Slide 24

Slide 24 text

Compiler optimizations

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Considerations

Slide 27

Slide 27 text

Construction defaultvalue withfield

Slide 28

Slide 28 text

class Point { int x; int y; Point() { this.x = 0; this.y = 0; } Point(int x, int y) { this.x = x; this.y = y; } } Point(int, int); descriptor: (II)V flags: (0x0000) Code: stack=2, locals=3, args_size=3 0: aload_0 1: invokespecial #1 // Method java/lang/Object."":()V 4: aload_0 5: iload_1 6: putfield #7 // Field x:I 9: aload_0 10: iload_2 11: putfield #13 // Field y:I 14: return LineNumberTable: line 10: 0 line 11: 4 line 12: 9 line 13: 14

Slide 29

Slide 29 text

inline class Point { final int x; final int y; Point() { this.x = 0; this.y = 0; } Point(int x, int y) { this.x = x; this.y = y; } } static Point Point(int, int); descriptor: (II)QPoint; flags: (0x0008) ACC_STATIC Code: stack=2, locals=3, args_size=2 0: defaultvalue #1 // class Point 3: astore_2 4: iload_0 5: aload_2 6: swap 7: withfield #3 // Field x:I 10: astore_2 11: iload_1 12: aload_2 13: swap 14: withfield #7 // Field y:I 17: astore_2 18: aload_2 19: areturn LineNumberTable: line 10: 0 line 11: 4 line 12: 11 line 13: 18 }

Slide 30

Slide 30 text

Arrays

Slide 31

Slide 31 text

Default values Foo.default x = T.default x = null

Slide 32

Slide 32 text

Default values

Slide 33

Slide 33 text

Flattening Value types are flattenable, but flattening is not mandatory in every scene.

Slide 34

Slide 34 text

Flattening V? ( http://hg.openjdk.java.net/valhalla/valhalla/file/a32457198d 3e/test/jdk/valhalla/valuetypes/NonFlattenValue.java public inline class NonFlattenValue { Point? nfp; NonFlattenValue() { this.nfp = Point.makePoint(0,0); } NonFlattenValue(Point p) { this.nfp = p; } public Point? point() { return nfp; } public Point pointValue() { return (Point) nfp; } ... }

Slide 35

Slide 35 text

Generics – specialized and erased Foo Foo

Slide 36

Slide 36 text

New top types (not yet in LW2, under discussion)

Slide 37

Slide 37 text

New top types (not yet in LW2, under discussion) By bringing ref-ness and val-ness into the type system x instance of RefObject RefObject m() { ... } void m(RefObject o) { … } class Foo { ... }

Slide 38

Slide 38 text

Nullity

Slide 39

Slide 39 text

Nullity Options

Slide 40

Slide 40 text

Equality

Slide 41

Slide 41 text

Equality Options

Slide 42

Slide 42 text

Migration https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/lang/doc- files/ValueBased.html https://docs.oracle.com/javase/jp/12/docs/api/java.base/java/lang/doc-files/ValueBased.html

Slide 43

Slide 43 text

Other identity-sensitive operations

Slide 44

Slide 44 text

Next action

Slide 45

Slide 45 text

Tons of things to do!

Slide 46

Slide 46 text

From Brian Goetz...

Slide 47

Slide 47 text

Resources

Slide 48

Slide 48 text

Resources https://youtu.be/1H4vmT-Va4o https://youtu.be/_26KZAegYRM https://youtu.be/49GUljUmGHg https://www.slideshare.net/DavidBuck7/valhalla-update-jjug-ccc-spring-2019

Slide 49

Slide 49 text

No content