Skip to content

Commit 0e417ef

Browse files
authored
Merge pull request #8930 from headius/repeat_specs
Run specs repeatedly with forced JIT
2 parents 5ffe48d + 71a15d6 commit 0e417ef

File tree

21 files changed

+165
-83
lines changed

21 files changed

+165
-83
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,34 @@ jobs:
3939
- name: rake ${{ matrix.target }}
4040
run: bin/jruby -S rake ${{ matrix.target }}
4141

42+
repeat-specs:
43+
runs-on: ubuntu-latest
44+
45+
strategy:
46+
fail-fast: false
47+
48+
name: run specs repeatedly to test optimizations
49+
50+
steps:
51+
- name: checkout
52+
uses: actions/checkout@v3
53+
- name: remove default java except 21
54+
run: sudo apt remove temurin-8-jdk temurin-11-jdk temurin-17-jdk
55+
- name: set up java 21
56+
uses: actions/setup-java@v3
57+
with:
58+
distribution: 'zulu'
59+
java-version: 21
60+
cache: 'maven'
61+
- name: bootstrap
62+
run: mvn -ntp -Pbootstrap clean package
63+
- name: bundle install
64+
run: bin/jruby --dev -S bundle install
65+
- name: run specs
66+
env:
67+
JAVA_OPTS: '-XX:TieredStopAtLevel=1'
68+
run: bin/jruby spec/mspec/bin/mspec ci -R 4 -T-Xjit.threshold=0 :language
69+
4270
jruby-tests-dev:
4371
runs-on: ubuntu-latest
4472

core/src/main/java/org/jruby/RubyKernel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ private static IRubyObject evalCommon(ThreadContext context, IRubyObject recv, I
12781278
binding.setLine(0);
12791279
}
12801280
} else { // no explicit file/line argument given
1281-
binding.setFile("(eval at " + context.getFileAndLine() + ")");
1281+
binding.setFile("(eval at " + context.getSingleBacktrace().getFileAndLine() + ")");
12821282
binding.setLine(0);
12831283
}
12841284

core/src/main/java/org/jruby/RubyObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObje
374374
file = args[1].convertToString().asJavaString();
375375
line = args.length > 2 ? toInt(context, args[2]) - 1 : 0;
376376
} else {
377-
file = "(eval at " + context.getFileAndLine() + ")";
377+
file = "(eval at " + context.getSingleBacktrace().getFileAndLine() + ")";
378378
line = 0;
379379
}
380380

core/src/main/java/org/jruby/ir/IRVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private void error(Object object) {
4949
public void BuildCompoundArrayInstr(BuildCompoundArrayInstr instr) { error(instr); }
5050
public void BuildCompoundStringInstr(BuildCompoundStringInstr instr) { error(instr); }
5151
public void BuildDynRegExpInstr(BuildDynRegExpInstr instr) { error(instr); }
52+
public void BuildNthRefInstr(BuildNthRefInstr instr) { error(instr); }
5253
public void BuildRangeInstr(BuildRangeInstr instr) { error(instr); }
5354
public void BuildSplatInstr(BuildSplatInstr instr) { error(instr); }
5455
public void CallInstr(CallInstr callinstr) { error(callinstr); }
@@ -189,7 +190,6 @@ private void error(Object object) {
189190
public void Label(Label label) { error(label); }
190191
public void LocalVariable(LocalVariable localvariable) { error(localvariable); }
191192
public void Nil(Nil nil) { error(nil); }
192-
public void NthRef(NthRef nthref) { error(nthref); }
193193
public void NullBlock(NullBlock nullblock) { error(nullblock); }
194194
public void Range(Range range) { error(range); }
195195
public void Rational(Rational rational) { error(rational); }

core/src/main/java/org/jruby/ir/Operation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public enum Operation {
152152
BINDING_LOAD(OpFlags.f_is_load),
153153
BINDING_STORE(OpFlags.f_is_store | OpFlags.f_has_side_effect),
154154
BUILD_BACKREF(OpFlags.f_can_raise_exception),
155+
BUILD_NTHREF(OpFlags.f_can_raise_exception),
155156
BUILD_COMPOUND_ARRAY(OpFlags.f_can_raise_exception),
156157
BUILD_COMPOUND_STRING(OpFlags.f_can_raise_exception),
157158
BUILD_DREGEXP(OpFlags.f_can_raise_exception),

core/src/main/java/org/jruby/ir/builder/IRBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ protected Operand buildNext(final Operand rv, int line) {
18071807
}
18081808

18091809
protected Operand buildNthRef(int matchNumber) {
1810-
return copy(new NthRef(scope, matchNumber));
1810+
return addResultInstr(new BuildNthRefInstr(temp(), matchNumber));
18111811
}
18121812

18131813
// FIXME: The logic for lazy and non-lazy building is pretty icky...clean up

core/src/main/java/org/jruby/ir/instructions/BuildBackrefInstr.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.jruby.RubyRegexp;
99
import org.jruby.ir.persistence.IRReaderDecoder;
1010
import org.jruby.ir.persistence.IRWriterEncoder;
11+
import org.jruby.ir.runtime.IRRuntimeHelpers;
1112
import org.jruby.ir.transformations.inlining.CloneInfo;
1213
import org.jruby.parser.StaticScope;
1314
import org.jruby.runtime.DynamicScope;
@@ -54,6 +55,8 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco
5455
case '`' : return RubyRegexp.match_pre(context, backref);
5556
case '\'': return RubyRegexp.match_post(context, backref);
5657
case '+' : return RubyRegexp.match_last(context, backref);
58+
case 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 :
59+
return IRRuntimeHelpers.nthMatch(context, type);
5760
default:
5861
assert false: "backref with invalid type";
5962
return null;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package org.jruby.ir.instructions;
2+
3+
import org.jruby.RubyRegexp;
4+
import org.jruby.ir.IRFlags;
5+
import org.jruby.ir.IRScope;
6+
import org.jruby.ir.IRVisitor;
7+
import org.jruby.ir.Operation;
8+
import org.jruby.ir.operands.Variable;
9+
import org.jruby.ir.persistence.IRReaderDecoder;
10+
import org.jruby.ir.persistence.IRWriterEncoder;
11+
import org.jruby.ir.runtime.IRRuntimeHelpers;
12+
import org.jruby.ir.transformations.inlining.CloneInfo;
13+
import org.jruby.parser.StaticScope;
14+
import org.jruby.runtime.DynamicScope;
15+
import org.jruby.runtime.ThreadContext;
16+
import org.jruby.runtime.builtin.IRubyObject;
17+
18+
import java.util.EnumSet;
19+
20+
// Represents a backref node in Ruby code
21+
public class BuildNthRefInstr extends NoOperandResultBaseInstr {
22+
final public int group;
23+
24+
public BuildNthRefInstr(Variable result, int group) {
25+
super(Operation.BUILD_NTHREF, result);
26+
this.group = group;
27+
}
28+
29+
@Override
30+
public void encode(IRWriterEncoder e) {
31+
super.encode(e);
32+
e.encode(group);
33+
}
34+
35+
public static BuildNthRefInstr decode(IRReaderDecoder d) {
36+
return new BuildNthRefInstr(d.decodeVariable(), d.decodeInt());
37+
}
38+
39+
@Override
40+
public Instr clone(CloneInfo ii) {
41+
return new BuildNthRefInstr(ii.getRenamedVariable(result), group);
42+
}
43+
44+
@Override
45+
public String[] toStringNonOperandArgs() {
46+
return new String[] {"$" + "'" + group + "'"};
47+
}
48+
49+
@Override
50+
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
51+
return IRRuntimeHelpers.nthMatch(context, group);
52+
}
53+
54+
@Override
55+
public void visit(IRVisitor visitor) {
56+
visitor.BuildNthRefInstr(this);
57+
}
58+
59+
@Override
60+
public boolean computeScopeFlags(IRScope scope, EnumSet<IRFlags> flags) {
61+
flags.add(IRFlags.REQUIRES_BACKREF);
62+
63+
return true;
64+
}
65+
}

core/src/main/java/org/jruby/ir/instructions/RuntimeHelperCall.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.util.EnumSet;
2727

28+
import static org.jruby.ir.IRFlags.REQUIRES_BACKREF;
2829
import static org.jruby.ir.IRFlags.REQUIRES_CLASS;
2930

3031
public class RuntimeHelperCall extends NOperandResultBaseInstr {
@@ -71,6 +72,9 @@ public boolean computeScopeFlags(IRScope scope, EnumSet<IRFlags> flags) {
7172
if (helperMethod == Methods.IS_DEFINED_SUPER) {
7273
modifiedScope = true;
7374
flags.add(REQUIRES_CLASS);
75+
} else if (helperMethod == Methods.IS_DEFINED_BACKREF || helperMethod == Methods.IS_DEFINED_NTH_REF) {
76+
modifiedScope = true;
77+
flags.add(REQUIRES_BACKREF);
7478
}
7579

7680
return modifiedScope;

core/src/main/java/org/jruby/ir/operands/NthRef.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)