joeq.Allocator
Class CodeAllocator.x86CodeBuffer

java.lang.Object
  extended by joeq.Allocator.CodeAllocator.x86CodeBuffer
Direct Known Subclasses:
BootstrapCodeAllocator.Bootstrapx86CodeBuffer, RuntimeCodeAllocator.Runtimex86CodeBuffer
Enclosing class:
CodeAllocator

public abstract static class CodeAllocator.x86CodeBuffer
extends Object

This class provides the interface for x86 code buffers. These code buffers are used to store generated x86 code. After the code is generated, use the allocateCodeBlock method to obtain a jq_CompiledCode object.


Constructor Summary
CodeAllocator.x86CodeBuffer()
           
 
Method Summary
abstract  void add1(byte i)
          Adds one byte to the end of this code buffer.
abstract  void add2_endian(int i)
          Adds two bytes (little-endian) to the end of this code buffer.
abstract  void add2(int i)
          Adds two bytes (big-endian) to the end of this code buffer.
abstract  void add3(int i)
          Adds three bytes (big-endian) to the end of this code buffer.
abstract  void add4_endian(int i)
          Adds four bytes (little-endian) to the end of this code buffer.
abstract  jq_CompiledCode allocateCodeBlock(jq_Method m, jq_TryCatch[] ex, jq_BytecodeMap bcm, ExceptionDeliverer x, int stackframesize, List codeRelocs, List dataRelocs)
          Uses the code in this buffer, along with the arguments, to create a jq_CompiledCode object.
abstract  byte get1(int k)
          Gets the byte at the given offset in this code buffer.
abstract  int get4_endian(int k)
          Gets the (little-endian) 4 bytes at the given offset in this code buffer.
abstract  CodeAddress getCurrentAddress()
          Returns the current address in this code buffer.
abstract  int getCurrentOffset()
          Returns the current offset in this code buffer.
abstract  CodeAddress getStartAddress()
          Returns the current address in this code buffer.
abstract  void put1(int k, byte instr)
          Sets the byte at the given offset to the given value.
abstract  void put4_endian(int k, int instr)
          Sets the 4 bytes at the given offset to the given (little-endian) value.
abstract  void setEntrypoint()
          Sets the current address as the entrypoint to this code buffer.
abstract  void skip(int nbytes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeAllocator.x86CodeBuffer

public CodeAllocator.x86CodeBuffer()
Method Detail

getCurrentOffset

public abstract int getCurrentOffset()
Returns the current offset in this code buffer.

Returns:
current offset

getStartAddress

public abstract CodeAddress getStartAddress()
Returns the current address in this code buffer.

Returns:
current address

getCurrentAddress

public abstract CodeAddress getCurrentAddress()
Returns the current address in this code buffer.

Returns:
current address

setEntrypoint

public abstract void setEntrypoint()
Sets the current address as the entrypoint to this code buffer.


add1

public abstract void add1(byte i)
Adds one byte to the end of this code buffer. Offset/address increase by 1.

Parameters:
i - the byte to add

add2_endian

public abstract void add2_endian(int i)
Adds two bytes (little-endian) to the end of this code buffer. Offset/address increase by 2.

Parameters:
i - the little-endian value to add

add2

public abstract void add2(int i)
Adds two bytes (big-endian) to the end of this code buffer. Offset/address increase by 2.

Parameters:
i - the big-endian value to add

add3

public abstract void add3(int i)
Adds three bytes (big-endian) to the end of this code buffer. Offset/address increase by 3.

Parameters:
i - the big-endian value to add

add4_endian

public abstract void add4_endian(int i)
Adds four bytes (little-endian) to the end of this code buffer. Offset/address increase by 4.

Parameters:
i - the little-endian value to add

get1

public abstract byte get1(int k)
Gets the byte at the given offset in this code buffer.

Parameters:
k - offset of byte to return
Returns:
byte at given offset

get4_endian

public abstract int get4_endian(int k)
Gets the (little-endian) 4 bytes at the given offset in this code buffer.

Parameters:
k - offset of little-endian 4 bytes to return
Returns:
little-endian 4 bytes at given offset

put1

public abstract void put1(int k,
                          byte instr)
Sets the byte at the given offset to the given value.

Parameters:
k - offset of byte to set
instr - value to set it to

put4_endian

public abstract void put4_endian(int k,
                                 int instr)
Sets the 4 bytes at the given offset to the given (little-endian) value.

Parameters:
k - offset of 4 bytes to set
instr - little-endian value to set it to

skip

public abstract void skip(int nbytes)

allocateCodeBlock

public abstract jq_CompiledCode allocateCodeBlock(jq_Method m,
                                                  jq_TryCatch[] ex,
                                                  jq_BytecodeMap bcm,
                                                  ExceptionDeliverer x,
                                                  int stackframesize,
                                                  List codeRelocs,
                                                  List dataRelocs)
Uses the code in this buffer, along with the arguments, to create a jq_CompiledCode object. Call this method after you are done generating code, and actually want to use it.

Parameters:
m - Java method of this code block, or null if none
ex - exception handler table, or null if none
bcm - bytecode map, or null if none
x - exception deliverer to use for this code, or null if none
stackframesize - size of stack frame in bytes
codeRelocs - list of code relocations for this code buffer, or null if none
dataRelocs - list of data relocations for this code buffer, or null if none
Returns:
a new jq_CompiledCode object for the code


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