use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class ContextObject method removeListener.
void removeListener(AllocationListener l) {
CompilerAsserts.neverPartOfCompilation();
boolean hasListeners = true;
synchronized (this) {
final int len = listeners.length;
if (len == 1) {
if (listeners[0] == l) {
listeners = null;
hasListeners = false;
}
} else {
for (int i = 0; i < len; i++) {
if (listeners[i] == l) {
if (i == (len - 1)) {
listeners = Arrays.copyOf(listeners, i);
} else if (i == 0) {
listeners = Arrays.copyOfRange(listeners, 1, len);
} else {
AllocationListener[] newListeners = new AllocationListener[len - 1];
System.arraycopy(listeners, 0, newListeners, 0, i);
System.arraycopy(listeners, i + 1, newListeners, i, len - i - 1);
listeners = newListeners;
}
break;
}
}
}
Assumption assumption = listenersNotChangedAssumption;
listenersNotChangedAssumption = Truffle.getRuntime().createAssumption();
assumption.invalidate();
}
if (!hasListeners) {
propSupport.firePropertyChange(PROPERTY_ACTIVE, true, false);
}
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class OptimizedCompilationProfile method injectArgumentProfile.
final Object[] injectArgumentProfile(Object[] originalArguments) {
Assumption argumentTypesAssumption = profiledArgumentTypesAssumption;
Object[] args = originalArguments;
if (argumentTypesAssumption != null && argumentTypesAssumption.isValid()) {
args = OptimizedCallTarget.unsafeCast(OptimizedCallTarget.castArrayFixedLength(args, profiledArgumentTypes.length), Object[].class, true, true, true);
args = castArgumentsImpl(args);
}
return args;
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class AssumptionPartialEvaluationTest method constantValue.
@Test
public void constantValue() {
Assumption assumption = Truffle.getRuntime().createAssumption();
AbstractTestNode result = new ConstantWithAssumptionTestNode(assumption, 42);
RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "constantValue", result);
OptimizedCallTarget callTarget = assertPartialEvalEquals("constant42", rootNode);
Assert.assertTrue(callTarget.isValid());
assertDeepEquals(42, callTarget.call());
Assert.assertTrue(callTarget.isValid());
try {
assumption.check();
} catch (InvalidAssumptionException e) {
Assert.fail("Assumption must not have been invalidated.");
}
assumption.invalidate();
try {
assumption.check();
Assert.fail("Assumption must have been invalidated.");
} catch (InvalidAssumptionException e) {
}
Assert.assertFalse(callTarget.isValid());
assertDeepEquals(43, callTarget.call());
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class AssumptionsTest method testAssumptionInvalidateTest1.
@Test
public void testAssumptionInvalidateTest1() {
AssumptionInvalidateTest1 node = AssumptionInvalidateTest1NodeGen.create();
node.execute(0);
node.execute(1);
node.execute(2);
for (int i = 0; i < 100; i++) {
int removeIndex = i % 3;
Assumption a = node.assumptions[removeIndex];
a.invalidate();
node.execute(removeIndex);
assertNotSame(a, node.assumptions[removeIndex]);
}
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class AssumptionsTest method testAssumptionArraysAreCompilationFinalCached.
@Test
public void testAssumptionArraysAreCompilationFinalCached() throws NoSuchFieldException, SecurityException, IllegalArgumentException {
AssumptionArraysAreCompilationFinalCached node = TestHelper.createNode(AssumptionArraysAreCompilationFinalCachedFactory.getInstance(), false);
Field doCachedField = node.getClass().getDeclaredField("do1_cache");
doCachedField.setAccessible(true);
Field field = doCachedField.getType().getDeclaredField("assumption0_");
field.setAccessible(true);
assertEquals(Assumption[].class, field.getType());
CompilationFinal compilationFinal = field.getAnnotation(CompilationFinal.class);
assertEquals(1, compilationFinal.dimensions());
}
Aggregations