use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class LLVMAarch64VaListStorage method shift.
/**
* This is the implementation of the {@code va_arg} instruction.
*/
@SuppressWarnings("static-method")
@ExportMessage
Object shift(Type type, @SuppressWarnings("unused") Frame frame, @CachedLibrary(limit = "1") LLVMManagedReadLibrary readLib, @CachedLibrary(limit = "1") LLVMManagedWriteLibrary writeLib, @Cached BranchProfile regAreaProfile, @Cached("createBinaryProfile()") ConditionProfile isNativizedProfile) {
int regSaveOffs = 0;
int regSaveStep = 0;
boolean lookIntoRegSaveArea = true;
VarArgArea varArgArea = getVarArgArea(type);
RegSaveArea regSaveArea = null;
switch(varArgArea) {
case GP_AREA:
regSaveOffs = Aarch64BitVarArgs.GP_OFFSET;
regSaveStep = Aarch64BitVarArgs.GP_STEP;
regSaveArea = gpSaveArea;
break;
case FP_AREA:
regSaveOffs = Aarch64BitVarArgs.FP_OFFSET;
regSaveStep = Aarch64BitVarArgs.FP_STEP;
regSaveArea = fpSaveArea;
break;
case OVERFLOW_AREA:
lookIntoRegSaveArea = false;
break;
}
if (lookIntoRegSaveArea) {
regAreaProfile.enter();
int offs = readLib.readI32(this, regSaveOffs);
if (offs < 0) {
// The va shift logic for GP/FP regsave areas is done by updating the gp/fp offset
// field in va_list
writeLib.writeI32(this, regSaveOffs, offs + regSaveStep);
assert regSaveArea != null;
long n = regSaveArea.offsetToIndex(offs);
if (n >= 0) {
int i = (int) ((n << 32) >> 32);
return regSaveArea.args[i];
}
}
}
// overflow area
if (isNativizedProfile.profile(isNativized())) {
// Synchronize the managed current argument pointer from the native overflow area
this.overflowArgArea.setOffset(getArgPtrFromNativePtr(this, readLib));
Object currentArg = this.overflowArgArea.getCurrentArg();
// Shift the managed current argument pointer
this.overflowArgArea.shift(1);
// Update the new native current argument pointer from the managed one
long shiftOffs = this.overflowArgArea.getOffset();
LLVMPointer shiftedOverflowAreaPtr = overflowArgAreaBaseNativePtr.increment(shiftOffs);
writeLib.writePointer(this, Aarch64BitVarArgs.OVERFLOW_ARG_AREA, shiftedOverflowAreaPtr);
return currentArg;
} else {
Object currentArg = this.overflowArgArea.getCurrentArg();
this.overflowArgArea.shift(1);
return currentArg;
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class CurrentScopeView method getMembers.
@ExportMessage
Object getMembers(@SuppressWarnings("unused") boolean includeInternal, @CachedLibrary("this.scope") InteropLibrary scopeLib, @CachedLibrary(limit = "5") InteropLibrary parentScopeLib) throws UnsupportedMessageException {
Object allKeys = scopeLib.getMembers(scope);
if (scopeLib.hasScopeParent(scope)) {
Object parentScope = scopeLib.getScopeParent(scope);
Object parentKeys = parentScopeLib.getMembers(parentScope);
return new SubtractedKeys(allKeys, parentKeys);
}
return allKeys;
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class LLVMGlobalContainer method toNative.
@TruffleBoundary
@ExportMessage
public void toNative(@Cached LLVMToNativeNode toNative) {
if (address == 0) {
LLVMMemory memory = LLVMLanguage.get(null).getLLVMMemory();
LLVMNativePointer pointer = memory.allocateMemory(toNative, 8);
address = pointer.asNative();
long value;
Object global = getFallback();
if (global instanceof Number) {
value = ((Number) global).longValue();
} else {
value = toNative.executeWithTarget(global).asNative();
}
memory.putI64(toNative, pointer, value);
}
}
Aggregations