|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface BaseCompiler
Language-independent base compiler interface to support general-purpose applications.
Field Summary | |
---|---|
static int |
C_DYNAMIC
Normal C-style calling convention except the parameters are on the runtime stack but the procedure address is on the shadow stack. |
static int |
C_JVM
Java-style calling convention for Squawk methods where the address of the method's bytecodes or machine code is passed to the function, and all parameters are provided on the shadow stack. |
static int |
C_JVM_DYNAMIC
Java-style calling convention for Squawk methods with the parameters on the runtime stack but the method address on the shadow stack. |
static int |
C_NORMAL
Normal C-style calling convention with the parameters and procedure address on the shadow stack. |
static int |
E_ADDRESS
Compiled Squawk procedure preamble. |
static int |
E_NONE
Standard C-style calling convention and parameter passing procedures. |
static int |
E_NULL
|
static int |
E_REGISTER
Squawk Interpreter procedure preamble. |
static int |
P_HIGH
Local and parm register allocation hints. |
static int |
P_LOW
Local and parm register allocation hints. |
static int |
P_MEDIUM
Local and parm register allocation hints. |
Fields inherited from interface com.sun.squawk.compiler.Types |
---|
BYTE, DOUBLE, FLOAT, INT, IP, LONG, LP, MP, OOP, REF, RELOC_ABSOLUTE_INT, RELOC_RELATIVE_INT, SHORT, SS, UBYTE, UINT, ULONG, USHORT, UWORD, VOID, WORD |
Method Summary | |
---|---|
Compiler |
add()
Add the top two elements on the stack. |
Compiler |
and()
And the top two elements on the stack. |
Compiler |
begin()
Begin a code scope. |
Compiler |
bf(int dst)
Branch to the label if the popped value is false. |
Compiler |
bf(Label label)
Branch to the label if the popped value is false. |
Compiler |
bind(Label label)
Bind a label to the current location. |
Compiler |
br(int dst)
Unconditionally branch to the label. |
Compiler |
br(Label label)
Unconditionally branch to the label. |
Compiler |
bt(int dst)
Branch to the label if the popped value is true. |
Compiler |
bt(Label label)
Branch to the label if the popped value is true. |
Compiler |
call(int nparms,
Type type)
Call a function. |
Compiler |
call(int nparms,
Type type,
int convention)
Call a function. |
Compiler |
call(Type type)
Call a function. |
Compiler |
call(Type type,
int convention)
Call a function. |
Compiler |
cmpg()
Test the top two floating point elements. |
Compiler |
cmpl()
Test the top two floating point elements. |
Compiler |
com()
Produce the 1's complement of the top element. |
Compiler |
comment(String str)
Add a comment node to the IR. |
Compiler |
compile()
Compiler the IR. |
Compiler |
convert(Type to)
Pop the top most element, convert it to a new type, and push the result. |
Compiler |
data(Label label,
Object obj)
Define some data. |
Compiler |
deadCode()
Specify an unreachable place. |
void |
decode(int relocation)
Dumps the assembler output of the compiler to the console. |
Compiler |
div()
Divide the top two elements on the stack. |
Compiler |
drop()
Pop the top element of the compiler stack. |
Compiler |
dumpAll()
Pop all the element of the compiler stack. |
Compiler |
dup()
Dup the top element of the stack. |
Compiler |
dupReceiver()
Dup the receiver element of the stack. |
Compiler |
end()
End a code scope. |
Compiler |
enter()
Emit a function prologue. |
Compiler |
enter(int preambleCode)
Emit a function prologue. |
Compiler |
enter(Label label)
Emit a function prologue. |
Compiler |
enter(Label label,
int preambleCode)
Emit a function prologue. |
Compiler |
eq()
Test the top two elements. |
Compiler |
force(Type to)
Pop the top most element, force it to be the new type, and push the result. |
Compiler |
ge()
Test the top two elements. |
byte[] |
getCode()
Get the code array buffer. |
int |
getCodeSize()
Get the length of the compiled code. |
SymbolicFixupTable |
getFixupInfo()
Return the offsets to unresolved symbols. |
int |
getLocalCount()
Return the number of locals currently defined. |
int[] |
getRelocationInfo()
Return the relocation information. |
Compiler |
gt()
Test the top two elements. |
boolean |
isBigEndian()
Boolean to say if the machine uses big endian ordering. |
Compiler |
jump()
Jump somewhere. |
Label |
label()
Allocate a label. |
Compiler |
le()
Test the top two elements. |
Compiler |
leave()
Emit a function epilogue. |
Compiler |
leave(MethodMap mmap)
Emit a function epilogue. |
Compiler |
literal(boolean n)
Push a boolean constant onto the stack. |
Compiler |
literal(double n)
Push a double constant onto the stack. |
Compiler |
literal(float n)
Push a float constant onto the stack. |
Compiler |
literal(int n)
Push an integer constant onto the stack. |
Compiler |
literal(Label label)
Push the address of a label onto the stack. |
Compiler |
literal(long n)
Push a long constant onto the stack. |
Compiler |
literal(Object array)
Push an address of an array onto the stack. |
Compiler |
load(Local local)
Get a local variable or parameter and push it onto the stack. |
Compiler |
loadParm()
Get the value of a parameter word. |
boolean |
loadsMustBeAligned()
Boolean to say if the machine can execute unaligned loads. |
Local |
local(Type type)
Define a local variable type. |
Local |
local(Type type,
int hint)
Define a local variable type. |
Compiler |
lt()
Test the top two elements. |
Compiler |
mul()
Multiply the top two elements on the stack. |
Compiler |
ne()
Test the top two elements. |
Compiler |
neg()
Negate (2's complement) the top element. |
Compiler |
or()
Or the top two elements on the stack. |
Local |
parm(Type type)
Define a parameter variable. |
Local |
parm(Type type,
int hint)
Define a parameter variable. |
Compiler |
pop(Type type)
Pop the top element of the runtime stack. |
Compiler |
popAll()
Pop all the elements of the runtime stack. |
Compiler |
push()
Push the data onto the runtime stack. |
Compiler |
read(Type type)
Load a value from a reference. |
Compiler |
rem()
Remainder the top two elements on the stack. |
Compiler |
result(Type type)
Define the function result. |
Compiler |
ret()
Return from a method. |
Compiler |
ret(Type type)
Return from a method. |
Compiler |
shl()
Shift the second element on the stack left by the number of bits specified by the top element. |
Compiler |
shr()
Shift the second element on the stack right by the number of bits specified by the top element. |
Compiler |
store(Local local)
Set a local variable or parameter to a value popped from the stack. |
Compiler |
storeParm()
Set the value of a parameter word. |
Compiler |
sub()
Subtract the top two elements on the stack. |
Compiler |
swap()
Swap the top two elements of the stack. |
Compiler |
swapAll()
Swap the contence of the stack. |
Compiler |
swapForABI()
Swap the contence of the stack if the target ABI push parameters right-to-left. |
Compiler |
symbol(String name)
Push an address of an unresolved symbol onto the stack. |
boolean |
tableSwitchEndPadding()
Boolean to say if the tableswitch and stableswitch are to be padded in such a way that the initial int (the low parameter) is placed on a 4 byte boundary and any padding at the start of the bytecode sequence is complemented at the end so that the size of the sequence is always a constant. |
boolean |
tableSwitchPadding()
Boolean to say if the tableswitch and stableswitch are to be padded in such a way that the initial int (the low parameter) is placed on a 4 byte boundary. |
Type |
tosType()
Return the type of the instruction on the top of the stack. |
Compiler |
ushr()
Shift the second element on the stack right by the number of bits specified by the top element. |
Compiler |
write(Type type)
Store a value at a reference. |
Compiler |
xor()
Xor the top two elements on the stack. |
Field Detail |
---|
static final int E_NONE
static final int E_NULL
static final int E_REGISTER
static final int E_ADDRESS
static final int C_NORMAL
static final int C_DYNAMIC
static final int C_JVM
static final int C_JVM_DYNAMIC
static final int P_LOW
A compliant compiler may ignore these values, but if the compiler does honor them then the following semantics is desired.
P_LOW variables may be allocated in registers or activation slots.
P_MEDIUM variables are better allocated in registers if there are free registers available, otherwise they are allocated in activation slots.
P_HIGH variables hust be allocated in registers, and a compiler that honors the hints should produce a fatal error if this is not possible.
Within each category the variables defined first have higher priority over those defined later.
static final int P_MEDIUM
A compliant compiler may ignore these values, but if the compiler does honor them then the following semantics is desired.
P_LOW variables may be allocated in registers or activation slots.
P_MEDIUM variables are better allocated in registers if there are free registers available, otherwise they are allocated in activation slots.
P_HIGH variables hust be allocated in registers, and a compiler that honors the hints should produce a fatal error if this is not possible.
Within each category the variables defined first have higher priority over those defined later.
static final int P_HIGH
A compliant compiler may ignore these values, but if the compiler does honor them then the following semantics is desired.
P_LOW variables may be allocated in registers or activation slots.
P_MEDIUM variables are better allocated in registers if there are free registers available, otherwise they are allocated in activation slots.
P_HIGH variables hust be allocated in registers, and a compiler that honors the hints should produce a fatal error if this is not possible.
Within each category the variables defined first have higher priority over those defined later.
Method Detail |
---|
Label label()
Stack: ... -> ...
Compiler bind(Label label)
Stack: ... -> ...
label
- the label to bind
Compiler enter(Label label, int preambleCode)
Stack: _ -> _
label
- a label to be bound to the start of the functionpreambleCode
- the special preamble code for the function
Compiler enter(Label label)
Stack: _ -> _
label
- a label to be bound to the start of the function
Compiler enter(int preambleCode)
Stack: _ -> _
preambleCode
- the special preamble code for the function
Compiler enter()
Stack: _ -> _
Local parm(Type type, int hint)
Stack: _ -> _
type
- the type of the local variable (Must be primary)hint
- the P_XXXX priority hint.
Local parm(Type type)
Stack: _ -> _
type
- the type of the local variable (Must be primary)
Compiler result(Type type)
Stack: _ -> _
type
- the type of the parameter (Must be primary)
Compiler leave(MethodMap mmap)
Stack: _ -> _
Compiler leave()
Stack: _ -> _
Compiler begin()
Stack: ... -> ...
Local local(Type type, int hint)
Stack: ... -> ...
type
- the type of the local variable (Must be primary)hint
- the P_XXXX priority hint.
Local local(Type type)
Stack: ... -> ...
type
- the type of the local variable (Must be primary)
Compiler end()
Stack: ... -> ...
int getLocalCount()
Type tosType()
Stack: ... -> ...
Compiler loadParm()
Stack: ..., INDEX -> ..., INT
Note that this method never returns a long. The user of this interface has to deal with longs as two words.
Checks: 1- The index needs to be of type INT.
Compiler storeParm()
Stack: ..., VALUE, INDEX -> ...
Checks: 1- The index needs to be of type INT.
Compiler comment(String str)
Stack: ... -> ...
str
- the comment
Compiler load(Local local)
Stack: ... -> ..., VALUE
local
- the local variable to load
Compiler store(Local local)
Stack: ..., VALUE -> ...
Checks: 1- The local and the value from the stack need to be a primary type.
local
- the local variable to store into
Compiler read(Type type)
Stack: ..., REF -> ..., VALUE
Checks: 1- The value on the top of the stack is of type reference (REF) or OOP. 2- The type of data to be read is either of primary or secondary type.
type
- the type of the data to load
Compiler write(Type type)
Stack: ..., VALUE, REF -> ...
Checks: 1- The address on the top of the stack should be of type reference (REF). 2- The other value on the stack has to have the same primitive type as the type of the write. All types can be used with this method (primary, secondary), except for pseudo types.
type
- the type of the data to load
Compiler literal(int n)
Stack: ... -> ..., VALUE
n
- the value of the constant
Compiler literal(long n)
Stack: ... -> ..., VALUE
n
- the value of the constant
Compiler literal(float n)
Stack: ... -> ..., VALUE
n
- the value of the constant
Compiler literal(double n)
Stack: ... -> ..., VALUE
n
- the value of the constant
Compiler literal(boolean n)
Stack: ... -> ..., VALUE
n
- the value of the constant
Compiler literal(Object array)
Stack: ... -> ..., VALUE
array
- the array
Compiler symbol(String name)
Stack: ... -> ..., VALUE
name
- the name of the symbol
Compiler literal(Label label)
Stack: ... -> ..., VALUE
label
- the label
Compiler data(Label label, Object obj)
Stack: _ -> _
label
- the label to the dataobj
- the array
Compiler dup()
Stack: ... -> ..., VALUE
Compiler dupReceiver()
Stack: ... -> ..., VALUE
In a method call, the receiver is the object whose method is being invoked. This is the implicit first parameter of method calls. Used by all functions that have an invoke virtual.
Compiler drop()
Stack: ..., VALUE -> ...
Compiler dumpAll()
Stack: ... -> _
Compiler swap()
Stack: ... VALUE1, VALUE2 -> ..., VALUE2, VALUE1
Compiler swapAll()
Stack: [VALUE0, ..., VALUEN] -> [VALUEN, ... , VALUE0]
Compiler swapForABI()
Stack: [VALUE0, ..., VALUEN] -> [VALUEN, ... , VALUE0] // Only on right-to-left systems
Compiler push()
Stack: ..., VALUE -> ...
Compiler pop(Type type)
Stack: ... -> ..., VALUE
type
- the data type to pop
Compiler popAll()
Stack: ... -> ...
Compiler force(Type to)
Stack: ... OLDVALUE -> ..., NEWVALUE
Force rules:
The force rules are summarized as follows
From/to int uint long ulong float double ref oop int fnop f f f32 f32 uint f fnop f32 f32 long fnop f f f64 f64 ulong f fnop f64 f64 float f fnop double f fnop ref f32 f32 f64 f64 fnop f oop f32 f32 f64 f64 f fnopwhere
to
- the type to force to
Compiler convert(Type to)
Stack: ... OLDVALUE -> ..., NEWVALUE
Convert rules:
From\To 2nd int uint long ulong float double ref oop 2nd int c cnop c c c uint cnop c long c cnop c c ulong c cnop float c c cnop c double c c c cnop ref cnop oop cnopwhere
to
- the type to convert to
Compiler add()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler sub()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler mul()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler div()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler rem()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler and()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler or()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler xor()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler shl()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler shr()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler ushr()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler neg()
Stack: ..., VALUE -> ..., RESULT
Compiler com()
Stack: ..., VALUE -> ..., RESULT
Compiler eq()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler ne()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler le()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler lt()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler ge()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler gt()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler cmpl()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler cmpg()
Stack: ..., VALUE1, VALUE2 -> ..., RESULT
Compiler br(Label label)
Stack: ... -> ...
Checks
label
- the label to branch to
Compiler bt(Label label)
Stack: ..., VALUE -> ...
label
- the label to branch to
Compiler bf(Label label)
Stack: ..., VALUE -> ...
label
- the label to branch to
Compiler br(int dst)
Stack: _ -> ._
dst
- the absolute destination
Compiler bt(int dst)
Stack: VALUE -> _
dst
- the absolute destination
Compiler bf(int dst)
Stack: VALUE -> _
dst
- the absolute destination
Compiler jump()
Stack: ADDRESS -> _
Checks
Compiler call(int nparms, Type type, int convention)
Stack: ..., VALUEN to VALUE1, ADDRESS -> ..., [RESULT]
Checks
nparms
- the number of parameters to poptype
- the return type to be pushed onto the stackconvention
- the calling convebtion
Compiler call(int nparms, Type type)
Stack: ..., VALUEN to VALUE1, ADDRESS -> ..., [RESULT]
nparms
- the number of parameters to poptype
- the return type to be pushed onto the stack
Compiler call(Type type)
Stack: ..., VALUEN to VALUE1, ADDRESS -> ..., [RESULT]
type
- the return type to be pushed onto the stack
Compiler call(Type type, int convention)
Stack: ..., VALUEN to VALUE1, ADDRESS -> ..., [RESULT]
type
- the return type to be pushed onto the stackconvention
- the calling convention
Compiler ret(Type type)
Stack: ..., [VALUE] -> _
Checks
type
- the return type
Compiler ret()
Stack: ..., [VALUE] -> _
Compiler deadCode()
Stack: _ -> _
boolean loadsMustBeAligned()
boolean isBigEndian()
boolean tableSwitchPadding()
boolean tableSwitchEndPadding()
Compiler compile()
Stack: _ -> _
void decode(int relocation)
int getCodeSize()
byte[] getCode()
int[] getRelocationInfo()
Stack: _ -> _
SymbolicFixupTable getFixupInfo()
Stack: _ -> _
|
" 2013 FRC Java API " |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |