Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit modifies the JIT to use invokedynamic for lazy init and caching of most literal values. This includes things like: * Immediate values like numbers, symbols, true/false/nil * Frozen strings * Symbol procs * Basically anything initialized once and cached in IR The original logic for "non-indy" literals followed this pattern: * Emit a small method body * In that method body, check a static field * If null, initialize the value and set the field * Return the value This mechanism has many down sides: * Extra method body emitted for every literal * Bytecode for initializing the value, only ever run once (and therefore never jitted by JVM) * Field access plus null check every time, preventing folding of what should be a constant value * Accompanying metaspace overhead and emitted code size from all of the above By moving this logic to indy, we should see no worse init costs for these values but get truly foldable constants. In addition, because all literals of a given type will use the same indy call site logic, that logic will JIT at the JVM level much sooner. We should also see a reduction in metaspace by making the generated class structure smaller and simpler.
- Loading branch information