Search in sources :

Example 1 with NoInline

use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.

the class VM method write.

/**
 * Low level print to console.
 * @param value   what is printed
 */
@NoInline
public static /* don't waste code space inlining these --dave */
void write(String value) {
    if (value == null) {
        write("null");
    } else {
        if (runningVM) {
            char[] chars = java.lang.JikesRVMSupport.getBackingCharArray(value);
            int numChars = java.lang.JikesRVMSupport.getStringLength(value);
            int offset = java.lang.JikesRVMSupport.getStringOffset(value);
            for (int i = 0; i < numChars; i++) {
                write(chars[offset + i]);
            }
        } else {
            writeNotRunningVM(value);
        }
    }
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) NoInline(org.vmmagic.pragma.NoInline)

Example 2 with NoInline

use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.

the class VM method write.

/**
 * Low level print of an <code>int</code> to console.
 * @param value       what is printed
 */
@NoInline
public static /* don't waste code space inlining these --dave */
void write(int value) {
    if (runningVM) {
        // hex only or decimal only
        int mode = (value < -(1 << 20) || value > (1 << 20)) ? 2 : 0;
        sysCall.sysConsoleWriteInteger(value, mode);
    } else {
        writeNotRunningVM(value);
    }
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) NoInline(org.vmmagic.pragma.NoInline)

Example 3 with NoInline

use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.

the class VM method writeField.

/**
 * Low level print to console.
 * @param value print value
 * @param fieldWidth the number of characters that the output should contain. If the value
 *  is too small, the output will be filled up with enough spaces, starting from the left
 */
@NoInline
public static /* don't waste code space inlining these --dave */
void writeField(int fieldWidth, int value) {
    int len = 1, temp = value;
    if (temp < 0) {
        len++;
        temp = -temp;
    }
    while (temp >= 10) {
        len++;
        temp /= 10;
    }
    while (fieldWidth > len++) write(" ");
    if (runningVM) {
        sysCall.sysConsoleWriteInteger(value, 0);
    } else {
        writeNotRunningVM(value);
    }
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) NoInline(org.vmmagic.pragma.NoInline)

Example 4 with NoInline

use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.

the class JNIHelpers method getVarArgAddress.

/**
 * This method supports var args passed from C.<p>
 *
 * In the Linux Intel C convention, the caller places the args immediately above the
 * saved return address, starting with the first arg. <br>
 *
 * For the JNI functions that takes var args, their prolog code will save the
 * var arg in the glue frame because the values in the register may be lost by
 * subsequent calls. <br>
 *
 * This method copies the var arg values that were saved earlier in glue frame into
 * the spill area of the original caller, thereby doing the work that the callee
 * normally performs in the AIX C convention. <br>
 *
 * NOTE: This method contains internal stack pointer.
 * For now we assume that the stack will not be relocatable while native code is running
 * because native code can hold an address into the stack, so this code is OK,
 * but this is an issue to be resolved later. <br>
 *
 * NOTE:  this method assumes that it is immediately above the
 * invokeWithDotDotVarArg frame, the JNI frame, the glue frame and
 * the C caller frame in the respective order.
 * Therefore, this method will not work if called from anywhere else.
 *
 * <pre>
 *  low address
 *
 *   |  fp  | &lt;- JNIEnvironment.getVarArgAddress
 *   | mid  |
 *   |      |
 *   |      |
 *   |------|
 *   |  fp  | &lt;- JNIEnvironment.invokeWithDotDotVarArg frame
 *   | mid  |
 *   | ...  |
 *   |      |
 *   |      |
 *   |------|
 *   |  fp  | &lt;- JNI method frame
 *   | mid  |
 *   | ...  |
 *   | arg 0|    args copied by JNI prolog (3 for static, nonvirtual,
 *   | arg 1|    or 4 for virtual)
 *   | arg 2|
 *   |      |
 *   |      |
 *   |------|
 *   | fp   | &lt;- Native C caller frame
 *   |return|
 *   | arg 0|
 *   | arg 1|
 *   | arg 2|
 *   | arg 3|
 *   | arg 4|
 *   | arg 5|
 *   | arg 6|
 *   | arg 7|
 *   | arg 8|
 *   | arg 9|
 *   |      |
 *   |      |
 *   |      |
 *
 *   high address
 * </pre>
 *
 * @param skip4Args if true, the calling JNI function has 4 args before the vararg
 *                  if false, the calling JNI function has 3 args before the vararg
 * @return the starting address of the vararg in the caller stack frame
 */
@NoInline
private static Address getVarArgAddress(boolean skip4Args) {
    Address fp = Magic.getFramePointer();
    fp = fp.loadAddress();
    fp = fp.loadAddress();
    return (fp.plus(2 * WORDSIZE + (skip4Args ? 4 * WORDSIZE : 3 * WORDSIZE)));
}
Also used : Address(org.vmmagic.unboxed.Address) NoInline(org.vmmagic.pragma.NoInline)

Example 5 with NoInline

use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.

the class JNIHelpers method invokeWithDotDotVarArg.

/**
 * Common code shared by the JNI functions CallStatic&lt;type&gt;Method
 * (static method invocation)
 * @param methodID the method ID
 * @param expectReturnType the return type of the method to be invoked
 * @return an object that may be the return object or a wrapper for the primitive return value
 * @throws Exception if the return type doesn't match the expected return type
 */
@NoInline
@NoOptCompile
public static // expect a certain stack frame structure
Object invokeWithDotDotVarArg(int methodID, TypeReference expectReturnType) throws Exception {
    MethodReference mr = MemberReference.getMethodRef(methodID);
    Address varargAddress = getVarArgAddress(false);
    Object[] argObjectArray = packageParameterFromVarArg(mr, varargAddress);
    return callMethod(null, mr, argObjectArray, expectReturnType, true);
}
Also used : Address(org.vmmagic.unboxed.Address) MethodReference(org.jikesrvm.classloader.MethodReference) NoInline(org.vmmagic.pragma.NoInline) NoOptCompile(org.vmmagic.pragma.NoOptCompile)

Aggregations

NoInline (org.vmmagic.pragma.NoInline)46 Entrypoint (org.vmmagic.pragma.Entrypoint)23 Address (org.vmmagic.unboxed.Address)22 Unpreemptible (org.vmmagic.pragma.Unpreemptible)10 TIB (org.jikesrvm.objectmodel.TIB)9 Interruptible (org.vmmagic.pragma.Interruptible)9 RVMArray (org.jikesrvm.classloader.RVMArray)8 Word (org.vmmagic.unboxed.Word)6 NoOptCompile (org.vmmagic.pragma.NoOptCompile)5 Offset (org.vmmagic.unboxed.Offset)5 MethodReference (org.jikesrvm.classloader.MethodReference)4 CodeArray (org.jikesrvm.compilers.common.CodeArray)4 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)4 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)3 RVMMethod (org.jikesrvm.classloader.RVMMethod)3 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)3 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)3 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 RVMType (org.jikesrvm.classloader.RVMType)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2