dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

add safe local var hoisting

Open jpbempel opened this issue 4 months ago • 2 comments

What Does This Do

Introduce local var hoisting level: 0: no hoisting 1: safe hoisting 2: aggressive hoisting. for now we are only implementing safe hoisting. Aggressive will be later. Safe hoisting consists of scanning the bytecode instructions of the methods to find the store and load for local var, scan local variable table to find potential slot or name conflicts. the safe hoisting is done when there is only one variable per slot without name conflict and for the same type. hoisting is done by extending the range of the local variable to range of the method and initializing to 0 at the beginning of the method. Long and double variable are not part of the safe hoisting because they are using 2 slots and hoisting them can result in a conflict with another variable in another range. Also we prevent hoisting for the second slot for the same reason (forbidden slots)

Motivation

capture local variables for method probe and exception probes

Additional Notes

Contributor Checklist

Jira ticket: DEBUG-3304

jpbempel avatar Jun 25 '25 17:06 jpbempel