Skip to content

Commit d82e749

Browse files
committed
[Truffle] Don't convert regexp matches to Java String.
1 parent b775ac1 commit d82e749

File tree

5 files changed

+7
-47
lines changed

5 files changed

+7
-47
lines changed

core/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public MatchNode(MatchNode prev) {
173173
public Object match(RubyRegexp regexp, RubyString string) {
174174
notDesignedForCompilation();
175175

176-
return regexp.match(string.toString());
176+
return regexp.match(string);
177177
}
178178

179179
}

core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,14 @@ public Object match(RubyString string, RubyString regexpString) {
620620
notDesignedForCompilation();
621621

622622
final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.toString(), Option.DEFAULT);
623-
return regexp.match(string.toString());
623+
return regexp.match(string);
624624
}
625625

626626
@Specialization
627627
public Object match(RubyString string, RubyRegexp regexp) {
628628
notDesignedForCompilation();
629629

630-
return regexp.match(string.toString());
630+
return regexp.match(string);
631631
}
632632
}
633633

core/src/main/java/org/jruby/truffle/runtime/core/RubyRegexp.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ public Object matchOperator(String string) {
154154
}
155155

156156
@CompilerDirectives.SlowPath
157-
public Object match(String string) {
157+
public Object match(RubyString string) {
158158
final RubyContext context = getContext();
159159

160160
final Frame frame = Truffle.getRuntime().getCallerFrame().getFrame(FrameInstance.FrameAccess.READ_WRITE, false);
161161

162-
final byte[] stringBytes = string.getBytes(StandardCharsets.UTF_8);
162+
final byte[] stringBytes = string.getBytes().bytes();
163163
final Matcher matcher = regex.matcher(stringBytes);
164164
final int match = matcher.search(0, stringBytes.length, Option.DEFAULT);
165165

@@ -175,7 +175,7 @@ public Object match(String string) {
175175
if (start == -1 || end == -1) {
176176
values[n] = NilPlaceholder.INSTANCE;
177177
} else {
178-
final RubyString groupString = context.makeString(string.substring(start, end));
178+
final RubyString groupString = new RubyString(context.getCoreLibrary().getStringClass(), string.getBytes().makeShared(start, end - start).dup());
179179
values[n] = groupString;
180180
}
181181
}

core/src/main/java/org/jruby/util/cli/Options.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class Options {
132132
public static final Option<Boolean> TRUFFLE_RUNTIME_VERSION_CHECK = bool(TRUFFLE, "truffle.runtime.version_check", true, "Check the version of Truffle supplied by the JVM before starting.");
133133
public static final Option<Boolean> TRUFFLE_TRACE = bool(TRUFFLE, "truffle.trace", true, "Install trace probes needed for set_trace_func.");
134134
public static final Option<Boolean> TRUFFLE_OBJECTSPACE = bool(TRUFFLE, "truffle.object_space", true, "Install safepoints needed for ObjectSpace.");
135-
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_java", false, "Print Java exceptions at the point of translating them to Ruby exceptions.");
135+
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_java", true, "Print Java exceptions at the point of translating them to Ruby exceptions.");
136136
public static final Option<Integer> TRUFFLE_ARRAYS_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.arrays.uninitialized_size", 32, "How large an array to allocate when we have no other information to go on.");
137137
public static final Option<Boolean> TRUFFLE_ARRAYS_OPTIMISTIC_LONG = bool(TRUFFLE, "truffle.arrays.optimistic.long", true, "If we allocate an int[] for an Array and it has been converted to a long[], directly allocate a long[] next time.");
138138
public static final Option<Integer> TRUFFLE_ARRAYS_SMALL = integer(TRUFFLE, "truffle.arrays.small", 3, "Maximum size of an Array to consider small for optimisations.");
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,5 @@
1-
fails:Regexp with character classes matches Unicode letter characters with [[:alnum:]]
2-
fails:Regexp with character classes matches Unicode digits with [[:alnum:]]
31
fails:Regexp with character classes doesn't match Unicode control characters with [[:alnum:]]
42
fails:Regexp with character classes doesn't match Unicode punctuation characters with [[:alnum:]]
5-
fails:Regexp with character classes matches Unicode letter characters with [[:alpha:]] Regexp with character classes doesn't match Unicode digits with [[:alpha:]]
63
fails:Regexp with character classes doesn't match Unicode control characters with [[:alpha:]]
74
fails:Regexp with character classes doesn't match Unicode punctuation characters with [[:alpha:]]
8-
fails:Regexp with character classes matches Unicode space characters with [[:blank:]]
9-
fails:Regexp with character classes matches Unicode digits with [[:digit:]]
10-
fails:Regexp with character classes matches Unicode letter characters with [[:graph:]]
11-
fails:Regexp with character classes matches Unicode digits with [[:graph:]]
12-
fails:Regexp with character classes matches Unicode marks with [[:graph:]]
13-
fails:Regexp with character classes match Unicode format characters with [[:graph:]]
14-
fails:Regexp with character classes match Unicode private-use characters with [[:graph:]]
15-
fails:Regexp with character classes matches Unicode lowercase letter characters with [[:lower:]]
16-
fails:Regexp with character classes matches Unicode lowercase letter characters with [[:print:]]
17-
fails:Regexp with character classes matches Unicode uppercase letter characters with [[:print:]]
18-
fails:Regexp with character classes matches Unicode title-case characters with [[:print:]]
19-
fails:Regexp with character classes matches Unicode digits with [[:print:]]
20-
fails:Regexp with character classes matches Unicode marks with [[:print:]]
21-
fails:Regexp with character classes match Unicode format characters with [[:print:]]
22-
fails:Regexp with character classes match Unicode private-use characters with [[:print:]]
23-
fails:Regexp with character classes matches Unicode Pc characters with [[:punct:]]
24-
fails:Regexp with character classes matches Unicode Pd characters with [[:punct:]]
25-
fails:Regexp with character classes matches Unicode Ps characters with [[:punct:]]
26-
fails:Regexp with character classes matches Unicode Pe characters with [[:punct:]]
27-
fails:Regexp with character classes matches Unicode Pi characters with [[:punct:]]
28-
fails:Regexp with character classes matches Unicode Pf characters with [[:punct:]]
29-
fails:Regexp with character classes matches Unicode Pf characters with [[:punct:]]
30-
fails:Regexp with character classes matches Unicode Po characters with [[:punct:]]
31-
fails:Regexp with character classes matches Unicode Zs characters with [[:space:]]
32-
fails:Regexp with character classes matches Unicode Zl characters with [[:space:]]
33-
fails:Regexp with character classes matches Unicode Zp characters with [[:space:]]
34-
fails:Regexp with character classes matches Unicode uppercase characters with [[:upper:]] Regexp with character classes matches Unicode lowercase characters with [[:word:]]
35-
fails:Regexp with character classes matches Unicode uppercase characters with [[:word:]]
36-
fails:Regexp with character classes matches Unicode title-case characters with [[:word:]]
37-
fails:Regexp with character classes matches Unicode decimal digits with [[:word:]]
38-
fails:Regexp with character classes matches Unicode marks with [[:word:]]
39-
fails:Regexp with character classes match Unicode Nl characters with [[:word:]]
40-
fails:Regexp with character classes matches unicode script properties
41-
fails:Regexp with character classes matches Unicode lowercase characters with [[:word:]]
42-
fails:Regexp with character classes matches Unicode uppercase characters with [[:upper:]]
435
fails:Regexp with character classes doesn't match Unicode digits with [[:alpha:]]
44-
fails:Regexp with character classes matches Unicode letter characters with [[:alpha:]]
45-

0 commit comments

Comments
 (0)