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: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: deabe675c687
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5e6fe27e8538
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Dec 28, 2015

  1. Copy the full SHA
    79e6247 View commit details
  2. Copy the full SHA
    5e6fe27 View commit details
Showing with 184 additions and 176 deletions.
  1. +1 −1 rakelib/gems.rake
  2. +1 −1 rakelib/preinstall_gems.rb
  3. +71 −69 spec/jit/call_site_spec.rb
  4. +107 −105 spec/jit/method_spec.rb
  5. +4 −0 spec/rbx.2.1.mspec
2 changes: 1 addition & 1 deletion rakelib/gems.rake
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ namespace :gems do
unless BUILD_CONFIG[:darwin] and
`which brew`.chomp.size > 0 and
$?.success? and
(openssl = `brew --prefix openssl`.chomp).size > 0
(openssl = `brew --prefix #{ENV["RBX_OPENSSL"] || "openssl"}`.chomp).size > 0
openssl = false
end

2 changes: 1 addition & 1 deletion rakelib/preinstall_gems.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
unless BUILD_CONFIG[:darwin] and
`which brew`.chomp.size > 0 and
$?.success? and
(openssl = `brew --prefix openssl`.chomp).size > 0
(openssl = `brew --prefix #{ENV["RBX_OPENSSL"] || "openssl"}`.chomp).size > 0
openssl = false
end

140 changes: 71 additions & 69 deletions spec/jit/call_site_spec.rb
Original file line number Diff line number Diff line change
@@ -1,100 +1,102 @@
require File.expand_path("../spec_helper", __FILE__)

describe "JIT compiling a call site" do
context "to m()" do
before :each do
klass = Class.new do
def m() :m end
def call() m() end
with_feature :jit do
describe "JIT compiling a call site" do
context "to m()" do
before :each do
klass = Class.new do
def m() :m end
def call() m() end
end

@o = klass.new

jit(@o, :call) { @o.call }
end

@o = klass.new
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

jit(@o, :call) { @o.call }
it "returns the result of calling the method" do
@o.call.should equal(:m)
end
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
context "to m() defined in an included module" do
before :each do
mod = Module.new do
def m() :m end
end
klass = Class.new do
def call() m() end
include mod
end

it "returns the result of calling the method" do
@o.call.should equal(:m)
end
end
@o = klass.new

context "to m() defined in an included module" do
before :each do
mod = Module.new do
def m() :m end
end
klass = Class.new do
def call() m() end
include mod
jit(@o, :call) { @o.call }
end

@o = klass.new
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

jit(@o, :call) { @o.call }
it "returns the result of calling the included method" do
@o.call.should equal(:m)
end
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
context "to m() defined in a prepended module" do
before :each do

it "returns the result of calling the included method" do
@o.call.should equal(:m)
end
end
mod = Module.new do
def m() :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
end

context "to m() defined in a prepended module" do
before :each do
o = @o = klass.new

mod = Module.new do
def m() :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
jit(o, :call) { o.call }
end

o = @o = klass.new
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

jit(o, :call) { o.call }
it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
end
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
context "to m() that calls super defined in a prepended module" do
before :each do

it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
end
end
mod = Module.new do
def m() super; :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
end

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

mod = Module.new do
def m() super; :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
jit(o, :call) { o.call }
end

o = @o = klass.new

jit(o, :call) { o.call }
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
end
end
end
end
212 changes: 107 additions & 105 deletions spec/jit/method_spec.rb
Original file line number Diff line number Diff line change
@@ -1,156 +1,158 @@
require File.expand_path("../spec_helper", __FILE__)

describe "JIT compiling a method call" do
context "to m()" do
before :each do
klass = Class.new do
def m() :m end
with_feature :jit do
describe "JIT compiling a method call" do
context "to m()" do
before :each do
klass = Class.new do
def m() :m end
end

@o = klass.new

jit(@o, :m) { @o.m }
end

@o = klass.new
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

jit(@o, :m) { @o.m }
end
it "returns the last computed value" do
@o.m.should equal(:m)
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
it "raises an ArgumentError if passed an argument" do
lambda { @o.m 5 }.should raise_error(ArgumentError)
end
end

it "returns the last computed value" do
@o.m.should equal(:m)
end
context "to m() without calling it" do
before :each do
klass = Class.new do
def m() :m end
end

it "raises an ArgumentError if passed an argument" do
lambda { @o.m 5 }.should raise_error(ArgumentError)
end
end
@o = klass.new

context "to m() without calling it" do
before :each do
klass = Class.new do
def m() :m end
jit(@o, :m)
end

@o = klass.new
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

jit(@o, :m)
end
it "returns the last computed value" do
@o.m.should == :m
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
it "raises an ArgumentError if passed an argument" do
lambda { @o.m 5 }.should raise_error(ArgumentError)
end
end

it "returns the last computed value" do
@o.m.should == :m
end
context "to m(a)" do
before :each do
klass = Class.new do
def m(a) a end
end

it "raises an ArgumentError if passed an argument" do
lambda { @o.m 5 }.should raise_error(ArgumentError)
end
end
@o = klass.new

context "to m(a)" do
before :each do
klass = Class.new do
def m(a) a end
jit(@o, :m) { @o.m 5 }
end

@o = klass.new
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

jit(@o, :m) { @o.m 5 }
end
it "returns the passed argument" do
@o.m(:a).should == :a
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
it "raises an ArgumentError when not passed an argument" do
lambda { @o.m }.should raise_error(ArgumentError)
end
end

it "returns the passed argument" do
@o.m(:a).should == :a
end
context "to m(*a)" do
before :each do
klass = Class.new do
def m(*a) a end
end

it "raises an ArgumentError when not passed an argument" do
lambda { @o.m }.should raise_error(ArgumentError)
end
end
@o = klass.new

context "to m(*a)" do
before :each do
klass = Class.new do
def m(*a) a end
jit(@o, :m) { @o.m }
end

@o = klass.new
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

jit(@o, :m) { @o.m }
end
it "returns an empty Array when passed no argument" do
@o.m.should == []
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
it "returns a one-element Array when passed one argument" do
@o.m(1).should == [1]
end
end

it "returns an empty Array when passed no argument" do
@o.m.should == []
end
context "to m(a: 0)" do
before :each do
klass = Class.new do
def m(a: 0) a end
end

it "returns a one-element Array when passed one argument" do
@o.m(1).should == [1]
end
end
@o = klass.new

context "to m(a: 0)" do
before :each do
klass = Class.new do
def m(a: 0) a end
jit(@o, :m) { @o.m }
end

@o = klass.new
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

jit(@o, :m) { @o.m }
end
it "returns the default keyword value when passed no arguments" do
@o.m.should == 0
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end
it "returns the passed value of the keyword" do
@o.m(a: 2).should == 2
end

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

it "returns the passed value of the keyword" do
@o.m(a: 2).should == 2
it "raises an ArgumentError when passed extra keyword arguments" do
lambda { @o.m(a: 2, b: 3) }.should raise_error(ArgumentError)
end
end

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

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

context "to m(a=1, **kw)" do
before :each do
klass = Class.new do
def m(a=1, **kw) [a, kw] end
jit(@o, :m) { @o.m }
end

@o = klass.new

jit(@o, :m) { @o.m }
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

context "when passed one argument" do
it "assigns Symbol keys to the keyword rest argument" do
@o.m(a: 1, b: 2).should == [1, {a: 1, b: 2}]
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

it "assigns non-Symbol keys to the default argument" do
@o.m("a" => 1, b: 2).should == [{"a" => 1}, {b: 2}]
context "when passed one argument" do
it "assigns Symbol keys to the keyword rest argument" do
@o.m(a: 1, b: 2).should == [1, {a: 1, b: 2}]
end

it "assigns non-Symbol keys to the default argument" do
@o.m("a" => 1, b: 2).should == [{"a" => 1}, {b: 2}]
end
end
end
end
4 changes: 4 additions & 0 deletions spec/rbx.2.1.mspec
Original file line number Diff line number Diff line change
@@ -65,4 +65,8 @@ class MSpecScript
else
MSpec.enable_feature :hash_bucket
end

if `#{get(:target)} -v` =~ /\sJID?\)/
MSpec.enable_feature :jit
end
end