Skip to content

Commit baccdb1

Browse files
committed
TRegex: fix missing TruffleBoundary on code introduced by RegressionTestMode
1 parent 6547448 commit baccdb1

File tree

1 file changed

+18
-12
lines changed
  • regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes

1 file changed

+18
-12
lines changed

regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/TRegexExecNode.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import com.oracle.truffle.api.CallTarget;
4747
import com.oracle.truffle.api.CompilerDirectives;
4848
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
49+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
50+
import com.oracle.truffle.api.frame.MaterializedFrame;
4951
import com.oracle.truffle.api.frame.VirtualFrame;
5052
import com.oracle.truffle.api.nodes.Node;
5153
import com.oracle.truffle.api.strings.TruffleString;
@@ -142,13 +144,7 @@ public final RegexResult execute(VirtualFrame frame, TruffleString input, int fr
142144
assert !sticky || source.getOptions().isBooleanMatch() || result == RegexResult.getNoMatchInstance() || RegexResult.RegexResultGetStartNode.getUncached().execute(result, 0) == fromIndex;
143145
assert validResult(input, fromIndex, maxIndex, regionFrom, regionTo, result);
144146
if (regressionTestMode) {
145-
if (!(backtrackerProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
146-
nfaProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
147-
noSimpleCGLazyDFAProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
148-
(source.getOptions().isBooleanMatch() || eagerAndLazyDFAProduceSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result)))) {
149-
CompilerDirectives.transferToInterpreterAndInvalidate();
150-
throw new AssertionError("Inconsistent results between different matching modes");
151-
}
147+
runInternalRegressionTests(frame.materialize(), input, fromIndex, maxIndex, regionFrom, regionTo, result);
152148
}
153149

154150
if (CompilerDirectives.inInterpreter() && !backtrackingMode) {
@@ -206,15 +202,25 @@ private boolean validResult(Object input, int fromIndex, int maxIndex, int regio
206202
return true;
207203
}
208204

209-
private RegexResult regressionTestRun(VirtualFrame frame, RunRegexSearchNode node, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo) {
205+
@TruffleBoundary
206+
private void runInternalRegressionTests(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
207+
if (!(backtrackerProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
208+
nfaProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
209+
noSimpleCGLazyDFAProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
210+
(source.getOptions().isBooleanMatch() || eagerAndLazyDFAProduceSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result)))) {
211+
throw new AssertionError("Inconsistent results between different matching modes");
212+
}
213+
}
214+
215+
private RegexResult regressionTestRun(MaterializedFrame frame, RunRegexSearchNode node, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo) {
210216
RunRegexSearchNode old = runnerNode;
211217
runnerNode = insert(node);
212218
RegexResult result = runnerNode.run(frame, input, fromIndex, maxIndex, regionFrom, regionTo);
213219
runnerNode = insert(old);
214220
return result;
215221
}
216222

217-
private boolean backtrackerProducesSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
223+
private boolean backtrackerProducesSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
218224
RegexResult btResult = regressionTestRun(frame, regressTestBacktrackingNode, input, fromIndex, maxIndex, regionFrom, regionTo);
219225
if (resultsEqual(result, btResult, getNumberOfCaptureGroups())) {
220226
return true;
@@ -223,7 +229,7 @@ private boolean backtrackerProducesSameResult(VirtualFrame frame, TruffleString
223229
return false;
224230
}
225231

226-
private boolean nfaProducesSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
232+
private boolean nfaProducesSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
227233
if (lazyDFANode == LAZY_DFA_BAILED_OUT) {
228234
return true;
229235
}
@@ -236,7 +242,7 @@ private boolean nfaProducesSameResult(VirtualFrame frame, TruffleString input, i
236242
return false;
237243
}
238244

239-
private boolean noSimpleCGLazyDFAProducesSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
245+
private boolean noSimpleCGLazyDFAProducesSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
240246
if (lazyDFANode == LAZY_DFA_BAILED_OUT || !lazyDFANode.isSimpleCG() || regressTestNoSimpleCGLazyDFANode == LAZY_DFA_BAILED_OUT) {
241247
return true;
242248
}
@@ -249,7 +255,7 @@ private boolean noSimpleCGLazyDFAProducesSameResult(VirtualFrame frame, TruffleS
249255
return false;
250256
}
251257

252-
private boolean eagerAndLazyDFAProduceSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult resultOfCurrentSearchNode) {
258+
private boolean eagerAndLazyDFAProduceSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult resultOfCurrentSearchNode) {
253259
if (lazyDFANode.captureGroupEntryNode == null || eagerDFANode == EAGER_DFA_BAILED_OUT) {
254260
return true;
255261
}

0 commit comments

Comments
 (0)