本文整理汇总了Java中com.oracle.truffle.api.CompilerDirectives.transferToInterpreterAndInvalidate方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerDirectives.transferToInterpreterAndInvalidate方法的具体用法?Java CompilerDirectives.transferToInterpreterAndInvalidate怎么用?Java CompilerDirectives.transferToInterpreterAndInvalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.oracle.truffle.api.CompilerDirectives
的用法示例。
在下文中一共展示了CompilerDirectives.transferToInterpreterAndInvalidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: instantiateClassObject
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
private SClass instantiateClassObject(final SObject rcvr) {
if (superclassAndMixinResolver == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
createResolverCallTargets();
}
Object superclassAndMixins = superclassAndMixinResolver.call(new Object[] {rcvr});
SClass classObject = instantiation.execute(rcvr, superclassAndMixins);
return classObject;
}
示例2: executeRepeating
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Override
public boolean executeRepeating(VirtualFrame frame) {
try {
if (invalidationCounter >= 0) {
if (invalidationCounter == 0) {
CompilerDirectives.transferToInterpreterAndInvalidate();
invalidationCounter = -1; // disable
} else {
invalidationCounter--;
}
}
if (CompilerDirectives.inCompiledCode()) {
compiled = true;
} else {
compiled = false;
}
int counter = frame.getInt(param1);
frame.setInt(param1, counter - 1);
return counter != 0;
} catch (FrameSlotTypeException e) {
return false;
}
}
示例3: getProfiledArgumentTypes
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
Class<?>[] getProfiledArgumentTypes() {
if (profiledArgumentTypesAssumption == null) {
/*
* We always need an assumption. If this method is called before the profile was
* initialized, we have to be conservative and disable profiling, which is done by
* creating an invalid assumption but leaving the type field null.
*/
CompilerDirectives.transferToInterpreterAndInvalidate();
profiledArgumentTypesAssumption = createAssumption("Profiled Argument Types");
profiledArgumentTypesAssumption.invalidate();
}
if (profiledArgumentTypesAssumption.isValid()) {
return profiledArgumentTypes;
} else {
return null;
}
}
示例4: getProfiledReturnType
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
Class<?> getProfiledReturnType() {
if (profiledReturnTypeAssumption == null) {
/*
* We always need an assumption. If this method is called before the profile was
* initialized, we have to be conservative and disable profiling, which is done by
* creating an invalid assumption but leaving the type field null.
*/
CompilerDirectives.transferToInterpreterAndInvalidate();
profiledReturnTypeAssumption = createAssumption("Profiled Return Type");
profiledReturnTypeAssumption.invalidate();
}
if (profiledReturnTypeAssumption.isValid()) {
return profiledReturnType;
} else {
return null;
}
}
示例5: profileReturnValue
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
final void profileReturnValue(Object result) {
Assumption returnTypeAssumption = profiledReturnTypeAssumption;
if (CompilerDirectives.inInterpreter() && returnTypeAssumption == null) {
// we only profile return values in the interpreter as we don't want to deoptimize
// for immediate compiles.
if (TruffleCompilerOptions.getValue(TruffleReturnTypeSpeculation)) {
profiledReturnType = classOf(result);
profiledReturnTypeAssumption = createAssumption("Profiled Return Type");
}
} else if (profiledReturnType != null) {
if (result == null || profiledReturnType != result.getClass()) {
CompilerDirectives.transferToInterpreterAndInvalidate();
profiledReturnType = null;
returnTypeAssumption.invalidate();
}
}
}
示例6: profileExceptionType
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
final <E extends Throwable> E profileExceptionType(E ex) {
Class<?> cachedClass = exceptionType;
// if cachedClass is null and we are not in the interpreter we don't want to deoptimize
// This usually happens only if the call target was compiled using compile without ever
// calling it.
if (cachedClass != Object.class) {
if (cachedClass != null && cachedClass == ex.getClass()) {
return (E) cachedClass.cast(ex);
}
CompilerDirectives.transferToInterpreterAndInvalidate();
if (cachedClass == null) {
exceptionType = ex.getClass();
} else {
// object class is not reachable for exceptions
exceptionType = Object.class;
}
}
return ex;
}
示例7: setLayoutAndTransferFields
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
private void setLayoutAndTransferFields() {
CompilerDirectives.transferToInterpreterAndInvalidate();
ObjectLayout layoutAtClass;
synchronized (clazz) {
layoutAtClass = clazz.getLayoutForInstances();
if (objectLayout == layoutAtClass) {
return;
}
}
HashMap<SlotDefinition, Object> fieldValues = getAllFields();
objectLayout = layoutAtClass;
extensionPrimFields = getExtendedPrimStorage(layoutAtClass);
extensionObjFields = getExtendedObjectStorage(layoutAtClass);
setAllFields(fieldValues);
}
示例8: evalForRemainingNils
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@ExplodeLoop
public static Object evalForRemainingNils(final VirtualFrame frame,
final ExpressionNode[] exprs, final int next) {
for (int i = next; i < exprs.length; i++) {
Object result = exprs[i].executeGeneric(frame);
if (result != Nil.nilObject) {
CompilerDirectives.transferToInterpreterAndInvalidate();
// TODO: not optimized for partially empty literals,
// changes immediately to object storage
Object[] newStorage = new Object[exprs.length];
for (int j = 0; j < i; j += 1) {
newStorage[j] = Nil.nilObject;
}
newStorage[i] = result;
return evalForRemaining(frame, exprs, newStorage, i + 1);
}
}
return exprs.length;
}
示例9: resolvePromise
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
protected final void resolvePromise(final VirtualFrame frame,
final SResolver resolver, final Object result,
final boolean haltOnResolver, final boolean haltOnResolution) {
// lazy initialization of resolution node
if (resolve == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
if (resolver == null) {
this.resolve = insert(new NullResolver(sourceSection));
} else {
this.resolve = insert(ResolvePromiseNodeFactory.create(false, sourceSection, vm, null,
null, null, null));
}
}
// resolve promise
resolve.executeEvaluated(frame, resolver, result, haltOnResolver, haltOnResolution);
}
示例10: errorPromise
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
protected final void errorPromise(final VirtualFrame frame,
final SResolver resolver, final Object exception,
final boolean haltOnResolver, final boolean haltOnResolution) {
// lazy initialization of resolution node
if (error == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
if (resolver == null) {
this.error = insert(new NullResolver(getSourceSection()));
} else {
this.error = insert(
ErrorPromiseNodeFactory.create(false, sourceSection, vm, null, null, null, null));
}
}
// error promise
error.executeEvaluated(frame, resolver, exception, haltOnResolver, haltOnResolution);
}
示例11: doPreEvaluated
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Override
public Object doPreEvaluated(final VirtualFrame frame, final Object[] args) {
CompilerDirectives.transferToInterpreterAndInvalidate();
// this specialize method is designed to be execute only once and
// tracks its replacement nodes to avoid re-specialization in case of
// re-execution
PreevaluatedExpression newNode;
Lock lock = getLock();
try {
lock.lock();
newNode = specialize(args);
} finally {
lock.unlock();
}
return newNode.doPreEvaluated(frame, args);
}
示例12: doWrite
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Override
public void doWrite(final SObject obj, final Object value) {
if (value instanceof Long) {
accessor.write(obj, (long) value);
if (!accessor.isPrimitiveSet(obj, primMarkProfile)) {
CompilerDirectives.transferToInterpreterAndInvalidate();
accessor.markPrimAsSet(obj);
// fall back to LongSlotWriteSetOrUnset
replace(new LongSlotWriteSetOrUnset(slot, accessor, guard, nextInCache));
}
} else {
TruffleCompiler.transferToInterpreterAndInvalidate("unstabelized write node");
ObjectTransitionSafepoint.INSTANCE.writeAndGeneralizeSlot(obj, slot, value);
}
}
示例13: setSlow
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization(replaces = "setFast")
public Object setSlow(Symbol symbol, Object value) {
CompilerDirectives.transferToInterpreterAndInvalidate();
FrameSlot frameSlot = lookupFrameSlot(symbol);
this.getGlobalFrame().setObject(frameSlot, value);
return value;
}
示例14: valueSlow
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization(replaces = "value")
public Object valueSlow(Symbol symbol) {
CompilerDirectives.transferToInterpreterAndInvalidate();
FrameSlot frameSlot = lookupFrameSlot(symbol);
if (frameSlot == null) {
throw new RuntimeException("value: not set: " + symbol);
}
try {
return this.getContext().getGlobalFrame().getObject(frameSlot);
} catch (FrameSlotTypeException e) {
throw new RuntimeException("value: frame slot type", e);
}
}
示例15: eval
import com.oracle.truffle.api.CompilerDirectives; //导入方法依赖的package包/类
@Specialization
//@CompilerDirectives.TruffleBoundary
public Object eval(VirtualFrame frame, Object expr) {
CompilerDirectives.transferToInterpreterAndInvalidate();
//System.out.println("eval: " + expr);
RootNode root = Analyzer.analyzeRoot(getContext().getLanguage(), expr, Builtins.BUILTIN_SOURCE.createUnavailableSection());
/*if(this.isTail()) {
root.setIsTail();
}*/
CallTarget callTarget = Truffle.getRuntime().createCallTarget(root);
return callTarget.call(frame.getArguments()[0]);
}