Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 15a805f

Browse files
committedDec 28, 2015
Merge branch 'master' into mcjit
2 parents c04d794 + 5e6fe27 commit 15a805f

File tree

6 files changed

+203
-185
lines changed

6 files changed

+203
-185
lines changed
 

‎kernel/common/array.rb

+19-9
Original file line numberDiff line numberDiff line change
@@ -1365,28 +1365,38 @@ def sample(count=undefined, options=undefined)
13651365
else
13661366
if size / count > 3
13671367
abandon = false
1368-
spin = 0
13691368

13701369
result = Array.new count
13711370
i = 1
13721371

13731372
result[0] = rng.rand(size)
13741373
while i < count
13751374
k = rng.rand(size)
1376-
j = 0
13771375

1378-
while j < i
1379-
while k == result[j]
1380-
spin += 1
1381-
if spin > 100
1376+
spin = false
1377+
spin_count = 0
1378+
1379+
while true
1380+
j = 0
1381+
while j < i
1382+
if k == result[j]
1383+
spin = true
1384+
break
1385+
end
1386+
1387+
j += 1
1388+
end
1389+
1390+
if spin
1391+
if (spin_count += 1) > 100
13821392
abandon = true
13831393
break
13841394
end
1395+
13851396
k = rng.rand(size)
1397+
else
1398+
break
13861399
end
1387-
break if abandon
1388-
1389-
j += 1
13901400
end
13911401

13921402
break if abandon

‎rakelib/gems.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace :gems do
5757
unless BUILD_CONFIG[:darwin] and
5858
`which brew`.chomp.size > 0 and
5959
$?.success? and
60-
(openssl = `brew --prefix openssl`.chomp).size > 0
60+
(openssl = `brew --prefix #{ENV["RBX_OPENSSL"] || "openssl"}`.chomp).size > 0
6161
openssl = false
6262
end
6363

‎rakelib/preinstall_gems.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
unless BUILD_CONFIG[:darwin] and
1111
`which brew`.chomp.size > 0 and
1212
$?.success? and
13-
(openssl = `brew --prefix openssl`.chomp).size > 0
13+
(openssl = `brew --prefix #{ENV["RBX_OPENSSL"] || "openssl"}`.chomp).size > 0
1414
openssl = false
1515
end
1616

‎spec/jit/call_site_spec.rb

+71-69
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
11
require File.expand_path("../spec_helper", __FILE__)
22

3-
describe "JIT compiling a call site" do
4-
context "to m()" do
5-
before :each do
6-
klass = Class.new do
7-
def m() :m end
8-
def call() m() end
3+
with_feature :jit do
4+
describe "JIT compiling a call site" do
5+
context "to m()" do
6+
before :each do
7+
klass = Class.new do
8+
def m() :m end
9+
def call() m() end
10+
end
11+
12+
@o = klass.new
13+
14+
jit(@o, :call) { @o.call }
915
end
1016

11-
@o = klass.new
17+
it "compiles" do
18+
@o.method(:call).executable.jitted?.should be_true
19+
end
1220

13-
jit(@o, :call) { @o.call }
21+
it "returns the result of calling the method" do
22+
@o.call.should equal(:m)
23+
end
1424
end
1525

16-
it "compiles" do
17-
@o.method(:call).executable.jitted?.should be_true
18-
end
26+
context "to m() defined in an included module" do
27+
before :each do
28+
mod = Module.new do
29+
def m() :m end
30+
end
31+
klass = Class.new do
32+
def call() m() end
33+
include mod
34+
end
1935

20-
it "returns the result of calling the method" do
21-
@o.call.should equal(:m)
22-
end
23-
end
36+
@o = klass.new
2437

25-
context "to m() defined in an included module" do
26-
before :each do
27-
mod = Module.new do
28-
def m() :m end
29-
end
30-
klass = Class.new do
31-
def call() m() end
32-
include mod
38+
jit(@o, :call) { @o.call }
3339
end
3440

35-
@o = klass.new
41+
it "compiles" do
42+
@o.method(:call).executable.jitted?.should be_true
43+
end
3644

37-
jit(@o, :call) { @o.call }
45+
it "returns the result of calling the included method" do
46+
@o.call.should equal(:m)
47+
end
3848
end
3949

40-
it "compiles" do
41-
@o.method(:call).executable.jitted?.should be_true
42-
end
50+
context "to m() defined in a prepended module" do
51+
before :each do
4352

44-
it "returns the result of calling the included method" do
45-
@o.call.should equal(:m)
46-
end
47-
end
53+
mod = Module.new do
54+
def m() :m end
55+
end
56+
klass = Class.new do
57+
def m() :shadowed end
58+
def call() m() end
59+
prepend mod
60+
end
4861

49-
context "to m() defined in a prepended module" do
50-
before :each do
62+
o = @o = klass.new
5163

52-
mod = Module.new do
53-
def m() :m end
54-
end
55-
klass = Class.new do
56-
def m() :shadowed end
57-
def call() m() end
58-
prepend mod
64+
jit(o, :call) { o.call }
5965
end
6066

61-
o = @o = klass.new
67+
it "compiles" do
68+
@o.method(:call).executable.jitted?.should be_true
69+
end
6270

63-
jit(o, :call) { o.call }
71+
it "returns the result of calling the prepended method" do
72+
@o.call.should equal(:m)
73+
end
6474
end
6575

66-
it "compiles" do
67-
@o.method(:call).executable.jitted?.should be_true
68-
end
76+
context "to m() that calls super defined in a prepended module" do
77+
before :each do
6978

70-
it "returns the result of calling the prepended method" do
71-
@o.call.should equal(:m)
72-
end
73-
end
79+
mod = Module.new do
80+
def m() super; :m end
81+
end
82+
klass = Class.new do
83+
def m() :shadowed end
84+
def call() m() end
85+
prepend mod
86+
end
7487

75-
context "to m() that calls super defined in a prepended module" do
76-
before :each do
88+
o = @o = klass.new
7789

78-
mod = Module.new do
79-
def m() super; :m end
80-
end
81-
klass = Class.new do
82-
def m() :shadowed end
83-
def call() m() end
84-
prepend mod
90+
jit(o, :call) { o.call }
8591
end
8692

87-
o = @o = klass.new
88-
89-
jit(o, :call) { o.call }
90-
end
91-
92-
it "compiles" do
93-
@o.method(:call).executable.jitted?.should be_true
94-
end
93+
it "compiles" do
94+
@o.method(:call).executable.jitted?.should be_true
95+
end
9596

96-
it "returns the result of calling the prepended method" do
97-
@o.call.should equal(:m)
97+
it "returns the result of calling the prepended method" do
98+
@o.call.should equal(:m)
99+
end
98100
end
99101
end
100102
end

‎spec/jit/method_spec.rb

+107-105
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,158 @@
11
require File.expand_path("../spec_helper", __FILE__)
22

3-
describe "JIT compiling a method call" do
4-
context "to m()" do
5-
before :each do
6-
klass = Class.new do
7-
def m() :m end
3+
with_feature :jit do
4+
describe "JIT compiling a method call" do
5+
context "to m()" do
6+
before :each do
7+
klass = Class.new do
8+
def m() :m end
9+
end
10+
11+
@o = klass.new
12+
13+
jit(@o, :m) { @o.m }
814
end
915

10-
@o = klass.new
16+
it "compiles" do
17+
@o.method(:m).executable.jitted?.should be_true
18+
end
1119

12-
jit(@o, :m) { @o.m }
13-
end
20+
it "returns the last computed value" do
21+
@o.m.should equal(:m)
22+
end
1423

15-
it "compiles" do
16-
@o.method(:m).executable.jitted?.should be_true
24+
it "raises an ArgumentError if passed an argument" do
25+
lambda { @o.m 5 }.should raise_error(ArgumentError)
26+
end
1727
end
1828

19-
it "returns the last computed value" do
20-
@o.m.should equal(:m)
21-
end
29+
context "to m() without calling it" do
30+
before :each do
31+
klass = Class.new do
32+
def m() :m end
33+
end
2234

23-
it "raises an ArgumentError if passed an argument" do
24-
lambda { @o.m 5 }.should raise_error(ArgumentError)
25-
end
26-
end
35+
@o = klass.new
2736

28-
context "to m() without calling it" do
29-
before :each do
30-
klass = Class.new do
31-
def m() :m end
37+
jit(@o, :m)
3238
end
3339

34-
@o = klass.new
40+
it "compiles" do
41+
@o.method(:m).executable.jitted?.should be_true
42+
end
3543

36-
jit(@o, :m)
37-
end
44+
it "returns the last computed value" do
45+
@o.m.should == :m
46+
end
3847

39-
it "compiles" do
40-
@o.method(:m).executable.jitted?.should be_true
48+
it "raises an ArgumentError if passed an argument" do
49+
lambda { @o.m 5 }.should raise_error(ArgumentError)
50+
end
4151
end
4252

43-
it "returns the last computed value" do
44-
@o.m.should == :m
45-
end
53+
context "to m(a)" do
54+
before :each do
55+
klass = Class.new do
56+
def m(a) a end
57+
end
4658

47-
it "raises an ArgumentError if passed an argument" do
48-
lambda { @o.m 5 }.should raise_error(ArgumentError)
49-
end
50-
end
59+
@o = klass.new
5160

52-
context "to m(a)" do
53-
before :each do
54-
klass = Class.new do
55-
def m(a) a end
61+
jit(@o, :m) { @o.m 5 }
5662
end
5763

58-
@o = klass.new
64+
it "compiles" do
65+
@o.method(:m).executable.jitted?.should be_true
66+
end
5967

60-
jit(@o, :m) { @o.m 5 }
61-
end
68+
it "returns the passed argument" do
69+
@o.m(:a).should == :a
70+
end
6271

63-
it "compiles" do
64-
@o.method(:m).executable.jitted?.should be_true
72+
it "raises an ArgumentError when not passed an argument" do
73+
lambda { @o.m }.should raise_error(ArgumentError)
74+
end
6575
end
6676

67-
it "returns the passed argument" do
68-
@o.m(:a).should == :a
69-
end
77+
context "to m(*a)" do
78+
before :each do
79+
klass = Class.new do
80+
def m(*a) a end
81+
end
7082

71-
it "raises an ArgumentError when not passed an argument" do
72-
lambda { @o.m }.should raise_error(ArgumentError)
73-
end
74-
end
83+
@o = klass.new
7584

76-
context "to m(*a)" do
77-
before :each do
78-
klass = Class.new do
79-
def m(*a) a end
85+
jit(@o, :m) { @o.m }
8086
end
8187

82-
@o = klass.new
88+
it "compiles" do
89+
@o.method(:m).executable.jitted?.should be_true
90+
end
8391

84-
jit(@o, :m) { @o.m }
85-
end
92+
it "returns an empty Array when passed no argument" do
93+
@o.m.should == []
94+
end
8695

87-
it "compiles" do
88-
@o.method(:m).executable.jitted?.should be_true
96+
it "returns a one-element Array when passed one argument" do
97+
@o.m(1).should == [1]
98+
end
8999
end
90100

91-
it "returns an empty Array when passed no argument" do
92-
@o.m.should == []
93-
end
101+
context "to m(a: 0)" do
102+
before :each do
103+
klass = Class.new do
104+
def m(a: 0) a end
105+
end
94106

95-
it "returns a one-element Array when passed one argument" do
96-
@o.m(1).should == [1]
97-
end
98-
end
107+
@o = klass.new
99108

100-
context "to m(a: 0)" do
101-
before :each do
102-
klass = Class.new do
103-
def m(a: 0) a end
109+
jit(@o, :m) { @o.m }
104110
end
105111

106-
@o = klass.new
112+
it "compiles" do
113+
@o.method(:m).executable.jitted?.should be_true
114+
end
107115

108-
jit(@o, :m) { @o.m }
109-
end
116+
it "returns the default keyword value when passed no arguments" do
117+
@o.m.should == 0
118+
end
110119

111-
it "compiles" do
112-
@o.method(:m).executable.jitted?.should be_true
113-
end
120+
it "returns the passed value of the keyword" do
121+
@o.m(a: 2).should == 2
122+
end
114123

115-
it "returns the default keyword value when passed no arguments" do
116-
@o.m.should == 0
117-
end
124+
it "raises an ArgumentError when passed a non-matching keyword argument" do
125+
lambda { @o.m(b: 2) }.should raise_error(ArgumentError)
126+
end
118127

119-
it "returns the passed value of the keyword" do
120-
@o.m(a: 2).should == 2
128+
it "raises an ArgumentError when passed extra keyword arguments" do
129+
lambda { @o.m(a: 2, b: 3) }.should raise_error(ArgumentError)
130+
end
121131
end
122132

123-
it "raises an ArgumentError when passed a non-matching keyword argument" do
124-
lambda { @o.m(b: 2) }.should raise_error(ArgumentError)
125-
end
133+
context "to m(a=1, **kw)" do
134+
before :each do
135+
klass = Class.new do
136+
def m(a=1, **kw) [a, kw] end
137+
end
126138

127-
it "raises an ArgumentError when passed extra keyword arguments" do
128-
lambda { @o.m(a: 2, b: 3) }.should raise_error(ArgumentError)
129-
end
130-
end
139+
@o = klass.new
131140

132-
context "to m(a=1, **kw)" do
133-
before :each do
134-
klass = Class.new do
135-
def m(a=1, **kw) [a, kw] end
141+
jit(@o, :m) { @o.m }
136142
end
137143

138-
@o = klass.new
139-
140-
jit(@o, :m) { @o.m }
141-
end
142-
143-
it "compiles" do
144-
@o.method(:m).executable.jitted?.should be_true
145-
end
146-
147-
context "when passed one argument" do
148-
it "assigns Symbol keys to the keyword rest argument" do
149-
@o.m(a: 1, b: 2).should == [1, {a: 1, b: 2}]
144+
it "compiles" do
145+
@o.method(:m).executable.jitted?.should be_true
150146
end
151147

152-
it "assigns non-Symbol keys to the default argument" do
153-
@o.m("a" => 1, b: 2).should == [{"a" => 1}, {b: 2}]
148+
context "when passed one argument" do
149+
it "assigns Symbol keys to the keyword rest argument" do
150+
@o.m(a: 1, b: 2).should == [1, {a: 1, b: 2}]
151+
end
152+
153+
it "assigns non-Symbol keys to the default argument" do
154+
@o.m("a" => 1, b: 2).should == [{"a" => 1}, {b: 2}]
155+
end
154156
end
155157
end
156158
end

‎spec/rbx.2.1.mspec

+4
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,8 @@ class MSpecScript
6565
else
6666
MSpec.enable_feature :hash_bucket
6767
end
68+
69+
if `#{get(:target)} -v` =~ /\sJID?\)/
70+
MSpec.enable_feature :jit
71+
end
6872
end

0 commit comments

Comments
 (0)
Please sign in to comment.