Skip to content

Commit 97fbd68

Browse files
committed
Fix quards in RegexpCompileNode
1 parent 848f776 commit 97fbd68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
import org.truffleruby.core.array.RubyArray;
2727
import org.truffleruby.core.cast.ToStrNode;
2828
import org.truffleruby.core.encoding.Encodings;
29+
import org.truffleruby.core.encoding.RubyEncoding;
2930
import org.truffleruby.core.encoding.TStringUtils;
3031
import org.truffleruby.core.klass.RubyClass;
3132
import org.truffleruby.core.string.ATStringWithEncoding;
33+
import org.truffleruby.core.string.StringHelperNodes;
3234
import org.truffleruby.core.string.TStringWithEncoding;
3335
import org.truffleruby.core.string.RubyString;
3436
import org.truffleruby.core.symbol.RubySymbol;
@@ -179,12 +181,18 @@ public abstract static class RegexpCompileNode extends PrimitiveArrayArgumentsNo
179181
static final InlinedBranchProfile UNCACHED_BRANCH_PROFILE = InlinedBranchProfile.getUncached();
180182

181183
@Specialization(
182-
guards = { "libPattern.isRubyString(pattern)", "pattern == cachedPattern" },
184+
guards = {
185+
"libPattern.isRubyString(pattern)",
186+
"patternEqualNode.execute(node, libPattern, pattern, cachedPattern, cachedPatternEnc)",
187+
"options == cachedOptions" },
183188
limit = "getDefaultCacheLimit()")
184189
static RubyRegexp fastCompiling(Object pattern, int options,
185190
@Cached @Shared TruffleString.AsTruffleStringNode asTruffleStringNode,
186191
@Cached @Shared RubyStringLibrary libPattern,
187-
@Cached(value = "pattern") Object cachedPattern,
192+
@Cached("asTruffleStringUncached(pattern)") TruffleString cachedPattern,
193+
@Cached("libPattern.getEncoding(pattern)") RubyEncoding cachedPatternEnc,
194+
@Cached("options") int cachedOptions,
195+
@Cached StringHelperNodes.EqualSameEncodingNode patternEqualNode,
188196
@Bind("this") Node node,
189197
@Cached("compile(pattern, options, node, libPattern, asTruffleStringNode, UNCACHED_BRANCH_PROFILE)") RubyRegexp regexp) {
190198
return regexp;

0 commit comments

Comments
 (0)