Skip to content

Class Label

🏭 Constructors

constructor public

ts
new Label(): Label

Constructs a new label.

Return Type

  • Label

Defined in: packages/asm/libs/Label.ts:233

🏷️ Properties

frame

ts
frame: null | Frame = null

Information about the input and output stack map frames of this basic block. This field is only used when [ClassWriter#COMPUTE_FRAMES] option is used.

Defined in: packages/asm/libs/Label.ts:201

info public

ts
info: any

Field used to associate user information to a label. Warning: this field is used by the ASM tree package. In order to use it with the ASM tree package you must override the [org.objectweb.asm.tree.MethodNode#getLabelNode] method.

Defined in: packages/asm/libs/Label.ts:122

inputStackTop

ts
inputStackTop: number

Start of the output stack relatively to the input stack. The exact semantics of this field depends on the algorithm that is used.

When only the maximum stack size is computed, this field is the number of elements in the input stack.

When the stack map frames are completely computed, this field is the offset of the first output stack element relatively to the top of the input stack. This offset is always negative or null. A null offset means that the output stack must be appended to the input stack. A -n offset means that the first n output stack elements must replace the top n input stack elements, and that the other elements must be appended to the input stack.

Defined in: packages/asm/libs/Label.ts:188

line

ts
line: number

The line number corresponding to this label, if known. If there are several lines, each line is stored in a separate label, all linked via their next field (these links are created in ClassReader and removed just before visitLabel is called, so that this does not impact the rest of the code).

Defined in: packages/asm/libs/Label.ts:146

next

ts
next: null | Label = null

The next basic block in the basic block stack. This stack is used in the main loop of the fix point algorithm used in the second step of the control flow analysis algorithms. It is also used in #visitSubroutine to avoid using a recursive method, and in ClassReader to temporarily store multiple source lines for a label.

Defined in: packages/asm/libs/Label.ts:228

outputStackMax

ts
outputStackMax: number

Maximum height reached by the output stack, relatively to the top of the input stack. This maximum is always positive or null.

Defined in: packages/asm/libs/Label.ts:194

position

ts
position: number

The position of this label in the code, if known.

Defined in: packages/asm/libs/Label.ts:151

referenceCount private

ts
referenceCount: number

Number of forward references to this label, times two.

Defined in: packages/asm/libs/Label.ts:156

srcAndRefPositions private

ts
srcAndRefPositions: null | number[] = null

Informations about forward references. Each forward reference is described by two consecutive integers in this array: the first one is the position of the first byte of the bytecode instruction that contains the forward reference, while the second is the position of the first byte of the forward reference itself. In fact the sign of the first integer indicates if this reference uses 2 or 4 bytes, and its absolute value gives the position of the bytecode instruction. This array is also used as a bitset to store the subroutines to which a basic block belongs. This information is needed in [MethodWriter#visitMaxs], after all forward references have been resolved. Hence the same array can be used for both purposes without problems.

Defined in: packages/asm/libs/Label.ts:171

status

ts
status: number

Flags that indicate the status of this label.

Defined in: packages/asm/libs/Label.ts:137

successor

ts
successor: Label

The successor of this label, in the order they are visited. This linked list does not include labels used for debug info only. If [ClassWriter#COMPUTE_FRAMES] option is used then, in addition, it does not contain successive labels that denote the same bytecode position (in this case only the first label appears in this list).

Defined in: packages/asm/libs/Label.ts:210

successors

ts
successors: Edge

The successors of this node in the control flow graph. These successors are stored in a linked list of [Edge Edge] objects, linked to each other by their [Edge#next] field.

Defined in: packages/asm/libs/Label.ts:217

DEBUG static

ts
DEBUG: number = 1

Indicates if this label is only used for debug attributes. Such a label is not the start of a basic block, the target of a jump instruction, or an exception handler. It can be safely ignored in control flow graph analysis algorithms (for optimization purposes).

Defined in: packages/asm/libs/Label.ts:55

JSR static

ts
JSR: number = 128

Indicates if this basic block ends with a JSR instruction.

Defined in: packages/asm/libs/Label.ts:92

PUSHED static

ts
PUSHED: number = 8

Indicates if this basic block has been pushed in the basic block stack. See [MethodWriter#visitMaxs visitMaxs].

Defined in: packages/asm/libs/Label.ts:71

REACHABLE static

ts
REACHABLE: number = 64

Indicates if this label corresponds to a reachable basic block.

Defined in: packages/asm/libs/Label.ts:87

RESIZED static

ts
RESIZED: number = 4

Indicates if this label has been updated, after instruction resizing.

Defined in: packages/asm/libs/Label.ts:65

RESOLVED static

ts
RESOLVED: number = 2

Indicates if the position of this label is known.

Defined in: packages/asm/libs/Label.ts:60

RET static

ts
RET: number = 256

Indicates if this basic block ends with a RET instruction.

Defined in: packages/asm/libs/Label.ts:97

STORE static

ts
STORE: number = 32

Indicates if a stack map frame must be stored for this label.

Defined in: packages/asm/libs/Label.ts:82

SUBROUTINE static

ts
SUBROUTINE: number = 512

Indicates if this basic block is the start of a subroutine.

Defined in: packages/asm/libs/Label.ts:102

TARGET static

ts
TARGET: number = 16

Indicates if this label is the target of a jump instruction, or the start of an exception handler.

Defined in: packages/asm/libs/Label.ts:77

VISITED static

ts
VISITED: number = 1024

Indicates if this subroutine basic block has been visited by a visitSubroutine(null, ...) call.

Defined in: packages/asm/libs/Label.ts:108

VISITED2 static

ts
VISITED2: number = 2048

Indicates if this subroutine basic block has been visited by a visitSubroutine(!null, ...) call.

Defined in: packages/asm/libs/Label.ts:114

🔧 Methods

addReference private

ts
addReference(sourcePosition: number, referencePosition: number): void

Adds a forward reference to this label. This method must be called only for a true forward reference, i.e. only if this label is not resolved yet. For backward references, the offset of the reference can be, and must be, computed and stored directly.

Parameters

  • sourcePosition: number the position of the referencing instruction. This position will be used to compute the offset of this forward reference.
  • referencePosition: number the position where the offset for this forward reference must be stored.

Return Type

  • void

Defined in: packages/asm/libs/Label.ts:309

addToSubroutine

ts
addToSubroutine(id: number, nbSubroutines: number): void

Marks this basic block as belonging to the given subroutine.

Parameters

  • id: number a subroutine id.
  • nbSubroutines: number the total number of subroutines in the method.

Return Type

  • void

Defined in: packages/asm/libs/Label.ts:437

getFirst

ts
getFirst(): Label

Returns the first label of the series to which this label belongs. For an isolated label or for the first label in a series of successive labels, this method returns the label itself. For other labels it returns the first label of the series.

Return Type

  • Label

Defined in: packages/asm/libs/Label.ts:387

getOffset public

ts
getOffset(): number

Returns the offset corresponding to this label. This offset is computed from the start of the method's bytecode. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>

Return Type

  • number

Defined in: packages/asm/libs/Label.ts:252

inSameSubroutine

ts
inSameSubroutine(block: Label): boolean

Returns true if this basic block and the given one belong to a common subroutine.

Parameters

  • block: Label another basic block.

Return Type

  • boolean

Defined in: packages/asm/libs/Label.ts:415

inSubroutine

ts
inSubroutine(id: number): boolean

Returns true is this basic block belongs to the given subroutine.

Parameters

  • id: number a subroutine id.

Return Type

  • boolean

Defined in: packages/asm/libs/Label.ts:398

put

ts
put(owner: MethodWriter, out: ByteVector, source: number, wideOffset: boolean): void

Puts a reference to this label in the bytecode of a method. If the position of the label is known, the offset is computed and written directly. Otherwise, a null offset is written and a new forward reference is declared for this label.

Parameters

  • owner: MethodWriter the code writer that calls this method.
  • out: ByteVector the bytecode of the method.
  • source: number the position of first byte of the bytecode instruction that contains this label.
  • wideOffset: boolean <tt>true</tt> if the reference must be stored in 4 bytes, or <tt>false</tt> if it must be stored with 2 bytes.

Return Type

  • void

Defined in: packages/asm/libs/Label.ts:278

resolve

ts
resolve(owner: MethodWriter, position: number, data: Uint8Array): boolean

Resolves all forward references to this label. This method must be called when this label is added to the bytecode of the method, i.e. when its position becomes known. This method fills in the blanks that where left in the bytecode by each forward reference previously added to this label.

Parameters

  • owner: MethodWriter the code writer that calls this method.
  • position: number the position of this label in the bytecode.
  • data: Uint8Array the bytecode of the method.

Return Type

  • boolean

Defined in: packages/asm/libs/Label.ts:345

toString public

ts
toString(): string

Returns a string representation of this label.

Return Type

  • string

Defined in: packages/asm/libs/Label.ts:505

visitSubroutine

ts
visitSubroutine(JSR: null | Label, id: number, nbSubroutines: number): void

Finds the basic blocks that belong to a given subroutine, and marks these blocks as belonging to this subroutine. This method follows the control flow graph to find all the blocks that are reachable from the current block WITHOUT following any JSR target.

Parameters

  • JSR: null | Label a JSR block that jumps to this subroutine. If this JSR is not null it is added to the successor of the RET blocks found in the subroutine.
  • id: number the id of this subroutine.
  • nbSubroutines: number the total number of subroutines in the method.

Return Type

  • void

Defined in: packages/asm/libs/Label.ts:461