Skip to content

Commit cf08d31

Browse files
committed
Fix the --warn-truffle-regex-compile-fallback warning to include caller location
1 parent cb6a142 commit cf08d31

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/main/java/org/truffleruby/core/regexp/TRegexCache.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import org.jcodings.specific.USASCIIEncoding;
2222
import org.jcodings.specific.UTF8Encoding;
2323
import org.truffleruby.RubyContext;
24+
import org.truffleruby.core.regexp.TruffleRegexpNodes.TRegexCompileNode;
2425
import org.truffleruby.core.rope.CannotConvertBinaryRubyStringToJavaString;
2526
import org.truffleruby.core.rope.Rope;
2627
import org.truffleruby.core.rope.RopeBuilder;
2728
import org.truffleruby.core.rope.RopeOperations;
2829
import org.truffleruby.language.Nil;
2930
import org.truffleruby.language.control.DeferredRaiseException;
30-
import org.truffleruby.language.dispatch.DispatchNode;
3131

3232
public final class TRegexCache {
3333

@@ -60,12 +60,13 @@ public Object getBinaryRegex(boolean atStart) {
6060
}
6161

6262
@TruffleBoundary
63-
public Object compile(RubyContext context, RubyRegexp regexp, boolean atStart, Encoding encoding) {
63+
public Object compile(RubyContext context, RubyRegexp regexp, boolean atStart, Encoding encoding,
64+
TRegexCompileNode node) {
6465
Object tregex = compileTRegex(context, regexp, atStart, encoding);
6566
if (tregex == null) {
6667
tregex = Nil.INSTANCE;
6768
if (context.getOptions().WARN_TRUFFLE_REGEX_COMPILE_FALLBACK) {
68-
DispatchNode.getUncached().call(
69+
node.getWarnOnFallbackNode().call(
6970
context.getCoreLibrary().truffleRegexpOperationsModule,
7071
"warn_fallback_regex",
7172
regexp,

src/main/java/org/truffleruby/core/regexp/TruffleRegexpNodes.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ protected Object usASCII(RubyRegexp regexp, boolean atStart, Encoding encoding)
254254
if (tregex != null) {
255255
return tregex;
256256
} else {
257-
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding);
257+
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
258258
}
259259
}
260260

@@ -264,7 +264,7 @@ protected Object latin1(RubyRegexp regexp, boolean atStart, Encoding encoding) {
264264
if (tregex != null) {
265265
return tregex;
266266
} else {
267-
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding);
267+
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
268268
}
269269
}
270270

@@ -274,7 +274,7 @@ protected Object utf8(RubyRegexp regexp, boolean atStart, Encoding encoding) {
274274
if (tregex != null) {
275275
return tregex;
276276
} else {
277-
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding);
277+
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
278278
}
279279
}
280280

@@ -284,7 +284,7 @@ protected Object binary(RubyRegexp regexp, boolean atStart, Encoding encoding) {
284284
if (tregex != null) {
285285
return tregex;
286286
} else {
287-
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding);
287+
return regexp.tregexCache.compile(getContext(), regexp, atStart, encoding, this);
288288
}
289289
}
290290

@@ -298,6 +298,13 @@ protected Object other(RubyRegexp regexp, boolean atStart, Encoding encoding) {
298298
return nil;
299299
}
300300

301+
DispatchNode getWarnOnFallbackNode() {
302+
if (warnOnFallbackNode == null) {
303+
CompilerDirectives.transferToInterpreterAndInvalidate();
304+
warnOnFallbackNode = insert(DispatchNode.create());
305+
}
306+
return warnOnFallbackNode;
307+
}
301308
}
302309

303310
public abstract static class RegexpStatsNode extends CoreMethodArrayArgumentsNode {

0 commit comments

Comments
 (0)