SlideShare a Scribd company logo
1 of 56
1   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JVM: A Platform for Multiple
Languages
Krystal Mo
Member of Technical Staff
HotSpot JVM Compiler Team



2   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The following is intended to outline our general product direction. It is intended
        for information purposes only, and may not be incorporated into any contract.
        It is not a commitment to deliver any material, code, or functionality, and should
        not be relied upon in making purchasing decisions. The development, release,
        and timing of any features or functionality described for Oracle’s products
        remains at the sole discretion of Oracle.




3   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Once there was a time…




                                                                           Java


                                                                                  Source: http://www.tiobe.com

4   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Oh wait…




                                                                           JavaTM


                                                                                    Source: http://www.tiobe.com

5   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
But really, what we meant was…




                                                                Java TM

                                                                           Source: http://www.tiobe.com

6   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Fortunately, clearer minds prevail
        Language Implementations on JVM

    Gosu                                                                                           Jaskell

                                                                                                             C
    JudoScript


                                                                                                   Fortress
         X10                                        Jacl
                                                                             BeanShell
                                               Fantom                            jgo
                                                                                                ABCL
      myForth                                                              jdart     Erjang ANTLR Nice
                                                                                                     (and many more…)

7   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Agenda


         Why make a language on JVM
         Language features by emulation
         What we did in JDK 7
         Building the future




8   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Agenda


         Why make a language on JVM
         Language features by emulation
         What we did in JDK 7
         Building the future




9   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Why Make a Language At All? (1)


            Syntax
                     – the “easy” part
                     – pick one that fits your eyes
            Semantics and Capabiliies
                     – static vs. dynamic
                     – sequential vs. parallel
                     – …one that fits the problem domain




10   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Why Make a Language At All? (2)
         Versus writing a library


            Language can use alternative syntax
                     – where as library has to adhere to some host language
            Language can impose more restrictions
                     – e.g. controlling capability
                     – where as library has no control over host language’s capabilities




11   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Why on JVM?


            Mature low-level services
                     – Dynamic (“JIT”) compilation
                     – Garbage collection
                     – Threading
                     – Debugging Support
            Cross-platform
            Vast array of libraries



12   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JVM Strengths
         Compiler Optimizations
     compiler tactics                                                       language-specific techniques              loop transformations
        delayed compilation                                                   class hierarchy analysis                  loop unrolling
        tiered compilation                                                    devirtualization                          loop peeling
        on-stack replacement                                                  symbolic constant propagation             safepoint elimination
        delayed reoptimization                                                autobox elimination                       iteration range splitting
        program dependence graph representation                               escape analysis                           range check elimination
        static single assignment representation                               lock elision                              loop vectorization
     proof-based techniques                                                   lock fusion                             global code shaping
        exact type inference                                                  de-reflection                             inlining (graph integration)
        memory value inference                                              speculative (profile-based) techniques      global code motion
        memory value tracking                                                 optimistic nullness assertions            heat-based code layout
        constant folding                                                      optimistic type assertions                switch balancing
        reassociation                                                         optimistic type strengthening             throw inlining
        operator strength reduction                                           optimistic array length strengthening   control flow graph transformation
        null check elimination                                                untaken branch pruning                    local code scheduling
        type test strength reduction                                          optimistic N-morphic inlining             local code bundling
        type test elimination                                                 branch frequency prediction               delay slot filling
        algebraic simplification                                              call frequency prediction                 graph-coloring register allocation
        common subexpression elimination                                    memory and placement transformation         linear scan register allocation
        integer range typing                                                  expression hoisting                       live range splitting
     flow-sensitive rewrites                                                  expression sinking                        copy coalescing
        conditional constant propagation                                      redundant store elimination               constant splitting
        dominating test detection                                             adjacent store fusion                     copy removal
        flow-carried type narrowing                                           card-mark elimination                     address mode matching
        dead code elimination                                                 merge-point splitting                     instruction peepholing
                                                                                                                        DFA-based code generator



13   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Why in Java?
         Instead of C/C++?


            Robustness: Runtime exceptions not fatal
            Reflection: Annotations instead of macros
            Tooling: Java IDEs speed up the development process
            etc.




14   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Ease of Development

         Excellent Tooling Support

          Good IDEs
          Good Profilers                                                   ANTLR
          Good tooling for developing
              parsers and other language
              support




15   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Developing a Language on JVM


                             Syntax                                             Semantics            Low-level Details



                                                                            •(your work goes here)
 •Mature parser libraries
                                                                            •Backed by various
 •e.g. ANTLR, JavaCC                                                                                 Backed by JVM
                                                                            libraries
                                                                            •e.g. ASM, dynalink




16   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Case Study: Writing a Compiler in Java
         Using Reflection
                                  class CompareNode extends FloatingNode,
                                                    implements ValueNumberable,
                                                               Canonicalizable {
                                      @Input ValueNode x;
                                      @Input ValueNode y;
                                      @Data Condition condition;

                                               public Node canonical(CanonicalizerTool t) {
                                                   return this;
                                               }
                                  }

                                  for (IfNode n : graph.getNodes(IfNode.class)) { ... }


17   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Agenda


          Why make a language on JVM
          Language features by emulation
          What we did in JDK 7
          Building the future




18   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
It can always be done
         Even without direct native support from JVM


            Java and JVM provide a rich set of primitives to build on
            Almost any language feature can be implemented on JVM
                     – albeit not necessarily efficient




19   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
“All problems in computer science can be solved by
          another level of indirection.”


            David Wheeler




20   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
“… except for the problem of too many layers of
          indirection.”


            Kevlin Henney




21   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Case Study: A Bytecode Interpreter in Java
         “Double interpretation”

                                                                                          Bytecode               Host JVM
      Java Source                                                     Bytecode            Interpreter in         (also an
      Program
                                                                                          Java                   interpreter)
                                                                                   while (true) {                   …
                                                                                     byte opcode = code[pc++];      …
                                                                                     switch (opcode) {              …
                                                                                     // ...                         …
                                                                        iload_2
                                                                                     case ILOAD_2:                  …
                                                                        iconst_1
           i = j + 1                                                                   int i = locals[2];           …
                                                                        iadd
                                                                                       stack[sp++] = i;             …
                                                                        istore_1
                                                                                       break;                       …
                                                                                     // ...                         …
                                                                                     }                              …
                                                                                   }                                …

22   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Case Study: A JVM in Java
         Ideally, redundant indirections are squeezed out

Java Source                                                                 Compiler in
                                                             Bytecode                     Host Machine
Program                                                                     Java

                                                                iload_2
                                                                iconst_1
     i = j + 1                                                                            lea eax, [edx+1]
                                                                iadd
                                                                istore_1




23   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Alternative Method Dispatching


            e.g. prototype-based dispatch, metaclass, etc.
            Emulate with reflection
                     – Custom lookup / binding
                     – Then java.lang.reflect.Method.invoke()
                     – Reflective invocation overhead
                                   Security checking
                                   Argument boxing / unboxing




24   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Tail-calls


            Often seen in functional languages
            Emulate with trampoline loop
            Special case:
                     – Direct tail-recursions can easily be transformed into loops
                     – e.g. Scala does this




25   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
static int trampolineLoop(Task t) {
         Case Study: tail-call                                                Context ctx = new Context();
         Rewrite into trampoline                                              while (t != null) {
                                                                                t = t.invoke(ctx);
                                                                              }
                                          static int a() {                    return ctx.value;
                                            return b();                     }
                                          }
                                                                            static Task a(Context ctx) {
                                          static int b() {                    return new Task(#b);
                                            return c();                     }
                                          }
                                                                            static Task b(Context ctx) {
                                          static int c() {                    return new Task(#c);
                                            return 42;                      }
                                          }
                                                                            static Task c(Context ctx) {
                                                                              ctx.value = 42;
                                                                              return null;
                                                                            }

26   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Case Study: tail-recursion
         Rewrite into loop


                                                                            static int fib(int n) {
     static int fib(int n) {                                                  int a = 0, b = 1;
       return fibInner(n, 0, 1);                                              while (n >= 2) {
     }                                                                          n = n - 1;
                                                                                int temp = a + b;
     static int fibInner(int n, int a, int b) {                                 a = b;
       if (n < 2) return b;                                                     b = temp;
       return fibInner(n - 1, b, a + b);                                      }
     }                                                                        return b;
                                                                            }




27   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Coroutines


            Emulate with threads
                     – Can implement full (“stackful”) coroutine semantics
                     – Often use thread pooling as an optimization
                     – Waste (virtual) memory
                     – Could leak memory
                     – e.g. used by JRuby on stock JVMs




28   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Coroutines


            Emulate with Finite State Machines
                     – Compile-time transformation
                     – Can only implement “stackless coroutines”
                                   Can only yield from the main method
                     – e.g. C# does this with its iterator
                     – e.g. there’s a coroutines library for Java that does the same




29   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Case Study: C#’s iterator
         Original source



                                                                  static IEnumerable<int> GetNaturals() {
                                                                    int i = 1;
                                                                    while (true) {
                                                                      yield return i++;
                                                                    }
                                                                  }




30   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Case Study: C#’s iterator
          Transformed into FSM (simplied from actual generated code)
     static IEnumerable<int> GetNaturals() {                                     bool IEnumerator.MoveNext() {
       return new NaturalsIterator(0);                                             switch (_state) {
     }                                                                             case 0:
                                                                                     _i = 1;
     sealed class NaturalsIterator :                                                 break;
         IEnumerable<int>, IEnumerable,                                            case 1:
         IEnumerator<int>, IEnumerator,                                              break;
         IDisposable {                                                             default:
       int _current, _state, _i;                                                     return false;
       public NaturalsIterator(int state) {                                        }
         _state = state;                                                           _current = _i++;
       }                                                                           _state = 1;
       int IEnumerator<int>.Current {                                              return true;
         get { return _current; }                                                }
       }                                                                     }


31    Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Reference Counting
                                                                            public class CountedReference<T> {
                                                                              private volatile int refCount = 1;
                                                                              private final T target;
                                                                              public CountedReference(T target) {
            Emulate with reified reference                                     this.target = target;
                                                                              }
                     – Boxing overhead                                        public T addRef() {
                                                                                refCount++;
                     – You really don’t want to do this…                        return target;
                                                                              }
                                                                              public void release() {
                                                                                if (refCount >= 1) refCount--;
                                                                                if (refCount < 1 && target != null) {
                                                                                  target.finalize();
                                                                                  target = null;
                                                                                }
                                                                              }
                                                                            }


32   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Infinite Precision Integer


            Emulate with java.math.BigInteger
                     – Boxing overhead
                                   Performance impact
                                   Heap bloat




33   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Closer to the Metal
         Reducing redundant emulation


            Less indirections
            Better performance




34   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The “J” in JVM
         Geared towards Java semantics


            Semantics match => good perf, easy to impl
            Closer to Java => closer to the metal on JVM




35   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The “J” in JVM
         Should optimize for non-Java features, too


            Languages on JVM shouldn’t be forced to be like Java to be
             performant
            Improve the VM to accommodate non-Java language features
                     – In turn, benefits Java itself, e.g. lambdas




36   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Agenda


          Why make a language on JVM
          Language features by emulation
          What we did in JDK 7
          Building the future




37   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Why dynamic languages?


            Fast turnaround time for simple programs
                     – no compile step required
                     – direct interpretation possible
                     – loose binding to the environment
            Data-driven programming
                     – program shape can change along with data shape
                     – radically open-ended code (plugins, aspects, closures)




38   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Dynamic languages are here to stay




                                                                            Source: http://www.tiobe.com

39   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
What slows down a JVM


            Non-Java languages require special call sites.
                     – e.g.: Smalltalk message sending (no static types).
                     – e.g.: JavaScript or Ruby method call (different lookup rules).
            In the past, special calls required simulation overheads
                     – ...such as reflection and/or extra levels of lookup and indirection
                     – ...which have inhibited JIT optimizations.
            Result: Pain for non-Java developers.
            Enter Java 7.


40   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Key Features


            New bytecode instruction: invokedynamic.
                     – Linked reflectively, under user control.
                     – User-visible object: java.lang.invoke.CallSite
                     – Dynamic call sites can be linked and relinked, dynamically.
            New unit of behavior: method handle
                     – The content of a dynamic call site is a method handle.
                     – Method handles are function pointers for the JVM.
                     – (Or if you like, each MH implements a single-method interface.)


41   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Dynamic Program Composition

                        Bytecodes are                                                                            A dynamic call site
                         created by Java                                                                           is created for each
                         compilers or                                                                              invokedynamic call
                         dynamic runtimes                                                      Dynamic Call        bytecode
                                                                            Bytecodes
                                                                                                  Sites

                                                                                        JVM
                                  The JVM seamlessly                                    JIT
                                   integrates execution,                                                Each call site is
                                   optimizing to native                             Method               bound to one or more
                                   code as necessary                                Handles              method handles,
                                                                                                         which point back to
                                                                                                         bytecoded methods



42   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Passing the burden to the JVM


            Non-Java languages require special call sites.
            In the past, special calls required simulation overheads


            Now, invokedynamic call sites are fully user-configurable
                     – ...and are fully optimizable by the JIT.
            Result: Much simpler code for language implementors
                     – ...and new leverage for the JIT.




43   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
What’s in a method call? (before invokedynamic)


                                                               Source code   Bytecode        Linking       Executing
            Naming                                             Identifiers   Utf8 constants JVM
                                                                                            “dictionary”
            Selecting                                          Scopes        Class names     Loaded        V-table lookup
                                                                                             classes
            Adapting                                           Argument                      C2I / I2C     Receiver
                                                               conversion                    adapters      narrowing
            Calling                                                                                        Jump with
                                                                                                           arguments

44   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
What’s in a method call? (using invokedynamic)


                                                               Source code   Bytecode    Linking       Executing
            Naming                                             ∞             ∞           ∞             ∞
            Selecting                                          ∞             Bootstrap   Bootstrap     ∞
                                                                             methods     method call
            Adapting                                           ∞                         Method        ∞
                                                                                         handles
            Calling                                                                                    Jump with
                                                                                                       arguments



45   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
“Invokedynamic is the most important addition to Java in
          years. It will change the face of the platform.”


            Charles Nutter
            JRuby Lead,
            Red Hat




46   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Agenda


          Why make a language on JVM
          Language features by emulation
          What we did in JDK 7
          Building the future




47   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Loose ends in the Java 7 API


            Method handle introspection (reflection)
            Generalized proxies (more than single-method intfs)
            Class hierarchy analysis (override notification)
            Smaller issues:
                     – usability (MethodHandle.toString, polymorphic bindTo)
                     – sharp corners (MethodHandle.invokeWithArguments)
                     – repertoire (tryFinally, more fold/spread/collect options)
            Integration with other APIs (java.lang.reflect)


48   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Support for Lambda in OpenJDK8


            More transforms for SAM types (as needed).
            Faster bindTo operation to create bound MHs
                     – No JNI calls.
                     – Maybe multiple-value bindTo.
            Faster inexact invoke (as needed).




49   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Let’s continue building our “future VM”
         http://hg.openjdk.java.net/mlvm/mlvm/hotspot/

            Da Vinci Machine Project: an open source
             incubator for JVM futures
            Contains code fragments (patches).
            Movement to OpenJDK requires:
                     – a standard (e.g., JSR 292)
                     – a feature release plan (7 vs. 8 vs. ...)


            bsd-port for developer friendliness.
            mlvm-dev@openjdk.java.net

50   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Current Da Vinci Machine Patches

            MLVM patches
            meth                                                   method handles implementation
            indy                                                   invokedynamic
            coro                                                   light weight coroutines (Lukas Stadler)
            inti                                                   interface injection (Tobias Ivarsson)
            tailc                                                  hard tail call optimization (Arnold Schwaighofer)
            tuple                                                  integrating tuple types (Michael Barker)
            hotswap                                                online general class schema updates (Thomas Wuerthinger)
            anonk                                                  anonymous classes; light weight bytecode loading


51   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Caveat: Change is hard and slow
         (especially the “last 20%”)
           Hacking code is relatively simple.
           Removing bugs is harder.
           Verifying is difficult (millions of users).
           Integrating to a giant system very hard.
                     – interpreter, multiple compilers
                     – managed heap (multiple GC algos.)
                     – debugging, monitoring, profiling machinery
                     – security interactions
            Specifying is hard (the last 20%...).
            Running process is time-consuming.

52   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Further Reading


            Multi-Language VM (MLVM) Project on OpenJDK
            JVM Language Summit
            JSR 292 Cookbook




53   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
References


            VM Optimizations for Language Designers, John Pampuch, JVM
             Language Summit 2008
            Method Handles and Beyond, Some basis vectors, John Rose, JVM
             Language Summit 2011




54   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
55   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
56   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

More Related Content

What's hot

JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovZeroTurnaround
 
Java Crash分析(2012-05-10)
Java Crash分析(2012-05-10)Java Crash分析(2012-05-10)
Java Crash分析(2012-05-10)Kris Mok
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDBLinaro
 
BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabTaeung Song
 
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtAnne Nicolas
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
Linux memory-management-kamal
Linux memory-management-kamalLinux memory-management-kamal
Linux memory-management-kamalKamal Maiti
 
Linux Kernel Crashdump
Linux Kernel CrashdumpLinux Kernel Crashdump
Linux Kernel CrashdumpMarian Marinov
 
Continguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelContinguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelKernel TLV
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsJava Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsBrendan Gregg
 
Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)Angel Boy
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugginglibfetion
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
PCD - Process control daemon
PCD - Process control daemonPCD - Process control daemon
PCD - Process control daemonhaish
 
David container security-with_falco
David container security-with_falcoDavid container security-with_falco
David container security-with_falcoLorenzo David
 
Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringShapeBlue
 
Windows 10 Nt Heap Exploitation (Chinese version)
Windows 10 Nt Heap Exploitation (Chinese version)Windows 10 Nt Heap Exploitation (Chinese version)
Windows 10 Nt Heap Exploitation (Chinese version)Angel Boy
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringGeorg Schönberger
 

What's hot (20)

JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir Ivanov
 
Java Crash分析(2012-05-10)
Java Crash分析(2012-05-10)Java Crash分析(2012-05-10)
Java Crash分析(2012-05-10)
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLab
 
Embedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile DevicesEmbedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile Devices
 
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Linux memory-management-kamal
Linux memory-management-kamalLinux memory-management-kamal
Linux memory-management-kamal
 
Linux Kernel Crashdump
Linux Kernel CrashdumpLinux Kernel Crashdump
Linux Kernel Crashdump
 
Continguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux KernelContinguous Memory Allocator in the Linux Kernel
Continguous Memory Allocator in the Linux Kernel
 
Java Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame GraphsJava Performance Analysis on Linux with Flame Graphs
Java Performance Analysis on Linux with Flame Graphs
 
Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
PCD - Process control daemon
PCD - Process control daemonPCD - Process control daemon
PCD - Process control daemon
 
David container security-with_falco
David container security-with_falcoDavid container security-with_falco
David container security-with_falco
 
Boosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uringBoosting I/O Performance with KVM io_uring
Boosting I/O Performance with KVM io_uring
 
Windows 10 Nt Heap Exploitation (Chinese version)
Windows 10 Nt Heap Exploitation (Chinese version)Windows 10 Nt Heap Exploitation (Chinese version)
Windows 10 Nt Heap Exploitation (Chinese version)
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
LLVM introduction
LLVM introductionLLVM introduction
LLVM introduction
 

Similar to JVM: A Platform for Multiple Languages

The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving JavaSteve Elliott
 
Code Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoCode Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoEvgeny Mandrikov
 
Java compilation
Java compilationJava compilation
Java compilationMike Kucera
 
Visual COBOL Development for Unix and Java
Visual COBOL Development for Unix and JavaVisual COBOL Development for Unix and Java
Visual COBOL Development for Unix and JavaMicro Focus
 
Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012Logica_hummingbird
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaManjula Kollipara
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8jclingan
 
Core Java Training
Core Java TrainingCore Java Training
Core Java TrainingDeccansoft
 
[Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic [Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic Challenge:Future
 
A comprehensive formal verification solution for ARM based SOC design
A comprehensive formal verification solution for ARM based SOC design A comprehensive formal verification solution for ARM based SOC design
A comprehensive formal verification solution for ARM based SOC design chiportal
 
What is new and cool j2se & java
What is new and cool j2se & javaWhat is new and cool j2se & java
What is new and cool j2se & javaEugene Bogaart
 
Graal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformGraal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformThomas Wuerthinger
 
Dependency injection
Dependency injectionDependency injection
Dependency injectionhousecor
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011Arun Gupta
 
Scala: An experience report
Scala: An experience reportScala: An experience report
Scala: An experience reportMark Needham
 

Similar to JVM: A Platform for Multiple Languages (20)

The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving Java
 
Code Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCoCode Coverage Revised : EclEmma on JaCoCo
Code Coverage Revised : EclEmma on JaCoCo
 
Java Starting
Java StartingJava Starting
Java Starting
 
Java compilation
Java compilationJava compilation
Java compilation
 
Visual COBOL Development for Unix and Java
Visual COBOL Development for Unix and JavaVisual COBOL Development for Unix and Java
Visual COBOL Development for Unix and Java
 
Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012
 
Java 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kolliparaJava 7 Dolphin manjula kollipara
Java 7 Dolphin manjula kollipara
 
Java 8
Java 8Java 8
Java 8
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
Core Java Training
Core Java TrainingCore Java Training
Core Java Training
 
[Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic [Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic
 
A comprehensive formal verification solution for ARM based SOC design
A comprehensive formal verification solution for ARM based SOC design A comprehensive formal verification solution for ARM based SOC design
A comprehensive formal verification solution for ARM based SOC design
 
What is new and cool j2se & java
What is new and cool j2se & javaWhat is new and cool j2se & java
What is new and cool j2se & java
 
Graal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformGraal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution Platform
 
Dependency injection
Dependency injectionDependency injection
Dependency injection
 
Java J2EE Training in Chennai, Tambaram
Java J2EE  Training in Chennai, TambaramJava J2EE  Training in Chennai, Tambaram
Java J2EE Training in Chennai, Tambaram
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
 
Scala: An experience report
Scala: An experience reportScala: An experience report
Scala: An experience report
 

JVM: A Platform for Multiple Languages

  • 1. 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 2. JVM: A Platform for Multiple Languages Krystal Mo Member of Technical Staff HotSpot JVM Compiler Team 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 4. Once there was a time… Java Source: http://www.tiobe.com 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 5. Oh wait… JavaTM Source: http://www.tiobe.com 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 6. But really, what we meant was… Java TM Source: http://www.tiobe.com 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 7. Fortunately, clearer minds prevail Language Implementations on JVM Gosu Jaskell C JudoScript Fortress X10 Jacl BeanShell Fantom jgo ABCL myForth jdart Erjang ANTLR Nice (and many more…) 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 8. Agenda  Why make a language on JVM  Language features by emulation  What we did in JDK 7  Building the future 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 9. Agenda  Why make a language on JVM  Language features by emulation  What we did in JDK 7  Building the future 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 10. Why Make a Language At All? (1)  Syntax – the “easy” part – pick one that fits your eyes  Semantics and Capabiliies – static vs. dynamic – sequential vs. parallel – …one that fits the problem domain 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 11. Why Make a Language At All? (2) Versus writing a library  Language can use alternative syntax – where as library has to adhere to some host language  Language can impose more restrictions – e.g. controlling capability – where as library has no control over host language’s capabilities 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 12. Why on JVM?  Mature low-level services – Dynamic (“JIT”) compilation – Garbage collection – Threading – Debugging Support  Cross-platform  Vast array of libraries 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 13. JVM Strengths Compiler Optimizations compiler tactics language-specific techniques loop transformations delayed compilation class hierarchy analysis loop unrolling tiered compilation devirtualization loop peeling on-stack replacement symbolic constant propagation safepoint elimination delayed reoptimization autobox elimination iteration range splitting program dependence graph representation escape analysis range check elimination static single assignment representation lock elision loop vectorization proof-based techniques lock fusion global code shaping exact type inference de-reflection inlining (graph integration) memory value inference speculative (profile-based) techniques global code motion memory value tracking optimistic nullness assertions heat-based code layout constant folding optimistic type assertions switch balancing reassociation optimistic type strengthening throw inlining operator strength reduction optimistic array length strengthening control flow graph transformation null check elimination untaken branch pruning local code scheduling type test strength reduction optimistic N-morphic inlining local code bundling type test elimination branch frequency prediction delay slot filling algebraic simplification call frequency prediction graph-coloring register allocation common subexpression elimination memory and placement transformation linear scan register allocation integer range typing expression hoisting live range splitting flow-sensitive rewrites expression sinking copy coalescing conditional constant propagation redundant store elimination constant splitting dominating test detection adjacent store fusion copy removal flow-carried type narrowing card-mark elimination address mode matching dead code elimination merge-point splitting instruction peepholing DFA-based code generator 13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 14. Why in Java? Instead of C/C++?  Robustness: Runtime exceptions not fatal  Reflection: Annotations instead of macros  Tooling: Java IDEs speed up the development process  etc. 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 15. Ease of Development Excellent Tooling Support  Good IDEs  Good Profilers ANTLR  Good tooling for developing parsers and other language support 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 16. Developing a Language on JVM Syntax Semantics Low-level Details •(your work goes here) •Mature parser libraries •Backed by various •e.g. ANTLR, JavaCC Backed by JVM libraries •e.g. ASM, dynalink 16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 17. Case Study: Writing a Compiler in Java Using Reflection class CompareNode extends FloatingNode, implements ValueNumberable, Canonicalizable { @Input ValueNode x; @Input ValueNode y; @Data Condition condition; public Node canonical(CanonicalizerTool t) { return this; } } for (IfNode n : graph.getNodes(IfNode.class)) { ... } 17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 18. Agenda  Why make a language on JVM  Language features by emulation  What we did in JDK 7  Building the future 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 19. It can always be done Even without direct native support from JVM  Java and JVM provide a rich set of primitives to build on  Almost any language feature can be implemented on JVM – albeit not necessarily efficient 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 20. “All problems in computer science can be solved by another level of indirection.” David Wheeler 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 21. “… except for the problem of too many layers of indirection.” Kevlin Henney 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 22. Case Study: A Bytecode Interpreter in Java “Double interpretation” Bytecode Host JVM Java Source Bytecode Interpreter in (also an Program Java interpreter) while (true) { … byte opcode = code[pc++]; … switch (opcode) { … // ... … iload_2 case ILOAD_2: … iconst_1 i = j + 1 int i = locals[2]; … iadd stack[sp++] = i; … istore_1 break; … // ... … } … } … 22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 23. Case Study: A JVM in Java Ideally, redundant indirections are squeezed out Java Source Compiler in Bytecode Host Machine Program Java iload_2 iconst_1 i = j + 1 lea eax, [edx+1] iadd istore_1 23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 24. Alternative Method Dispatching  e.g. prototype-based dispatch, metaclass, etc.  Emulate with reflection – Custom lookup / binding – Then java.lang.reflect.Method.invoke() – Reflective invocation overhead  Security checking  Argument boxing / unboxing 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 25. Tail-calls  Often seen in functional languages  Emulate with trampoline loop  Special case: – Direct tail-recursions can easily be transformed into loops – e.g. Scala does this 25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 26. static int trampolineLoop(Task t) { Case Study: tail-call Context ctx = new Context(); Rewrite into trampoline while (t != null) { t = t.invoke(ctx); } static int a() { return ctx.value; return b(); } } static Task a(Context ctx) { static int b() { return new Task(#b); return c(); } } static Task b(Context ctx) { static int c() { return new Task(#c); return 42; } } static Task c(Context ctx) { ctx.value = 42; return null; } 26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 27. Case Study: tail-recursion Rewrite into loop static int fib(int n) { static int fib(int n) { int a = 0, b = 1; return fibInner(n, 0, 1); while (n >= 2) { } n = n - 1; int temp = a + b; static int fibInner(int n, int a, int b) { a = b; if (n < 2) return b; b = temp; return fibInner(n - 1, b, a + b); } } return b; } 27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 28. Coroutines  Emulate with threads – Can implement full (“stackful”) coroutine semantics – Often use thread pooling as an optimization – Waste (virtual) memory – Could leak memory – e.g. used by JRuby on stock JVMs 28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 29. Coroutines  Emulate with Finite State Machines – Compile-time transformation – Can only implement “stackless coroutines”  Can only yield from the main method – e.g. C# does this with its iterator – e.g. there’s a coroutines library for Java that does the same 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 30. Case Study: C#’s iterator Original source static IEnumerable<int> GetNaturals() { int i = 1; while (true) { yield return i++; } } 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 31. Case Study: C#’s iterator Transformed into FSM (simplied from actual generated code) static IEnumerable<int> GetNaturals() { bool IEnumerator.MoveNext() { return new NaturalsIterator(0); switch (_state) { } case 0: _i = 1; sealed class NaturalsIterator : break; IEnumerable<int>, IEnumerable, case 1: IEnumerator<int>, IEnumerator, break; IDisposable { default: int _current, _state, _i; return false; public NaturalsIterator(int state) { } _state = state; _current = _i++; } _state = 1; int IEnumerator<int>.Current { return true; get { return _current; } } } } 31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 32. Reference Counting public class CountedReference<T> { private volatile int refCount = 1; private final T target; public CountedReference(T target) {  Emulate with reified reference this.target = target; } – Boxing overhead public T addRef() { refCount++; – You really don’t want to do this… return target; } public void release() { if (refCount >= 1) refCount--; if (refCount < 1 && target != null) { target.finalize(); target = null; } } } 32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 33. Infinite Precision Integer  Emulate with java.math.BigInteger – Boxing overhead  Performance impact  Heap bloat 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 34. Closer to the Metal Reducing redundant emulation  Less indirections  Better performance 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 35. The “J” in JVM Geared towards Java semantics  Semantics match => good perf, easy to impl  Closer to Java => closer to the metal on JVM 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 36. The “J” in JVM Should optimize for non-Java features, too  Languages on JVM shouldn’t be forced to be like Java to be performant  Improve the VM to accommodate non-Java language features – In turn, benefits Java itself, e.g. lambdas 36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 37. Agenda  Why make a language on JVM  Language features by emulation  What we did in JDK 7  Building the future 37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 38. Why dynamic languages?  Fast turnaround time for simple programs – no compile step required – direct interpretation possible – loose binding to the environment  Data-driven programming – program shape can change along with data shape – radically open-ended code (plugins, aspects, closures) 38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 39. Dynamic languages are here to stay Source: http://www.tiobe.com 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 40. What slows down a JVM  Non-Java languages require special call sites. – e.g.: Smalltalk message sending (no static types). – e.g.: JavaScript or Ruby method call (different lookup rules).  In the past, special calls required simulation overheads – ...such as reflection and/or extra levels of lookup and indirection – ...which have inhibited JIT optimizations.  Result: Pain for non-Java developers.  Enter Java 7. 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 41. Key Features  New bytecode instruction: invokedynamic. – Linked reflectively, under user control. – User-visible object: java.lang.invoke.CallSite – Dynamic call sites can be linked and relinked, dynamically.  New unit of behavior: method handle – The content of a dynamic call site is a method handle. – Method handles are function pointers for the JVM. – (Or if you like, each MH implements a single-method interface.) 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 42. Dynamic Program Composition  Bytecodes are  A dynamic call site created by Java is created for each compilers or invokedynamic call dynamic runtimes Dynamic Call bytecode Bytecodes Sites JVM  The JVM seamlessly JIT integrates execution,  Each call site is optimizing to native Method bound to one or more code as necessary Handles method handles, which point back to bytecoded methods 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 43. Passing the burden to the JVM  Non-Java languages require special call sites.  In the past, special calls required simulation overheads  Now, invokedynamic call sites are fully user-configurable – ...and are fully optimizable by the JIT.  Result: Much simpler code for language implementors – ...and new leverage for the JIT. 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 44. What’s in a method call? (before invokedynamic) Source code Bytecode Linking Executing Naming Identifiers Utf8 constants JVM “dictionary” Selecting Scopes Class names Loaded V-table lookup classes Adapting Argument C2I / I2C Receiver conversion adapters narrowing Calling Jump with arguments 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 45. What’s in a method call? (using invokedynamic) Source code Bytecode Linking Executing Naming ∞ ∞ ∞ ∞ Selecting ∞ Bootstrap Bootstrap ∞ methods method call Adapting ∞ Method ∞ handles Calling Jump with arguments 45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 46. “Invokedynamic is the most important addition to Java in years. It will change the face of the platform.” Charles Nutter JRuby Lead, Red Hat 46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 47. Agenda  Why make a language on JVM  Language features by emulation  What we did in JDK 7  Building the future 47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 48. Loose ends in the Java 7 API  Method handle introspection (reflection)  Generalized proxies (more than single-method intfs)  Class hierarchy analysis (override notification)  Smaller issues: – usability (MethodHandle.toString, polymorphic bindTo) – sharp corners (MethodHandle.invokeWithArguments) – repertoire (tryFinally, more fold/spread/collect options)  Integration with other APIs (java.lang.reflect) 48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 49. Support for Lambda in OpenJDK8  More transforms for SAM types (as needed).  Faster bindTo operation to create bound MHs – No JNI calls. – Maybe multiple-value bindTo.  Faster inexact invoke (as needed). 49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 50. Let’s continue building our “future VM” http://hg.openjdk.java.net/mlvm/mlvm/hotspot/  Da Vinci Machine Project: an open source incubator for JVM futures  Contains code fragments (patches).  Movement to OpenJDK requires: – a standard (e.g., JSR 292) – a feature release plan (7 vs. 8 vs. ...)  bsd-port for developer friendliness.  mlvm-dev@openjdk.java.net 50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 51. Current Da Vinci Machine Patches MLVM patches meth method handles implementation indy invokedynamic coro light weight coroutines (Lukas Stadler) inti interface injection (Tobias Ivarsson) tailc hard tail call optimization (Arnold Schwaighofer) tuple integrating tuple types (Michael Barker) hotswap online general class schema updates (Thomas Wuerthinger) anonk anonymous classes; light weight bytecode loading 51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 52. Caveat: Change is hard and slow (especially the “last 20%”)  Hacking code is relatively simple.  Removing bugs is harder.  Verifying is difficult (millions of users).  Integrating to a giant system very hard. – interpreter, multiple compilers – managed heap (multiple GC algos.) – debugging, monitoring, profiling machinery – security interactions  Specifying is hard (the last 20%...).  Running process is time-consuming. 52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 53. Further Reading  Multi-Language VM (MLVM) Project on OpenJDK  JVM Language Summit  JSR 292 Cookbook 53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 54. References  VM Optimizations for Language Designers, John Pampuch, JVM Language Summit 2008  Method Handles and Beyond, Some basis vectors, John Rose, JVM Language Summit 2011 54 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 55. 55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 56. 56 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Editor's Notes

  1. JavaFX is an example of a good language got dumped.
  2. Suppose register allocations is done, i is allocated in eax, j is allocated in edx