translateToLevelTwo

fun translateToLevelTwo(code: A_RawFunction, optimizationLevel: OptimizationLevel, interpreter: Interpreter)

Translate the provided A_RawFunction to produce an optimized L2Chunk that is then written back into the code for subsequent executions. Also update the Interpreter's chunk and offset to use this new chunk right away. If the code was a primitive, make sure to adjust the offset to just beyond its L2_TRY_PRIMITIVE instruction, which must have already been attempted and failed for us to have reached the L2_DECREMENT_COUNTER_AND_REOPTIMIZE_ON_ZERO that caused this optimization to happen.

Parameters

code

The A_RawFunction to optimize.

optimizationLevel

How much optimization to attempt.

interpreter

The Interpreter used for folding expressions, and to be updated with the new chunk and post-primitive offset.