Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Don't convert regexp matches to Java String.
  • Loading branch information
chrisseaton committed Oct 5, 2014
1 parent b775ac1 commit d82e749
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 47 deletions.
Expand Up @@ -173,7 +173,7 @@ public MatchNode(MatchNode prev) {
public Object match(RubyRegexp regexp, RubyString string) {
notDesignedForCompilation();

return regexp.match(string.toString());
return regexp.match(string);
}

}
Expand Down
Expand Up @@ -620,14 +620,14 @@ public Object match(RubyString string, RubyString regexpString) {
notDesignedForCompilation();

final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.toString(), Option.DEFAULT);
return regexp.match(string.toString());
return regexp.match(string);
}

@Specialization
public Object match(RubyString string, RubyRegexp regexp) {
notDesignedForCompilation();

return regexp.match(string.toString());
return regexp.match(string);
}
}

Expand Down
Expand Up @@ -154,12 +154,12 @@ public Object matchOperator(String string) {
}

@CompilerDirectives.SlowPath
public Object match(String string) {
public Object match(RubyString string) {
final RubyContext context = getContext();

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

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

Expand All @@ -175,7 +175,7 @@ public Object match(String string) {
if (start == -1 || end == -1) {
values[n] = NilPlaceholder.INSTANCE;
} else {
final RubyString groupString = context.makeString(string.substring(start, end));
final RubyString groupString = new RubyString(context.getCoreLibrary().getStringClass(), string.getBytes().makeShared(start, end - start).dup());
values[n] = groupString;
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Expand Up @@ -132,7 +132,7 @@ public class Options {
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.");
public static final Option<Boolean> TRUFFLE_TRACE = bool(TRUFFLE, "truffle.trace", true, "Install trace probes needed for set_trace_func.");
public static final Option<Boolean> TRUFFLE_OBJECTSPACE = bool(TRUFFLE, "truffle.object_space", true, "Install safepoints needed for ObjectSpace.");
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.");
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.");
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.");
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.");
public static final Option<Integer> TRUFFLE_ARRAYS_SMALL = integer(TRUFFLE, "truffle.arrays.small", 3, "Maximum size of an Array to consider small for optimisations.");
Expand Down
40 changes: 0 additions & 40 deletions spec/truffle/tags/language/regexp/character_classes_tags.txt
@@ -1,45 +1,5 @@
fails:Regexp with character classes matches Unicode letter characters with [[:alnum:]]
fails:Regexp with character classes matches Unicode digits with [[:alnum:]]
fails:Regexp with character classes doesn't match Unicode control characters with [[:alnum:]]
fails:Regexp with character classes doesn't match Unicode punctuation characters with [[:alnum:]]
fails:Regexp with character classes matches Unicode letter characters with [[:alpha:]] Regexp with character classes doesn't match Unicode digits with [[:alpha:]]
fails:Regexp with character classes doesn't match Unicode control characters with [[:alpha:]]
fails:Regexp with character classes doesn't match Unicode punctuation characters with [[:alpha:]]
fails:Regexp with character classes matches Unicode space characters with [[:blank:]]
fails:Regexp with character classes matches Unicode digits with [[:digit:]]
fails:Regexp with character classes matches Unicode letter characters with [[:graph:]]
fails:Regexp with character classes matches Unicode digits with [[:graph:]]
fails:Regexp with character classes matches Unicode marks with [[:graph:]]
fails:Regexp with character classes match Unicode format characters with [[:graph:]]
fails:Regexp with character classes match Unicode private-use characters with [[:graph:]]
fails:Regexp with character classes matches Unicode lowercase letter characters with [[:lower:]]
fails:Regexp with character classes matches Unicode lowercase letter characters with [[:print:]]
fails:Regexp with character classes matches Unicode uppercase letter characters with [[:print:]]
fails:Regexp with character classes matches Unicode title-case characters with [[:print:]]
fails:Regexp with character classes matches Unicode digits with [[:print:]]
fails:Regexp with character classes matches Unicode marks with [[:print:]]
fails:Regexp with character classes match Unicode format characters with [[:print:]]
fails:Regexp with character classes match Unicode private-use characters with [[:print:]]
fails:Regexp with character classes matches Unicode Pc characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Pd characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Ps characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Pe characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Pi characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Pf characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Pf characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Po characters with [[:punct:]]
fails:Regexp with character classes matches Unicode Zs characters with [[:space:]]
fails:Regexp with character classes matches Unicode Zl characters with [[:space:]]
fails:Regexp with character classes matches Unicode Zp characters with [[:space:]]
fails:Regexp with character classes matches Unicode uppercase characters with [[:upper:]] Regexp with character classes matches Unicode lowercase characters with [[:word:]]
fails:Regexp with character classes matches Unicode uppercase characters with [[:word:]]
fails:Regexp with character classes matches Unicode title-case characters with [[:word:]]
fails:Regexp with character classes matches Unicode decimal digits with [[:word:]]
fails:Regexp with character classes matches Unicode marks with [[:word:]]
fails:Regexp with character classes match Unicode Nl characters with [[:word:]]
fails:Regexp with character classes matches unicode script properties
fails:Regexp with character classes matches Unicode lowercase characters with [[:word:]]
fails:Regexp with character classes matches Unicode uppercase characters with [[:upper:]]
fails:Regexp with character classes doesn't match Unicode digits with [[:alpha:]]
fails:Regexp with character classes matches Unicode letter characters with [[:alpha:]]

0 comments on commit d82e749

Please sign in to comment.