Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: aea3d01040d5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7b1204e6e17f
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Aug 6, 2016

  1. [Truffle] Handle the regexp matcher being interrupted.

    * It was returning -2 (INTERRUPTED) which was considered a success.
    eregon committed Aug 6, 2016
    Copy the full SHA
    e029b47 View commit details
  2. Copy the full SHA
    267f775 View commit details
  3. Copy the full SHA
    7b1204e View commit details
1 change: 1 addition & 0 deletions spec/ruby/core/process/fixtures/common.rb
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ def initialize(scenario=nil, ruby_exe=nil)
rm_r @pid_file

@thread = Thread.new do
Thread.current.abort_on_exception = true
args = [@pid_file, scenario, ruby_exe]
@result = ruby_exe @script, args: args
end
4 changes: 3 additions & 1 deletion spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -160,7 +160,9 @@ if i = ARGV.index('slow') and ARGV[i-1] == '--excl-tag' and is_child_process

def exception(state)
if state.exception.is_a? SlowSpecException
tag = SpecTag.new("slow:#{state.describe} #{state.it}")
tag = SpecTag.new
tag.tag = 'slow'
tag.description = "#{state.describe} #{state.it}"
MSpec.write_tag(tag)
end
end
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.rubinius.RegexpPrimitiveNodes.RegexpSetLastMatchPrimitiveNode;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.core.thread.ThreadManager.BlockingAction;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
@@ -94,20 +95,27 @@ public static Matcher preprocess(RubyContext context, DynamicObject regexp, Dyna
}

@TruffleBoundary
public static Object matchCommon(RubyContext context, RopeNodes.MakeSubstringNode makeSubstringNode, DynamicObject regexp, DynamicObject string, boolean operator, boolean setNamedCaptures, int startPos) {
public static Object matchCommon(RubyContext context, Node currentNode, RopeNodes.MakeSubstringNode makeSubstringNode, DynamicObject regexp, DynamicObject string, boolean operator,
boolean setNamedCaptures, int startPos) {
final Matcher matcher = preprocess(context, regexp, string);
int range = StringOperations.rope(string).byteLength();
return matchCommon(context, makeSubstringNode, regexp, string, operator, setNamedCaptures, matcher, startPos, range);
return matchCommon(context, currentNode, makeSubstringNode, regexp, string, operator, setNamedCaptures, matcher, startPos, range);
}

@TruffleBoundary
public static Object matchCommon(RubyContext context, RopeNodes.MakeSubstringNode makeSubstringNode, DynamicObject regexp, DynamicObject string, boolean operator, boolean setNamedCaptures, Matcher matcher, int startPos, int range) {
public static Object matchCommon(RubyContext context, Node currentNode, RopeNodes.MakeSubstringNode makeSubstringNode, DynamicObject regexp, DynamicObject string, boolean operator,
boolean setNamedCaptures, Matcher matcher, int startPos, int range) {
assert RubyGuards.isRubyRegexp(regexp);
assert RubyGuards.isRubyString(string);

final Rope sourceRope = StringOperations.rope(string);

final int match = matcher.search(startPos, range, Option.DEFAULT);
int match = context.getThreadManager().runUntilResult(currentNode, new BlockingAction<Integer>() {
@Override
public Integer block() throws InterruptedException {
return matcher.searchInterruptible(startPos, range, Option.DEFAULT);
}
});

final DynamicObject nil = context.getCoreLibrary().getNilObject();

@@ -126,6 +134,8 @@ public static Object matchCommon(RubyContext context, RopeNodes.MakeSubstringNod
return nil;
}

assert match >= 0;

final Region region = matcher.getEagerRegion();
final Object[] values = new Object[region.numRegs];

@@ -398,7 +408,7 @@ public MatchOperatorNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyString(string)")
public Object match(DynamicObject regexp, DynamicObject string) {
return matchCommon(getContext(), makeSubstringNode, regexp, string, true, true, 0);
return matchCommon(getContext(), this, makeSubstringNode, regexp, string, true, true, 0);
}

@Specialization(guards = "isRubySymbol(symbol)")
@@ -452,7 +462,7 @@ public MatchStartNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyString(string)")
public Object matchStart(DynamicObject regexp, DynamicObject string, int startPos) {
final Object matchResult = matchCommon(getContext(), makeSubstringNode, regexp, string, false, false, startPos);
final Object matchResult = matchCommon(getContext(), this, makeSubstringNode, regexp, string, false, false, startPos);
if (RubyGuards.isRubyMatchData(matchResult) && Layouts.MATCH_DATA.getRegion((DynamicObject) matchResult).numRegs > 0
&& Layouts.MATCH_DATA.getRegion((DynamicObject) matchResult).beg[0] == startPos) {
return matchResult;
@@ -506,7 +516,7 @@ public SearchFromNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyString(string)")
public Object searchFrom(DynamicObject regexp, DynamicObject string, int startPos) {
return matchCommon(getContext(), makeSubstringNode, regexp, string, false, false, startPos);
return matchCommon(getContext(), this, makeSubstringNode, regexp, string, false, false, startPos);
}
}

Original file line number Diff line number Diff line change
@@ -118,10 +118,10 @@ public Object searchRegion(DynamicObject regexp, DynamicObject string, int start

if (forward) {
// Search forward through the string.
return RegexpNodes.matchCommon(getContext(), makeSubstringNode, regexp, string, false, false, matcher, start, end);
return RegexpNodes.matchCommon(getContext(), this, makeSubstringNode, regexp, string, false, false, matcher, start, end);
} else {
// Search backward through the string.
return RegexpNodes.matchCommon(getContext(), makeSubstringNode, regexp, string, false, false, matcher, end, start);
return RegexpNodes.matchCommon(getContext(), this, makeSubstringNode, regexp, string, false, false, matcher, end, start);
}
}