joeq.Allocator
Class RuntimeCodeAllocator

java.lang.Object
  extended by joeq.Allocator.CodeAllocator
      extended by joeq.Allocator.RuntimeCodeAllocator

public class RuntimeCodeAllocator
extends CodeAllocator

RuntimeCodeAllocator

Version:
$Id: RuntimeCodeAllocator.java,v 1.22 2004/09/30 03:35:30 joewhaley Exp $
Author:
John Whaley

Nested Class Summary
 class RuntimeCodeAllocator.Runtimex86CodeBuffer
           
 
Nested classes/interfaces inherited from class joeq.Allocator.CodeAllocator
CodeAllocator.InstructionPointer, CodeAllocator.x86CodeBuffer
 
Field Summary
static int BLOCK_SIZE
          Size of blocks allocated from the OS.
 
Fields inherited from class joeq.Allocator.CodeAllocator
_class, _compiledMethods, _highAddress, _lowAddress, compiledMethods, TRACE
 
Constructor Summary
RuntimeCodeAllocator()
           
 
Method Summary
static short endian2(int k)
           
 CodeAllocator.x86CodeBuffer getCodeBuffer(int estimatedSize, int offset, int alignment)
          Allocate a code buffer of the given estimated size, such that the given offset will have the given alignment.
 void init()
          Initialize this code allocator.
 void patchAbsolute(Address addr1, Address addr2)
          Patch the given address to refer to the other given address, in absolute terms.
 void patchRelativeOffset(CodeAddress code, CodeAddress target)
          Patch the given code address to refer to the given code address, in relative terms.
 
Methods inherited from class joeq.Allocator.CodeAllocator
getCodeContaining, getCompiledMethods, getHighAddress, getLowAddress, getNumberOfCompiledMethods, initializeCompiledMethodMap, registerCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

public static final int BLOCK_SIZE
Size of blocks allocated from the OS.

See Also:
Constant Field Values
Constructor Detail

RuntimeCodeAllocator

public RuntimeCodeAllocator()
Method Detail

init

public void init()
          throws OutOfMemoryError
Description copied from class: CodeAllocator
Initialize this code allocator. This method is always called before the code allocator is actually used.

Specified by:
init in class CodeAllocator
Throws:
OutOfMemoryError

getCodeBuffer

public CodeAllocator.x86CodeBuffer getCodeBuffer(int estimatedSize,
                                                 int offset,
                                                 int alignment)
Allocate a code buffer of the given estimated size, such that the given offset will have the given alignment. It is legal for code to exceed the estimated size, but the cost may be high (i.e. it may require recopying of the buffer.)

Specified by:
getCodeBuffer in class CodeAllocator
Parameters:
estimatedSize - estimated size, in bytes, of desired code buffer
offset - desired offset to align to
alignment - desired alignment, or 0 if don't care
Returns:
the new code buffer

patchAbsolute

public void patchAbsolute(Address addr1,
                          Address addr2)
Description copied from class: CodeAllocator
Patch the given address to refer to the other given address, in absolute terms. This is used to patch heap address references in the code, and code references in the heap.

Specified by:
patchAbsolute in class CodeAllocator
Parameters:
addr1 - address to patch
addr2 - address to patch to

patchRelativeOffset

public void patchRelativeOffset(CodeAddress code,
                                CodeAddress target)
Description copied from class: CodeAllocator
Patch the given code address to refer to the given code address, in relative terms. This is used to patch branch targets in the code.

Specified by:
patchRelativeOffset in class CodeAllocator
Parameters:
code - code address to patch
target - code address to patch to

endian2

public static short endian2(int k)


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