AOT | Ahead Of Time compilation |
AST | Abstract Syntax Tree |
CST | Concrete Syntax Tree |
GC | Garbage Collection |
IL | Intermediate Language |
IR | Intermediate Representation |
JIT | Just In Time compilation |
JVM | Java Virtual Machine |
LALR | Look Ahead Left-to-right Right derivation |
LL | Left-to-right Left derivation |
LR | Left-to-right Right derivation |
LSP | Local Stack Pointer |
PC | Program Counter |
SP | Stack Pointer |
VM | Virtual Machine |
if
var0
{
- alternation |
363.EQ.363
; avoids mattching 363.
as float(a) * b
is either a type cast or a multiplication if a
is a type or variable respectively.
rule at the end to match any unexpected character if no other rules matchflex
\n
%option yylineno
to get the updated variable0
prefix), and throw if rule matcheselse
with the closest unmatched if
if then end
, if then else end
becomes if then ifend
, where ifend
→ end | else end
Left recursion also a problem. A → A β | ε expands to ε | A | A β | A β β … |
S'
) is on the stack.class
files
0xCAFEBABE
)java.lang.ClassLoader
this
) if anysp
) pointing to top of stacklsp
) points to location in current stack framepc
) points to current instruction.method <modifiers> <name>(<parameter types>) <return type>
.limit stack <limit>
, .limit locals <limit>
.end method
ineg
- negatei2c
- to char, % 65536
iadd
isub
irem
iinc k a
- local[k] += a
iconst_0
- load 0aconst_null
-load null
ldc_int i
- load int
iload k
- add local[k]
to stackistore k
- pop stack and store to local[k]
aload
, astore
, counterparts for referencesgetfield f sig
, putfield f sig
, modify fields of objects using value from stack.goto L
ifeq L
, ifgt L
, ifnonnull L
- reads first stack valueif_icmpeq_L
- compares top two elementsdup
- repeat stack valuepop
swap
nop
- does nothingnew C
- allocate spaceinvokespecial C/<init>()V
- execute constructorinstance_of C
- puts 0 or 1 on stackcheckcast
invokevirtual m sig
- calls method taking in o
(self) plus all argsireturn
, return
ClassLoader
finds class and checks that method exists0xCAFEBABE
if
- 1 labelifelse
- 2 labelswhile
- 2 labels||
and &&
- 1 label (short circuit)==
,<
, >
, <=
, >=
, and !=
- 2 labels (like ifelse
branching, as we are not saving a value in the stack)!:
- 2 labelstoString
coercion - 2 labelsTemplate | Jasmin |
---|---|
if (E) S | E ifeq stop S stop: |
if (E) S_1 else S_2 | E ifeq else S_1 goto stop else: S_2 stop: |
register count;
{
register n = (count + 7) / 8;
switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while (--n > 0);
}
}
retain
and release
inserted at compile timeForward
to ensure that all reference go to the to-space (before the switch)Ri
- unbounded general purpose registerssp
- stack pointer to top of stackfp
- frame pointer to current stack framepc
- program counter to current instruction
[..]
indicates memory location store in registerst <src>, <dst>
st Ri, [Rj]
; [Rj] := Ri
ld <src>, <dst>
ld [Ri + C], Rj
; Rj := [Ri + C]
mov <src>, <dst>
mov Ri, Rj
; Rj := Ri
op <src1>, <src2>, <dst>
add Ri, Rj, Rk
; Rk := Ri + Rj
; (sub
, mul
, div
)b L
; (bg
, bge
, bl
, ble
, bne
)if R1 <= 0 goto L1
→ cmp R1, 0; ble L1
call L
; R15 := pc; pc := L
save sp, -C, sp
; save registers, allocating C bytes on stackrestore
; restore registersret
; pc := R15 + 8
nop
; do nothingpush fp; fp := sp; sp := sp + C
sp := fp; fp = pop
fp
save sp, -C, sp
, where C is arbitrarily large (eg 112; multiple of 4)restore
, then ret
, where the value is R0
R0
, R1
, etcfp = 68 + 4k
, where k is a non-negative integer; this is stored in the callers framefp = 4k
, where k is a non-negative integer (in class, starts at [fp = 12]
)ulimit -a
0x7F
→ i32
flex
or SableCC
dup
, swap
, putfield Class