Nashorn War Stories: Dynamic Language Performance on the JVM
summary
Nashorn is a pure‑Java ECMAScript engine in JDK8 that uses invokedynamic and method handles to specialize callsites, add optimistic primitive types, and patch JVM pain points. Conservative compilation is slow; adding optimistic ints, JVM intrinsics for addExact and catch‑based “unwarranted optimism” rewrites drops a microbenchmark from Rhino 34s → Nashorn 10–11s → optimistic 5.8s → intrinsics 4.4s → with type profiling 2.5s, while V8 remains ~1.3s. Workarounds include LambdaForm/inlining fixes, metaspace tweaks and one‑frame unwinding for deoptimizations.
AI-written summary · about
chapters (27)
- 0:00Introduction
- 3:35What is Nashorn?
- 5:20Why Nashorn?
- 7:07When is Nashom available?
- 11:12Let's talk about JavaScript - Numbers
- 13:37Let's talk about JavaScript - Types/Numbers
- 15:41Let's talk about JavaScript - Static type info
- 20:35Fibonacci calculator
- 20:58Callsite specialization
- 24:22Type Specialization - Prove ints
- 24:49Type Specialization - Prove doubles
- 25:03Static range analysis-fold doubles to ints
- 27:04Summary - Static analysis
- 28:07Statically provable callsites for am3
- 29:29We really want to use ints where we can
- 31:38Using Ints, problem 1 of 2 - Overflow check
- 32:29Solutions Intrinsity math operations
- 38:29Continuations, you say?
- 44:21JVM issues
- 48:12War story: warmup
- 48:43Another war story: Metaspace
- 51:04Future work. JVM
- 51:42Nashorn current performance status
- 52:08Nashorn with optimistic types
- 52:18Patch JVM to keep more type into while
- 55:12ORACLE
- 56:12UPGRADE








