|
24 | 24 | import com.oracle.truffle.api.CompilerDirectives;
|
25 | 25 | import com.oracle.truffle.api.TruffleSafepoint;
|
26 | 26 | import com.oracle.truffle.api.dsl.Bind;
|
| 27 | +import com.oracle.truffle.api.dsl.Cached.Exclusive; |
27 | 28 | import com.oracle.truffle.api.dsl.Fallback;
|
28 | 29 | import com.oracle.truffle.api.dsl.GenerateCached;
|
29 | 30 | import com.oracle.truffle.api.dsl.GenerateInline;
|
|
86 | 87 | import org.truffleruby.language.library.RubyStringLibrary;
|
87 | 88 | import org.truffleruby.language.objects.AllocationTracing;
|
88 | 89 | import org.truffleruby.parser.RubyDeferredWarnings;
|
| 90 | +import org.truffleruby.utils.RunTwiceBranchProfile; |
89 | 91 |
|
90 | 92 | import static com.oracle.truffle.api.strings.TruffleString.CodeRange.ASCII;
|
91 | 93 | import static com.oracle.truffle.api.strings.TruffleString.CodeRange.BROKEN;
|
@@ -372,41 +374,49 @@ public abstract static class TRegexCompileNode extends RubyBaseNode {
|
372 | 374 | @Child DispatchNode warnOnFallbackNode;
|
373 | 375 |
|
374 | 376 | @Specialization(guards = "encoding == US_ASCII")
|
375 |
| - Object usASCII(RubyRegexp regexp, boolean atStart, RubyEncoding encoding) { |
| 377 | + Object usASCII(RubyRegexp regexp, boolean atStart, RubyEncoding encoding, |
| 378 | + @Cached @Exclusive RunTwiceBranchProfile compileProfile) { |
376 | 379 | final Object tregex = regexp.tregexCache.getUSASCIIRegex(atStart);
|
377 | 380 | if (tregex != null) {
|
378 | 381 | return tregex;
|
379 | 382 | } else {
|
| 383 | + compileProfile.enter(); |
380 | 384 | return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
|
381 | 385 | }
|
382 | 386 | }
|
383 | 387 |
|
384 | 388 | @Specialization(guards = "encoding == ISO_8859_1")
|
385 |
| - Object latin1(RubyRegexp regexp, boolean atStart, RubyEncoding encoding) { |
| 389 | + Object latin1(RubyRegexp regexp, boolean atStart, RubyEncoding encoding, |
| 390 | + @Cached @Exclusive RunTwiceBranchProfile compileProfile) { |
386 | 391 | final Object tregex = regexp.tregexCache.getLatin1Regex(atStart);
|
387 | 392 | if (tregex != null) {
|
388 | 393 | return tregex;
|
389 | 394 | } else {
|
| 395 | + compileProfile.enter(); |
390 | 396 | return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
|
391 | 397 | }
|
392 | 398 | }
|
393 | 399 |
|
394 | 400 | @Specialization(guards = "encoding == UTF_8")
|
395 |
| - Object utf8(RubyRegexp regexp, boolean atStart, RubyEncoding encoding) { |
| 401 | + Object utf8(RubyRegexp regexp, boolean atStart, RubyEncoding encoding, |
| 402 | + @Cached @Exclusive RunTwiceBranchProfile compileProfile) { |
396 | 403 | final Object tregex = regexp.tregexCache.getUTF8Regex(atStart);
|
397 | 404 | if (tregex != null) {
|
398 | 405 | return tregex;
|
399 | 406 | } else {
|
| 407 | + compileProfile.enter(); |
400 | 408 | return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
|
401 | 409 | }
|
402 | 410 | }
|
403 | 411 |
|
404 | 412 | @Specialization(guards = "encoding == BINARY")
|
405 |
| - Object binary(RubyRegexp regexp, boolean atStart, RubyEncoding encoding) { |
| 413 | + Object binary(RubyRegexp regexp, boolean atStart, RubyEncoding encoding, |
| 414 | + @Cached @Exclusive RunTwiceBranchProfile compileProfile) { |
406 | 415 | final Object tregex = regexp.tregexCache.getBinaryRegex(atStart);
|
407 | 416 | if (tregex != null) {
|
408 | 417 | return tregex;
|
409 | 418 | } else {
|
| 419 | + compileProfile.enter(); |
410 | 420 | return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
|
411 | 421 | }
|
412 | 422 | }
|
|
0 commit comments