dynjs
(almost) 100% invokedynamic JS implementation
JUDCon 2012:Boston
@qmx on parsers
@porcelli joins
programming language design 101
generate the desired
bytecode
output
(at least that was I've wanted)
bytecode
is hard to grasp
Rhino
DIY
bytecode generation
ASM4
supports invokedynamic
jitescript
DSL for bytecode generation
jitescript
// calls the default constructor
invokespecial(p(Car.class),
"<init>", sig(void.class));
// calls the "honk" method
invokevirtual(p(Car.class),
"honk", sig(void.class));
avoiding reflection
int (*foo)(int)
strong roots on
functional
programming
MethodHandles
MethodHandle honk = MethodHandles
.lookup()
.findVirtual(Car.class, "honk",
MethodType.methodType(void.class));
honk.invoke(new Car());
reflection is slow because of
security checks
at each call
MethodHandles do all
security checks
during creation
(and they are immutable too :))
you need to think
spɹɐʍʞɔɐq
to fully exploit the API
invokebinder
(MethodHandles for mortals)
invokebinder
mh = Binder.from(void.class, Object.class)
.invokeVirtual(lookup(), "run");
dynjs-spec
11474 tests failing!