-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
197 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
require File.expand_path("../spec_helper", __FILE__) | ||
|
||
describe "JIT compiling a string_dup instruction" do | ||
before :each do | ||
klass = Class.new do | ||
def m() "abc" end | ||
end | ||
with_feature :jit do | ||
describe "JIT compiling a string_dup instruction" do | ||
before :each do | ||
klass = Class.new do | ||
def m() "abc" end | ||
end | ||
|
||
@o = klass.new | ||
@o = klass.new | ||
|
||
jit(@o, :m) { @o.m } | ||
end | ||
jit(@o, :m) { @o.m } | ||
end | ||
|
||
it "compiles" do | ||
@o.method(:m).executable.jitted?.should be_true | ||
end | ||
it "compiles" do | ||
@o.method(:m).executable.jitted?.should be_true | ||
end | ||
|
||
it "dups the literal String" do | ||
@o.method(:m).executable.literals[0].object_id.should_not equal(@o.m) | ||
it "dups the literal String" do | ||
@o.method(:m).executable.literals[0].object_id.should_not equal(@o.m) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters