public class OptimizingStatementWriter
extends StatementWriter
A StatementWriter that emits optimized fast-path bytecode for statements involving integer (and other primitive) operations. When type guards confirm that the operands have their original (unboxed) types, the fast path is taken; otherwise execution falls back to the standard dynamic-dispatch slow path.
| Modifiers | Name | Description |
|---|---|---|
static class |
OptimizingStatementWriter.ClassNodeSkip |
Marker metadata used to skip optimization analysis for a class node. |
static class |
OptimizingStatementWriter.StatementMeta |
Stores optimization metadata collected for a statement or expression. |
| Fields inherited from class | Fields |
|---|---|
class StatementWriter |
controller |
| Constructor and description |
|---|
OptimizingStatementWriter(WriterController controller)Creates an optimizing statement writer backed by the given controller. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
setNodeMeta(TypeChooser chooser, ClassNode classNode)Populates optimization metadata for the supplied class. |
|
public void |
writeBlockStatement(BlockStatement statement)* Generates bytecode for a block statement by visiting each contained statement. * Pushes the block's variable scope, emits the statements, and pops afterward. * Named labels on the block create a breakable region so that break label
* within the block jumps to the end of it.
*
*
|
|
public void |
writeDoWhileLoop(DoWhileStatement statement)* Generates bytecode for a do-while loop. * *
|
|
public void |
writeExpressionStatement(ExpressionStatement statement)* Generates bytecode for an expression statement. * Evaluates the expression and discards any value left on the operand stack. * Marks method-call and binary expressions so that unused return values * are elided rather than boxed. * *
|
|
protected void |
writeForInLoop(ForStatement statement)* Generates bytecode for a for-in loop by calling iterator() on the
* collection expression and delegating loop control to
* writeForInLoopControlAndBlock.
*
*
|
|
protected void |
writeForLoopWithClosureList(ForStatement statement)* Generates bytecode for a C-style for(init; cond; incr) loop.
* The collection expression is a ClosureListExpression whose middle
* element is the boolean condition, lower elements are initializers, and
* upper elements are incrementors.
*
*
|
|
public void |
writeIfElse(IfStatement statement)* Generates bytecode for an if/else statement. * *
|
|
protected void |
writeIteratorHasNext(org.objectweb.asm.MethodVisitor mv)* Emits the Iterator.hasNext call via the given visitor. * Overrideable so subclasses can substitute a specialized or inlined variant. * *
|
|
protected void |
writeIteratorNext(org.objectweb.asm.MethodVisitor mv)* Emits the Iterator.next call via the given visitor. * Overrideable so subclasses can substitute a specialized or inlined variant. * *
|
|
public void |
writeReturn(ReturnStatement statement)* Generates bytecode for a return statement. * For void methods emits RETURN after applying any finally blocks.
* For value-returning methods evaluates the expression, casts it to the
* declared return type, and emits the appropriate typed return instruction.
*
*
|
|
public void |
writeWhileLoop(WhileStatement statement)* Generates bytecode for a while loop. * *
|
| Methods inherited from class | Name |
|---|---|
class StatementWriter |
defineLoopIndexVariable, writeAssert, writeBlockStatement, writeBreak, writeContinue, writeDoWhileLoop, writeExpressionStatement, writeForInLoop, writeForInLoopControlAndBlock, writeForLoopWithClosureList, writeForStatement, writeIfElse, writeIteratorHasNext, writeIteratorNext, writeLoopBackEdge, writeReturn, writeStatementLabel, writeSwitch, writeSynchronized, writeThrow, writeTryCatchFinally, writeWhileLoop |
Creates an optimizing statement writer backed by the given controller.
controller - the writer controller for the current compilationPopulates optimization metadata for the supplied class.
chooser - the type chooser used during analysisclassNode - the class to annotate
* Generates bytecode for a block statement by visiting each contained statement.
* Pushes the block's variable scope, emits the statements, and pops afterward.
* Named labels on the block create a breakable region so that break label
* within the block jumps to the end of it.
*
*
block - the block statement to compile* Generates bytecode for a do-while loop. * *
statement - the do-while statement to compile* Generates bytecode for an expression statement. * Evaluates the expression and discards any value left on the operand stack. * Marks method-call and binary expressions so that unused return values * are elided rather than boxed. * *
statement - the expression statement to compile
* Generates bytecode for a for-in loop by calling iterator() on the
* collection expression and delegating loop control to
* writeForInLoopControlAndBlock.
*
*
statement - the for-in statement to compile
* Generates bytecode for a C-style for(init; cond; incr) loop.
* The collection expression is a ClosureListExpression whose middle
* element is the boolean condition, lower elements are initializers, and
* upper elements are incrementors.
*
*
statement - the for statement with a ClosureListExpression collection* Generates bytecode for an if/else statement. * *
statement - the if statement to compile* Emits the Iterator.hasNext call via the given visitor. * Overrideable so subclasses can substitute a specialized or inlined variant. * *
mv - the method visitor to write to* Emits the Iterator.next call via the given visitor. * Overrideable so subclasses can substitute a specialized or inlined variant. * *
mv - the method visitor to write to
* Generates bytecode for a return statement.
* For void methods emits RETURN after applying any finally blocks.
* For value-returning methods evaluates the expression, casts it to the
* declared return type, and emits the appropriate typed return instruction.
*
*
statement - the return statement to compile* Generates bytecode for a while loop. * *
statement - the while statement to compileCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.