JVM bytecode • Java, Scala, Groovy, JRuby, Clojure, … • OpenJDK contains Sun’s JVM “HotSpot” • Oracle’s JDK is based on OpenJDK • Many other JVMs exist for many platforms • Some just replace HotSpot
• Java, Solaris, OpenOffice, NetBeans, VirtualBox, ZFS, Dtrace, and more • Unable to capitalize on OSS • Hardware can’t make up the difference • Oracle takes over Sun…oh no!!!
7u2 7u3 7u4 7u5 7u6 7u7 7u9 7u10 7u11 7u13 7u15 7u17 7u21 7u25 7u40 7u45 Time since last release Flurry of exploits New numbering 9mo of security releases
on OpenJDK is slowly loosening. They're still the dominant player and perhaps always will be, but things are more level than they were.! ! - Andrew Haley of Red Hat! ! Upon nomination to the OpenJDK governing board for 2013
return "I love to hate you!";" case "Scala": return "I love you, I think!";" case "Clojure": return "(love I you)";" case "Groovy": return "I love ?: you";" case "Ruby": return "I.love? you # => true";" default: return "Who are you?";" }" }
code • supported by a rich Runtime library • You may be familiar with JNA • Foreign Function Interface (FFI) • https://github.com/jnr • Maven artifacts for everything
int i, int i1);" public int execv(String string, String[] strings);" public int execve(String string, String[] strings, String[] strings1);" public int fork();" public int seteuid(int i);" public int getgid();" public String getlogin();" public int getpgid();" public int getpgid(int i);" public int getpgrp();" public int getpid();" public int getppid();" public Passwd getpwent();! public Passwd getpwuid(int i);! public Passwd getpwnam(String string);" public Group getgrgid(int i);! public Group getgrnam(String string);" public int getuid();! public boolean isatty(FileDescriptor fd);" public int kill(int i, int i1);! public int symlink(String string, String string1);" public int link(String string, String string1);" public String readlink(String string) throws IOException;" public String getenv(String string);" public int setenv(String string, String string1, int i);" public int unsetenv(String string);" public int getpriority(int i, int i1);" public int setpriority(int i, int i1, int i2);" public int setuid(int i);" public FileStat stat(String string);" public int stat(String string, FileStat fs);" public int umask(int i);" public Times times();" public int utimes(String string, long[] longs, long[] longs1);" public int waitpid(int i, int[] ints, int i1);" public int wait(int[] ints);" public int errno();" public void errno(int i);" public int posix_spawnp(String string, List<? extends SpawnFileAction> list, List<? extends CharSequence> list1, List<? extends CharSequence> list2);
public void unimplementedError(String string);! public void warn(WARNING_ID wrngd, String string, Object[] os);" public boolean isVerbose();! public File getCurrentWorkingDirectory();! public String[] getEnv();! public InputStream getInputStream();! public PrintStream getOutputStream();! public int getPID();! public PrintStream getErrorStream();" }
NativeSocketChannel(int fd);! public NativeSocketChannel(int fd, int ops);! public final int validOps();! public final int getFD();! public int read(ByteBuffer dst) throws IOException;" public int write(ByteBuffer src) throws IOException" public void shutdownInput() throws IOException;" public void shutdownOutput() throws IOException;! }
• JIT intelligence • Drop JNI overhead where possible • Bind native call directly at call site • Security policies, segv protection, etc • Time for an FFI JSR
have targeted JVM • Hundreds of JVM languages now • But JVM was a mismatch for many of them • Usually required tricks that defeated JVM optimizations • Or required features JDK could not provide
up method on Java class 3. Cache method 4. Invoke method invokevirtual" 1. Confirm object is of correct type 2. Confirm arguments are of correct type 3. Look up method on Java class 4. Cache method 5. Invoke method invokeinterface" 1. Confirm object’s type implements interface 2. Confirm arguments are of correct type 3. Look up method on Java class 4. Cache method 5. Invoke method invokespecial" 1. Confirm object is of correct type 2. Confirm arguments are of correct type 3. Confirm target method is visible 4. Look up method on Java class 5. Cache method 6. Invoke method invokestatic invokevirtual invokeinterface invokespecial invokedynamic! 1. Call bootstrap handle (your code) 2. Bootstrap prepares CallSite + MethodHandle 3. MethodHandle invoked now and future (until CallSite changes)
7 release • Got fast in 7u2...and turned out broken • Rewritten for 7u40 • Slow to warm up • Still some issues (memory use, etc) • Java 8 due in March…
of the 100% Java “Maxine” JVM • Backends to assembly or HotSpot IR • Directly control code generation • Build a language without using JVM bytecode • http://openjdk.java.net/projects/graal/
fulfill the dream • Implement interpreter • Truffle feeds that to backend • No compiler expertise needed • https://wiki.openjdk.java.net/display/Graal/Truffle+FAQ+and+Guidelines