joeq.Compiler.Quad.x86
Class SimpleCompiler

java.lang.Object
  extended by joeq.Compiler.Quad.x86.SimpleCompiler
All Implemented Interfaces:
x86Constants, BasicBlockVisitor, QuadVisitor

public class SimpleCompiler
extends Object
implements x86Constants, BasicBlockVisitor, QuadVisitor

Version:
$Id: SimpleCompiler.java,v 1.28 2004/09/30 03:37:06 joewhaley Exp $
Author:
John Whaley

Nested Class Summary
static class SimpleCompiler.Factory
           
 
Nested classes/interfaces inherited from interface joeq.Compiler.Quad.BasicBlockVisitor
BasicBlockVisitor.AllBasicBlockVisitor, BasicBlockVisitor.EmptyVisitor
 
Nested classes/interfaces inherited from interface joeq.Compiler.Quad.QuadVisitor
QuadVisitor.AllQuadVisitor, QuadVisitor.EmptyVisitor
 
Field Summary
static boolean ALWAYS_TRACE
           
 ControlFlowGraph cfg
           
static int DEFAULT_ALIGNMENT
           
 jq_Method method
           
 Map registerLocations
           
static int THREAD_BLOCK_OFFSET
           
static byte THREAD_BLOCK_PREFIX
           
 boolean TRACE
           
static boolean TRACE_STUBS
           
 boolean TraceArguments
           
static Set TraceMethod_ClassNames
           
static Set TraceMethod_MethodNames
           
 boolean TraceMethods
           
static Set TraceQuad_ClassNames
           
static Set TraceQuad_MethodNames
           
 boolean TraceQuads
           
 
Fields inherited from interface joeq.Assembler.x86.x86Constants
AL, AX, BOUNDS_EX_NUM, CACHE_LINE_SIZE, CJUMP_NEAR, CJUMP_SHORT, COMPLEX, EAX, EBP, EBX, ECX, EDI, EDX, ESI, ESP, JUMP_NEAR, JUMP_SHORT, MOD_DISP32, MOD_DISP8, MOD_EA, MOD_REG, NP, PU, PV, RA, RM_SIB, SCALE_1, SCALE_2, SCALE_4, SCALE_8, SEIMM8, SHIFT_ONCE, UV
 
Constructor Summary
SimpleCompiler()
           
SimpleCompiler(ControlFlowGraph cfg)
           
SimpleCompiler(jq_Method m)
           
 
Method Summary
 jq_CompiledCode compile()
           
 void emitCallMemory(jq_StaticField f)
           
static void emitCallMemory(jq_StaticField f, x86Assembler asm, List data_relocs)
           
 void emitCallRelative(jq_Method target)
           
static void emitCallRelative(jq_Method target, x86Assembler asm, List code_relocs)
           
 void emitFLD64(jq_StaticField f)
           
static void emitFLD64(jq_StaticField f, x86Assembler asm, List data_relocs)
           
 void emitPopMemory(jq_StaticField f)
           
static void emitPopMemory(jq_StaticField f, x86Assembler asm, List data_relocs)
           
 void emitPopMemory8(jq_StaticField f)
           
static void emitPopMemory8(jq_StaticField f, x86Assembler asm, List data_relocs)
           
 void emitPushAddressOf(Object o)
           
static void emitPushAddressOf(Object o, x86Assembler asm, List data_relocs)
           
 void emitPushMemory(jq_StaticField f)
           
static void emitPushMemory(jq_StaticField f, x86Assembler asm, List data_relocs)
           
 void emitPushMemory8(jq_StaticField f)
           
static void emitPushMemory8(jq_StaticField f, x86Assembler asm, List data_relocs)
           
static jq_CompiledCode generate_compile_stub(jq_Method method)
           
 List getCodeRelocs()
           
 List getDataRelocs()
           
 void init(ControlFlowGraph cfg)
           
 void init(jq_Method m)
           
static void main(String[] args)
           
 String toString()
           
 void visitALength(Quad obj)
          An array length instruction.
 void visitAllocation(Quad obj)
          An instruction.that does an allocation.
 void visitALoad(Quad obj)
          An array load instruction.
 void visitArray(Quad obj)
          An instruction.that accesses an array.
 void visitAStore(Quad obj)
          An array store instruction.
 void visitBasicBlock(BasicBlock bb)
          Visit a basic block.
 void visitBinary(Quad obj)
          A binary operation instruction.
 void visitBoundsCheck(Quad obj)
          An array bounds check instruction.
 void visitBranch(Quad obj)
          An instruction that may branch (not including exceptional control flow).
 void visitCheck(Quad obj)
          An exception check instruction.
 void visitCheckCast(Quad obj)
          A type cast check instruction.
 void visitCondBranch(Quad obj)
          A conditional branch instruction.
 void visitExceptionThrower(Quad obj)
          A potentially excepting instruction..
 void visitGetfield(Quad obj)
          A get instance field instruction.
 void visitGetstatic(Quad obj)
          A get static field instruction.
 void visitGoto(Quad obj)
          A goto instruction.
 void visitInstanceField(Quad obj)
          An instruction.that accesses an instance field.
 void visitInstanceOf(Quad obj)
          A type instance of instruction.
 void visitIntIfCmp(Quad obj)
          A compare and branch instruction.
 void visitInvoke(Quad obj)
          An invoke instruction.
 void visitJsr(Quad obj)
          A jump local subroutine instruction.
 void visitLoad(Quad obj)
          An instruction that loads from memory.
 void visitLookupSwitch(Quad obj)
          A lookup switch instruction.
 void visitMemLoad(Quad obj)
          A raw memory load instruction.
 void visitMemStore(Quad obj)
          A raw memory store instruction.
 void visitMonitor(Quad obj)
          An object monitor lock/unlock instruction.
 void visitMove(Quad obj)
          A register move instruction.
 void visitNew(Quad obj)
          An object allocation instruction.
 void visitNewArray(Quad obj)
          An array allocation instruction.
 void visitNullCheck(Quad obj)
          A null pointer check instruction.
 void visitPhi(Quad obj)
          A phi instruction.
 void visitPutfield(Quad obj)
          A put instance field instruction.
 void visitPutstatic(Quad obj)
          A put static field instruction.
 void visitQuad(Quad obj)
          Any quad.
 void visitRet(Quad obj)
          A return from local subroutine instruction.
 void visitReturn(Quad obj)
          A return from method instruction.
 void visitSpecial(Quad obj)
          A special instruction.
 void visitStaticField(Quad obj)
          An instruction.that accesses a static field.
 void visitStore(Quad obj)
          An instruction that stores into memory.
 void visitStoreCheck(Quad obj)
          An object array store type check instruction.
 void visitTableSwitch(Quad obj)
          A jump table switch instruction.
 void visitTypeCheck(Quad obj)
          An instruction.that does a type check.
 void visitUnary(Quad obj)
          A unary operation instruction.
 void visitZeroCheck(Quad obj)
          A divide-by-zero check instruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALWAYS_TRACE

public static boolean ALWAYS_TRACE

TRACE_STUBS

public static boolean TRACE_STUBS

TraceMethod_MethodNames

public static final Set TraceMethod_MethodNames

TraceMethod_ClassNames

public static final Set TraceMethod_ClassNames

TraceQuad_MethodNames

public static final Set TraceQuad_MethodNames

TraceQuad_ClassNames

public static final Set TraceQuad_ClassNames

TraceQuads

public boolean TraceQuads

TraceMethods

public boolean TraceMethods

TraceArguments

public boolean TraceArguments

DEFAULT_ALIGNMENT

public static final int DEFAULT_ALIGNMENT
See Also:
Constant Field Values

cfg

public ControlFlowGraph cfg

method

public jq_Method method

registerLocations

public Map registerLocations

TRACE

public boolean TRACE

THREAD_BLOCK_PREFIX

public static byte THREAD_BLOCK_PREFIX

THREAD_BLOCK_OFFSET

public static int THREAD_BLOCK_OFFSET
Constructor Detail

SimpleCompiler

public SimpleCompiler()

SimpleCompiler

public SimpleCompiler(ControlFlowGraph cfg)

SimpleCompiler

public SimpleCompiler(jq_Method m)
Method Detail

init

public void init(jq_Method m)

init

public void init(ControlFlowGraph cfg)

toString

public String toString()
Overrides:
toString in class Object

emitCallRelative

public final void emitCallRelative(jq_Method target)

emitCallRelative

public static final void emitCallRelative(jq_Method target,
                                          x86Assembler asm,
                                          List code_relocs)

emitPushAddressOf

public final void emitPushAddressOf(Object o)

emitPushAddressOf

public static final void emitPushAddressOf(Object o,
                                           x86Assembler asm,
                                           List data_relocs)

emitPushMemory

public final void emitPushMemory(jq_StaticField f)

emitPushMemory

public static final void emitPushMemory(jq_StaticField f,
                                        x86Assembler asm,
                                        List data_relocs)

emitPushMemory8

public final void emitPushMemory8(jq_StaticField f)

emitPushMemory8

public static final void emitPushMemory8(jq_StaticField f,
                                         x86Assembler asm,
                                         List data_relocs)

emitPopMemory

public final void emitPopMemory(jq_StaticField f)

emitPopMemory

public static final void emitPopMemory(jq_StaticField f,
                                       x86Assembler asm,
                                       List data_relocs)

emitPopMemory8

public final void emitPopMemory8(jq_StaticField f)

emitPopMemory8

public static final void emitPopMemory8(jq_StaticField f,
                                        x86Assembler asm,
                                        List data_relocs)

emitCallMemory

public final void emitCallMemory(jq_StaticField f)

emitCallMemory

public static final void emitCallMemory(jq_StaticField f,
                                        x86Assembler asm,
                                        List data_relocs)

emitFLD64

public final void emitFLD64(jq_StaticField f)

emitFLD64

public static final void emitFLD64(jq_StaticField f,
                                   x86Assembler asm,
                                   List data_relocs)

getCodeRelocs

public final List getCodeRelocs()

getDataRelocs

public final List getDataRelocs()

generate_compile_stub

public static final jq_CompiledCode generate_compile_stub(jq_Method method)

compile

public final jq_CompiledCode compile()

visitBasicBlock

public void visitBasicBlock(BasicBlock bb)
Description copied from interface: BasicBlockVisitor
Visit a basic block.

Specified by:
visitBasicBlock in interface BasicBlockVisitor
Parameters:
bb - basic block to visit

visitExceptionThrower

public void visitExceptionThrower(Quad obj)
Description copied from interface: QuadVisitor
A potentially excepting instruction..

Specified by:
visitExceptionThrower in interface QuadVisitor
See Also:
QuadVisitor.visitExceptionThrower(joeq.Compiler.Quad.Quad)

visitLoad

public void visitLoad(Quad obj)
Description copied from interface: QuadVisitor
An instruction that loads from memory.

Specified by:
visitLoad in interface QuadVisitor
See Also:
QuadVisitor.visitLoad(joeq.Compiler.Quad.Quad)

visitStore

public void visitStore(Quad obj)
Description copied from interface: QuadVisitor
An instruction that stores into memory.

Specified by:
visitStore in interface QuadVisitor
See Also:
QuadVisitor.visitStore(joeq.Compiler.Quad.Quad)

visitBranch

public void visitBranch(Quad obj)
Description copied from interface: QuadVisitor
An instruction that may branch (not including exceptional control flow).

Specified by:
visitBranch in interface QuadVisitor
See Also:
QuadVisitor.visitBranch(joeq.Compiler.Quad.Quad)

visitCondBranch

public void visitCondBranch(Quad obj)
Description copied from interface: QuadVisitor
A conditional branch instruction.

Specified by:
visitCondBranch in interface QuadVisitor
See Also:
QuadVisitor.visitCondBranch(joeq.Compiler.Quad.Quad)

visitCheck

public void visitCheck(Quad obj)
Description copied from interface: QuadVisitor
An exception check instruction.

Specified by:
visitCheck in interface QuadVisitor
See Also:
QuadVisitor.visitCheck(joeq.Compiler.Quad.Quad)

visitStaticField

public void visitStaticField(Quad obj)
Description copied from interface: QuadVisitor
An instruction.that accesses a static field.

Specified by:
visitStaticField in interface QuadVisitor
See Also:
QuadVisitor.visitStaticField(joeq.Compiler.Quad.Quad)

visitInstanceField

public void visitInstanceField(Quad obj)
Description copied from interface: QuadVisitor
An instruction.that accesses an instance field.

Specified by:
visitInstanceField in interface QuadVisitor
See Also:
QuadVisitor.visitInstanceField(joeq.Compiler.Quad.Quad)

visitArray

public void visitArray(Quad obj)
Description copied from interface: QuadVisitor
An instruction.that accesses an array.

Specified by:
visitArray in interface QuadVisitor
See Also:
QuadVisitor.visitArray(joeq.Compiler.Quad.Quad)

visitAllocation

public void visitAllocation(Quad obj)
Description copied from interface: QuadVisitor
An instruction.that does an allocation.

Specified by:
visitAllocation in interface QuadVisitor
See Also:
QuadVisitor.visitAllocation(joeq.Compiler.Quad.Quad)

visitTypeCheck

public void visitTypeCheck(Quad obj)
Description copied from interface: QuadVisitor
An instruction.that does a type check.

Specified by:
visitTypeCheck in interface QuadVisitor
See Also:
QuadVisitor.visitTypeCheck(joeq.Compiler.Quad.Quad)

visitALoad

public void visitALoad(Quad obj)
Description copied from interface: QuadVisitor
An array load instruction.

Specified by:
visitALoad in interface QuadVisitor
See Also:
QuadVisitor.visitALoad(joeq.Compiler.Quad.Quad)

visitAStore

public void visitAStore(Quad obj)
Description copied from interface: QuadVisitor
An array store instruction.

Specified by:
visitAStore in interface QuadVisitor
See Also:
QuadVisitor.visitAStore(joeq.Compiler.Quad.Quad)

visitALength

public void visitALength(Quad obj)
Description copied from interface: QuadVisitor
An array length instruction.

Specified by:
visitALength in interface QuadVisitor
See Also:
QuadVisitor.visitALength(joeq.Compiler.Quad.Quad)

visitBinary

public void visitBinary(Quad obj)
Description copied from interface: QuadVisitor
A binary operation instruction.

Specified by:
visitBinary in interface QuadVisitor
See Also:
QuadVisitor.visitBinary(joeq.Compiler.Quad.Quad)

visitBoundsCheck

public void visitBoundsCheck(Quad obj)
Description copied from interface: QuadVisitor
An array bounds check instruction.

Specified by:
visitBoundsCheck in interface QuadVisitor
See Also:
QuadVisitor.visitBoundsCheck(joeq.Compiler.Quad.Quad)

visitCheckCast

public void visitCheckCast(Quad obj)
Description copied from interface: QuadVisitor
A type cast check instruction.

Specified by:
visitCheckCast in interface QuadVisitor
See Also:
QuadVisitor.visitCheckCast(joeq.Compiler.Quad.Quad)

visitGetfield

public void visitGetfield(Quad obj)
Description copied from interface: QuadVisitor
A get instance field instruction.

Specified by:
visitGetfield in interface QuadVisitor
See Also:
QuadVisitor.visitGetfield(joeq.Compiler.Quad.Quad)

visitGetstatic

public void visitGetstatic(Quad obj)
Description copied from interface: QuadVisitor
A get static field instruction.

Specified by:
visitGetstatic in interface QuadVisitor
See Also:
QuadVisitor.visitGetstatic(joeq.Compiler.Quad.Quad)

visitGoto

public void visitGoto(Quad obj)
Description copied from interface: QuadVisitor
A goto instruction.

Specified by:
visitGoto in interface QuadVisitor
See Also:
QuadVisitor.visitGoto(joeq.Compiler.Quad.Quad)

visitInstanceOf

public void visitInstanceOf(Quad obj)
Description copied from interface: QuadVisitor
A type instance of instruction.

Specified by:
visitInstanceOf in interface QuadVisitor
See Also:
QuadVisitor.visitInstanceOf(joeq.Compiler.Quad.Quad)

visitIntIfCmp

public void visitIntIfCmp(Quad obj)
Description copied from interface: QuadVisitor
A compare and branch instruction.

Specified by:
visitIntIfCmp in interface QuadVisitor
See Also:
QuadVisitor.visitIntIfCmp(joeq.Compiler.Quad.Quad)

visitInvoke

public void visitInvoke(Quad obj)
Description copied from interface: QuadVisitor
An invoke instruction.

Specified by:
visitInvoke in interface QuadVisitor
See Also:
QuadVisitor.visitInvoke(joeq.Compiler.Quad.Quad)

visitJsr

public void visitJsr(Quad obj)
Description copied from interface: QuadVisitor
A jump local subroutine instruction.

Specified by:
visitJsr in interface QuadVisitor
See Also:
QuadVisitor.visitJsr(joeq.Compiler.Quad.Quad)

visitLookupSwitch

public void visitLookupSwitch(Quad obj)
Description copied from interface: QuadVisitor
A lookup switch instruction.

Specified by:
visitLookupSwitch in interface QuadVisitor
See Also:
QuadVisitor.visitLookupSwitch(joeq.Compiler.Quad.Quad)

visitMemLoad

public void visitMemLoad(Quad obj)
Description copied from interface: QuadVisitor
A raw memory load instruction.

Specified by:
visitMemLoad in interface QuadVisitor
See Also:
QuadVisitor.visitMemLoad(joeq.Compiler.Quad.Quad)

visitMemStore

public void visitMemStore(Quad obj)
Description copied from interface: QuadVisitor
A raw memory store instruction.

Specified by:
visitMemStore in interface QuadVisitor
See Also:
QuadVisitor.visitMemStore(joeq.Compiler.Quad.Quad)

visitMonitor

public void visitMonitor(Quad obj)
Description copied from interface: QuadVisitor
An object monitor lock/unlock instruction.

Specified by:
visitMonitor in interface QuadVisitor
See Also:
QuadVisitor.visitMonitor(joeq.Compiler.Quad.Quad)

visitMove

public void visitMove(Quad obj)
Description copied from interface: QuadVisitor
A register move instruction.

Specified by:
visitMove in interface QuadVisitor
See Also:
QuadVisitor.visitMove(joeq.Compiler.Quad.Quad)

visitPhi

public void visitPhi(Quad obj)
Description copied from interface: QuadVisitor
A phi instruction. (For SSA.)

Specified by:
visitPhi in interface QuadVisitor
See Also:
QuadVisitor.visitPhi(joeq.Compiler.Quad.Quad)

visitNew

public void visitNew(Quad obj)
Description copied from interface: QuadVisitor
An object allocation instruction.

Specified by:
visitNew in interface QuadVisitor
See Also:
QuadVisitor.visitNew(joeq.Compiler.Quad.Quad)

visitNewArray

public void visitNewArray(Quad obj)
Description copied from interface: QuadVisitor
An array allocation instruction.

Specified by:
visitNewArray in interface QuadVisitor
See Also:
QuadVisitor.visitNewArray(joeq.Compiler.Quad.Quad)

visitNullCheck

public void visitNullCheck(Quad obj)
Description copied from interface: QuadVisitor
A null pointer check instruction.

Specified by:
visitNullCheck in interface QuadVisitor
See Also:
QuadVisitor.visitNullCheck(joeq.Compiler.Quad.Quad)

visitPutfield

public void visitPutfield(Quad obj)
Description copied from interface: QuadVisitor
A put instance field instruction.

Specified by:
visitPutfield in interface QuadVisitor
See Also:
QuadVisitor.visitPutfield(joeq.Compiler.Quad.Quad)

visitPutstatic

public void visitPutstatic(Quad obj)
Description copied from interface: QuadVisitor
A put static field instruction.

Specified by:
visitPutstatic in interface QuadVisitor
See Also:
QuadVisitor.visitPutstatic(joeq.Compiler.Quad.Quad)

visitRet

public void visitRet(Quad obj)
Description copied from interface: QuadVisitor
A return from local subroutine instruction.

Specified by:
visitRet in interface QuadVisitor
See Also:
QuadVisitor.visitRet(joeq.Compiler.Quad.Quad)

visitReturn

public void visitReturn(Quad obj)
Description copied from interface: QuadVisitor
A return from method instruction.

Specified by:
visitReturn in interface QuadVisitor
See Also:
QuadVisitor.visitReturn(joeq.Compiler.Quad.Quad)

visitSpecial

public void visitSpecial(Quad obj)
Description copied from interface: QuadVisitor
A special instruction.

Specified by:
visitSpecial in interface QuadVisitor
See Also:
QuadVisitor.visitSpecial(joeq.Compiler.Quad.Quad)

visitStoreCheck

public void visitStoreCheck(Quad obj)
Description copied from interface: QuadVisitor
An object array store type check instruction.

Specified by:
visitStoreCheck in interface QuadVisitor
See Also:
QuadVisitor.visitStoreCheck(joeq.Compiler.Quad.Quad)

visitTableSwitch

public void visitTableSwitch(Quad obj)
Description copied from interface: QuadVisitor
A jump table switch instruction.

Specified by:
visitTableSwitch in interface QuadVisitor
See Also:
QuadVisitor.visitTableSwitch(joeq.Compiler.Quad.Quad)

visitUnary

public void visitUnary(Quad obj)
Description copied from interface: QuadVisitor
A unary operation instruction.

Specified by:
visitUnary in interface QuadVisitor
See Also:
QuadVisitor.visitUnary(joeq.Compiler.Quad.Quad)

visitZeroCheck

public void visitZeroCheck(Quad obj)
Description copied from interface: QuadVisitor
A divide-by-zero check instruction.

Specified by:
visitZeroCheck in interface QuadVisitor
See Also:
QuadVisitor.visitZeroCheck(joeq.Compiler.Quad.Quad)

visitQuad

public void visitQuad(Quad obj)
Description copied from interface: QuadVisitor
Any quad.

Specified by:
visitQuad in interface QuadVisitor
See Also:
QuadVisitor.visitQuad(joeq.Compiler.Quad.Quad)

main

public static void main(String[] args)


Copyright © 2001-2005 John Whaley. All Rights Reserved.