use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method unresolvedNewArray.
/**
* Allocate something like "new Foo[]".
* @param numElements number of array elements
* @param id id of type reference of array to create.
* @param site the site id of the calling allocation site
* @return array with header installed and all fields set to zero/null
* See also: bytecode 0xbc ("anewarray")
*/
@Entrypoint
public static Object unresolvedNewArray(int numElements, int id, int site) throws NoClassDefFoundError, OutOfMemoryError, NegativeArraySizeException {
TypeReference tRef = TypeReference.getTypeRef(id);
RVMType t = tRef.peekType();
if (t == null) {
t = tRef.resolve();
}
RVMArray array = t.asArray();
if (!array.isInitialized()) {
array.resolve();
array.instantiate();
}
return resolvedNewArray(numElements, array, site);
}
use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method unresolvedNewScalar.
// ---------------------------------------------------------------//
// Object Allocation. //
// ---------------------------------------------------------------//
/**
* Allocate something like "new Foo()".
* @param id id of type reference of class to create
* @param site the site id of the calling allocation site
* @return object with header installed and all fields set to zero/null
* (ready for initializer to be run on it)
* See also: bytecode 0xbb ("new")
*/
@Entrypoint
static Object unresolvedNewScalar(int id, int site) throws NoClassDefFoundError, OutOfMemoryError {
TypeReference tRef = TypeReference.getTypeRef(id);
RVMType t = tRef.peekType();
if (t == null) {
t = tRef.resolve();
}
RVMClass cls = t.asClass();
if (!cls.isInitialized()) {
initializeClassForDynamicLink(cls);
}
int allocator = MemoryManager.pickAllocator(cls);
int align = ObjectModel.getAlignment(cls);
int offset = ObjectModel.getOffsetForAlignment(cls, false);
return resolvedNewScalar(cls.getInstanceSize(), cls.getTypeInformationBlock(), cls.hasFinalizer(), allocator, align, offset, site);
}
use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.
the class OutOfLineMachineCode method generateReflectiveMethodInvokerInstructions.
/**
* Machine code for reflective method invocation.
* See also: "Compiler.generateMethodInvocation".
*
*<pre>
* Registers taken at runtime:
* T0 == address of method entrypoint to be called
* T1 == address of gpr registers to be loaded
* T2 == address of fpr registers to be loaded
* T4 == address of spill area in calling frame
*
* Registers returned at runtime:
* standard return value conventions used
*
* Side effects at runtime:
* artificial stackframe created and destroyed
* R0, volatile, and scratch registers destroyed
* </pre>
*/
private static CodeArray generateReflectiveMethodInvokerInstructions() {
Assembler asm = new Assembler(0);
//
// free registers: 0, S0
//
// save...
asm.emitMFLR(GPR.R0);
// ...return address
asm.emitSTAddr(GPR.R0, STACKFRAME_RETURN_ADDRESS_OFFSET.toInt(), FP);
// CTR := start of method code
asm.emitMTCTR(T0);
//
// free registers: 0, S0, T0
//
// create new frame
//
// S0 := old frame pointer
asm.emitMR(S0, FP);
// T0 := number of spill words
asm.emitLIntOffset(T0, T4, ObjectModel.getArrayLengthOffset());
// T4 -= 4 (predecrement, ie. T4 + 4 is &spill[0] )
asm.emitADDI(T4, -BYTES_IN_ADDRESS, T4);
int spillLoopLabel = asm.getMachineCodeIndex();
// T0 -= 1 (and set CR)
asm.emitADDICr(T0, T0, -1);
// if T0 < 0 then break
ForwardReference fr1 = asm.emitForwardBC(LT);
// R0 := *(T4 += 4)
asm.emitLAddrU(GPR.R0, BYTES_IN_ADDRESS, T4);
// put one word of spill area
asm.emitSTAddrU(GPR.R0, -BYTES_IN_ADDRESS, FP);
// goto spillLoop:
asm.emitB(spillLoopLabel);
fr1.resolve(asm);
// allocate frame header and save old fp
asm.emitSTAddrU(S0, -STACKFRAME_HEADER_SIZE, FP);
asm.emitLVAL(T0, INVISIBLE_METHOD_ID);
// set method id
asm.emitSTWoffset(T0, FP, STACKFRAME_METHOD_ID_OFFSET);
//
// free registers: 0, S0, T0, T4
//
// load up fprs
//
ForwardReference setupFPRLoader = asm.emitForwardBL();
for (int i = LAST_VOLATILE_FPR.value(); i >= FIRST_VOLATILE_FPR.value(); --i) {
// FPRi := fprs[i]
asm.emitLFDU(FPR.lookup(i), BYTES_IN_DOUBLE, T2);
}
//
// free registers: 0, S0, T0, T2, T4
//
// load up gprs
//
ForwardReference setupGPRLoader = asm.emitForwardBL();
for (int i = LAST_VOLATILE_GPR.value(); i >= FIRST_VOLATILE_GPR.value(); --i) {
// GPRi := gprs[i]
asm.emitLAddrU(GPR.lookup(i), BYTES_IN_ADDRESS, S0);
}
//
// free registers: 0, S0
//
// invoke method
//
// branch and link to method code
asm.emitBCCTRL();
// emit method epilog
//
// restore caller's frame
asm.emitLAddr(FP, 0, FP);
// pick up return address
asm.emitLAddr(S0, STACKFRAME_RETURN_ADDRESS_OFFSET.toInt(), FP);
//
asm.emitMTLR(S0);
// return to caller
asm.emitBCLR();
setupFPRLoader.resolve(asm);
// T4 := address of first fpr load instruction
asm.emitMFLR(T4);
// T0 := number of fprs to be loaded
asm.emitLIntOffset(T0, T2, ObjectModel.getArrayLengthOffset());
asm.emitADDI(T4, VOLATILE_FPRS << LG_INSTRUCTION_WIDTH, // T4 := address of first instruction following fpr loads
T4);
// T0 := number of bytes of fpr load instructions
asm.emitSLWI(T0, T0, LG_INSTRUCTION_WIDTH);
// T4 := address of instruction for highest numbered fpr to be loaded
asm.emitSUBFC(T4, T0, T4);
// LR := """
asm.emitMTLR(T4);
// predecrement fpr index (to prepare for update instruction)
asm.emitADDI(T2, -BYTES_IN_DOUBLE, T2);
// branch to fpr loading instructions
asm.emitBCLR();
setupGPRLoader.resolve(asm);
// T4 := address of first gpr load instruction
asm.emitMFLR(T4);
// T0 := number of gprs to be loaded
asm.emitLIntOffset(T0, T1, ObjectModel.getArrayLengthOffset());
asm.emitADDI(T4, VOLATILE_GPRS << LG_INSTRUCTION_WIDTH, // T4 := address of first instruction following gpr loads
T4);
// T0 := number of bytes of gpr load instructions
asm.emitSLWI(T0, T0, LG_INSTRUCTION_WIDTH);
// T4 := address of instruction for highest numbered gpr to be loaded
asm.emitSUBFC(T4, T0, T4);
// LR := """
asm.emitMTLR(T4);
// predecrement gpr index (to prepare for update instruction)
asm.emitADDI(S0, -BYTES_IN_ADDRESS, T1);
// branch to gpr loading instructions
asm.emitBCLR();
return asm.getMachineCodes();
}
use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.
the class DynamicLinker method lazyMethodInvoker.
/**
* Resolve, compile if necessary, and invoke a method.
* <pre>
* Taken: nothing (calling context is implicit)
* Returned: does not return (method dispatch table is updated and method is executed)
* </pre>
*/
@Entrypoint
static void lazyMethodInvoker() {
DynamicLink dl = DL_Helper.resolveDynamicInvocation();
RVMMethod targMethod = DL_Helper.resolveMethodRef(dl);
DL_Helper.compileMethod(dl, targMethod);
CodeArray code = targMethod.getCurrentEntryCodeArray();
// restore parameters and invoke
Magic.dynamicBridgeTo(code);
// does not return here
if (VM.VerifyAssertions)
VM._assert(NOT_REACHED);
}
use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.
the class DynamicLinker method unimplementedNativeMethod.
/**
* Report unimplemented native method error.
* <pre>
* Taken: nothing (calling context is implicit)
* Returned: does not return (throws UnsatisfiedLinkError)
* </pre>
*/
@Entrypoint
static void unimplementedNativeMethod() {
DynamicLink dl = DL_Helper.resolveDynamicInvocation();
RVMMethod targMethod = DL_Helper.resolveMethodRef(dl);
throw new UnsatisfiedLinkError(targMethod.toString());
}
Aggregations