46
46
import com .oracle .truffle .api .CallTarget ;
47
47
import com .oracle .truffle .api .CompilerDirectives ;
48
48
import com .oracle .truffle .api .CompilerDirectives .CompilationFinal ;
49
+ import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
50
+ import com .oracle .truffle .api .frame .MaterializedFrame ;
49
51
import com .oracle .truffle .api .frame .VirtualFrame ;
50
52
import com .oracle .truffle .api .nodes .Node ;
51
53
import com .oracle .truffle .api .strings .TruffleString ;
@@ -142,13 +144,7 @@ public final RegexResult execute(VirtualFrame frame, TruffleString input, int fr
142
144
assert !sticky || source .getOptions ().isBooleanMatch () || result == RegexResult .getNoMatchInstance () || RegexResult .RegexResultGetStartNode .getUncached ().execute (result , 0 ) == fromIndex ;
143
145
assert validResult (input , fromIndex , maxIndex , regionFrom , regionTo , result );
144
146
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 );
152
148
}
153
149
154
150
if (CompilerDirectives .inInterpreter () && !backtrackingMode ) {
@@ -206,15 +202,25 @@ private boolean validResult(Object input, int fromIndex, int maxIndex, int regio
206
202
return true ;
207
203
}
208
204
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 ) {
210
216
RunRegexSearchNode old = runnerNode ;
211
217
runnerNode = insert (node );
212
218
RegexResult result = runnerNode .run (frame , input , fromIndex , maxIndex , regionFrom , regionTo );
213
219
runnerNode = insert (old );
214
220
return result ;
215
221
}
216
222
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 ) {
218
224
RegexResult btResult = regressionTestRun (frame , regressTestBacktrackingNode , input , fromIndex , maxIndex , regionFrom , regionTo );
219
225
if (resultsEqual (result , btResult , getNumberOfCaptureGroups ())) {
220
226
return true ;
@@ -223,7 +229,7 @@ private boolean backtrackerProducesSameResult(VirtualFrame frame, TruffleString
223
229
return false ;
224
230
}
225
231
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 ) {
227
233
if (lazyDFANode == LAZY_DFA_BAILED_OUT ) {
228
234
return true ;
229
235
}
@@ -236,7 +242,7 @@ private boolean nfaProducesSameResult(VirtualFrame frame, TruffleString input, i
236
242
return false ;
237
243
}
238
244
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 ) {
240
246
if (lazyDFANode == LAZY_DFA_BAILED_OUT || !lazyDFANode .isSimpleCG () || regressTestNoSimpleCGLazyDFANode == LAZY_DFA_BAILED_OUT ) {
241
247
return true ;
242
248
}
@@ -249,7 +255,7 @@ private boolean noSimpleCGLazyDFAProducesSameResult(VirtualFrame frame, TruffleS
249
255
return false ;
250
256
}
251
257
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 ) {
253
259
if (lazyDFANode .captureGroupEntryNode == null || eagerDFANode == EAGER_DFA_BAILED_OUT ) {
254
260
return true ;
255
261
}
0 commit comments