|
26 | 26 | import org.truffleruby.core.array.RubyArray;
|
27 | 27 | import org.truffleruby.core.cast.ToStrNode;
|
28 | 28 | import org.truffleruby.core.encoding.Encodings;
|
| 29 | +import org.truffleruby.core.encoding.RubyEncoding; |
29 | 30 | import org.truffleruby.core.encoding.TStringUtils;
|
30 | 31 | import org.truffleruby.core.klass.RubyClass;
|
31 | 32 | import org.truffleruby.core.string.ATStringWithEncoding;
|
| 33 | +import org.truffleruby.core.string.StringHelperNodes; |
32 | 34 | import org.truffleruby.core.string.TStringWithEncoding;
|
33 | 35 | import org.truffleruby.core.string.RubyString;
|
34 | 36 | import org.truffleruby.core.symbol.RubySymbol;
|
@@ -179,12 +181,18 @@ public abstract static class RegexpCompileNode extends PrimitiveArrayArgumentsNo
|
179 | 181 | static final InlinedBranchProfile UNCACHED_BRANCH_PROFILE = InlinedBranchProfile.getUncached();
|
180 | 182 |
|
181 | 183 | @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" }, |
183 | 188 | limit = "getDefaultCacheLimit()")
|
184 | 189 | static RubyRegexp fastCompiling(Object pattern, int options,
|
185 | 190 | @Cached @Shared TruffleString.AsTruffleStringNode asTruffleStringNode,
|
186 | 191 | @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, |
188 | 196 | @Bind("this") Node node,
|
189 | 197 | @Cached("compile(pattern, options, node, libPattern, asTruffleStringNode, UNCACHED_BRANCH_PROFILE)") RubyRegexp regexp) {
|
190 | 198 | return regexp;
|
|
0 commit comments