use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class BreakpointSnippets method sessionsAssumptionInvalidate.
private void sessionsAssumptionInvalidate() {
assert Thread.holdsLock(this);
Assumption assumption = sessionsUnchanged;
if (assumption != null) {
this.sessionsUnchanged = null;
assumption.invalidate();
}
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class BreakpointSnippets method setCondition.
/**
* Assigns to this breakpoint a boolean expression whose evaluation will determine whether the
* breakpoint suspends execution (i.e. "hits"), {@code null} to remove any condition and always
* suspend.
* <p>
* Breakpoints are by default unconditional.
* </p>
* <p>
* <strong>Evaluation:</strong> expressions are parsed and evaluated in the lexical context of
* the breakpoint's location. A conditional breakpoint that applies to multiple code locations
* will be parsed and evaluated separately for each location.
* </p>
* <p>
* <strong>Evaluation failure:</strong> when evaluation of a condition fails for any reason,
* including the return of a non-boolean value:
* <ul>
* <li>execution suspends, as if evaluation had returned {@code true}, and</li>
* <li>a message is logged that can be
* {@linkplain SuspendedEvent#getBreakpointConditionException(Breakpoint) retrieved} while
* execution is suspended.</li>
* </ul>
* When not {@link #isModifiable() modifiable}, {@link IllegalStateException} is thrown.
*
* @param expression if non{@code -null}, a boolean expression, expressed in the guest language
* of the breakpoint's location.
* @see SuspendedEvent#getBreakpointConditionException(Breakpoint)
*
* @since 0.9
*/
public synchronized void setCondition(String expression) {
boolean existsChanged = (this.condition == null) != (expression == null);
this.condition = expression;
Assumption assumption = conditionUnchanged;
if (assumption != null) {
this.conditionUnchanged = null;
assumption.invalidate();
}
if (existsChanged) {
assumption = conditionExistsUnchanged;
if (assumption != null) {
this.conditionExistsUnchanged = null;
assumption.invalidate();
}
}
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class AssumptionsTest method testAssumptionArrays.
@Test
public void testAssumptionArrays() {
CallTarget root = createCallTarget(AssumptionArrayTestFactory.getInstance());
AssumptionArrayTest node = getNode(root);
Assumption a1 = Truffle.getRuntime().createAssumption();
Assumption a2 = Truffle.getRuntime().createAssumption();
node.assumptions = new Assumption[] { a1, a2 };
assertEquals("do1", root.call(42));
a2.invalidate();
assertEquals("do2", root.call(42));
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class AssumptionsTest method testAssumptionInvalidateTest4.
@Test
public void testAssumptionInvalidateTest4() {
AssumptionInvalidateTest4 node = AssumptionInvalidateTest4NodeGen.create();
node.execute(0);
for (int i = 0; i < 100; i++) {
int removeIndex = 0;
Assumption a = node.assumptions;
a.invalidate();
node.execute(removeIndex);
assertNotSame(a, node.assumptions);
}
}
use of com.oracle.truffle.api.Assumption in project graal by oracle.
the class AssumptionsTest method testMultipleAssumptionArrays.
@Test
public void testMultipleAssumptionArrays() {
CallTarget root = createCallTarget(MultipleAssumptionArraysTestFactory.getInstance());
MultipleAssumptionArraysTest node = getNode(root);
Assumption a1 = Truffle.getRuntime().createAssumption();
Assumption a2 = Truffle.getRuntime().createAssumption();
node.assumptions1 = new Assumption[] { a1 };
node.assumptions2 = new Assumption[] { a2 };
assertEquals("do1", root.call(42));
a2.invalidate();
assertEquals("do2", root.call(42));
}
Aggregations