Skip to content

Instantly share code, notes, and snippets.

View xushijie's full-sized avatar

Shijie xushijie

  • Canada
View GitHub Profile
package java.lang.invoke;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import java.util.Arrays;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.FieldVisitor;
@xushijie
xushijie / gist:8184377
Created December 30, 2013 16:34
Bytecodes meet Combinators: invokedynamic on the JVM(VMIL 09)
The author from SUN provides a general introduction of JSR292(invokedynamic introduction):
A dynamic compiler can traverse both representations simultaneously, producing optimized machine code which is the seamless union of both kinds of input. As a final twist, the user-defined linkage of a call site may change, allowing the code to adapt as the application evolves over time.
Some of hints are:
1, Operand types are collected at message sends and other opportune points, and are captured in inline caches or summarized
in a type profile. This information is local to each instruction.
@xushijie
xushijie / gist:8174975
Created December 29, 2013 21:22
Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches (Stanford) Published in ECOOP ‘91 proceedings, Springer Verlag Lecture Notes in Computer Science 512, July, 1991
This is basic background literature for dynamic language and polymorphic inline cache.
The basic idea:
1, collect type information by recording all of the receiver types actually used at a given call site.
2, The compiler can exploit this type information to generate better code when recompiling a method.
@xushijie
xushijie / gist:8174601
Created December 29, 2013 20:41
Dynamic Optimization of Bytecode Instrumentation (VMIL 13)
an analysis model and a framework that enables reducing analysis overhead at runtime through adaptive instrumentation of
the base program. Overhead reduction is achieved by removing instrumentation from code locations that are considered unimportant for the analysis results, thereby avoiding execution of analysis code for those locations.
=> Hints: 对于MH chains,由于有很多MH,但并不是所有的MH都是有效的或者被调用到的,因此我在运行时候删除部分的不会/很少调用到的MH...
But what's the difference between inline cache VS reduction of MHs.
@xushijie
xushijie / gist:8173720
Last active January 1, 2016 16:58
Characteristics of Dynamic JVM Languages (VMIL13)
They use various metrics to characterize the dynamic behavior of a variety of programs written in three dynamic languages (Clojure, Python, and Ruby) executing on the JVM.
We have previously presented a comprehensive toolchain [20] for workload characterization across JVM languages2, which was successfully applied in studying the differences.
The metrics are:
Call-site Polymorphism.
Hints at opportunities for optimizations at polymorphic call-sites, e.g. inline caching [13] (based on the number of receiver types), or method inlining [10] (based on the number of target methods). => On average, 98% call site only has one targte method.
Field, Object, and Class Immutability.
Enables load elimination [3] (replacing repeated accessess to immutable objects with an access to a compiler-generated temporary stored in a register), and identifies objects and side-effectfree data structures amenable to parallelization.
@xushijie
xushijie / gist:8171714
Created December 29, 2013 15:51
Why Nothing Matters: The Impact of Zeroing
Why Nothing Matters: The Impact of Zeroing -OOPSLA’11