org.jikesrvm.compilers.opt.bc2ir
Class GenerateMagic

java.lang.Object
  extended by org.jikesrvm.compilers.opt.bc2ir.GenerateMagic
All Implemented Interfaces:
TIBLayoutConstants

public class GenerateMagic
extends Object
implements TIBLayoutConstants

This class implements the non-machine-specific magics for the opt compiler. By non-machine-specific we mean that the IR generated to implement the magic is independent of the target-architecture. It does not mean that the eventual MIR that implements the magic won't differ from architecture to architecture.


Field Summary
private static int ATTEMPT_OP
           
private static int LOAD_OP
           
private static int PREPARE_OP
           
private static int STORE_OP
           
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Constructor Summary
GenerateMagic()
           
 
Method Summary
private static void cmpHelper(BC2IR bc2ir, GenerationContext gc, ConditionOperand cond, Operand given_o2)
           
(package private) static boolean generateMagic(BC2IR bc2ir, GenerationContext gc, MethodReference meth)
          "Semantic inlining" of methods of the Magic class.
(package private) static boolean generatePolymorphicMagic(BC2IR bc2ir, GenerationContext gc, MethodReference meth, Atom methodName)
           
private static Operator getOperator(TypeReference type, int operatorClass)
           
private static boolean isLoad(Atom methodName)
           
private static boolean isPrefix(Atom prefix, byte[] b)
          Is string a a prefix of string b.
private static boolean isPrepare(Atom methodName)
           
private static LocationOperand mapToMetadata(Operand metadata)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOAD_OP

private static final int LOAD_OP
See Also:
Constant Field Values

PREPARE_OP

private static final int PREPARE_OP
See Also:
Constant Field Values

STORE_OP

private static final int STORE_OP
See Also:
Constant Field Values

ATTEMPT_OP

private static final int ATTEMPT_OP
See Also:
Constant Field Values
Constructor Detail

GenerateMagic

public GenerateMagic()
Method Detail

generateMagic

static boolean generateMagic(BC2IR bc2ir,
                             GenerationContext gc,
                             MethodReference meth)
                      throws MagicNotImplementedException
"Semantic inlining" of methods of the Magic class. Based on the methodName, generate a sequence of opt instructions that implement the magic, updating the expression stack as necessary.

Parameters:
bc2ir - the bc2ir object that is generating the ir containing this magic
gc - must be bc2ir.gc
meth - the RVMMethod that is the magic method
Throws:
MagicNotImplementedException

generatePolymorphicMagic

static boolean generatePolymorphicMagic(BC2IR bc2ir,
                                        GenerationContext gc,
                                        MethodReference meth,
                                        Atom methodName)

cmpHelper

private static void cmpHelper(BC2IR bc2ir,
                              GenerationContext gc,
                              ConditionOperand cond,
                              Operand given_o2)

mapToMetadata

private static LocationOperand mapToMetadata(Operand metadata)

getOperator

private static Operator getOperator(TypeReference type,
                                    int operatorClass)
                             throws MagicNotImplementedException
Throws:
MagicNotImplementedException

isLoad

private static boolean isLoad(Atom methodName)

isPrepare

private static boolean isPrepare(Atom methodName)

isPrefix

private static boolean isPrefix(Atom prefix,
                                byte[] b)
Is string a a prefix of string b. String b is encoded as an ASCII byte array.

Parameters:
prefix - Prefix atom
b - String which may contain prefix, encoded as an ASCII byte array.
Returns:
true if a is a prefix of b