本文整理汇总了Java中com.oracle.truffle.api.CompilerDirectives类的典型用法代码示例。如果您正苦于以下问题:Java CompilerDirectives类的具体用法?Java CompilerDirectives怎么用?Java CompilerDirectives使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilerDirectives类属于com.oracle.truffle.api包,在下文中一共展示了CompilerDirectives类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:smarr,项目名称:SOMns,代码行数:11,代码来源:ClassSlotAccessNode.java
示例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;
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:26,代码来源:OptimizedOSRLoopNodeTest.java
示例3: executeLoop
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Override
public void executeLoop(VirtualFrame frame) {
if (CompilerDirectives.inInterpreter()) {
try {
boolean done = false;
while (!done) {
if (compiledOSRLoop == null) {
done = profilingLoop(frame);
} else {
done = compilingLoop(frame);
}
}
} finally {
baseLoopCount = 0;
}
} else {
while (repeatableNode.executeRepeating(frame)) {
if (CompilerDirectives.inInterpreter()) {
// compiled method got invalidated. We might need OSR again.
executeLoop(frame);
return;
}
}
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:26,代码来源:OptimizedOSRLoopNode.java
示例4: executeImpl
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Override
protected Object executeImpl(VirtualFrame originalFrame) {
FrameWithoutBoxing loopFrame = (FrameWithoutBoxing) (originalFrame);
FrameWithoutBoxing parentFrame = (FrameWithoutBoxing) (loopFrame.getArguments()[0]);
executeTransfer(parentFrame, loopFrame, readFrameSlots, readFrameSlotsTags);
try {
while (loopNode.getRepeatingNode().executeRepeating(loopFrame)) {
if (CompilerDirectives.inInterpreter()) {
return Boolean.FALSE;
}
}
return Boolean.TRUE;
} finally {
executeTransfer(loopFrame, parentFrame, writtenFrameSlots, writtenFrameSlotsTags);
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:17,代码来源:OptimizedOSRLoopNode.java
示例5: 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;
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:19,代码来源:OptimizedCompilationProfile.java
示例6: 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;
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:19,代码来源:OptimizedCompilationProfile.java
示例7: 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();
}
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:18,代码来源:OptimizedCompilationProfile.java
示例8: 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;
}
开发者ID:graalvm,项目名称:graal-core,代码行数:21,代码来源:OptimizedCompilationProfile.java
示例9: postPartialEvaluation
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
private static void postPartialEvaluation(final StructuredGraph graph) {
NeverPartOfCompilationNode.verifyNotFoundIn(graph);
for (AllowMaterializeNode materializeNode : graph.getNodes(AllowMaterializeNode.TYPE).snapshot()) {
materializeNode.replaceAtUsages(materializeNode.getFrame());
graph.removeFixed(materializeNode);
}
for (VirtualObjectNode virtualObjectNode : graph.getNodes(VirtualObjectNode.TYPE)) {
if (virtualObjectNode instanceof VirtualInstanceNode) {
VirtualInstanceNode virtualInstanceNode = (VirtualInstanceNode) virtualObjectNode;
ResolvedJavaType type = virtualInstanceNode.type();
if (type.getAnnotation(CompilerDirectives.ValueType.class) != null) {
virtualInstanceNode.setIdentity(false);
}
}
}
if (!TruffleCompilerOptions.getValue(TruffleInlineAcrossTruffleBoundary)) {
// Do not inline across Truffle boundaries.
for (MethodCallTargetNode mct : graph.getNodes(MethodCallTargetNode.TYPE)) {
if (mct.targetMethod().getAnnotation(TruffleBoundary.class) != null) {
mct.invoke().setUseForInlining(false);
}
}
}
}
开发者ID:graalvm,项目名称:graal-core,代码行数:26,代码来源:PartialEvaluator.java
示例10: 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);
}
开发者ID:smarr,项目名称:SOMns,代码行数:20,代码来源:SObject.java
示例11: doPutEvalBlock
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization
public SMutableArray doPutEvalBlock(final SMutableArray rcvr,
final SBlock block, final long length) {
if (length <= 0) {
return rcvr;
}
try {
Object newStorage = ArraySetAllStrategy.evaluateFirstDetermineStorageAndEvaluateRest(
block, length, this.block);
rcvr.transitionTo(newStorage);
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return rcvr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:PutAllNode.java
示例12: doEmptyArray
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "arr.isEmptyType()")
public final SArray doEmptyArray(final SArray arr, final SBlock block) {
int length = arr.getEmptyStorage(storageType);
try {
if (SArray.FIRST_IDX < length) {
execBlock(block, Nil.nilObject);
}
for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
execBlock(block, Nil.nilObject);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return arr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:18,代码来源:DoPrim.java
示例13: doPartiallyEmptyArray
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "arr.isPartiallyEmptyType()")
public final SArray doPartiallyEmptyArray(final SArray arr, final SBlock block) {
PartiallyEmptyArray storage = arr.getPartiallyEmptyStorage(storageType);
int length = storage.getLength();
try {
if (SArray.FIRST_IDX < length) {
execBlock(block, storage.get(SArray.FIRST_IDX));
}
for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
execBlock(block, storage.get(i));
}
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return arr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:DoPrim.java
示例14: doObjectArray
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "arr.isObjectType()")
public final SArray doObjectArray(final SArray arr, final SBlock block) {
Object[] storage = arr.getObjectStorage(storageType);
int length = storage.length;
try {
if (SArray.FIRST_IDX < length) {
execBlock(block, storage[SArray.FIRST_IDX]);
}
for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
execBlock(block, storage[(int) i]);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return arr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:DoPrim.java
示例15: doLongArray
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "arr.isLongType()")
public final SArray doLongArray(final SArray arr, final SBlock block) {
long[] storage = arr.getLongStorage(storageType);
int length = storage.length;
try {
if (SArray.FIRST_IDX < length) {
execBlock(block, storage[SArray.FIRST_IDX]);
}
for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
execBlock(block, storage[(int) i]);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return arr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:DoPrim.java
示例16: doDoubleArray
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "arr.isDoubleType()")
public final SArray doDoubleArray(final SArray arr, final SBlock block) {
double[] storage = arr.getDoubleStorage(storageType);
int length = storage.length;
try {
if (SArray.FIRST_IDX < length) {
execBlock(block, storage[SArray.FIRST_IDX]);
}
for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
execBlock(block, storage[(int) i]);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return arr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:DoPrim.java
示例17: doBooleanArray
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "arr.isBooleanType()")
public final SArray doBooleanArray(final SArray arr, final SBlock block) {
boolean[] storage = arr.getBooleanStorage(storageType);
int length = storage.length;
try {
if (SArray.FIRST_IDX < length) {
execBlock(block, storage[SArray.FIRST_IDX]);
}
for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
execBlock(block, storage[(int) i]);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(length, this);
}
}
return arr;
}
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:DoPrim.java
示例18: create
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization(guards = "isValueArrayClass(valueArrayClass)")
public SImmutableArray create(final SClass valueArrayClass, final long size,
final SBlock block) {
if (size <= 0) {
return new SImmutableArray(0, valueArrayClass);
}
try {
Object newStorage = ArraySetAllStrategy.evaluateFirstDetermineStorageAndEvaluateRest(
block, size, this.block, isValue);
return new SImmutableArray(newStorage, valueArrayClass);
} finally {
if (CompilerDirectives.inInterpreter()) {
SomLoop.reportLoopCount(size, this);
}
}
}
开发者ID:smarr,项目名称:SOMns,代码行数:18,代码来源:NewImmutableArrayNode.java
示例19: 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;
}
开发者ID:smarr,项目名称:SOMns,代码行数:20,代码来源:ArraySetAllStrategy.java
示例20: write
import com.oracle.truffle.api.CompilerDirectives; //导入依赖的package包/类
@Specialization
public final Object write(final VirtualFrame frame, final SChannelOutput out,
final Object val) {
if (!isVal.executeEvaluated(val)) {
KernelObj.signalException("signalNotAValueWith:", val);
}
try {
out.writeAndSuspendReader(val, afterRead.executeShouldHalt());
if (out.shouldBreakAfterWrite()) {
haltNode.executeEvaluated(frame, val);
}
} catch (InterruptedException e) {
CompilerDirectives.transferToInterpreter();
throw new RuntimeException(e);
}
return val;
}
开发者ID:smarr,项目名称:SOMns,代码行数:18,代码来源:ChannelPrimitives.java
注:本文中的com.oracle.truffle.api.CompilerDirectives类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论