Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Project Valhalla Update - JVMLS Feedback

Project Valhalla Update - JVMLS Feedback

This material was used at JVMLS feedback in Tokyo, Osaka, and Fukuoka (August 9, 23, and 30).

C732029414e4c194b34639341e5eb199?s=128

Akihiro Nishikawa

August 30, 2019
Tweet

Transcript

  1. Project Valhalla Update JVM Language Summit Feedback #JVMLS_jp

  2. Agenda

  3. Project Valhalla

  4. Project Valhalla - Reboot JVM relationship with data in memory

  5. Project Valhalla - Reboot JVM relationship with data in memory

     Value Types  Generic Specialization
  6. Will be discussed in JVMLS 2020...

  7. 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
  8. For example... class Point { int x; int y; }

    public class App { ... Point[] points = new Point[5]; points[0] = new Point(); ... }
  9. As is... header x y header x y header x

    y header x y header x y header
  10. 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
  11. Who cares about project Valhalla?

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

  13. What the project has done

  14. 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...
  15. Q World Q qload

  16. Worked, but...

  17. L World a*

  18. L World benefits

  19. L World costs

  20. Project status

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

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

  23. Inline class value class Point { int x; int y;

    } inline class Point { int x; int y; }
  24. Compiler optimizations

  25. None
  26. Considerations

  27. Construction defaultvalue withfield

  28. 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."<init>":()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
  29. 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 }
  30. Arrays

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

  32. Default values

  33. Flattening Value types are flattenable, but flattening is not mandatory

    in every scene.
  34. 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; } ... }
  35. Generics – specialized and erased Foo<V> Foo<V?>

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

  37. 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<T extents RefObject> { ... }
  38. Nullity

  39. Nullity Options

  40. Equality

  41. Equality Options

  42. 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

  43. Other identity-sensitive operations

  44. Next action

  45. Tons of things to do!

  46. From Brian Goetz...

  47. Resources

  48. 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

  49. None