Nashorn Under the Hood: Making This Rhinoceros Thunder
summary
Nashorn is a JavaScript runtime in OpenJDK that always compiles to JVM bytecode (no interpreter), using parameter type specialization, static local type inference and optimistic typing to generate tight int/double/object-specialized variants on demand. It uses lazy compilation and on-stack recompile via exception handlers to replace code while running. Practical guidance: reuse a single ScriptEngine, precompile scripts or use single global bindings to cut median latency from hundreds of ms to ~35–60ms; enabling optimistic typing drops median to ~12ms but raises startup from ~3s to ~4.7s (type cache can drop it to ~3.5s).
AI-written summary · about
chapters (6)
- 0:00Introduction to Nashorn
- 4:19Compiler optimizations
- 11:16Handling dynamic types
- 21:08De-optimization mechanism
- 22:05Integrating with web systems
- 33:50Advanced tuning and results
related talks
57mNashorn War Stories: Dynamic Language Performance on the JVM
45mNashorn: implementing a dynamic language runtime on JVM in 2014
57mNashorn for Java 9
50mNashorn - what's all the fuss about
01h 01mNashorn ... In Enterprise Applications
25mServer-side JavaScript the untold story
46mEmbracing Collaboration with JRuby and JavaScript
01h 30mServer-side JavaScript with Nashorn and Spring
