diff --git a/.travis.yml b/.travis.yml
index 67a3281de3c..229e75177bc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,27 +27,30 @@ env:
global:
- JAVA_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xmn48M -Xmx512M"
- MALLOC_ARENA_MAX=2
- matrix:
- - JT='test specs :command_line'
- - JT='test specs :language'
- - JT='test specs :core'
- - JT='test specs :library'
- - JT='test specs :truffle'
- - JT='test integration fast'
- - JT='test integration long' JAVA_OPTS="$JAVA_OPTS -Xmx512m" HAS_REDIS=true
matrix:
include:
- - env: COMMAND=test/check_versions.sh
+ # JRuby+Truffle needs Java 8
+ - env: JT='test specs :command_line'
+ jdk: oraclejdk8
+ - env: JT='test specs :language'
+ jdk: oraclejdk8
+ - env: JT='test specs :core'
+ jdk: oraclejdk8
+ - env: JT='test specs :library'
+ jdk: oraclejdk8
+ - env: JT='test specs :truffle'
+ jdk: oraclejdk8
+ - env: JT='test integration'
+ jdk: oraclejdk8
+ - env: JT='test gems' JAVA_OPTS="$JAVA_OPTS -Xmx512m" HAS_REDIS=true
jdk: oraclejdk8
- env: JT=check_ambiguous_arguments SKIP_BUILD=true
jdk: oraclejdk8
allow_failures:
- - env: PHASE='-Prake -Dtask=test:mri:fullint'
- env: JT='test mri'
- - env: PHASE='-Pj2ee --projects !truffle'
- jdk: oraclejdk7
- - env: JT='test integration long' JAVA_OPTS="$JAVA_OPTS -Xmx512m" HAS_REDIS=true
+ jdk: oraclejdk8
+ - env: JT='test gems' JAVA_OPTS="$JAVA_OPTS -Xmx512m" HAS_REDIS=true
# NOTE: build seems to never start (waited for any to finish for more than a day) - probably a travis-ci bug
#- env: PHASE='-Pmain'
# sudo: required
@@ -65,8 +68,12 @@ branches:
- ruby-2.3
script: tool/travis_runner.sh
-install:
- - if [ -z "$SKIP_BUILD" ]; then travis_retry ./mvnw -Pbootstrap clean install -B -Dinvoker.skip -Dmaven.test.skip; fi
+install: |
+ if [[ -n "$PHASE" && $JAVA_HOME == *"java-8"* ]]; then
+ travis_retry ./mvnw package -B --projects '!truffle' -Dinvoker.skip -Dmaven.test.skip;
+ else
+ if [ -z "$SKIP_BUILD" ]; then travis_retry ./mvnw package -B -Dinvoker.skip -Dmaven.test.skip; fi
+ fi
notifications:
irc:
diff --git a/VERSION b/VERSION
index 317eca68734..fc299062b27 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-9.1.0.0
+9.1.1.0-SNAPSHOT
diff --git a/bench/yarv/bm_app_answer.rb b/bench/mri/bm_app_answer.rb
similarity index 100%
rename from bench/yarv/bm_app_answer.rb
rename to bench/mri/bm_app_answer.rb
diff --git a/bench/mri/bm_app_aobench.rb b/bench/mri/bm_app_aobench.rb
new file mode 100644
index 00000000000..2bd6acfaf85
--- /dev/null
+++ b/bench/mri/bm_app_aobench.rb
@@ -0,0 +1,291 @@
+# AO render benchmark
+# Original program (C) Syoyo Fujita in Javascript (and other languages)
+# https://code.google.com/p/aobench/
+# Ruby(yarv2llvm) version by Hideki Miura
+#
+
+IMAGE_WIDTH = 256
+IMAGE_HEIGHT = 256
+NSUBSAMPLES = 2
+NAO_SAMPLES = 8
+
+class Vec
+ def initialize(x, y, z)
+ @x = x
+ @y = y
+ @z = z
+ end
+
+ attr_accessor :x, :y, :z
+
+ def vadd(b)
+ Vec.new(@x + b.x, @y + b.y, @z + b.z)
+ end
+
+ def vsub(b)
+ Vec.new(@x - b.x, @y - b.y, @z - b.z)
+ end
+
+ def vcross(b)
+ Vec.new(@y * b.z - @z * b.y,
+ @z * b.x - @x * b.z,
+ @x * b.y - @y * b.x)
+ end
+
+ def vdot(b)
+ @x * b.x + @y * b.y + @z * b.z
+ end
+
+ def vlength
+ Math.sqrt(@x * @x + @y * @y + @z * @z)
+ end
+
+ def vnormalize
+ len = vlength
+ v = Vec.new(@x, @y, @z)
+ if len > 1.0e-17 then
+ v.x = v.x / len
+ v.y = v.y / len
+ v.z = v.z / len
+ end
+ v
+ end
+end
+
+
+class Sphere
+ def initialize(center, radius)
+ @center = center
+ @radius = radius
+ end
+
+ attr_reader :center, :radius
+
+ def intersect(ray, isect)
+ rs = ray.org.vsub(@center)
+ b = rs.vdot(ray.dir)
+ c = rs.vdot(rs) - (@radius * @radius)
+ d = b * b - c
+ if d > 0.0 then
+ t = - b - Math.sqrt(d)
+
+ if t > 0.0 and t < isect.t then
+ isect.t = t
+ isect.hit = true
+ isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
+ ray.org.y + ray.dir.y * t,
+ ray.org.z + ray.dir.z * t)
+ n = isect.pl.vsub(@center)
+ isect.n = n.vnormalize
+ else
+ 0.0
+ end
+ end
+ nil
+ end
+end
+
+class Plane
+ def initialize(p, n)
+ @p = p
+ @n = n
+ end
+
+ def intersect(ray, isect)
+ d = -@p.vdot(@n)
+ v = ray.dir.vdot(@n)
+ v0 = v
+ if v < 0.0 then
+ v0 = -v
+ end
+ if v0 < 1.0e-17 then
+ return
+ end
+
+ t = -(ray.org.vdot(@n) + d) / v
+
+ if t > 0.0 and t < isect.t then
+ isect.hit = true
+ isect.t = t
+ isect.n = @n
+ isect.pl = Vec.new(ray.org.x + t * ray.dir.x,
+ ray.org.y + t * ray.dir.y,
+ ray.org.z + t * ray.dir.z)
+ end
+ nil
+ end
+end
+
+class Ray
+ def initialize(org, dir)
+ @org = org
+ @dir = dir
+ end
+
+ attr_accessor :org, :dir
+end
+
+class Isect
+ def initialize
+ @t = 10000000.0
+ @hit = false
+ @pl = Vec.new(0.0, 0.0, 0.0)
+ @n = Vec.new(0.0, 0.0, 0.0)
+ end
+
+ attr_accessor :t, :hit, :pl, :n
+end
+
+def clamp(f)
+ i = f * 255.5
+ if i > 255.0 then
+ i = 255.0
+ end
+ if i < 0.0 then
+ i = 0.0
+ end
+ i.to_i
+end
+
+def otherBasis(basis, n)
+ basis[2] = Vec.new(n.x, n.y, n.z)
+ basis[1] = Vec.new(0.0, 0.0, 0.0)
+
+ if n.x < 0.6 and n.x > -0.6 then
+ basis[1].x = 1.0
+ elsif n.y < 0.6 and n.y > -0.6 then
+ basis[1].y = 1.0
+ elsif n.z < 0.6 and n.z > -0.6 then
+ basis[1].z = 1.0
+ else
+ basis[1].x = 1.0
+ end
+
+ basis[0] = basis[1].vcross(basis[2])
+ basis[0] = basis[0].vnormalize
+
+ basis[1] = basis[2].vcross(basis[0])
+ basis[1] = basis[1].vnormalize
+end
+
+class Scene
+ def initialize
+ @spheres = Array.new
+ @spheres[0] = Sphere.new(Vec.new(-2.0, 0.0, -3.5), 0.5)
+ @spheres[1] = Sphere.new(Vec.new(-0.5, 0.0, -3.0), 0.5)
+ @spheres[2] = Sphere.new(Vec.new(1.0, 0.0, -2.2), 0.5)
+ @plane = Plane.new(Vec.new(0.0, -0.5, 0.0), Vec.new(0.0, 1.0, 0.0))
+ end
+
+ def ambient_occlusion(isect)
+ basis = Array.new
+ otherBasis(basis, isect.n)
+
+ ntheta = NAO_SAMPLES
+ nphi = NAO_SAMPLES
+ eps = 0.0001
+ occlusion = 0.0
+
+ p0 = Vec.new(isect.pl.x + eps * isect.n.x,
+ isect.pl.y + eps * isect.n.y,
+ isect.pl.z + eps * isect.n.z)
+ nphi.times do |j|
+ ntheta.times do |i|
+ r = rand
+ phi = 2.0 * 3.14159265 * rand
+ x = Math.cos(phi) * Math.sqrt(1.0 - r)
+ y = Math.sin(phi) * Math.sqrt(1.0 - r)
+ z = Math.sqrt(r)
+
+ rx = x * basis[0].x + y * basis[1].x + z * basis[2].x
+ ry = x * basis[0].y + y * basis[1].y + z * basis[2].y
+ rz = x * basis[0].z + y * basis[1].z + z * basis[2].z
+
+ raydir = Vec.new(rx, ry, rz)
+ ray = Ray.new(p0, raydir)
+
+ occisect = Isect.new
+ @spheres[0].intersect(ray, occisect)
+ @spheres[1].intersect(ray, occisect)
+ @spheres[2].intersect(ray, occisect)
+ @plane.intersect(ray, occisect)
+ if occisect.hit then
+ occlusion = occlusion + 1.0
+ else
+ 0.0
+ end
+ end
+ end
+
+ occlusion = (ntheta.to_f * nphi.to_f - occlusion) / (ntheta.to_f * nphi.to_f)
+
+ Vec.new(occlusion, occlusion, occlusion)
+ end
+
+ def render(w, h, nsubsamples)
+ cnt = 0
+ nsf = nsubsamples.to_f
+ h.times do |y|
+ w.times do |x|
+ rad = Vec.new(0.0, 0.0, 0.0)
+
+ # Subsampling
+ nsubsamples.times do |v|
+ nsubsamples.times do |u|
+
+ cnt = cnt + 1
+ wf = w.to_f
+ hf = h.to_f
+ xf = x.to_f
+ yf = y.to_f
+ uf = u.to_f
+ vf = v.to_f
+
+ px = (xf + (uf / nsf) - (wf / 2.0)) / (wf / 2.0)
+ py = -(yf + (vf / nsf) - (hf / 2.0)) / (hf / 2.0)
+
+ eye = Vec.new(px, py, -1.0).vnormalize
+
+ ray = Ray.new(Vec.new(0.0, 0.0, 0.0), eye)
+
+ isect = Isect.new
+ @spheres[0].intersect(ray, isect)
+ @spheres[1].intersect(ray, isect)
+ @spheres[2].intersect(ray, isect)
+ @plane.intersect(ray, isect)
+ if isect.hit then
+ col = ambient_occlusion(isect)
+ rad.x = rad.x + col.x
+ rad.y = rad.y + col.y
+ rad.z = rad.z + col.z
+ end
+ end
+ end
+
+ r = rad.x / (nsf * nsf)
+ g = rad.y / (nsf * nsf)
+ b = rad.z / (nsf * nsf)
+ printf("%c", clamp(r))
+ printf("%c", clamp(g))
+ printf("%c", clamp(b))
+ end
+ nil
+ end
+
+ nil
+ end
+end
+
+alias printf_orig printf
+def printf *args
+end
+
+# File.open("ao.ppm", "w") do |fp|
+ printf("P6\n")
+ printf("%d %d\n", IMAGE_WIDTH, IMAGE_HEIGHT)
+ printf("255\n", IMAGE_WIDTH, IMAGE_HEIGHT)
+ Scene.new.render(IMAGE_WIDTH, IMAGE_HEIGHT, NSUBSAMPLES)
+# end
+
+undef printf
+alias printf printf_orig
diff --git a/bench/yarv/bm_app_erb.rb b/bench/mri/bm_app_erb.rb
similarity index 89%
rename from bench/yarv/bm_app_erb.rb
rename to bench/mri/bm_app_erb.rb
index c4fcfac8877..77c66a79492 100644
--- a/bench/yarv/bm_app_erb.rb
+++ b/bench/mri/bm_app_erb.rb
@@ -1,26 +1,26 @@
-#
-# Create many HTML strings with ERB.
-#
-
-require 'erb'
-
-data = DATA.read
-max = 5_000
-title = "hello world!"
-content = "hello world!\n" * 10
-
-max.times{
- ERB.new(data).result(binding)
-}
-
-__END__
-
-
-
<%= title %>
-
- <%= title %>
-
- <%= content %>
-
-
-
+#
+# Create many HTML strings with ERB.
+#
+
+require 'erb'
+
+data = DATA.read
+max = 15_000
+title = "hello world!"
+content = "hello world!\n" * 10
+
+max.times{
+ ERB.new(data).result(binding)
+}
+
+__END__
+
+
+ <%= title %>
+
+ <%= title %>
+
+ <%= content %>
+
+
+
diff --git a/bench/yarv/bm_app_factorial.rb b/bench/mri/bm_app_factorial.rb
similarity index 84%
rename from bench/yarv/bm_app_factorial.rb
rename to bench/mri/bm_app_factorial.rb
index a5a5de04260..45f471dfdb8 100644
--- a/bench/yarv/bm_app_factorial.rb
+++ b/bench/mri/bm_app_factorial.rb
@@ -6,6 +6,6 @@ def fact(n)
end
end
-8.times{
+100.times {
fact(5000)
-}
\ No newline at end of file
+}
diff --git a/bench/yarv/bm_app_fib.rb b/bench/mri/bm_app_fib.rb
similarity index 100%
rename from bench/yarv/bm_app_fib.rb
rename to bench/mri/bm_app_fib.rb
diff --git a/bench/mri/bm_app_lc_fizzbuzz.rb b/bench/mri/bm_app_lc_fizzbuzz.rb
new file mode 100644
index 00000000000..f09574bbeb1
--- /dev/null
+++ b/bench/mri/bm_app_lc_fizzbuzz.rb
@@ -0,0 +1,52 @@
+#
+# FizzBuzz program using only lambda calculus
+#
+# This program is quoted from
+# "Understanding Computation" by Tom Stuart
+# http://computationbook.com/
+#
+# You can understand why this program works fine by reading this book.
+#
+
+solution = -> k { -> f { -> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> l { -> x { -> g { -> b { b }[-> p { p[-> x { -> y { x } }] }[l]][x][-> y { g[f[-> l { -> p { p[-> x { -> y { y } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][x][g]][-> l { -> p { p[-> x { -> y { x } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][y] }] } } } }][k][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> l { -> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[l][f[x]] } }] } }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[m][n]][-> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[f[-> n { -> p { -> x { p[n[p][x]] } } }[m]][n]][m][x] }][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]] } } }][-> p { -> x { p[x] } }][-> p { -> x { p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] } }]][-> n { -> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> p { -> x { p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[x]]]]]]]]]]]]]]] } }]]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]][-> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> p { -> x { p[p[p[x]]] } }]]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]][-> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]]][-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> n { -> p { -> x { p[n[p][x]] } } }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]]]][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> n { -> l { -> x { -> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> l { -> x { -> g { -> b { b }[-> p { p[-> x { -> y { x } }] }[l]][x][-> y { g[f[-> l { -> p { p[-> x { -> y { y } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][x][g]][-> l { -> p { p[-> x { -> y { x } }] }[-> p { p[-> x { -> y { y } }] }[l]] }[l]][y] }] } } } }][l][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][x]][-> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }] } }[-> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }[-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]]][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> x { f[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { -> n { -> p { -> x { p[n[p][x]] } } }[f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n]][x] }][-> p { -> x { x } }] } } }][n][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]][x] }]][-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]] } }[n][m]][-> x { f[-> m { -> n { n[-> n { -> p { p[-> x { -> y { x } }] }[n[-> p { -> x { -> y { -> f { f[x][y] } } }[-> p { p[-> x { -> y { y } }] }[p]][-> n { -> p { -> x { p[n[p][x]] } } }[-> p { p[-> x { -> y { y } }] }[p]]] }][-> x { -> y { -> f { f[x][y] } } }[-> p { -> x { x } }][-> p { -> x { x } }]]] }][m] } }[m][n]][n][x] }][m] } } }][n][-> m { -> n { n[-> m { -> n { n[-> n { -> p { -> x { p[n[p][x]] } } }][m] } }[m]][-> p { -> x { x } }] } }[-> p { -> x { p[p[x]] } }][-> p { -> x { p[p[p[p[p[x]]]]] } }]]] } }][n]]]] }]
+
+FIRST = -> l { LEFT[RIGHT[l]] }
+IF = -> b { b }
+LEFT = -> p { p[-> x { -> y { x } } ] }
+RIGHT = -> p { p[-> x { -> y { y } } ] }
+IS_EMPTY = LEFT
+REST = -> l { RIGHT[RIGHT[l]] }
+
+def to_integer(proc)
+ proc[-> n { n + 1 }][0]
+end
+
+def to_boolean(proc)
+ IF[proc][true][false]
+end
+
+def to_array(proc)
+ array = []
+
+ until to_boolean(IS_EMPTY[proc])
+ array.push(FIRST[proc])
+ proc = REST[proc]
+ end
+
+ array
+end
+
+def to_char(c)
+ '0123456789BFiuz'.slice(to_integer(c))
+end
+
+def to_string(s)
+ to_array(s).map { |c| to_char(c) }.join
+end
+
+answer = to_array(solution).map do |p|
+ to_string(p)
+end
+
+answer_ary = answer.to_a
+# puts answer_ary
diff --git a/bench/yarv/bm_app_mandelbrot.rb b/bench/mri/bm_app_mandelbrot.rb
similarity index 81%
rename from bench/yarv/bm_app_mandelbrot.rb
rename to bench/mri/bm_app_mandelbrot.rb
index a0dcf5e874a..801b75e8e28 100644
--- a/bench/yarv/bm_app_mandelbrot.rb
+++ b/bench/mri/bm_app_mandelbrot.rb
@@ -3,7 +3,7 @@
def mandelbrot? z
i = 0
while i<100
- i+=1
+ i += 1
z = z * z
return false if z.abs > 2
end
@@ -12,8 +12,8 @@ def mandelbrot? z
ary = []
-(0..100).each{|dx|
- (0..100).each{|dy|
+(0..1000).each{|dx|
+ (0..1000).each{|dy|
x = dx / 50.0
y = dy / 50.0
c = Complex(x, y)
diff --git a/bench/yarv/bm_app_pentomino.rb b/bench/mri/bm_app_pentomino.rb
similarity index 100%
rename from bench/yarv/bm_app_pentomino.rb
rename to bench/mri/bm_app_pentomino.rb
diff --git a/bench/yarv/bm_app_raise.rb b/bench/mri/bm_app_raise.rb
similarity index 77%
rename from bench/yarv/bm_app_raise.rb
rename to bench/mri/bm_app_raise.rb
index 01d2ae32192..5db8f95d507 100644
--- a/bench/yarv/bm_app_raise.rb
+++ b/bench/mri/bm_app_raise.rb
@@ -1,6 +1,6 @@
-i=0
+i = 0
while i<300000
- i+=1
+ i += 1
begin
raise
rescue
diff --git a/bench/mri/bm_app_strconcat.rb b/bench/mri/bm_app_strconcat.rb
new file mode 100644
index 00000000000..7eed7c1aed9
--- /dev/null
+++ b/bench/mri/bm_app_strconcat.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<2_000_000
+ "#{1+1} #{1+1} #{1+1}"
+ i += 1
+end
diff --git a/bench/yarv/bm_app_tak.rb b/bench/mri/bm_app_tak.rb
similarity index 100%
rename from bench/yarv/bm_app_tak.rb
rename to bench/mri/bm_app_tak.rb
diff --git a/bench/yarv/bm_app_tarai.rb b/bench/mri/bm_app_tarai.rb
similarity index 100%
rename from bench/yarv/bm_app_tarai.rb
rename to bench/mri/bm_app_tarai.rb
diff --git a/bench/yarv/bm_app_uri.rb b/bench/mri/bm_app_uri.rb
similarity index 93%
rename from bench/yarv/bm_app_uri.rb
rename to bench/mri/bm_app_uri.rb
index 49fe5a81a80..586edfd5dca 100644
--- a/bench/yarv/bm_app_uri.rb
+++ b/bench/mri/bm_app_uri.rb
@@ -1,8 +1,8 @@
-require 'uri'
-
-100_000.times{
- uri = URI.parse('http://www.ruby-lang.org')
- uri.scheme
- uri.host
- uri.port
-}
+require 'uri'
+
+100_000.times{
+ uri = URI.parse('http://www.ruby-lang.org')
+ uri.scheme
+ uri.host
+ uri.port
+}
diff --git a/bench/mri/bm_array_shift.rb b/bench/mri/bm_array_shift.rb
new file mode 100644
index 00000000000..798bb9e3f40
--- /dev/null
+++ b/bench/mri/bm_array_shift.rb
@@ -0,0 +1,14 @@
+require 'benchmark'
+
+Benchmark.bm do |x|
+ [10_000,1_000_000,100_000_000].each do |n|
+ ary = Array.new(n,0)
+ GC.start
+ x.report("#{n}:shift"){ ary.shift }
+ (0..4).each do |i|
+ ary = Array.new(n,0)
+ GC.start
+ x.report("#{n}:shift(#{i})"){ ary.shift(i) }
+ end
+ end
+end
diff --git a/bench/mri/bm_hash_aref_dsym.rb b/bench/mri/bm_hash_aref_dsym.rb
new file mode 100644
index 00000000000..af4f8c36d43
--- /dev/null
+++ b/bench/mri/bm_hash_aref_dsym.rb
@@ -0,0 +1,4 @@
+h = {}
+syms = ('a'..'z').map { |s| s.to_sym }
+syms.each { |s| h[s] = 1 }
+200_000.times { syms.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_aref_dsym_long.rb b/bench/mri/bm_hash_aref_dsym_long.rb
new file mode 100644
index 00000000000..9d7759379ea
--- /dev/null
+++ b/bench/mri/bm_hash_aref_dsym_long.rb
@@ -0,0 +1,21 @@
+# [ruby-core:70129] [Bug #11396]
+collection_size = 200000
+sample_size = 10000
+
+values = (1..collection_size).to_a.map do |x|
+ "THIS IS A LONGER STRING THAT IS ALSO UNIQUE #{x}"
+end
+
+symbol_hash = {}
+
+values.each do |x|
+ symbol_hash[x.to_sym] = 1
+end
+
+# use the same samples each time to minimize deviations
+rng = Random.new(0)
+symbol_sample_array = values.sample(sample_size, random: rng).map(&:to_sym)
+
+3000.times do
+ symbol_sample_array.each { |x| symbol_hash[x] }
+end
diff --git a/bench/mri/bm_hash_aref_fix.rb b/bench/mri/bm_hash_aref_fix.rb
new file mode 100644
index 00000000000..13468905822
--- /dev/null
+++ b/bench/mri/bm_hash_aref_fix.rb
@@ -0,0 +1,4 @@
+h = {}
+nums = (1..26).to_a
+nums.each { |i| h[i] = i }
+200_000.times { nums.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_aref_flo.rb b/bench/mri/bm_hash_aref_flo.rb
new file mode 100644
index 00000000000..2217274c822
--- /dev/null
+++ b/bench/mri/bm_hash_aref_flo.rb
@@ -0,0 +1,4 @@
+h = {}
+strs = [*1..10000].map! {|i| i.fdiv(10)}
+strs.each { |s| h[s] = s }
+50.times { strs.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_aref_miss.rb b/bench/mri/bm_hash_aref_miss.rb
new file mode 100644
index 00000000000..b0913dd4bb9
--- /dev/null
+++ b/bench/mri/bm_hash_aref_miss.rb
@@ -0,0 +1,5 @@
+h = {}
+strs = ('a'..'z').to_a.map!(&:freeze)
+strs.each { |s| h[s] = s }
+strs = ('A'..'Z').to_a
+200_000.times { strs.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_aref_str.rb b/bench/mri/bm_hash_aref_str.rb
new file mode 100644
index 00000000000..19439b061b3
--- /dev/null
+++ b/bench/mri/bm_hash_aref_str.rb
@@ -0,0 +1,4 @@
+h = {}
+strs = ('a'..'z').to_a.map!(&:freeze)
+strs.each { |s| h[s] = s }
+200_000.times { strs.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_aref_sym.rb b/bench/mri/bm_hash_aref_sym.rb
new file mode 100644
index 00000000000..f75d163fe67
--- /dev/null
+++ b/bench/mri/bm_hash_aref_sym.rb
@@ -0,0 +1,9 @@
+h = {}
+syms = ('a'..'z').to_a
+begin
+ syms = eval("%i[#{syms.join(' ')}]")
+rescue SyntaxError # <= 1.9.3
+ syms.map!(&:to_sym)
+end
+syms.each { |s| h[s] = s }
+200_000.times { syms.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_aref_sym_long.rb b/bench/mri/bm_hash_aref_sym_long.rb
new file mode 100644
index 00000000000..9dab8df7be4
--- /dev/null
+++ b/bench/mri/bm_hash_aref_sym_long.rb
@@ -0,0 +1,13 @@
+h = {}
+syms = %w[puts warn syswrite write stat bacon lettuce tomato
+some symbols in this array may already be interned others should not be
+hash browns make good breakfast but not cooked using prime numbers
+shift for division entries delete_if keys exist?
+]
+begin
+ syms = eval("%i[#{syms.join(' ')}]")
+rescue SyntaxError # <= 1.9.3
+ syms.map!(&:to_sym)
+end
+syms.each { |s| h[s] = s }
+200_000.times { syms.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_flatten.rb b/bench/mri/bm_hash_flatten.rb
new file mode 100644
index 00000000000..e944aae9f24
--- /dev/null
+++ b/bench/mri/bm_hash_flatten.rb
@@ -0,0 +1,9 @@
+h = {}
+
+10000.times do |i|
+ h[i] = nil
+end
+
+1000.times do
+ h.flatten
+end
diff --git a/bench/mri/bm_hash_ident_flo.rb b/bench/mri/bm_hash_ident_flo.rb
new file mode 100644
index 00000000000..0c7edfed3eb
--- /dev/null
+++ b/bench/mri/bm_hash_ident_flo.rb
@@ -0,0 +1,4 @@
+h = {}.compare_by_identity
+strs = (1..10000).to_a.map!(&:to_f)
+strs.each { |s| h[s] = s }
+50.times { strs.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_ident_num.rb b/bench/mri/bm_hash_ident_num.rb
new file mode 100644
index 00000000000..b226736c6f6
--- /dev/null
+++ b/bench/mri/bm_hash_ident_num.rb
@@ -0,0 +1,4 @@
+h = {}.compare_by_identity
+nums = (1..26).to_a
+nums.each { |n| h[n] = n }
+200_000.times { nums.each { |n| h[n] } }
diff --git a/bench/mri/bm_hash_ident_obj.rb b/bench/mri/bm_hash_ident_obj.rb
new file mode 100644
index 00000000000..4b3b58edec9
--- /dev/null
+++ b/bench/mri/bm_hash_ident_obj.rb
@@ -0,0 +1,4 @@
+h = {}.compare_by_identity
+objs = 26.times.map { Object.new }
+objs.each { |o| h[o] = o }
+200_000.times { objs.each { |o| h[o] } }
diff --git a/bench/mri/bm_hash_ident_str.rb b/bench/mri/bm_hash_ident_str.rb
new file mode 100644
index 00000000000..8582b38e319
--- /dev/null
+++ b/bench/mri/bm_hash_ident_str.rb
@@ -0,0 +1,4 @@
+h = {}.compare_by_identity
+strs = ('a'..'z').to_a
+strs.each { |s| h[s] = s }
+200_000.times { strs.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_ident_sym.rb b/bench/mri/bm_hash_ident_sym.rb
new file mode 100644
index 00000000000..4c81e3d28e2
--- /dev/null
+++ b/bench/mri/bm_hash_ident_sym.rb
@@ -0,0 +1,4 @@
+h = {}.compare_by_identity
+syms = ('a'..'z').to_a.map(&:to_sym)
+syms.each { |s| h[s] = s }
+200_000.times { syms.each { |s| h[s] } }
diff --git a/bench/mri/bm_hash_keys.rb b/bench/mri/bm_hash_keys.rb
new file mode 100644
index 00000000000..6863cd01f9d
--- /dev/null
+++ b/bench/mri/bm_hash_keys.rb
@@ -0,0 +1,9 @@
+h = {}
+
+10000.times do |i|
+ h[i] = nil
+end
+
+5000.times do
+ h.keys
+end
diff --git a/bench/mri/bm_hash_shift.rb b/bench/mri/bm_hash_shift.rb
new file mode 100644
index 00000000000..a645671a5bf
--- /dev/null
+++ b/bench/mri/bm_hash_shift.rb
@@ -0,0 +1,10 @@
+h = {}
+
+10000.times do |i|
+ h[i] = nil
+end
+
+50000.times do
+ k, v = h.shift
+ h[k] = v
+end
diff --git a/bench/mri/bm_hash_shift_u16.rb b/bench/mri/bm_hash_shift_u16.rb
new file mode 100644
index 00000000000..ec800d0342a
--- /dev/null
+++ b/bench/mri/bm_hash_shift_u16.rb
@@ -0,0 +1,10 @@
+h = {}
+
+(16384..65536).each do |i|
+ h[i] = nil
+end
+
+300000.times do
+ k, v = h.shift
+ h[k] = v
+end
diff --git a/bench/mri/bm_hash_shift_u24.rb b/bench/mri/bm_hash_shift_u24.rb
new file mode 100644
index 00000000000..de4e0fa6962
--- /dev/null
+++ b/bench/mri/bm_hash_shift_u24.rb
@@ -0,0 +1,10 @@
+h = {}
+
+(0xff4000..0xffffff).each do |i|
+ h[i] = nil
+end
+
+300000.times do
+ k, v = h.shift
+ h[k] = v
+end
diff --git a/bench/mri/bm_hash_shift_u32.rb b/bench/mri/bm_hash_shift_u32.rb
new file mode 100644
index 00000000000..656aa555839
--- /dev/null
+++ b/bench/mri/bm_hash_shift_u32.rb
@@ -0,0 +1,10 @@
+h = {}
+
+(0xffff4000..0xffffffff).each do |i|
+ h[i] = nil
+end
+
+300000.times do
+ k, v = h.shift
+ h[k] = v
+end
diff --git a/bench/mri/bm_hash_to_proc.rb b/bench/mri/bm_hash_to_proc.rb
new file mode 100644
index 00000000000..2b675bf509d
--- /dev/null
+++ b/bench/mri/bm_hash_to_proc.rb
@@ -0,0 +1,9 @@
+h = {}
+
+10000.times do |i|
+ h[i] = nil
+end
+
+5000.times do |i|
+ [i].map(&h)
+end
diff --git a/bench/mri/bm_hash_values.rb b/bench/mri/bm_hash_values.rb
new file mode 100644
index 00000000000..069441302f5
--- /dev/null
+++ b/bench/mri/bm_hash_values.rb
@@ -0,0 +1,9 @@
+h = {}
+
+10000.times do |i|
+ h[i] = nil
+end
+
+5000.times do
+ h.values
+end
diff --git a/bench/yarv/bm_io_file_create.rb b/bench/mri/bm_io_file_create.rb
similarity index 83%
rename from bench/yarv/bm_io_file_create.rb
rename to bench/mri/bm_io_file_create.rb
index db4e4dedd2b..2f205c1333a 100644
--- a/bench/yarv/bm_io_file_create.rb
+++ b/bench/mri/bm_io_file_create.rb
@@ -1,13 +1,13 @@
-#
-# Create files
-#
-
-max = 50_000
-file = './tmpfile_of_bm_io_file_create'
-
-max.times{
- f = open(file, 'w')
- f.close#(true)
-}
-File.unlink(file)
-
+#
+# Create files
+#
+
+max = 200_000
+file = './tmpfile_of_bm_io_file_create'
+
+max.times{
+ f = open(file, 'w')
+ f.close#(true)
+}
+File.unlink(file)
+
diff --git a/bench/yarv/bm_io_file_read.rb b/bench/mri/bm_io_file_read.rb
similarity index 84%
rename from bench/yarv/bm_io_file_read.rb
rename to bench/mri/bm_io_file_read.rb
index 488a4e90ad7..b9e796ed30e 100644
--- a/bench/yarv/bm_io_file_read.rb
+++ b/bench/mri/bm_io_file_read.rb
@@ -1,15 +1,15 @@
-#
-# Seek and Read file.
-#
-
-require 'tempfile'
-
-max = 20_000
-str = "Hello world! " * 1000
-f = Tempfile.new('yarv-benchmark')
-f.write str
-
-max.times{
- f.seek 0
- f.read
-}
+#
+# Seek and Read file.
+#
+
+require 'tempfile'
+
+max = 200_000
+str = "Hello world! " * 1000
+f = Tempfile.new('yarv-benchmark')
+f.write str
+
+max.times{
+ f.seek 0
+ f.read
+}
diff --git a/bench/yarv/bm_io_file_write.rb b/bench/mri/bm_io_file_write.rb
similarity index 84%
rename from bench/yarv/bm_io_file_write.rb
rename to bench/mri/bm_io_file_write.rb
index 05c7e7e45e7..aa1be0e5fe8 100644
--- a/bench/yarv/bm_io_file_write.rb
+++ b/bench/mri/bm_io_file_write.rb
@@ -1,14 +1,14 @@
-#
-# Seek and Write file.
-#
-
-require 'tempfile'
-
-max = 20_000
-str = "Hello world! " * 1000
-f = Tempfile.new('yarv-benchmark')
-
-max.times{
- f.seek 0
- f.write str
-}
+#
+# Seek and Write file.
+#
+
+require 'tempfile'
+
+max = 200_000
+str = "Hello world! " * 1000
+f = Tempfile.new('yarv-benchmark')
+
+max.times{
+ f.seek 0
+ f.write str
+}
diff --git a/bench/mri/bm_io_nonblock_noex.rb b/bench/mri/bm_io_nonblock_noex.rb
new file mode 100644
index 00000000000..da9357fdc6b
--- /dev/null
+++ b/bench/mri/bm_io_nonblock_noex.rb
@@ -0,0 +1,22 @@
+nr = 1_000_000
+i = 0
+msg = '.'
+buf = '.'
+noex = { exception: false }
+begin
+ r, w = IO.pipe
+ while i < nr
+ i += 1
+ w.write_nonblock(msg, noex)
+ r.read_nonblock(1, buf, noex)
+ end
+rescue ArgumentError # old Rubies
+ while i < nr
+ i += 1
+ w.write_nonblock(msg)
+ r.read_nonblock(1, buf)
+ end
+ensure
+ r.close
+ w.close
+end
diff --git a/bench/mri/bm_io_nonblock_noex2.rb b/bench/mri/bm_io_nonblock_noex2.rb
new file mode 100644
index 00000000000..56819d049b1
--- /dev/null
+++ b/bench/mri/bm_io_nonblock_noex2.rb
@@ -0,0 +1,21 @@
+nr = 1_000_000
+i = 0
+msg = '.'
+buf = '.'
+begin
+ r, w = IO.pipe
+ while i < nr
+ i += 1
+ w.write_nonblock(msg, exception: false)
+ r.read_nonblock(1, buf, exception: false)
+ end
+rescue ArgumentError # old Rubies
+ while i < nr
+ i += 1
+ w.write_nonblock(msg)
+ r.read_nonblock(1, buf)
+ end
+ensure
+ r.close
+ w.close
+end
diff --git a/bench/mri/bm_io_select.rb b/bench/mri/bm_io_select.rb
new file mode 100644
index 00000000000..19248daeb12
--- /dev/null
+++ b/bench/mri/bm_io_select.rb
@@ -0,0 +1,9 @@
+# IO.select performance
+
+w = [ IO.pipe[1] ];
+
+nr = 1000000
+nr.times {
+ IO.select nil, w
+}
+
diff --git a/bench/mri/bm_io_select2.rb b/bench/mri/bm_io_select2.rb
new file mode 100644
index 00000000000..10e37d71b2e
--- /dev/null
+++ b/bench/mri/bm_io_select2.rb
@@ -0,0 +1,22 @@
+# IO.select performance. worst case of single fd.
+
+ios = []
+nr = 1000000
+if defined?(Process::RLIMIT_NOFILE)
+ max = Process.getrlimit(Process::RLIMIT_NOFILE)[0]
+else
+ max = 64
+end
+puts "max fd: #{max} (results not apparent with <= 1024 max fd)"
+
+((max / 2) - 10).times do
+ ios.concat IO.pipe
+end
+
+last = [ ios[-1] ]
+puts "last IO: #{last[0].inspect}"
+
+nr.times do
+ IO.select nil, last
+end
+
diff --git a/bench/mri/bm_io_select3.rb b/bench/mri/bm_io_select3.rb
new file mode 100644
index 00000000000..7d0ba1f092b
--- /dev/null
+++ b/bench/mri/bm_io_select3.rb
@@ -0,0 +1,21 @@
+# IO.select performance. a lot of fd
+
+ios = []
+nr = 100
+if defined?(Process::RLIMIT_NOFILE)
+ max = Process.getrlimit(Process::RLIMIT_NOFILE)[0]
+else
+ max = 64
+end
+puts "max fd: #{max} (results not apparent with <= 1024 max fd)"
+
+(max - 10).times do
+ r, w = IO.pipe
+ r.close
+ ios.push w
+end
+
+nr.times do
+ IO.select nil, ios
+end
+
diff --git a/bench/mri/bm_loop_for.rb b/bench/mri/bm_loop_for.rb
new file mode 100644
index 00000000000..0fc4cc15115
--- /dev/null
+++ b/bench/mri/bm_loop_for.rb
@@ -0,0 +1,3 @@
+for i in 1..30_000_000
+ #
+end
diff --git a/bench/yarv/bm_loop_generator.rb b/bench/mri/bm_loop_generator.rb
similarity index 100%
rename from bench/yarv/bm_loop_generator.rb
rename to bench/mri/bm_loop_generator.rb
diff --git a/bench/mri/bm_loop_times.rb b/bench/mri/bm_loop_times.rb
new file mode 100644
index 00000000000..521f72ad1a7
--- /dev/null
+++ b/bench/mri/bm_loop_times.rb
@@ -0,0 +1 @@
+30_000_000.times{|e|}
diff --git a/bench/yarv/bm_loop_whileloop.rb b/bench/mri/bm_loop_whileloop.rb
similarity index 73%
rename from bench/yarv/bm_loop_whileloop.rb
rename to bench/mri/bm_loop_whileloop.rb
index 43d35e1131c..0072822c06d 100644
--- a/bench/yarv/bm_loop_whileloop.rb
+++ b/bench/mri/bm_loop_whileloop.rb
@@ -1,4 +1,4 @@
-i=0
+i = 0
while i<30_000_000 # benchmark loop 1
- i+=1
+ i += 1
end
diff --git a/bench/yarv/bm_loop_whileloop2.rb b/bench/mri/bm_loop_whileloop2.rb
similarity index 73%
rename from bench/yarv/bm_loop_whileloop2.rb
rename to bench/mri/bm_loop_whileloop2.rb
index e5149896619..47d02dffc42 100644
--- a/bench/yarv/bm_loop_whileloop2.rb
+++ b/bench/mri/bm_loop_whileloop2.rb
@@ -1,4 +1,4 @@
-i=0
+i = 0
while i< 6_000_000 # benchmark loop 2
- i+=1
+ i += 1
end
diff --git a/bench/mri/bm_marshal_dump_flo.rb b/bench/mri/bm_marshal_dump_flo.rb
new file mode 100644
index 00000000000..9b8d0c6afb4
--- /dev/null
+++ b/bench/mri/bm_marshal_dump_flo.rb
@@ -0,0 +1,2 @@
+bug10761 = 10000.times.map { |x| x.to_f }
+100.times { Marshal.dump(bug10761) }
diff --git a/bench/mri/bm_marshal_dump_load_geniv.rb b/bench/mri/bm_marshal_dump_load_geniv.rb
new file mode 100644
index 00000000000..8252ad90faf
--- /dev/null
+++ b/bench/mri/bm_marshal_dump_load_geniv.rb
@@ -0,0 +1,10 @@
+a = ''
+a.instance_eval do
+ @a = :a
+ @b = :b
+ @c = :c
+end
+100000.times do
+ a = Marshal.load(Marshal.dump(a))
+end
+#p(a.instance_eval { @a == :a && @b == :b && @c == :c })
diff --git a/bench/mri/bm_marshal_dump_load_time.rb b/bench/mri/bm_marshal_dump_load_time.rb
new file mode 100644
index 00000000000..e29743b791d
--- /dev/null
+++ b/bench/mri/bm_marshal_dump_load_time.rb
@@ -0,0 +1 @@
+100000.times { Marshal.load(Marshal.dump(Time.now)) }
diff --git a/bench/mri/bm_require.rb b/bench/mri/bm_require.rb
new file mode 100644
index 00000000000..b8abc88f417
--- /dev/null
+++ b/bench/mri/bm_require.rb
@@ -0,0 +1,7 @@
+$:.push File.join(File.dirname(__FILE__), "bm_require.data")
+
+1.upto(10000) do |i|
+ require "c#{i}"
+end
+
+$:.pop
diff --git a/bench/mri/bm_require_thread.rb b/bench/mri/bm_require_thread.rb
new file mode 100644
index 00000000000..e54db6c6e55
--- /dev/null
+++ b/bench/mri/bm_require_thread.rb
@@ -0,0 +1,15 @@
+$:.push File.join(File.dirname(__FILE__), "bm_require.data")
+
+i=0
+t = Thread.new do
+ while true
+ i = i+1 # dummy loop
+ end
+end
+
+1.upto(100) do |i|
+ require "c#{i}"
+end
+
+$:.pop
+t.kill
diff --git a/bench/mri/bm_securerandom.rb b/bench/mri/bm_securerandom.rb
new file mode 100644
index 00000000000..a082ea6d5b8
--- /dev/null
+++ b/bench/mri/bm_securerandom.rb
@@ -0,0 +1,5 @@
+require "securerandom"
+
+20_0000.times do
+ SecureRandom.random_number(100)
+end
diff --git a/bench/yarv/bm_so_ackermann.rb b/bench/mri/bm_so_ackermann.rb
similarity index 100%
rename from bench/yarv/bm_so_ackermann.rb
rename to bench/mri/bm_so_ackermann.rb
diff --git a/bench/yarv/bm_so_array.rb b/bench/mri/bm_so_array.rb
similarity index 100%
rename from bench/yarv/bm_so_array.rb
rename to bench/mri/bm_so_array.rb
diff --git a/bench/yarv/bm_so_binary_trees.rb b/bench/mri/bm_so_binary_trees.rb
similarity index 91%
rename from bench/yarv/bm_so_binary_trees.rb
rename to bench/mri/bm_so_binary_trees.rb
index 138c5290f56..b1693e4109e 100644
--- a/bench/yarv/bm_so_binary_trees.rb
+++ b/bench/mri/bm_so_binary_trees.rb
@@ -1,57 +1,62 @@
-# The Computer Language Shootout Benchmarks
-# http://shootout.alioth.debian.org
-#
-# contributed by Jesse Millikan
-
-# disable output
-def STDOUT.write_ *args
-end
-
-def item_check(tree)
- if tree[0] == nil
- tree[1]
- else
- tree[1] + item_check(tree[0]) - item_check(tree[2])
- end
-end
-
-def bottom_up_tree(item, depth)
- if depth > 0
- item_item = 2 * item
- depth -= 1
- [bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)]
- else
- [nil, item, nil]
- end
-end
-
-max_depth = 12 # 16 # ARGV[0].to_i
-min_depth = 4
-
-max_depth = min_depth + 2 if min_depth + 2 > max_depth
-
-stretch_depth = max_depth + 1
-stretch_tree = bottom_up_tree(0, stretch_depth)
-
-puts "stretch tree of depth #{stretch_depth}\t check: #{item_check(stretch_tree)}"
-stretch_tree = nil
-
-long_lived_tree = bottom_up_tree(0, max_depth)
-
-min_depth.step(max_depth + 1, 2) do |depth|
- iterations = 2**(max_depth - depth + min_depth)
-
- check = 0
-
- for i in 1..iterations
- temp_tree = bottom_up_tree(i, depth)
- check += item_check(temp_tree)
-
- temp_tree = bottom_up_tree(-i, depth)
- check += item_check(temp_tree)
- end
-
- puts "#{iterations * 2}\t trees of depth #{depth}\t check: #{check}"
-end
-
-puts "long lived tree of depth #{max_depth}\t check: #{item_check(long_lived_tree)}"
+# The Computer Language Shootout Benchmarks
+# http://shootout.alioth.debian.org
+#
+# contributed by Jesse Millikan
+
+# disable output
+alias puts_orig puts
+def puts str
+ # disable puts
+end
+
+def item_check(tree)
+ if tree[0] == nil
+ tree[1]
+ else
+ tree[1] + item_check(tree[0]) - item_check(tree[2])
+ end
+end
+
+def bottom_up_tree(item, depth)
+ if depth > 0
+ item_item = 2 * item
+ depth -= 1
+ [bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)]
+ else
+ [nil, item, nil]
+ end
+end
+
+max_depth = 16 # ARGV[0].to_i
+min_depth = 4
+
+max_depth = min_depth + 2 if min_depth + 2 > max_depth
+
+stretch_depth = max_depth + 1
+stretch_tree = bottom_up_tree(0, stretch_depth)
+
+puts "stretch tree of depth #{stretch_depth}\t check: #{item_check(stretch_tree)}"
+stretch_tree = nil
+
+long_lived_tree = bottom_up_tree(0, max_depth)
+
+min_depth.step(max_depth + 1, 2) do |depth|
+ iterations = 2**(max_depth - depth + min_depth)
+
+ check = 0
+
+ for i in 1..iterations
+ temp_tree = bottom_up_tree(i, depth)
+ check += item_check(temp_tree)
+
+ temp_tree = bottom_up_tree(-i, depth)
+ check += item_check(temp_tree)
+ end
+
+ puts "#{iterations * 2}\t trees of depth #{depth}\t check: #{check}"
+end
+
+puts "long lived tree of depth #{max_depth}\t check: #{item_check(long_lived_tree)}"
+
+undef puts
+alias puts puts_orig
diff --git a/bench/yarv/bm_so_concatenate.rb b/bench/mri/bm_so_concatenate.rb
similarity index 88%
rename from bench/yarv/bm_so_concatenate.rb
rename to bench/mri/bm_so_concatenate.rb
index 82629688b72..873214de7c3 100644
--- a/bench/yarv/bm_so_concatenate.rb
+++ b/bench/mri/bm_so_concatenate.rb
@@ -5,11 +5,11 @@
# based on code from Aristarkh A Zagorodnikov and Dat Nguyen
STUFF = "hello\n"
-i=0
+i = 0
while i<10
- i+=1
+ i += 1
hello = ''
- 400000.times do |e|
+ 4_000_000.times do |e|
hello << STUFF
end
end
diff --git a/bench/yarv/bm_so_count_words.rb b/bench/mri/bm_so_count_words.rb
similarity index 100%
rename from bench/yarv/bm_so_count_words.rb
rename to bench/mri/bm_so_count_words.rb
diff --git a/bench/yarv/bm_so_exception.rb b/bench/mri/bm_so_exception.rb
similarity index 98%
rename from bench/yarv/bm_so_exception.rb
rename to bench/mri/bm_so_exception.rb
index d8b461290cd..deb003a5940 100644
--- a/bench/yarv/bm_so_exception.rb
+++ b/bench/mri/bm_so_exception.rb
@@ -56,6 +56,6 @@ def blowup(num)
i = 1
max = NUM+1
while i < max
- i+=1
+ i += 1
some_function(i+1)
end
diff --git a/bench/yarv/bm_so_fannkuch.rb b/bench/mri/bm_so_fannkuch.rb
similarity index 92%
rename from bench/yarv/bm_so_fannkuch.rb
rename to bench/mri/bm_so_fannkuch.rb
index 23298a8a31a..bac5ecd44c9 100644
--- a/bench/yarv/bm_so_fannkuch.rb
+++ b/bench/mri/bm_so_fannkuch.rb
@@ -1,45 +1,45 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-# Contributed by Sokolov Yura
-# Modified by Ryan Williams
-
-def fannkuch(n)
- maxFlips, m, r, check = 0, n-1, n, 0
- count = (1..n).to_a
- perm = (1..n).to_a
-
- while true
- if check < 30
- puts "#{perm}"
- check += 1
- end
-
- while r != 1
- count[r-1] = r
- r -= 1
- end
-
- if perm[0] != 1 and perm[m] != n
- perml = perm.clone #.dup
- flips = 0
- while (k = perml.first ) != 1
- perml = perml.slice!(0, k).reverse + perml
- flips += 1
- end
- maxFlips = flips if flips > maxFlips
- end
- while true
- if r==n then return maxFlips end
- perm.insert r,perm.shift
- break if (count[r] -= 1) > 0
- r += 1
- end
- end
-end
-
-def puts *args
-end
-
-N = 10 # (ARGV[0] || 1).to_i
-puts "Pfannkuchen(#{N}) = #{fannkuch(N)}"
-
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org/
+# Contributed by Sokolov Yura
+# Modified by Ryan Williams
+
+def fannkuch(n)
+ maxFlips, m, r, check = 0, n-1, n, 0
+ count = (1..n).to_a
+ perm = (1..n).to_a
+
+ while true
+ if check < 30
+ puts "#{perm}"
+ check += 1
+ end
+
+ while r != 1
+ count[r-1] = r
+ r -= 1
+ end
+
+ if perm[0] != 1 and perm[m] != n
+ perml = perm.clone #.dup
+ flips = 0
+ while (k = perml.first ) != 1
+ perml = perml.slice!(0, k).reverse + perml
+ flips += 1
+ end
+ maxFlips = flips if flips > maxFlips
+ end
+ while true
+ if r==n then return maxFlips end
+ perm.insert r,perm.shift
+ break if (count[r] -= 1) > 0
+ r += 1
+ end
+ end
+end
+
+def puts *args
+end
+
+N = 9 # (ARGV[0] || 1).to_i
+puts "Pfannkuchen(#{N}) = #{fannkuch(N)}"
+
diff --git a/bench/yarv/bm_so_fasta.rb b/bench/mri/bm_so_fasta.rb
similarity index 95%
rename from bench/yarv/bm_so_fasta.rb
rename to bench/mri/bm_so_fasta.rb
index b95f5e9f107..3f759ba7ae8 100644
--- a/bench/yarv/bm_so_fasta.rb
+++ b/bench/mri/bm_so_fasta.rb
@@ -1,81 +1,81 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-# Contributed by Sokolov Yura
-
-$last = 42.0
-def gen_random (max,im=139968,ia=3877,ic=29573)
- (max * ($last = ($last * ia + ic) % im)) / im
-end
-
-alu =
- "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
- "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+
- "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+
- "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+
- "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+
- "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+
- "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
-
-iub = [
- ["a", 0.27],
- ["c", 0.12],
- ["g", 0.12],
- ["t", 0.27],
-
- ["B", 0.02],
- ["D", 0.02],
- ["H", 0.02],
- ["K", 0.02],
- ["M", 0.02],
- ["N", 0.02],
- ["R", 0.02],
- ["S", 0.02],
- ["V", 0.02],
- ["W", 0.02],
- ["Y", 0.02],
-]
-homosapiens = [
- ["a", 0.3029549426680],
- ["c", 0.1979883004921],
- ["g", 0.1975473066391],
- ["t", 0.3015094502008],
-]
-
-def make_repeat_fasta(id, desc, src, n)
- puts ">#{id} #{desc}"
- v = nil
- width = 60
- l = src.length
- s = src * ((n / l) + 1)
- s.slice!(n, l)
- puts(s.scan(/.{1,#{width}}/).join("\n"))
-end
-
-def make_random_fasta(id, desc, table, n)
- puts ">#{id} #{desc}"
- rand, v = nil,nil
- width = 60
- chunk = 1 * width
- prob = 0.0
- table.each{|v| v[1]= (prob += v[1])}
- for i in 1..(n/width)
- puts((1..width).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
- if n%width != 0
- puts((1..(n%width)).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
-end
-
-
-n = (ARGV[0] or 250_000).to_i
-
-make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2)
-make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3)
-make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5)
-
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org/
+# Contributed by Sokolov Yura
+
+$last = 42.0
+def gen_random (max,im=139968,ia=3877,ic=29573)
+ (max * ($last = ($last * ia + ic) % im)) / im
+end
+
+alu =
+ "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
+ "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+
+ "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+
+ "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+
+ "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+
+ "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+
+ "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
+
+iub = [
+ ["a", 0.27],
+ ["c", 0.12],
+ ["g", 0.12],
+ ["t", 0.27],
+
+ ["B", 0.02],
+ ["D", 0.02],
+ ["H", 0.02],
+ ["K", 0.02],
+ ["M", 0.02],
+ ["N", 0.02],
+ ["R", 0.02],
+ ["S", 0.02],
+ ["V", 0.02],
+ ["W", 0.02],
+ ["Y", 0.02],
+]
+homosapiens = [
+ ["a", 0.3029549426680],
+ ["c", 0.1979883004921],
+ ["g", 0.1975473066391],
+ ["t", 0.3015094502008],
+]
+
+def make_repeat_fasta(id, desc, src, n)
+ puts ">#{id} #{desc}"
+ v = nil
+ width = 60
+ l = src.length
+ s = src * ((n / l) + 1)
+ s.slice!(n, l)
+ puts(s.scan(/.{1,#{width}}/).join("\n"))
+end
+
+def make_random_fasta(id, desc, table, n)
+ puts ">#{id} #{desc}"
+ rand, v = nil,nil
+ width = 60
+ chunk = 1 * width
+ prob = 0.0
+ table.each{|v| v[1]= (prob += v[1])}
+ for i in 1..(n/width)
+ puts((1..width).collect{
+ rand = gen_random(1.0)
+ table.find{|v| v[1]>rand}[0]
+ }.join)
+ end
+ if n%width != 0
+ puts((1..(n%width)).collect{
+ rand = gen_random(1.0)
+ table.find{|v| v[1]>rand}[0]
+ }.join)
+ end
+end
+
+
+n = (ARGV[0] or 250_000).to_i
+
+make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2)
+make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3)
+make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5)
+
diff --git a/bench/yarv/bm_so_k_nucleotide.rb b/bench/mri/bm_so_k_nucleotide.rb
similarity index 95%
rename from bench/yarv/bm_so_k_nucleotide.rb
rename to bench/mri/bm_so_k_nucleotide.rb
index c0a5ba50462..dadab3e79c6 100644
--- a/bench/yarv/bm_so_k_nucleotide.rb
+++ b/bench/mri/bm_so_k_nucleotide.rb
@@ -1,48 +1,48 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org
-#
-# contributed by jose fco. gonzalez
-# modified by Sokolov Yura
-
-seq = String.new
-
-def frecuency( seq,length )
- n, table = seq.length - length + 1, Hash.new(0)
- f, i = nil, nil
- (0 ... length).each do |f|
- (f ... n).step(length) do |i|
- table[seq[i,length]] += 1
- end
- end
- [n,table]
-
-end
-
-def sort_by_freq( seq,length )
- n,table = frecuency( seq,length )
- a, b, v = nil, nil, nil
- table.sort{|a,b| b[1] <=> a[1]}.each do |v|
- puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)]
- end
- puts
-end
-
-def find_seq( seq,s )
- n,table = frecuency( seq,s.length )
- puts "#{table[s].to_s}\t#{s.upcase}"
-end
-
-input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb')
-
-line = input.gets while line !~ /^>THREE/
-line = input.gets
-
-while (line !~ /^>/) & line do
- seq << line.chomp
- line = input.gets
-end
-
-[1,2].each {|i| sort_by_freq( seq,i ) }
-
-%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) }
-
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org
+#
+# contributed by jose fco. gonzalez
+# modified by Sokolov Yura
+
+seq = String.new
+
+def frecuency( seq,length )
+ n, table = seq.length - length + 1, Hash.new(0)
+ f, i = nil, nil
+ (0 ... length).each do |f|
+ (f ... n).step(length) do |i|
+ table[seq[i,length]] += 1
+ end
+ end
+ [n,table]
+
+end
+
+def sort_by_freq( seq,length )
+ n,table = frecuency( seq,length )
+ a, b, v = nil, nil, nil
+ table.sort{|a,b| b[1] <=> a[1]}.each do |v|
+ puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)]
+ end
+ puts
+end
+
+def find_seq( seq,s )
+ n,table = frecuency( seq,s.length )
+ puts "#{table[s].to_s}\t#{s.upcase}"
+end
+
+input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb')
+
+line = input.gets while line !~ /^>THREE/
+line = input.gets
+
+while (line !~ /^>/) & line do
+ seq << line.chomp
+ line = input.gets
+end
+
+[1,2].each {|i| sort_by_freq( seq,i ) }
+
+%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) }
+
diff --git a/bench/yarv/bm_so_lists.rb b/bench/mri/bm_so_lists.rb
similarity index 98%
rename from bench/yarv/bm_so_lists.rb
rename to bench/mri/bm_so_lists.rb
index 36522888816..e8f4a2a5f70 100644
--- a/bench/yarv/bm_so_lists.rb
+++ b/bench/mri/bm_so_lists.rb
@@ -1,6 +1,6 @@
#from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
-NUM = 100
+NUM = 300
SIZE = 10000
def test_lists()
@@ -40,7 +40,7 @@ def test_lists()
i = 0
while i LIMIT_SQUARED
- escape = true
- break
- end
- end
-
- byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1)
- bit_num += 1
-
- # Code is very similar for these cases, but using separate blocks
- # ensures we skip the shifting when it's unnecessary, which is most cases.
- if (bit_num == 8)
- print byte_acc.chr
- byte_acc = 0
- bit_num = 0
- elsif (x == count_size)
- byte_acc <<= (8 - bit_num)
- print byte_acc.chr
- byte_acc = 0
- bit_num = 0
- end
- end
-end
+# The Computer Language Benchmarks Game
+# http://shootout.alioth.debian.org/
+#
+# contributed by Karl von Laudermann
+# modified by Jeremy Echols
+
+size = 600 # ARGV[0].to_i
+
+puts "P4\n#{size} #{size}"
+
+ITER = 49 # Iterations - 1 for easy for..in looping
+LIMIT_SQUARED = 4.0 # Presquared limit
+
+byte_acc = 0
+bit_num = 0
+
+count_size = size - 1 # Precomputed size for easy for..in looping
+
+# For..in loops are faster than .upto, .downto, .times, etc.
+for y in 0..count_size
+ for x in 0..count_size
+ zr = 0.0
+ zi = 0.0
+ cr = (2.0*x/size)-1.5
+ ci = (2.0*y/size)-1.0
+ escape = false
+
+ # To make use of the for..in code, we use a dummy variable,
+ # like one would in C
+ for dummy in 0..ITER
+ tr = zr*zr - zi*zi + cr
+ ti = 2*zr*zi + ci
+ zr, zi = tr, ti
+
+ if (zr*zr+zi*zi) > LIMIT_SQUARED
+ escape = true
+ break
+ end
+ end
+
+ byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1)
+ bit_num += 1
+
+ # Code is very similar for these cases, but using separate blocks
+ # ensures we skip the shifting when it's unnecessary, which is most cases.
+ if (bit_num == 8)
+ print byte_acc.chr
+ byte_acc = 0
+ bit_num = 0
+ elsif (x == count_size)
+ byte_acc <<= (8 - bit_num)
+ print byte_acc.chr
+ byte_acc = 0
+ bit_num = 0
+ end
+ end
+end
diff --git a/bench/yarv/bm_so_matrix.rb b/bench/mri/bm_so_matrix.rb
similarity index 99%
rename from bench/yarv/bm_so_matrix.rb
rename to bench/mri/bm_so_matrix.rb
index 0f274ad06c7..e2c5c8e5596 100644
--- a/bench/yarv/bm_so_matrix.rb
+++ b/bench/mri/bm_so_matrix.rb
@@ -5,7 +5,7 @@
n = 60 #Integer(ARGV.shift || 1)
-size = 30
+size = 40
def mkmatrix(rows, cols)
count = 1
diff --git a/bench/yarv/bm_so_meteor_contest.rb b/bench/mri/bm_so_meteor_contest.rb
similarity index 95%
rename from bench/yarv/bm_so_meteor_contest.rb
rename to bench/mri/bm_so_meteor_contest.rb
index 5dd720c340e..64a7d46afea 100644
--- a/bench/yarv/bm_so_meteor_contest.rb
+++ b/bench/mri/bm_so_meteor_contest.rb
@@ -1,564 +1,563 @@
-#!/usr/bin/env ruby
-#
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org
-# contributed by Kevin Barnes (Ruby novice)
-
-# PROGRAM: the main body is at the bottom.
-# 1) read about the problem here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
-# 2) see how I represent a board as a bitmask by reading the blank_board comments
-# 3) read as your mental paths take you
-
-def print *args
-end
-
-# class to represent all information about a particular rotation of a particular piece
-class Rotation
- # an array (by location) containing a bit mask for how the piece maps at the given location.
- # if the rotation is illegal at that location the mask will contain false
- attr_reader :start_masks
-
- # maps a direction to a relative location. these differ depending on whether it is an even or
- # odd row being mapped from
- @@rotation_even_adder = { :west => -1, :east => 1, :nw => -7, :ne => -6, :sw => 5, :se => 6 }
- @@rotation_odd_adder = { :west => -1, :east => 1, :nw => -6, :ne => -5, :sw => 6, :se => 7 }
-
- def initialize( directions )
- @even_offsets, @odd_offsets = normalize_offsets( get_values( directions ))
-
- @even_mask = mask_for_offsets( @even_offsets)
- @odd_mask = mask_for_offsets( @odd_offsets)
-
- @start_masks = Array.new(60)
-
- # create the rotational masks by placing the base mask at the location and seeing if
- # 1) it overlaps the boundries and 2) it produces a prunable board. if either of these
- # is true the piece cannot be placed
- 0.upto(59) do | offset |
- mask = is_even(offset) ? (@even_mask << offset) : (@odd_mask << offset)
- if (blank_board & mask == 0 && !prunable(blank_board | mask, 0, true)) then
- imask = compute_required( mask, offset)
- @start_masks[offset] = [ mask, imask, imask | mask ]
- else
- @start_masks[offset] = false
- end
- end
- end
-
- def compute_required( mask, offset )
- board = blank_board
- 0.upto(offset) { | i | board |= 1 << i }
- board |= mask
- return 0 if (!prunable(board | mask, offset))
- board = flood_fill(board,58)
- count = 0
- imask = 0
- 0.upto(59) do | i |
- if (board[i] == 0) then
- imask |= (1 << i)
- count += 1
- end
- end
- (count > 0 && count < 5) ? imask : 0
- end
-
- def flood_fill( board, location)
- return board if (board[location] == 1)
- board |= 1 << location
- row, col = location.divmod(6)
- board = flood_fill( board, location - 1) if (col > 0)
- board = flood_fill( board, location + 1) if (col < 4)
- if (row % 2 == 0) then
- board = flood_fill( board, location - 7) if (col > 0 && row > 0)
- board = flood_fill( board, location - 6) if (row > 0)
- board = flood_fill( board, location + 6) if (row < 9)
- board = flood_fill( board, location + 5) if (col > 0 && row < 9)
- else
- board = flood_fill( board, location - 5) if (col < 4 && row > 0)
- board = flood_fill( board, location - 6) if (row > 0)
- board = flood_fill( board, location + 6) if (row < 9)
- board = flood_fill( board, location + 7) if (col < 4 && row < 9)
- end
- board
- end
-
- # given a location, produces a list of relative locations covered by the piece at this rotation
- def offsets( location)
- if is_even( location) then
- @even_offsets.collect { | value | value + location }
- else
- @odd_offsets.collect { | value | value + location }
- end
- end
-
- # returns a set of offsets relative to the top-left most piece of the rotation (by even or odd rows)
- # this is hard to explain. imagine we have this partial board:
- # 0 0 0 0 0 x [positions 0-5]
- # 0 0 1 1 0 x [positions 6-11]
- # 0 0 1 0 0 x [positions 12-17]
- # 0 1 0 0 0 x [positions 18-23]
- # 0 1 0 0 0 x [positions 24-29]
- # 0 0 0 0 0 x [positions 30-35]
- # ...
- # The top-left of the piece is at position 8, the
- # board would be passed as a set of positions (values array) containing [8,9,14,19,25] not necessarily in that
- # sorted order. Since that array starts on an odd row, the offsets for an odd row are: [0,1,6,11,17] obtained
- # by subtracting 8 from everything. Now imagine the piece shifted up and to the right so it's on an even row:
- # 0 0 0 1 1 x [positions 0-5]
- # 0 0 1 0 0 x [positions 6-11]
- # 0 0 1 0 0 x [positions 12-17]
- # 0 1 0 0 0 x [positions 18-23]
- # 0 0 0 0 0 x [positions 24-29]
- # 0 0 0 0 0 x [positions 30-35]
- # ...
- # Now the positions are [3,4,8,14,19] which after subtracting the lowest value (3) gives [0,1,5,11,16] thus, the
- # offsets for this particular piece are (in even, odd order) [0,1,5,11,16],[0,1,6,11,17] which is what
- # this function would return
- def normalize_offsets( values)
- min = values.min
- even_min = is_even(min)
- other_min = even_min ? min + 6 : min + 7
- other_values = values.collect do | value |
- if is_even(value) then
- value + 6 - other_min
- else
- value + 7 - other_min
- end
- end
- values.collect! { | value | value - min }
-
- if even_min then
- [values, other_values]
- else
- [other_values, values]
- end
- end
-
- # produce a bitmask representation of an array of offset locations
- def mask_for_offsets( offsets )
- mask = 0
- offsets.each { | value | mask = mask + ( 1 << value ) }
- mask
- end
-
- # finds a "safe" position that a position as described by a list of directions can be placed
- # without falling off any edge of the board. the values returned a location to place the first piece
- # at so it will fit after making the described moves
- def start_adjust( directions )
- south = east = 0;
- directions.each do | direction |
- east += 1 if ( direction == :sw || direction == :nw || direction == :west )
- south += 1 if ( direction == :nw || direction == :ne )
- end
- south * 6 + east
- end
-
- # given a set of directions places the piece (as defined by a set of directions) on the board at
- # a location that will not take it off the edge
- def get_values ( directions )
- start = start_adjust(directions)
- values = [ start ]
- directions.each do | direction |
- if (start % 12 >= 6) then
- start += @@rotation_odd_adder[direction]
- else
- start += @@rotation_even_adder[direction]
- end
- values += [ start ]
- end
-
- # some moves take you back to an existing location, we'll strip duplicates
- values.uniq
- end
-end
-
-# describes a piece and caches information about its rotations to as to be efficient for iteration
-# ATTRIBUTES:
-# rotations -- all the rotations of the piece
-# type -- a numeic "name" of the piece
-# masks -- an array by location of all legal rotational masks (a n inner array) for that location
-# placed -- the mask that this piece was last placed at (not a location, but the actual mask used)
-class Piece
- attr_reader :rotations, :type, :masks
- attr_accessor :placed
-
- # transform hashes that change one direction into another when you either flip or rotate a set of directions
- @@flip_converter = { :west => :west, :east => :east, :nw => :sw, :ne => :se, :sw => :nw, :se => :ne }
- @@rotate_converter = { :west => :nw, :east => :se, :nw => :ne, :ne => :east, :sw => :west, :se => :sw }
-
- def initialize( directions, type )
- @type = type
- @rotations = Array.new();
- @map = {}
-
- generate_rotations( directions )
- directions.collect! { | value | @@flip_converter[value] }
- generate_rotations( directions )
-
- # creates the masks AND a map that returns [location, rotation] for any given mask
- # this is used when a board is found and we want to draw it, otherwise the map is unused
- @masks = Array.new();
- 0.upto(59) do | i |
- even = true
- @masks[i] = @rotations.collect do | rotation |
- mask = rotation.start_masks[i]
- @map[mask[0]] = [ i, rotation ] if (mask)
- mask || nil
- end
- @masks[i].compact!
- end
- end
-
- # rotates a set of directions through all six angles and adds a Rotation to the list for each one
- def generate_rotations( directions )
- 6.times do
- rotations.push( Rotation.new(directions))
- directions.collect! { | value | @@rotate_converter[value] }
- end
- end
-
- # given a board string, adds this piece to the board at whatever location/rotation
- # important: the outbound board string is 5 wide, the normal location notation is six wide (padded)
- def fill_string( board_string)
- location, rotation = @map[@placed]
- rotation.offsets(location).each do | offset |
- row, col = offset.divmod(6)
- board_string[ row*5 + col, 1 ] = @type.to_s
- end
- end
-end
-
-# a blank bit board having this form:
-#
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 1 1 1 1 1 1
-#
-# where left lest significant bit is the top left and the most significant is the lower right
-# the actual board only consists of the 0 places, the 1 places are blockers to keep things from running
-# off the edges or bottom
-def blank_board
- 0b111111100000100000100000100000100000100000100000100000100000100000
-end
-
-def full_board
- 0b111111111111111111111111111111111111111111111111111111111111111111
-end
-
-# determines if a location (bit position) is in an even row
-def is_even( location)
- (location % 12) < 6
-end
-
-# support function that create three utility maps:
-# $converter -- for each row an array that maps a five bit row (via array mapping)
-# to the a a five bit representation of the bits below it
-# $bit_count -- maps a five bit row (via array mapping) to the number of 1s in the row
-# @@new_regions -- maps a five bit row (via array mapping) to an array of "region" arrays
-# a region array has three values the first is a mask of bits in the region,
-# the second is the count of those bits and the third is identical to the first
-# examples:
-# 0b10010 => [ 0b01100, 2, 0b01100 ], [ 0b00001, 1, 0b00001]
-# 0b01010 => [ 0b10000, 1, 0b10000 ], [ 0b00100, 1, 0b00100 ], [ 0b00001, 1, 0b00001]
-# 0b10001 => [ 0b01110, 3, 0b01110 ]
-def create_collector_support
- odd_map = [0b11, 0b110, 0b1100, 0b11000, 0b10000]
- even_map = [0b1, 0b11, 0b110, 0b1100, 0b11000]
-
- all_odds = Array.new(0b100000)
- all_evens = Array.new(0b100000)
- bit_counts = Array.new(0b100000)
- new_regions = Array.new(0b100000)
- 0.upto(0b11111) do | i |
- bit_count = odd = even = 0
- 0.upto(4) do | bit |
- if (i[bit] == 1) then
- bit_count += 1
- odd |= odd_map[bit]
- even |= even_map[bit]
- end
- end
- all_odds[i] = odd
- all_evens[i] = even
- bit_counts[i] = bit_count
- new_regions[i] = create_regions( i)
- end
-
- $converter = []
- 10.times { | row | $converter.push((row % 2 == 0) ? all_evens : all_odds) }
- $bit_counts = bit_counts
- $regions = new_regions.collect { | set | set.collect { | value | [ value, bit_counts[value], value] } }
-end
-
-# determines if a board is punable, meaning that there is no possibility that it
-# can be filled up with pieces. A board is prunable if there is a grouping of unfilled spaces
-# that are not a multiple of five. The following board is an example of a prunable board:
-# 0 0 1 0 0
-# 0 1 0 0 0
-# 1 1 0 0 0
-# 0 1 0 0 0
-# 0 0 0 0 0
-# ...
-#
-# This board is prunable because the top left corner is only 3 bits in area, no piece will ever fit it
-# parameters:
-# board -- an initial bit board (6 bit padded rows, see blank_board for format)
-# location -- starting location, everything above and to the left is already full
-# slotting -- set to true only when testing initial pieces, when filling normally
-# additional assumptions are possible
-#
-# Algorithm:
-# The algorithm starts at the top row (as determined by location) and iterates a row at a time
-# maintainng counts of active open areas (kept in the collector array) each collector contains
-# three values at the start of an iteration:
-# 0: mask of bits that would be adjacent to the collector in this row
-# 1: the number of bits collected so far
-# 2: a scratch space starting as zero, but used during the computation to represent
-# the empty bits in the new row that are adjacent (position 0)
-# The exact procedure is described in-code
-def prunable( board, location, slotting = false)
- collectors = []
- # loop accross the rows
- (location / 6).to_i.upto(9) do | row_on |
- # obtain a set of regions representing the bits of the curent row.
- regions = $regions[(board >> (row_on * 6)) & 0b11111]
- converter = $converter[row_on]
-
- # track the number of collectors at the start of the cycle so that
- # we don't compute against newly created collectors, only existing collectors
- initial_collector_count = collectors.length
-
- # loop against the regions. For each region of the row
- # we will see if it connects to one or more existing collectors.
- # if it connects to 1 collector, the bits from the region are added to the
- # bits of the collector and the mask is placed in collector[2]
- # If the region overlaps more than one collector then all the collectors
- # it overlaps with are merged into the first one (the others are set to nil in the array)
- # if NO collectors are found then the region is copied as a new collector
- regions.each do | region |
- collector_found = nil
- region_mask = region[2]
- initial_collector_count.times do | collector_num |
- collector = collectors[collector_num]
- if (collector) then
- collector_mask = collector[0]
- if (collector_mask & region_mask != 0) then
- if (collector_found) then
- collector_found[0] |= collector_mask
- collector_found[1] += collector[1]
- collector_found[2] |= collector[2]
- collectors[collector_num] = nil
- else
- collector_found = collector
- collector[1] += region[1]
- collector[2] |= region_mask
- end
- end
- end
- end
- if (collector_found == nil) then
- collectors.push(Array.new(region))
- end
- end
-
- # check the existing collectors, if any collector overlapped no bits in the region its [2] value will
- # be zero. The size of any such reaason is tested if it is not a muliple of five true is returned since
- # the board is prunable. if it is a multiple of five it is removed.
- # Collector that are still active have a new adjacent value [0] set based n the matched bits
- # and have [2] cleared out for the next cycle.
- collectors.length.times do | collector_num |
- collector = collectors[collector_num]
- if (collector) then
- if (collector[2] == 0) then
- return true if (collector[1] % 5 != 0)
- collectors[collector_num] = nil
- else
- # if a collector matches all bits in the row then we can return unprunable early for the
- # follwing reasons:
- # 1) there can be no more unavailable bits bince we fill from the top left downward
- # 2) all previous regions have been closed or joined so only this region can fail
- # 3) this region must be good since there can never be only 1 region that is nuot
- # a multiple of five
- # this rule only applies when filling normally, so we ignore the rule if we are "slotting"
- # in pieces to see what configurations work for them (the only other time this algorithm is used).
- return false if (collector[2] == 0b11111 && !slotting)
- collector[0] = converter[collector[2]]
- collector[2] = 0
- end
- end
- end
-
- # get rid of all the empty converters for the next round
- collectors.compact!
- end
- return false if (collectors.length <= 1) # 1 collector or less and the region is fine
- collectors.any? { | collector | (collector[1] % 5) != 0 } # more than 1 and we test them all for bad size
-end
-
-# creates a region given a row mask. see prunable for what a "region" is
-def create_regions( value )
- regions = []
- cur_region = 0
- 5.times do | bit |
- if (value[bit] == 0) then
- cur_region |= 1 << bit
- else
- if (cur_region != 0 ) then
- regions.push( cur_region)
- cur_region = 0;
- end
- end
- end
- regions.push(cur_region) if (cur_region != 0)
- regions
-end
-
-# find up to the counted number of solutions (or all solutions) and prints the final result
-def find_all
- find_top( 1)
- find_top( 0)
- print_results
-end
-
-# show the board
-def print_results
- print "#{@boards_found} solutions found\n\n"
- print_full_board( @min_board)
- print "\n"
- print_full_board( @max_board)
- print "\n"
-end
-
-# finds solutions. This special version of the main function is only used for the top level
-# the reason for it is basically to force a particular ordering on how the rotations are tested for
-# the first piece. It is called twice, first looking for placements of the odd rotations and then
-# looking for placements of the even locations.
-#
-# WHY?
-# Since any found solution has an inverse we want to maximize finding solutions that are not already found
-# as an inverse. The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away
-# (an odd number). Checking even vs odd then produces a higher probability of finding more pieces earlier
-# in the cycle. We still need to keep checking all the permutations, but our probability of finding one will
-# diminsh over time. Since we are TOLD how many to search for this lets us exit before checking all pieces
-# this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the
-# maximum number
-def find_top( rotation_skip)
- board = blank_board
- (@pieces.length-1).times do
- piece = @pieces.shift
- piece.masks[0].each do | mask, imask, cmask |
- if ((rotation_skip += 1) % 2 == 0) then
- piece.placed = mask
- find( 1, 1, board | mask)
- end
- end
- @pieces.push(piece)
- end
- piece = @pieces.shift
- @pieces.push(piece)
-end
-
-# the normail find routine, iterates through the available pieces, checks all rotations at the current location
-# and adds any boards found. depth is acheived via recursion. the overall approach is described
-# here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
-# parameters:
-# start_location -- where to start looking for place for the next piece at
-# placed -- number of pieces placed
-# board -- current state of the board
-#
-# see in-code comments
-def find( start_location, placed, board)
- # find the next location to place a piece by looking for an empty bit
- while board[start_location] == 1
- start_location += 1
- end
-
- @pieces.length.times do
- piece = @pieces.shift
- piece.masks[start_location].each do | mask, imask, cmask |
- if ( board & cmask == imask) then
- piece.placed = mask
- if (placed == 9) then
- add_board
- else
- find( start_location + 1, placed + 1, board | mask)
- end
- end
- end
- @pieces.push(piece)
- end
-end
-
-# print the board
-def print_full_board( board_string)
- 10.times do | row |
- print " " if (row % 2 == 1)
- 5.times do | col |
- print "#{board_string[row*5 + col,1]} "
- end
- print "\n"
- end
-end
-
-# when a board is found we "draw it" into a string and then flip that string, adding both to
-# the list (hash) of solutions if they are unique.
-def add_board
- board_string = "99999999999999999999999999999999999999999999999999"
- @all_pieces.each { | piece | piece.fill_string( board_string ) }
- save( board_string)
- save( board_string.reverse)
-end
-
-# adds a board string to the list (if new) and updates the current best/worst board
-def save( board_string)
- if (@all_boards[board_string] == nil) then
- @min_board = board_string if (board_string < @min_board)
- @max_board = board_string if (board_string > @max_board)
- @all_boards.store(board_string,true)
- @boards_found += 1
-
- # the exit motif is a time saver. Ideally the function should return, but those tests
- # take noticable time (performance).
- if (@boards_found == @stop_count) then
- print_results
- exit(0)
- end
- end
-end
-
-
-##
-## MAIN BODY :)
-##
-create_collector_support
-@pieces = [
- Piece.new( [ :nw, :ne, :east, :east ], 2),
- Piece.new( [ :ne, :se, :east, :ne ], 7),
- Piece.new( [ :ne, :east, :ne, :nw ], 1),
- Piece.new( [ :east, :sw, :sw, :se ], 6),
- Piece.new( [ :east, :ne, :se, :ne ], 5),
- Piece.new( [ :east, :east, :east, :se ], 0),
- Piece.new( [ :ne, :nw, :se, :east, :se ], 4),
- Piece.new( [ :se, :se, :se, :west ], 9),
- Piece.new( [ :se, :se, :east, :se ], 8),
- Piece.new( [ :east, :east, :sw, :se ], 3)
- ];
-
-@all_pieces = Array.new( @pieces)
-
-@min_board = "99999999999999999999999999999999999999999999999999"
-@max_board = "00000000000000000000000000000000000000000000000000"
-@stop_count = ARGV[0].to_i || 2089
-@all_boards = {}
-@boards_found = 0
-
-find_all ######## DO IT!!!
-
+#!/usr/bin/env ruby
+#
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org
+# contributed by Kevin Barnes (Ruby novice)
+
+# PROGRAM: the main body is at the bottom.
+# 1) read about the problem here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
+# 2) see how I represent a board as a bitmask by reading the blank_board comments
+# 3) read as your mental paths take you
+
+def print *args
+end
+
+# class to represent all information about a particular rotation of a particular piece
+class Rotation
+ # an array (by location) containing a bit mask for how the piece maps at the given location.
+ # if the rotation is invalid at that location the mask will contain false
+ attr_reader :start_masks
+
+ # maps a direction to a relative location. these differ depending on whether it is an even or
+ # odd row being mapped from
+ @@rotation_even_adder = { :west => -1, :east => 1, :nw => -7, :ne => -6, :sw => 5, :se => 6 }
+ @@rotation_odd_adder = { :west => -1, :east => 1, :nw => -6, :ne => -5, :sw => 6, :se => 7 }
+
+ def initialize( directions )
+ @even_offsets, @odd_offsets = normalize_offsets( get_values( directions ))
+
+ @even_mask = mask_for_offsets( @even_offsets)
+ @odd_mask = mask_for_offsets( @odd_offsets)
+
+ @start_masks = Array.new(60)
+
+ # create the rotational masks by placing the base mask at the location and seeing if
+ # 1) it overlaps the boundaries and 2) it produces a prunable board. if either of these
+ # is true the piece cannot be placed
+ 0.upto(59) do | offset |
+ mask = is_even(offset) ? (@even_mask << offset) : (@odd_mask << offset)
+ if (blank_board & mask == 0 && !prunable(blank_board | mask, 0, true)) then
+ imask = compute_required( mask, offset)
+ @start_masks[offset] = [ mask, imask, imask | mask ]
+ else
+ @start_masks[offset] = false
+ end
+ end
+ end
+
+ def compute_required( mask, offset )
+ board = blank_board
+ 0.upto(offset) { | i | board |= 1 << i }
+ board |= mask
+ return 0 if (!prunable(board | mask, offset))
+ board = flood_fill(board,58)
+ count = 0
+ imask = 0
+ 0.upto(59) do | i |
+ if (board[i] == 0) then
+ imask |= (1 << i)
+ count += 1
+ end
+ end
+ (count > 0 && count < 5) ? imask : 0
+ end
+
+ def flood_fill( board, location)
+ return board if (board[location] == 1)
+ board |= 1 << location
+ row, col = location.divmod(6)
+ board = flood_fill( board, location - 1) if (col > 0)
+ board = flood_fill( board, location + 1) if (col < 4)
+ if (row % 2 == 0) then
+ board = flood_fill( board, location - 7) if (col > 0 && row > 0)
+ board = flood_fill( board, location - 6) if (row > 0)
+ board = flood_fill( board, location + 6) if (row < 9)
+ board = flood_fill( board, location + 5) if (col > 0 && row < 9)
+ else
+ board = flood_fill( board, location - 5) if (col < 4 && row > 0)
+ board = flood_fill( board, location - 6) if (row > 0)
+ board = flood_fill( board, location + 6) if (row < 9)
+ board = flood_fill( board, location + 7) if (col < 4 && row < 9)
+ end
+ board
+ end
+
+ # given a location, produces a list of relative locations covered by the piece at this rotation
+ def offsets( location)
+ if is_even( location) then
+ @even_offsets.collect { | value | value + location }
+ else
+ @odd_offsets.collect { | value | value + location }
+ end
+ end
+
+ # returns a set of offsets relative to the top-left most piece of the rotation (by even or odd rows)
+ # this is hard to explain. imagine we have this partial board:
+ # 0 0 0 0 0 x [positions 0-5]
+ # 0 0 1 1 0 x [positions 6-11]
+ # 0 0 1 0 0 x [positions 12-17]
+ # 0 1 0 0 0 x [positions 18-23]
+ # 0 1 0 0 0 x [positions 24-29]
+ # 0 0 0 0 0 x [positions 30-35]
+ # ...
+ # The top-left of the piece is at position 8, the
+ # board would be passed as a set of positions (values array) containing [8,9,14,19,25] not necessarily in that
+ # sorted order. Since that array starts on an odd row, the offsets for an odd row are: [0,1,6,11,17] obtained
+ # by subtracting 8 from everything. Now imagine the piece shifted up and to the right so it's on an even row:
+ # 0 0 0 1 1 x [positions 0-5]
+ # 0 0 1 0 0 x [positions 6-11]
+ # 0 0 1 0 0 x [positions 12-17]
+ # 0 1 0 0 0 x [positions 18-23]
+ # 0 0 0 0 0 x [positions 24-29]
+ # 0 0 0 0 0 x [positions 30-35]
+ # ...
+ # Now the positions are [3,4,8,14,19] which after subtracting the lowest value (3) gives [0,1,5,11,16] thus, the
+ # offsets for this particular piece are (in even, odd order) [0,1,5,11,16],[0,1,6,11,17] which is what
+ # this function would return
+ def normalize_offsets( values)
+ min = values.min
+ even_min = is_even(min)
+ other_min = even_min ? min + 6 : min + 7
+ other_values = values.collect do | value |
+ if is_even(value) then
+ value + 6 - other_min
+ else
+ value + 7 - other_min
+ end
+ end
+ values.collect! { | value | value - min }
+
+ if even_min then
+ [values, other_values]
+ else
+ [other_values, values]
+ end
+ end
+
+ # produce a bitmask representation of an array of offset locations
+ def mask_for_offsets( offsets )
+ mask = 0
+ offsets.each { | value | mask = mask + ( 1 << value ) }
+ mask
+ end
+
+ # finds a "safe" position that a position as described by a list of directions can be placed
+ # without falling off any edge of the board. the values returned a location to place the first piece
+ # at so it will fit after making the described moves
+ def start_adjust( directions )
+ south = east = 0;
+ directions.each do | direction |
+ east += 1 if ( direction == :sw || direction == :nw || direction == :west )
+ south += 1 if ( direction == :nw || direction == :ne )
+ end
+ south * 6 + east
+ end
+
+ # given a set of directions places the piece (as defined by a set of directions) on the board at
+ # a location that will not take it off the edge
+ def get_values ( directions )
+ start = start_adjust(directions)
+ values = [ start ]
+ directions.each do | direction |
+ if (start % 12 >= 6) then
+ start += @@rotation_odd_adder[direction]
+ else
+ start += @@rotation_even_adder[direction]
+ end
+ values += [ start ]
+ end
+
+ # some moves take you back to an existing location, we'll strip duplicates
+ values.uniq
+ end
+end
+
+# describes a piece and caches information about its rotations to as to be efficient for iteration
+# ATTRIBUTES:
+# rotations -- all the rotations of the piece
+# type -- a numeic "name" of the piece
+# masks -- an array by location of all legal rotational masks (a n inner array) for that location
+# placed -- the mask that this piece was last placed at (not a location, but the actual mask used)
+class Piece
+ attr_reader :rotations, :type, :masks
+ attr_accessor :placed
+
+ # transform hashes that change one direction into another when you either flip or rotate a set of directions
+ @@flip_converter = { :west => :west, :east => :east, :nw => :sw, :ne => :se, :sw => :nw, :se => :ne }
+ @@rotate_converter = { :west => :nw, :east => :se, :nw => :ne, :ne => :east, :sw => :west, :se => :sw }
+
+ def initialize( directions, type )
+ @type = type
+ @rotations = Array.new();
+ @map = {}
+
+ generate_rotations( directions )
+ directions.collect! { | value | @@flip_converter[value] }
+ generate_rotations( directions )
+
+ # creates the masks AND a map that returns [location, rotation] for any given mask
+ # this is used when a board is found and we want to draw it, otherwise the map is unused
+ @masks = Array.new();
+ 0.upto(59) do | i |
+ even = true
+ @masks[i] = @rotations.collect do | rotation |
+ mask = rotation.start_masks[i]
+ @map[mask[0]] = [ i, rotation ] if (mask)
+ mask || nil
+ end
+ @masks[i].compact!
+ end
+ end
+
+ # rotates a set of directions through all six angles and adds a Rotation to the list for each one
+ def generate_rotations( directions )
+ 6.times do
+ rotations.push( Rotation.new(directions))
+ directions.collect! { | value | @@rotate_converter[value] }
+ end
+ end
+
+ # given a board string, adds this piece to the board at whatever location/rotation
+ # important: the outbound board string is 5 wide, the normal location notation is six wide (padded)
+ def fill_string( board_string)
+ location, rotation = @map[@placed]
+ rotation.offsets(location).each do | offset |
+ row, col = offset.divmod(6)
+ board_string[ row*5 + col, 1 ] = @type.to_s
+ end
+ end
+end
+
+# a blank bit board having this form:
+#
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 0 0 0 0 0 1
+# 1 1 1 1 1 1
+#
+# where left lest significant bit is the top left and the most significant is the lower right
+# the actual board only consists of the 0 places, the 1 places are blockers to keep things from running
+# off the edges or bottom
+def blank_board
+ 0b111111100000100000100000100000100000100000100000100000100000100000
+end
+
+def full_board
+ 0b111111111111111111111111111111111111111111111111111111111111111111
+end
+
+# determines if a location (bit position) is in an even row
+def is_even( location)
+ (location % 12) < 6
+end
+
+# support function that create three utility maps:
+# $converter -- for each row an array that maps a five bit row (via array mapping)
+# to the a five bit representation of the bits below it
+# $bit_count -- maps a five bit row (via array mapping) to the number of 1s in the row
+# @@new_regions -- maps a five bit row (via array mapping) to an array of "region" arrays
+# a region array has three values the first is a mask of bits in the region,
+# the second is the count of those bits and the third is identical to the first
+# examples:
+# 0b10010 => [ 0b01100, 2, 0b01100 ], [ 0b00001, 1, 0b00001]
+# 0b01010 => [ 0b10000, 1, 0b10000 ], [ 0b00100, 1, 0b00100 ], [ 0b00001, 1, 0b00001]
+# 0b10001 => [ 0b01110, 3, 0b01110 ]
+def create_collector_support
+ odd_map = [0b11, 0b110, 0b1100, 0b11000, 0b10000]
+ even_map = [0b1, 0b11, 0b110, 0b1100, 0b11000]
+
+ all_odds = Array.new(0b100000)
+ all_evens = Array.new(0b100000)
+ bit_counts = Array.new(0b100000)
+ new_regions = Array.new(0b100000)
+ 0.upto(0b11111) do | i |
+ bit_count = odd = even = 0
+ 0.upto(4) do | bit |
+ if (i[bit] == 1) then
+ bit_count += 1
+ odd |= odd_map[bit]
+ even |= even_map[bit]
+ end
+ end
+ all_odds[i] = odd
+ all_evens[i] = even
+ bit_counts[i] = bit_count
+ new_regions[i] = create_regions( i)
+ end
+
+ $converter = []
+ 10.times { | row | $converter.push((row % 2 == 0) ? all_evens : all_odds) }
+ $bit_counts = bit_counts
+ $regions = new_regions.collect { | set | set.collect { | value | [ value, bit_counts[value], value] } }
+end
+
+# determines if a board is punable, meaning that there is no possibility that it
+# can be filled up with pieces. A board is prunable if there is a grouping of unfilled spaces
+# that are not a multiple of five. The following board is an example of a prunable board:
+# 0 0 1 0 0
+# 0 1 0 0 0
+# 1 1 0 0 0
+# 0 1 0 0 0
+# 0 0 0 0 0
+# ...
+#
+# This board is prunable because the top left corner is only 3 bits in area, no piece will ever fit it
+# parameters:
+# board -- an initial bit board (6 bit padded rows, see blank_board for format)
+# location -- starting location, everything above and to the left is already full
+# slotting -- set to true only when testing initial pieces, when filling normally
+# additional assumptions are possible
+#
+# Algorithm:
+# The algorithm starts at the top row (as determined by location) and iterates a row at a time
+# maintainng counts of active open areas (kept in the collector array) each collector contains
+# three values at the start of an iteration:
+# 0: mask of bits that would be adjacent to the collector in this row
+# 1: the number of bits collected so far
+# 2: a scratch space starting as zero, but used during the computation to represent
+# the empty bits in the new row that are adjacent (position 0)
+# The exact procedure is described in-code
+def prunable( board, location, slotting = false)
+ collectors = []
+ # loop across the rows
+ (location / 6).to_i.upto(9) do | row_on |
+ # obtain a set of regions representing the bits of the current row.
+ regions = $regions[(board >> (row_on * 6)) & 0b11111]
+ converter = $converter[row_on]
+
+ # track the number of collectors at the start of the cycle so that
+ # we don't compute against newly created collectors, only existing collectors
+ initial_collector_count = collectors.length
+
+ # loop against the regions. For each region of the row
+ # we will see if it connects to one or more existing collectors.
+ # if it connects to 1 collector, the bits from the region are added to the
+ # bits of the collector and the mask is placed in collector[2]
+ # If the region overlaps more than one collector then all the collectors
+ # it overlaps with are merged into the first one (the others are set to nil in the array)
+ # if NO collectors are found then the region is copied as a new collector
+ regions.each do | region |
+ collector_found = nil
+ region_mask = region[2]
+ initial_collector_count.times do | collector_num |
+ collector = collectors[collector_num]
+ if (collector) then
+ collector_mask = collector[0]
+ if (collector_mask & region_mask != 0) then
+ if (collector_found) then
+ collector_found[0] |= collector_mask
+ collector_found[1] += collector[1]
+ collector_found[2] |= collector[2]
+ collectors[collector_num] = nil
+ else
+ collector_found = collector
+ collector[1] += region[1]
+ collector[2] |= region_mask
+ end
+ end
+ end
+ end
+ if (collector_found == nil) then
+ collectors.push(Array.new(region))
+ end
+ end
+
+ # check the existing collectors, if any collector overlapped no bits in the region its [2] value will
+ # be zero. The size of any such reaason is tested if it is not a multiple of five true is returned since
+ # the board is prunable. if it is a multiple of five it is removed.
+ # Collector that are still active have a new adjacent value [0] set based n the matched bits
+ # and have [2] cleared out for the next cycle.
+ collectors.length.times do | collector_num |
+ collector = collectors[collector_num]
+ if (collector) then
+ if (collector[2] == 0) then
+ return true if (collector[1] % 5 != 0)
+ collectors[collector_num] = nil
+ else
+ # if a collector matches all bits in the row then we can return unprunable early for the
+ # following reasons:
+ # 1) there can be no more unavailable bits bince we fill from the top left downward
+ # 2) all previous regions have been closed or joined so only this region can fail
+ # 3) this region must be good since there can never be only 1 region that is nuot
+ # a multiple of five
+ # this rule only applies when filling normally, so we ignore the rule if we are "slotting"
+ # in pieces to see what configurations work for them (the only other time this algorithm is used).
+ return false if (collector[2] == 0b11111 && !slotting)
+ collector[0] = converter[collector[2]]
+ collector[2] = 0
+ end
+ end
+ end
+
+ # get rid of all the empty converters for the next round
+ collectors.compact!
+ end
+ return false if (collectors.length <= 1) # 1 collector or less and the region is fine
+ collectors.any? { | collector | (collector[1] % 5) != 0 } # more than 1 and we test them all for bad size
+end
+
+# creates a region given a row mask. see prunable for what a "region" is
+def create_regions( value )
+ regions = []
+ cur_region = 0
+ 5.times do | bit |
+ if (value[bit] == 0) then
+ cur_region |= 1 << bit
+ else
+ if (cur_region != 0 ) then
+ regions.push( cur_region)
+ cur_region = 0;
+ end
+ end
+ end
+ regions.push(cur_region) if (cur_region != 0)
+ regions
+end
+
+# find up to the counted number of solutions (or all solutions) and prints the final result
+def find_all
+ find_top( 1)
+ find_top( 0)
+ print_results
+end
+
+# show the board
+def print_results
+ print "#{@boards_found} solutions found\n\n"
+ print_full_board( @min_board)
+ print "\n"
+ print_full_board( @max_board)
+ print "\n"
+end
+
+# finds solutions. This special version of the main function is only used for the top level
+# the reason for it is basically to force a particular ordering on how the rotations are tested for
+# the first piece. It is called twice, first looking for placements of the odd rotations and then
+# looking for placements of the even locations.
+#
+# WHY?
+# Since any found solution has an inverse we want to maximize finding solutions that are not already found
+# as an inverse. The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away
+# (an odd number). Checking even vs odd then produces a higher probability of finding more pieces earlier
+# in the cycle. We still need to keep checking all the permutations, but our probability of finding one will
+# diminsh over time. Since we are TOLD how many to search for this lets us exit before checking all pieces
+# this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the
+# maximum number
+def find_top( rotation_skip)
+ board = blank_board
+ (@pieces.length-1).times do
+ piece = @pieces.shift
+ piece.masks[0].each do | mask, imask, cmask |
+ if ((rotation_skip += 1) % 2 == 0) then
+ piece.placed = mask
+ find( 1, 1, board | mask)
+ end
+ end
+ @pieces.push(piece)
+ end
+ piece = @pieces.shift
+ @pieces.push(piece)
+end
+
+# the normail find routine, iterates through the available pieces, checks all rotations at the current location
+# and adds any boards found. depth is achieved via recursion. the overall approach is described
+# here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
+# parameters:
+# start_location -- where to start looking for place for the next piece at
+# placed -- number of pieces placed
+# board -- current state of the board
+#
+# see in-code comments
+def find( start_location, placed, board)
+ # find the next location to place a piece by looking for an empty bit
+ while board[start_location] == 1
+ start_location += 1
+ end
+
+ @pieces.length.times do
+ piece = @pieces.shift
+ piece.masks[start_location].each do | mask, imask, cmask |
+ if ( board & cmask == imask) then
+ piece.placed = mask
+ if (placed == 9) then
+ add_board
+ else
+ find( start_location + 1, placed + 1, board | mask)
+ end
+ end
+ end
+ @pieces.push(piece)
+ end
+end
+
+# print the board
+def print_full_board( board_string)
+ 10.times do | row |
+ print " " if (row % 2 == 1)
+ 5.times do | col |
+ print "#{board_string[row*5 + col,1]} "
+ end
+ print "\n"
+ end
+end
+
+# when a board is found we "draw it" into a string and then flip that string, adding both to
+# the list (hash) of solutions if they are unique.
+def add_board
+ board_string = "99999999999999999999999999999999999999999999999999"
+ @all_pieces.each { | piece | piece.fill_string( board_string ) }
+ save( board_string)
+ save( board_string.reverse)
+end
+
+# adds a board string to the list (if new) and updates the current best/worst board
+def save( board_string)
+ if (@all_boards[board_string] == nil) then
+ @min_board = board_string if (board_string < @min_board)
+ @max_board = board_string if (board_string > @max_board)
+ @all_boards.store(board_string,true)
+ @boards_found += 1
+
+ # the exit motif is a time saver. Ideally the function should return, but those tests
+ # take noticeable time (performance).
+ if (@boards_found == @stop_count) then
+ print_results
+ exit(0)
+ end
+ end
+end
+
+
+##
+## MAIN BODY :)
+##
+create_collector_support
+@pieces = [
+ Piece.new( [ :nw, :ne, :east, :east ], 2),
+ Piece.new( [ :ne, :se, :east, :ne ], 7),
+ Piece.new( [ :ne, :east, :ne, :nw ], 1),
+ Piece.new( [ :east, :sw, :sw, :se ], 6),
+ Piece.new( [ :east, :ne, :se, :ne ], 5),
+ Piece.new( [ :east, :east, :east, :se ], 0),
+ Piece.new( [ :ne, :nw, :se, :east, :se ], 4),
+ Piece.new( [ :se, :se, :se, :west ], 9),
+ Piece.new( [ :se, :se, :east, :se ], 8),
+ Piece.new( [ :east, :east, :sw, :se ], 3)
+ ];
+
+@all_pieces = Array.new( @pieces)
+
+@min_board = "99999999999999999999999999999999999999999999999999"
+@max_board = "00000000000000000000000000000000000000000000000000"
+@stop_count = ARGV[0].to_i || 2089
+@all_boards = {}
+@boards_found = 0
+
+find_all ######## DO IT!!!
diff --git a/bench/yarv/bm_so_nbody.rb b/bench/mri/bm_so_nbody.rb
similarity index 95%
rename from bench/yarv/bm_so_nbody.rb
rename to bench/mri/bm_so_nbody.rb
index 709d58b7ff8..d6c5bb9e61f 100644
--- a/bench/yarv/bm_so_nbody.rb
+++ b/bench/mri/bm_so_nbody.rb
@@ -1,148 +1,148 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org
-#
-# Optimized for Ruby by Jesse Millikan
-# From version ported by Michael Neumann from the C gcc version,
-# which was written by Christoph Bauer.
-
-SOLAR_MASS = 4 * Math::PI**2
-DAYS_PER_YEAR = 365.24
-
-def _puts *args
-end
-
-class Planet
- attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass
-
- def initialize(x, y, z, vx, vy, vz, mass)
- @x, @y, @z = x, y, z
- @vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR
- @mass = mass * SOLAR_MASS
- end
-
- def move_from_i(bodies, nbodies, dt, i)
- while i < nbodies
- b2 = bodies[i]
- dx = @x - b2.x
- dy = @y - b2.y
- dz = @z - b2.z
-
- distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
- mag = dt / (distance * distance * distance)
- b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag
-
- @vx -= dx * b2_mass_mag
- @vy -= dy * b2_mass_mag
- @vz -= dz * b2_mass_mag
- b2.vx += dx * b_mass_mag
- b2.vy += dy * b_mass_mag
- b2.vz += dz * b_mass_mag
- i += 1
- end
-
- @x += dt * @vx
- @y += dt * @vy
- @z += dt * @vz
- end
-end
-
-def energy(bodies)
- e = 0.0
- nbodies = bodies.size
-
- for i in 0 ... nbodies
- b = bodies[i]
- e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz)
- for j in (i + 1) ... nbodies
- b2 = bodies[j]
- dx = b.x - b2.x
- dy = b.y - b2.y
- dz = b.z - b2.z
- distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
- e -= (b.mass * b2.mass) / distance
- end
- end
- e
-end
-
-def offset_momentum(bodies)
- px, py, pz = 0.0, 0.0, 0.0
-
- for b in bodies
- m = b.mass
- px += b.vx * m
- py += b.vy * m
- pz += b.vz * m
- end
-
- b = bodies[0]
- b.vx = - px / SOLAR_MASS
- b.vy = - py / SOLAR_MASS
- b.vz = - pz / SOLAR_MASS
-end
-
-BODIES = [
- # sun
- Planet.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0),
-
- # jupiter
- Planet.new(
- 4.84143144246472090e+00,
- -1.16032004402742839e+00,
- -1.03622044471123109e-01,
- 1.66007664274403694e-03,
- 7.69901118419740425e-03,
- -6.90460016972063023e-05,
- 9.54791938424326609e-04),
-
- # saturn
- Planet.new(
- 8.34336671824457987e+00,
- 4.12479856412430479e+00,
- -4.03523417114321381e-01,
- -2.76742510726862411e-03,
- 4.99852801234917238e-03,
- 2.30417297573763929e-05,
- 2.85885980666130812e-04),
-
- # uranus
- Planet.new(
- 1.28943695621391310e+01,
- -1.51111514016986312e+01,
- -2.23307578892655734e-01,
- 2.96460137564761618e-03,
- 2.37847173959480950e-03,
- -2.96589568540237556e-05,
- 4.36624404335156298e-05),
-
- # neptune
- Planet.new(
- 1.53796971148509165e+01,
- -2.59193146099879641e+01,
- 1.79258772950371181e-01,
- 2.68067772490389322e-03,
- 1.62824170038242295e-03,
- -9.51592254519715870e-05,
- 5.15138902046611451e-05)
-]
-
-init = 200_000 # ARGV[0]
-n = Integer(init)
-
-offset_momentum(BODIES)
-
-puts "%.9f" % energy(BODIES)
-
-nbodies = BODIES.size
-dt = 0.01
-
-n.times do
- i = 0
- while i < nbodies
- b = BODIES[i]
- b.move_from_i(BODIES, nbodies, dt, i + 1)
- i += 1
- end
-end
-
-puts "%.9f" % energy(BODIES)
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org
+#
+# Optimized for Ruby by Jesse Millikan
+# From version ported by Michael Neumann from the C gcc version,
+# which was written by Christoph Bauer.
+
+SOLAR_MASS = 4 * Math::PI**2
+DAYS_PER_YEAR = 365.24
+
+def _puts *args
+end
+
+class Planet
+ attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass
+
+ def initialize(x, y, z, vx, vy, vz, mass)
+ @x, @y, @z = x, y, z
+ @vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR
+ @mass = mass * SOLAR_MASS
+ end
+
+ def move_from_i(bodies, nbodies, dt, i)
+ while i < nbodies
+ b2 = bodies[i]
+ dx = @x - b2.x
+ dy = @y - b2.y
+ dz = @z - b2.z
+
+ distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
+ mag = dt / (distance * distance * distance)
+ b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag
+
+ @vx -= dx * b2_mass_mag
+ @vy -= dy * b2_mass_mag
+ @vz -= dz * b2_mass_mag
+ b2.vx += dx * b_mass_mag
+ b2.vy += dy * b_mass_mag
+ b2.vz += dz * b_mass_mag
+ i += 1
+ end
+
+ @x += dt * @vx
+ @y += dt * @vy
+ @z += dt * @vz
+ end
+end
+
+def energy(bodies)
+ e = 0.0
+ nbodies = bodies.size
+
+ for i in 0 ... nbodies
+ b = bodies[i]
+ e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz)
+ for j in (i + 1) ... nbodies
+ b2 = bodies[j]
+ dx = b.x - b2.x
+ dy = b.y - b2.y
+ dz = b.z - b2.z
+ distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
+ e -= (b.mass * b2.mass) / distance
+ end
+ end
+ e
+end
+
+def offset_momentum(bodies)
+ px, py, pz = 0.0, 0.0, 0.0
+
+ for b in bodies
+ m = b.mass
+ px += b.vx * m
+ py += b.vy * m
+ pz += b.vz * m
+ end
+
+ b = bodies[0]
+ b.vx = - px / SOLAR_MASS
+ b.vy = - py / SOLAR_MASS
+ b.vz = - pz / SOLAR_MASS
+end
+
+BODIES = [
+ # sun
+ Planet.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0),
+
+ # jupiter
+ Planet.new(
+ 4.84143144246472090e+00,
+ -1.16032004402742839e+00,
+ -1.03622044471123109e-01,
+ 1.66007664274403694e-03,
+ 7.69901118419740425e-03,
+ -6.90460016972063023e-05,
+ 9.54791938424326609e-04),
+
+ # saturn
+ Planet.new(
+ 8.34336671824457987e+00,
+ 4.12479856412430479e+00,
+ -4.03523417114321381e-01,
+ -2.76742510726862411e-03,
+ 4.99852801234917238e-03,
+ 2.30417297573763929e-05,
+ 2.85885980666130812e-04),
+
+ # uranus
+ Planet.new(
+ 1.28943695621391310e+01,
+ -1.51111514016986312e+01,
+ -2.23307578892655734e-01,
+ 2.96460137564761618e-03,
+ 2.37847173959480950e-03,
+ -2.96589568540237556e-05,
+ 4.36624404335156298e-05),
+
+ # neptune
+ Planet.new(
+ 1.53796971148509165e+01,
+ -2.59193146099879641e+01,
+ 1.79258772950371181e-01,
+ 2.68067772490389322e-03,
+ 1.62824170038242295e-03,
+ -9.51592254519715870e-05,
+ 5.15138902046611451e-05)
+]
+
+init = 200_000 # ARGV[0]
+n = Integer(init)
+
+offset_momentum(BODIES)
+
+puts "%.9f" % energy(BODIES)
+
+nbodies = BODIES.size
+dt = 0.01
+
+n.times do
+ i = 0
+ while i < nbodies
+ b = BODIES[i]
+ b.move_from_i(BODIES, nbodies, dt, i + 1)
+ i += 1
+ end
+end
+
+puts "%.9f" % energy(BODIES)
diff --git a/bench/yarv/bm_so_nested_loop.rb b/bench/mri/bm_so_nested_loop.rb
similarity index 100%
rename from bench/yarv/bm_so_nested_loop.rb
rename to bench/mri/bm_so_nested_loop.rb
diff --git a/bench/yarv/bm_so_nsieve.rb b/bench/mri/bm_so_nsieve.rb
similarity index 95%
rename from bench/yarv/bm_so_nsieve.rb
rename to bench/mri/bm_so_nsieve.rb
index 59aead58938..a65cc782331 100644
--- a/bench/yarv/bm_so_nsieve.rb
+++ b/bench/mri/bm_so_nsieve.rb
@@ -1,35 +1,35 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# contributed by Glenn Parker, March 2005
-# modified by Evan Phoenix, Sept 2006
-
-def sieve(m)
- flags = Flags.dup[0,m]
- count = 0
- pmax = m - 1
- p = 2
- while p <= pmax
- unless flags[p].zero?
- count += 1
- mult = p
- while mult <= pmax
- flags[mult] = 0
- mult += p
- end
- end
- p += 1
- end
- count
-end
-
-n = 9 # (ARGV[0] || 2).to_i
-Flags = ("\x1" * ( 2 ** n * 10_000)).unpack("c*")
-
-n.downto(n-2) do |exponent|
- break if exponent < 0
- m = (1 << exponent) * 10_000
- # m = (2 ** exponent) * 10_000
- count = sieve(m)
- printf "Primes up to %8d %8d\n", m, count
-end
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org/
+#
+# contributed by Glenn Parker, March 2005
+# modified by Evan Phoenix, Sept 2006
+
+def sieve(m)
+ flags = Flags.dup[0,m]
+ count = 0
+ pmax = m - 1
+ p = 2
+ while p <= pmax
+ unless flags[p].zero?
+ count += 1
+ mult = p
+ while mult <= pmax
+ flags[mult] = 0
+ mult += p
+ end
+ end
+ p += 1
+ end
+ count
+end
+
+n = 9 # (ARGV[0] || 2).to_i
+Flags = ("\x1" * ( 2 ** n * 10_000)).unpack("c*")
+
+n.downto(n-2) do |exponent|
+ break if exponent < 0
+ m = (1 << exponent) * 10_000
+ # m = (2 ** exponent) * 10_000
+ count = sieve(m)
+ printf "Primes up to %8d %8d\n", m, count
+end
diff --git a/bench/yarv/bm_so_nsieve_bits.rb b/bench/mri/bm_so_nsieve_bits.rb
similarity index 95%
rename from bench/yarv/bm_so_nsieve_bits.rb
rename to bench/mri/bm_so_nsieve_bits.rb
index 693b2f246dd..6f958ee44e7 100644
--- a/bench/yarv/bm_so_nsieve_bits.rb
+++ b/bench/mri/bm_so_nsieve_bits.rb
@@ -1,42 +1,43 @@
-#!/usr/bin/ruby
-#
-# The Great Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# nsieve-bits in Ruby
-# Contributed by Glenn Parker, March 2005
-
-CharExponent = 3
-BitsPerChar = 1 << CharExponent
-LowMask = BitsPerChar - 1
-
-def sieve(m)
- items = "\xFF" * ((m / BitsPerChar) + 1)
- masks = ""
- BitsPerChar.times do |b|
- masks << (1 << b).chr
- end
-
- count = 0
- pmax = m - 1
- 2.step(pmax, 1) do |p|
- if items[p >> CharExponent][p & LowMask] == 1
- count += 1
- p.step(pmax, p) do |mult|
- a = mult >> CharExponent
- b = mult & LowMask
- items[a] -= masks[b] if items[a][b] != 0
- end
- end
- end
- count
-end
-
-n = 9 # (ARGV[0] || 2).to_i
-n.step(n - 2, -1) do |exponent|
- break if exponent < 0
- m = 2 ** exponent * 10_000
- count = sieve(m)
- printf "Primes up to %8d %8d\n", m, count
-end
-
+#!/usr/bin/ruby
+#coding: us-ascii
+#
+# The Great Computer Language Shootout
+# http://shootout.alioth.debian.org/
+#
+# nsieve-bits in Ruby
+# Contributed by Glenn Parker, March 2005
+
+CharExponent = 3
+BitsPerChar = 1 << CharExponent
+LowMask = BitsPerChar - 1
+
+def sieve(m)
+ items = "\xFF" * ((m / BitsPerChar) + 1)
+ masks = ""
+ BitsPerChar.times do |b|
+ masks << (1 << b).chr
+ end
+
+ count = 0
+ pmax = m - 1
+ 2.step(pmax, 1) do |p|
+ if items[p >> CharExponent][p & LowMask] == 1
+ count += 1
+ p.step(pmax, p) do |mult|
+ a = mult >> CharExponent
+ b = mult & LowMask
+ items[a] -= masks[b] if items[a][b] != 0
+ end
+ end
+ end
+ count
+end
+
+n = 9 # (ARGV[0] || 2).to_i
+n.step(n - 2, -1) do |exponent|
+ break if exponent < 0
+ m = 2 ** exponent * 10_000
+ count = sieve(m)
+ printf "Primes up to %8d %8d\n", m, count
+end
+
diff --git a/bench/yarv/bm_so_object.rb b/bench/mri/bm_so_object.rb
similarity index 100%
rename from bench/yarv/bm_so_object.rb
rename to bench/mri/bm_so_object.rb
diff --git a/bench/yarv/bm_so_partial_sums.rb b/bench/mri/bm_so_partial_sums.rb
similarity index 96%
rename from bench/yarv/bm_so_partial_sums.rb
rename to bench/mri/bm_so_partial_sums.rb
index 41f0a5fb874..630b45cb8de 100644
--- a/bench/yarv/bm_so_partial_sums.rb
+++ b/bench/mri/bm_so_partial_sums.rb
@@ -1,31 +1,31 @@
-n = 2_500_000 # (ARGV.shift || 1).to_i
-
-alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0
-
-1.upto(n) do |d|
- d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d)
-
- s0 += (2.0 / 3.0) ** (d - 1.0)
- s1 += 1.0 / Math.sqrt(d)
- s2 += 1.0 / (d * (d + 1.0))
- s3 += 1.0 / (d3 * ds * ds)
- s4 += 1.0 / (d3 * dc * dc)
- s5 += 1.0 / d
- s6 += 1.0 / d2
- s7 += alt / d
- s8 += alt / (2.0 * d - 1.0)
-
- alt = -alt
-end
-
-if false
- printf("%.9f\t(2/3)^k\n", s0)
- printf("%.9f\tk^-0.5\n", s1)
- printf("%.9f\t1/k(k+1)\n", s2)
- printf("%.9f\tFlint Hills\n", s3)
- printf("%.9f\tCookson Hills\n", s4)
- printf("%.9f\tHarmonic\n", s5)
- printf("%.9f\tRiemann Zeta\n", s6)
- printf("%.9f\tAlternating Harmonic\n", s7)
- printf("%.9f\tGregory\n", s8)
-end
+n = 2_500_000 # (ARGV.shift || 1).to_i
+
+alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0
+
+1.upto(n) do |d|
+ d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d)
+
+ s0 += (2.0 / 3.0) ** (d - 1.0)
+ s1 += 1.0 / Math.sqrt(d)
+ s2 += 1.0 / (d * (d + 1.0))
+ s3 += 1.0 / (d3 * ds * ds)
+ s4 += 1.0 / (d3 * dc * dc)
+ s5 += 1.0 / d
+ s6 += 1.0 / d2
+ s7 += alt / d
+ s8 += alt / (2.0 * d - 1.0)
+
+ alt = -alt
+end
+
+if false
+ printf("%.9f\t(2/3)^k\n", s0)
+ printf("%.9f\tk^-0.5\n", s1)
+ printf("%.9f\t1/k(k+1)\n", s2)
+ printf("%.9f\tFlint Hills\n", s3)
+ printf("%.9f\tCookson Hills\n", s4)
+ printf("%.9f\tHarmonic\n", s5)
+ printf("%.9f\tRiemann Zeta\n", s6)
+ printf("%.9f\tAlternating Harmonic\n", s7)
+ printf("%.9f\tGregory\n", s8)
+end
diff --git a/bench/yarv/bm_so_pidigits.rb b/bench/mri/bm_so_pidigits.rb
similarity index 94%
rename from bench/yarv/bm_so_pidigits.rb
rename to bench/mri/bm_so_pidigits.rb
index acffe71ae78..c7d6fbfb4d2 100644
--- a/bench/yarv/bm_so_pidigits.rb
+++ b/bench/mri/bm_so_pidigits.rb
@@ -1,92 +1,92 @@
-# The Great Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# contributed by Gabriele Renzi
-
-class PiDigitSpigot
-
- def initialize()
- @z = Transformation.new 1,0,0,1
- @x = Transformation.new 0,0,0,0
- @inverse = Transformation.new 0,0,0,0
- end
-
- def next!
- @y = @z.extract(3)
- if safe? @y
- @z = produce(@y)
- @y
- else
- @z = consume @x.next!()
- next!()
- end
- end
-
- def safe?(digit)
- digit == @z.extract(4)
- end
-
- def produce(i)
- @inverse.qrst(10,-10*i,0,1).compose(@z)
- end
-
- def consume(a)
- @z.compose(a)
- end
-end
-
-
-class Transformation
- attr_reader :q, :r, :s, :t
- def initialize (q, r, s, t)
- @q,@r,@s,@t,@k = q,r,s,t,0
- end
-
- def next!()
- @q = @k = @k + 1
- @r = 4 * @k + 2
- @s = 0
- @t = 2 * @k + 1
- self
- end
-
- def extract(j)
- (@q * j + @r) / (@s * j + @t)
- end
-
- def compose(a)
- self.class.new( @q * a.q,
- @q * a.r + r * a.t,
- @s * a.q + t * a.s,
- @s * a.r + t * a.t
- )
- end
-
- def qrst *args
- initialize *args
- self
- end
-
-
-end
-
-
-WIDTH = 10
-n = 2_500 # Integer(ARGV[0])
-j = 0
-
-digits = PiDigitSpigot.new
-
-while n > 0
- if n >= WIDTH
- WIDTH.times {print digits.next!}
- j += WIDTH
- else
- n.times {print digits.next!}
- (WIDTH-n).times {print " "}
- j += n
- end
- puts "\t:"+j.to_s
- n -= WIDTH
-end
-
+# The Great Computer Language Shootout
+# http://shootout.alioth.debian.org/
+#
+# contributed by Gabriele Renzi
+
+class PiDigitSpigot
+
+ def initialize()
+ @z = Transformation.new 1,0,0,1
+ @x = Transformation.new 0,0,0,0
+ @inverse = Transformation.new 0,0,0,0
+ end
+
+ def next!
+ @y = @z.extract(3)
+ if safe? @y
+ @z = produce(@y)
+ @y
+ else
+ @z = consume @x.next!()
+ next!()
+ end
+ end
+
+ def safe?(digit)
+ digit == @z.extract(4)
+ end
+
+ def produce(i)
+ @inverse.qrst(10,-10*i,0,1).compose(@z)
+ end
+
+ def consume(a)
+ @z.compose(a)
+ end
+end
+
+
+class Transformation
+ attr_reader :q, :r, :s, :t
+ def initialize (q, r, s, t)
+ @q,@r,@s,@t,@k = q,r,s,t,0
+ end
+
+ def next!()
+ @q = @k = @k + 1
+ @r = 4 * @k + 2
+ @s = 0
+ @t = 2 * @k + 1
+ self
+ end
+
+ def extract(j)
+ (@q * j + @r) / (@s * j + @t)
+ end
+
+ def compose(a)
+ self.class.new( @q * a.q,
+ @q * a.r + r * a.t,
+ @s * a.q + t * a.s,
+ @s * a.r + t * a.t
+ )
+ end
+
+ def qrst *args
+ initialize *args
+ self
+ end
+
+
+end
+
+
+WIDTH = 10
+n = 2_500 # Integer(ARGV[0])
+j = 0
+
+digits = PiDigitSpigot.new
+
+while n > 0
+ if n >= WIDTH
+ WIDTH.times {print digits.next!}
+ j += WIDTH
+ else
+ n.times {print digits.next!}
+ (WIDTH-n).times {print " "}
+ j += n
+ end
+ puts "\t:"+j.to_s
+ n -= WIDTH
+end
+
diff --git a/bench/yarv/bm_so_random.rb b/bench/mri/bm_so_random.rb
similarity index 90%
rename from bench/yarv/bm_so_random.rb
rename to bench/mri/bm_so_random.rb
index 83c0d6d380e..a66b9e8e633 100644
--- a/bench/yarv/bm_so_random.rb
+++ b/bench/mri/bm_so_random.rb
@@ -10,11 +10,11 @@ def gen_random(max)
(max * ($last = ($last * IA + IC) % IM)) / IM
end
-N = 1000000
+N = 3_000_000
-i=0
+i = 0
while i/
- if seq.length != 0
- revcomp(seq.join)
- seq=Array.new
- end
- puts $_
- else
- $_.sub(/\n/,'')
- seq.push $_
- end
-end
-revcomp(seq.join)
+#!/usr/bin/ruby
+# The Great Computer Language Shootout
+# http://shootout.alioth.debian.org/
+#
+# Contributed by Peter Bjarke Olsen
+# Modified by Doug King
+
+seq=Array.new
+
+def revcomp(seq)
+ seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
+ stringlen=seq.length
+ 0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"}
+end
+
+input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')
+
+while input.gets
+ if $_ =~ />/
+ if seq.length != 0
+ revcomp(seq.join)
+ seq=Array.new
+ end
+ puts $_
+ else
+ $_.sub(/\n/,'')
+ seq.push $_
+ end
+end
+revcomp(seq.join)
diff --git a/bench/yarv/bm_so_sieve.rb b/bench/mri/bm_so_sieve.rb
similarity index 92%
rename from bench/yarv/bm_so_sieve.rb
rename to bench/mri/bm_so_sieve.rb
index dbe2bfa63d0..43dc3026485 100644
--- a/bench/yarv/bm_so_sieve.rb
+++ b/bench/mri/bm_so_sieve.rb
@@ -1,15 +1,15 @@
# from http://www.bagley.org/~doug/shootout/bench/sieve/sieve.ruby
-num = 40
+num = 500
count = i = j = 0
flags0 = Array.new(8192,1)
k = 0
while k < num
- k+=1
+ k += 1
count = 0
flags = flags0.dup
i = 2
while i<8192
- i+=1
+ i += 1
if flags[i]
# remove all multiples of prime: i
j = i*i
diff --git a/bench/yarv/bm_so_spectralnorm.rb b/bench/mri/bm_so_spectralnorm.rb
similarity index 94%
rename from bench/yarv/bm_so_spectralnorm.rb
rename to bench/mri/bm_so_spectralnorm.rb
index 3617da5236f..6b972066891 100644
--- a/bench/yarv/bm_so_spectralnorm.rb
+++ b/bench/mri/bm_so_spectralnorm.rb
@@ -1,50 +1,50 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-# Contributed by Sokolov Yura
-
-def eval_A(i,j)
- return 1.0/((i+j)*(i+j+1)/2+i+1)
-end
-
-def eval_A_times_u(u)
- v, i = nil, nil
- (0..u.length-1).collect { |i|
- v = 0
- for j in 0..u.length-1
- v += eval_A(i,j)*u[j]
- end
- v
- }
-end
-
-def eval_At_times_u(u)
- v, i = nil, nil
- (0..u.length-1).collect{|i|
- v = 0
- for j in 0..u.length-1
- v += eval_A(j,i)*u[j]
- end
- v
- }
-end
-
-def eval_AtA_times_u(u)
- return eval_At_times_u(eval_A_times_u(u))
-end
-
-n = 500 # ARGV[0].to_i
-
-u=[1]*n
-for i in 1..10
- v=eval_AtA_times_u(u)
- u=eval_AtA_times_u(v)
-end
-vBv=0
-vv=0
-for i in 0..n-1
- vBv += u[i]*v[i]
- vv += v[i]*v[i]
-end
-
-str = "%0.9f" % (Math.sqrt(vBv/vv)), "\n"
-# print str
+# The Computer Language Shootout
+# http://shootout.alioth.debian.org/
+# Contributed by Sokolov Yura
+
+def eval_A(i,j)
+ return 1.0/((i+j)*(i+j+1)/2+i+1)
+end
+
+def eval_A_times_u(u)
+ v, i = nil, nil
+ (0..u.length-1).collect { |i|
+ v = 0
+ for j in 0..u.length-1
+ v += eval_A(i,j)*u[j]
+ end
+ v
+ }
+end
+
+def eval_At_times_u(u)
+ v, i = nil, nil
+ (0..u.length-1).collect{|i|
+ v = 0
+ for j in 0..u.length-1
+ v += eval_A(j,i)*u[j]
+ end
+ v
+ }
+end
+
+def eval_AtA_times_u(u)
+ return eval_At_times_u(eval_A_times_u(u))
+end
+
+n = 500 # ARGV[0].to_i
+
+u=[1]*n
+for i in 1..10
+ v=eval_AtA_times_u(u)
+ u=eval_AtA_times_u(v)
+end
+vBv=0
+vv=0
+for i in 0..n-1
+ vBv += u[i]*v[i]
+ vv += v[i]*v[i]
+end
+
+str = "%0.9f" % (Math.sqrt(vBv/vv)), "\n"
+# print str
diff --git a/bench/yarv/bm_startup.rb b/bench/mri/bm_startup.rb
similarity index 100%
rename from bench/yarv/bm_startup.rb
rename to bench/mri/bm_startup.rb
diff --git a/bench/mri/bm_vm1_attr_ivar.rb b/bench/mri/bm_vm1_attr_ivar.rb
new file mode 100644
index 00000000000..16906f3605a
--- /dev/null
+++ b/bench/mri/bm_vm1_attr_ivar.rb
@@ -0,0 +1,14 @@
+class C
+ attr_reader :a, :b
+ def initialize
+ @a = nil
+ @b = nil
+ end
+end
+obj = C.new
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ j = obj.a
+ k = obj.b
+end
diff --git a/bench/mri/bm_vm1_attr_ivar_set.rb b/bench/mri/bm_vm1_attr_ivar_set.rb
new file mode 100644
index 00000000000..7e7a6b48c01
--- /dev/null
+++ b/bench/mri/bm_vm1_attr_ivar_set.rb
@@ -0,0 +1,14 @@
+class C
+ attr_accessor :a, :b
+ def initialize
+ @a = nil
+ @b = nil
+ end
+end
+obj = C.new
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ obj.a = 1
+ obj.b = 2
+end
diff --git a/bench/mri/bm_vm1_block.rb b/bench/mri/bm_vm1_block.rb
new file mode 100644
index 00000000000..a9f56b15ea2
--- /dev/null
+++ b/bench/mri/bm_vm1_block.rb
@@ -0,0 +1,10 @@
+def m
+ yield
+end
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ m{
+ }
+end
diff --git a/bench/yarv/bm_vm1_const.rb b/bench/mri/bm_vm1_const.rb
similarity index 51%
rename from bench/yarv/bm_vm1_const.rb
rename to bench/mri/bm_vm1_const.rb
index 3e395d9478d..ac59ebccf1e 100644
--- a/bench/yarv/bm_vm1_const.rb
+++ b/bench/mri/bm_vm1_const.rb
@@ -1,8 +1,8 @@
Const = 1
i = 0
-while i<30000000 # while loop 1
- i+= 1
+while i<30_000_000 # while loop 1
+ i += 1
j = Const
k = Const
end
diff --git a/bench/yarv/bm_vm1_ensure.rb b/bench/mri/bm_vm1_ensure.rb
similarity index 51%
rename from bench/yarv/bm_vm1_ensure.rb
rename to bench/mri/bm_vm1_ensure.rb
index c3b71ead5af..a1596145f2f 100644
--- a/bench/yarv/bm_vm1_ensure.rb
+++ b/bench/mri/bm_vm1_ensure.rb
@@ -1,6 +1,6 @@
-i=0
-while i<30000000 # benchmark loop 1
- i+=1
+i = 0
+while i<30_000_000 # benchmark loop 1
+ i += 1
begin
begin
ensure
diff --git a/bench/mri/bm_vm1_float_simple.rb b/bench/mri/bm_vm1_float_simple.rb
new file mode 100644
index 00000000000..d4581439ff0
--- /dev/null
+++ b/bench/mri/bm_vm1_float_simple.rb
@@ -0,0 +1,7 @@
+i = 0.0; f = 0.0
+while i<30_000_000
+ i += 1
+ f += 0.1; f -= 0.1
+ f += 0.1; f -= 0.1
+ f += 0.1; f -= 0.1
+end
diff --git a/bench/mri/bm_vm1_gc_short_lived.rb b/bench/mri/bm_vm1_gc_short_lived.rb
new file mode 100644
index 00000000000..e78bca56685
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_short_lived.rb
@@ -0,0 +1,10 @@
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_gc_short_with_complex_long.rb b/bench/mri/bm_vm1_gc_short_with_complex_long.rb
new file mode 100644
index 00000000000..b66052dee04
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_short_with_complex_long.rb
@@ -0,0 +1,27 @@
+def nested_hash h, n
+ if n == 0
+ ''
+ else
+ 10.times{
+ h[Object.new] = nested_hash(h, n-1)
+ }
+ end
+end
+
+long_lived = Hash.new
+nested_hash long_lived, 6
+
+GC.start
+GC.start
+
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
+
diff --git a/bench/mri/bm_vm1_gc_short_with_long.rb b/bench/mri/bm_vm1_gc_short_with_long.rb
new file mode 100644
index 00000000000..298dbc845b0
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_short_with_long.rb
@@ -0,0 +1,13 @@
+long_lived = Array.new(1_000_000){|i| "#{i}"}
+GC.start
+GC.start
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_gc_short_with_symbol.rb b/bench/mri/bm_vm1_gc_short_with_symbol.rb
new file mode 100644
index 00000000000..6b15c1b7bfe
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_short_with_symbol.rb
@@ -0,0 +1,15 @@
+# make many symbols
+50_000.times{|i| sym = "sym#{i}".to_sym}
+GC.start
+GC.start
+
+i = 0
+while i<30_000_000 # while loop 1
+ a = '' # short-lived String
+ b = ''
+ c = ''
+ d = ''
+ e = ''
+ f = ''
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_gc_wb_ary.rb b/bench/mri/bm_vm1_gc_wb_ary.rb
new file mode 100644
index 00000000000..881528845b0
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_wb_ary.rb
@@ -0,0 +1,12 @@
+short_lived_ary = []
+
+if RUBY_VERSION >= "2.2.0"
+ GC.start(full_mark: false, immediate_mark: true, lazy_sweep: false)
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ short_lived_ary[0] = short_lived # write barrier
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_gc_wb_ary_promoted.rb b/bench/mri/bm_vm1_gc_wb_ary_promoted.rb
new file mode 100644
index 00000000000..3c8279c9565
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_wb_ary_promoted.rb
@@ -0,0 +1,14 @@
+long_lived = []
+
+if RUBY_VERSION > "2.2.0"
+ 3.times{ GC.start(full_mark: false, immediate_mark: true, lazy_sweep: false) }
+elsif
+ GC.start
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ long_lived[0] = short_lived # write barrier
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_gc_wb_obj.rb b/bench/mri/bm_vm1_gc_wb_obj.rb
new file mode 100644
index 00000000000..a4067af36bd
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_wb_obj.rb
@@ -0,0 +1,15 @@
+class C
+ attr_accessor :foo
+end
+short_lived_obj = C.new
+
+if RUBY_VERSION >= "2.2.0"
+ GC.start(full_mark: false, immediate_mark: true, lazy_sweep: false)
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ short_lived_obj.foo = short_lived # write barrier
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_gc_wb_obj_promoted.rb b/bench/mri/bm_vm1_gc_wb_obj_promoted.rb
new file mode 100644
index 00000000000..eee07a0248c
--- /dev/null
+++ b/bench/mri/bm_vm1_gc_wb_obj_promoted.rb
@@ -0,0 +1,17 @@
+class C
+ attr_accessor :foo
+end
+long_lived = C.new
+
+if RUBY_VERSION >= "2.2.0"
+ 3.times{ GC.start(full_mark: false, immediate_mark: true, lazy_sweep: false) }
+elsif
+ GC.start
+end
+
+i = 0
+short_lived = ''
+while i<30_000_000 # while loop 1
+ long_lived.foo = short_lived # write barrier
+ i+=1
+end
diff --git a/bench/mri/bm_vm1_ivar.rb b/bench/mri/bm_vm1_ivar.rb
new file mode 100644
index 00000000000..68a73cf92fa
--- /dev/null
+++ b/bench/mri/bm_vm1_ivar.rb
@@ -0,0 +1,8 @@
+@a = 1
+
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ j = @a
+ k = @a
+end
diff --git a/bench/yarv/bm_vm1_ivar_set.rb b/bench/mri/bm_vm1_ivar_set.rb
similarity index 81%
rename from bench/yarv/bm_vm1_ivar_set.rb
rename to bench/mri/bm_vm1_ivar_set.rb
index 023e397e922..bd81b06c34f 100644
--- a/bench/yarv/bm_vm1_ivar_set.rb
+++ b/bench/mri/bm_vm1_ivar_set.rb
@@ -1,6 +1,6 @@
-i = 0
-while i<30_000_000 # while loop 1
- i+= 1
- @a = 1
- @b = 2
-end
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ @a = 1
+ @b = 2
+end
diff --git a/bench/yarv/bm_vm1_length.rb b/bench/mri/bm_vm1_length.rb
similarity index 51%
rename from bench/yarv/bm_vm1_length.rb
rename to bench/mri/bm_vm1_length.rb
index 2d7d7f0b52d..353de3ab0ec 100644
--- a/bench/yarv/bm_vm1_length.rb
+++ b/bench/mri/bm_vm1_length.rb
@@ -1,8 +1,8 @@
a = 'abc'
b = [1, 2, 3]
-i=0
-while i<30000000 # while loop 1
- i+=1
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
a.length
b.length
end
diff --git a/bench/mri/bm_vm1_lvar_init.rb b/bench/mri/bm_vm1_lvar_init.rb
new file mode 100644
index 00000000000..36f2068811c
--- /dev/null
+++ b/bench/mri/bm_vm1_lvar_init.rb
@@ -0,0 +1,18 @@
+def m v
+ unless v
+ # unreachable code
+ v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v9 = v10 =
+ v11 = v12 = v13 = v14 = v15 = v16 = v17 = v18 = v19 = v20 =
+ v21 = v22 = v23 = v24 = v25 = v26 = v27 = v28 = v29 = v30 =
+ v31 = v32 = v33 = v34 = v35 = v36 = v37 = v38 = v39 = v40 =
+ v41 = v42 = v43 = v44 = v45 = v46 = v47 = v48 = v49 = v50 = 1
+ end
+end
+
+i = 0
+
+while i<30_000_000 # while loop 1
+ i += 1
+ m i
+end
+
diff --git a/bench/mri/bm_vm1_lvar_set.rb b/bench/mri/bm_vm1_lvar_set.rb
new file mode 100644
index 00000000000..222e8641343
--- /dev/null
+++ b/bench/mri/bm_vm1_lvar_set.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ a = b = c = d = e = f = g = h = j = k = l = m = n = o = p = q = r = 1
+end
diff --git a/bench/mri/bm_vm1_neq.rb b/bench/mri/bm_vm1_neq.rb
new file mode 100644
index 00000000000..bbb4ae07a46
--- /dev/null
+++ b/bench/mri/bm_vm1_neq.rb
@@ -0,0 +1,8 @@
+i = 0
+obj1 = Object.new
+obj2 = Object.new
+
+while i<30_000_000 # while loop 1
+ i += 1
+ obj1 != obj2
+end
diff --git a/bench/mri/bm_vm1_not.rb b/bench/mri/bm_vm1_not.rb
new file mode 100644
index 00000000000..b09ecdcc21f
--- /dev/null
+++ b/bench/mri/bm_vm1_not.rb
@@ -0,0 +1,7 @@
+i = 0
+obj = Object.new
+
+while i<30_000_000 # while loop 1
+ i += 1
+ !obj
+end
diff --git a/bench/mri/bm_vm1_rescue.rb b/bench/mri/bm_vm1_rescue.rb
new file mode 100644
index 00000000000..b0d3e2bdfab
--- /dev/null
+++ b/bench/mri/bm_vm1_rescue.rb
@@ -0,0 +1,7 @@
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ begin
+ rescue
+ end
+end
diff --git a/bench/mri/bm_vm1_simplereturn.rb b/bench/mri/bm_vm1_simplereturn.rb
new file mode 100644
index 00000000000..63f9f216752
--- /dev/null
+++ b/bench/mri/bm_vm1_simplereturn.rb
@@ -0,0 +1,9 @@
+def m
+ return 1
+end
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ m
+end
+
diff --git a/bench/mri/bm_vm1_swap.rb b/bench/mri/bm_vm1_swap.rb
new file mode 100644
index 00000000000..918f8b2112a
--- /dev/null
+++ b/bench/mri/bm_vm1_swap.rb
@@ -0,0 +1,8 @@
+a = 1
+b = 2
+i = 0
+while i<30_000_000 # while loop 1
+ i += 1
+ a, b = b, a
+end
+
diff --git a/bench/mri/bm_vm1_yield.rb b/bench/mri/bm_vm1_yield.rb
new file mode 100644
index 00000000000..775597cea64
--- /dev/null
+++ b/bench/mri/bm_vm1_yield.rb
@@ -0,0 +1,10 @@
+def m
+ i = 0
+ while i<30_000_000 # while loop 1
+ i += 1
+ yield
+ end
+end
+
+m{}
+
diff --git a/bench/mri/bm_vm2_array.rb b/bench/mri/bm_vm2_array.rb
new file mode 100644
index 00000000000..df9037c83ce
--- /dev/null
+++ b/bench/mri/bm_vm2_array.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ a = [1,2,3,4,5,6,7,8,9,10]
+end
diff --git a/bench/mri/bm_vm2_bigarray.rb b/bench/mri/bm_vm2_bigarray.rb
new file mode 100644
index 00000000000..b02509d6a2c
--- /dev/null
+++ b/bench/mri/bm_vm2_bigarray.rb
@@ -0,0 +1,106 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ a = [
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ 1,2,3,4,5,6,7,8,9,10,
+ ]
+end
diff --git a/bench/mri/bm_vm2_bighash.rb b/bench/mri/bm_vm2_bighash.rb
new file mode 100644
index 00000000000..5e3f437bb8a
--- /dev/null
+++ b/bench/mri/bm_vm2_bighash.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<60_000 # benchmark loop 2
+ i += 1
+ a = {0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9, 10=>10, 11=>11, 12=>12, 13=>13, 14=>14, 15=>15, 16=>16, 17=>17, 18=>18, 19=>19, 20=>20, 21=>21, 22=>22, 23=>23, 24=>24, 25=>25, 26=>26, 27=>27, 28=>28, 29=>29, 30=>30, 31=>31, 32=>32, 33=>33, 34=>34, 35=>35, 36=>36, 37=>37, 38=>38, 39=>39, 40=>40, 41=>41, 42=>42, 43=>43, 44=>44, 45=>45, 46=>46, 47=>47, 48=>48, 49=>49, 50=>50, 51=>51, 52=>52, 53=>53, 54=>54, 55=>55, 56=>56, 57=>57, 58=>58, 59=>59, 60=>60, 61=>61, 62=>62, 63=>63, 64=>64, 65=>65, 66=>66, 67=>67, 68=>68, 69=>69, 70=>70, 71=>71, 72=>72, 73=>73, 74=>74, 75=>75, 76=>76, 77=>77, 78=>78, 79=>79, 80=>80, 81=>81, 82=>82, 83=>83, 84=>84, 85=>85, 86=>86, 87=>87, 88=>88, 89=>89, 90=>90, 91=>91, 92=>92, 93=>93, 94=>94, 95=>95, 96=>96, 97=>97, 98=>98, 99=>99, 100=>100, 101=>101, 102=>102, 103=>103, 104=>104, 105=>105, 106=>106, 107=>107, 108=>108, 109=>109, 110=>110, 111=>111, 112=>112, 113=>113, 114=>114, 115=>115, 116=>116, 117=>117, 118=>118, 119=>119, 120=>120, 121=>121, 122=>122, 123=>123, 124=>124, 125=>125, 126=>126, 127=>127, 128=>128, 129=>129, 130=>130, 131=>131, 132=>132, 133=>133, 134=>134, 135=>135, 136=>136, 137=>137, 138=>138, 139=>139, 140=>140, 141=>141, 142=>142, 143=>143, 144=>144, 145=>145, 146=>146, 147=>147, 148=>148, 149=>149, 150=>150, 151=>151, 152=>152, 153=>153, 154=>154, 155=>155, 156=>156, 157=>157, 158=>158, 159=>159, 160=>160, 161=>161, 162=>162, 163=>163, 164=>164, 165=>165, 166=>166, 167=>167, 168=>168, 169=>169, 170=>170, 171=>171, 172=>172, 173=>173, 174=>174, 175=>175, 176=>176, 177=>177, 178=>178, 179=>179, 180=>180, 181=>181, 182=>182, 183=>183, 184=>184, 185=>185, 186=>186, 187=>187, 188=>188, 189=>189, 190=>190, 191=>191, 192=>192, 193=>193, 194=>194, 195=>195, 196=>196, 197=>197, 198=>198, 199=>199, 200=>200, 201=>201, 202=>202, 203=>203, 204=>204, 205=>205, 206=>206, 207=>207, 208=>208, 209=>209, 210=>210, 211=>211, 212=>212, 213=>213, 214=>214, 215=>215, 216=>216, 217=>217, 218=>218, 219=>219, 220=>220, 221=>221, 222=>222, 223=>223, 224=>224, 225=>225, 226=>226, 227=>227, 228=>228, 229=>229, 230=>230, 231=>231, 232=>232, 233=>233, 234=>234, 235=>235, 236=>236, 237=>237, 238=>238, 239=>239, 240=>240, 241=>241, 242=>242, 243=>243, 244=>244, 245=>245, 246=>246, 247=>247, 248=>248, 249=>249, 250=>250, 251=>251, 252=>252, 253=>253, 254=>254, 255=>255, 256=>256, 257=>257, 258=>258, 259=>259, 260=>260, 261=>261, 262=>262, 263=>263, 264=>264, 265=>265, 266=>266, 267=>267, 268=>268, 269=>269, 270=>270, 271=>271, 272=>272, 273=>273, 274=>274, 275=>275, 276=>276, 277=>277, 278=>278, 279=>279, 280=>280, 281=>281, 282=>282, 283=>283, 284=>284, 285=>285, 286=>286, 287=>287, 288=>288, 289=>289, 290=>290, 291=>291, 292=>292, 293=>293, 294=>294, 295=>295, 296=>296, 297=>297, 298=>298, 299=>299, 300=>300, 301=>301, 302=>302, 303=>303, 304=>304, 305=>305, 306=>306, 307=>307, 308=>308, 309=>309, 310=>310, 311=>311, 312=>312, 313=>313, 314=>314, 315=>315, 316=>316, 317=>317, 318=>318, 319=>319, 320=>320, 321=>321, 322=>322, 323=>323, 324=>324, 325=>325, 326=>326, 327=>327, 328=>328, 329=>329, 330=>330, 331=>331, 332=>332, 333=>333, 334=>334, 335=>335, 336=>336, 337=>337, 338=>338, 339=>339, 340=>340, 341=>341, 342=>342, 343=>343, 344=>344, 345=>345, 346=>346, 347=>347, 348=>348, 349=>349, 350=>350, 351=>351, 352=>352, 353=>353, 354=>354, 355=>355, 356=>356, 357=>357, 358=>358, 359=>359, 360=>360, 361=>361, 362=>362, 363=>363, 364=>364, 365=>365, 366=>366, 367=>367, 368=>368, 369=>369, 370=>370, 371=>371, 372=>372, 373=>373, 374=>374, 375=>375, 376=>376, 377=>377, 378=>378, 379=>379, 380=>380, 381=>381, 382=>382, 383=>383, 384=>384, 385=>385, 386=>386, 387=>387, 388=>388, 389=>389, 390=>390, 391=>391, 392=>392, 393=>393, 394=>394, 395=>395, 396=>396, 397=>397, 398=>398, 399=>399, 400=>400, 401=>401, 402=>402, 403=>403, 404=>404, 405=>405, 406=>406, 407=>407, 408=>408, 409=>409, 410=>410, 411=>411, 412=>412, 413=>413, 414=>414, 415=>415, 416=>416, 417=>417, 418=>418, 419=>419, 420=>420, 421=>421, 422=>422, 423=>423, 424=>424, 425=>425, 426=>426, 427=>427, 428=>428, 429=>429, 430=>430, 431=>431, 432=>432, 433=>433, 434=>434, 435=>435, 436=>436, 437=>437, 438=>438, 439=>439, 440=>440, 441=>441, 442=>442, 443=>443, 444=>444, 445=>445, 446=>446, 447=>447, 448=>448, 449=>449, 450=>450, 451=>451, 452=>452, 453=>453, 454=>454, 455=>455, 456=>456, 457=>457, 458=>458, 459=>459, 460=>460, 461=>461, 462=>462, 463=>463, 464=>464, 465=>465, 466=>466, 467=>467, 468=>468, 469=>469, 470=>470, 471=>471, 472=>472, 473=>473, 474=>474, 475=>475, 476=>476, 477=>477, 478=>478, 479=>479, 480=>480, 481=>481, 482=>482, 483=>483, 484=>484, 485=>485, 486=>486, 487=>487, 488=>488, 489=>489, 490=>490, 491=>491, 492=>492, 493=>493, 494=>494, 495=>495, 496=>496, 497=>497, 498=>498, 499=>499, 500=>500,}
+end
diff --git a/bench/yarv/bm_vm2_case.rb b/bench/mri/bm_vm2_case.rb
similarity index 66%
rename from bench/yarv/bm_vm2_case.rb
rename to bench/mri/bm_vm2_case.rb
index 1ec34ad6925..adc6e4df0a9 100644
--- a/bench/yarv/bm_vm2_case.rb
+++ b/bench/mri/bm_vm2_case.rb
@@ -1,5 +1,5 @@
-i=0
-while i<6000000 # while loop 2
+i = 0
+while i<6_000_000 # while loop 2
case :foo
when :bar
raise
@@ -8,7 +8,7 @@
when :boo
raise
when :foo
- i+=1
+ i += 1
end
end
diff --git a/bench/mri/bm_vm2_case_lit.rb b/bench/mri/bm_vm2_case_lit.rb
new file mode 100644
index 00000000000..c62b294e0e5
--- /dev/null
+++ b/bench/mri/bm_vm2_case_lit.rb
@@ -0,0 +1,19 @@
+i = 0
+@ret = [ "foo", true, false, :sym, 6, nil, 0.1, 0xffffffffffffffff ]
+def foo(i)
+ @ret[i % @ret.size]
+end
+
+while i<6_000_000 # while loop 2
+ case foo(i)
+ when "foo" then :foo
+ when true then true
+ when false then false
+ when :sym then :sym
+ when 6 then :fix
+ when nil then nil
+ when 0.1 then :float
+ when 0xffffffffffffffff then :big
+ end
+ i += 1
+end
diff --git a/bench/mri/bm_vm2_defined_method.rb b/bench/mri/bm_vm2_defined_method.rb
new file mode 100644
index 00000000000..053ed6c9129
--- /dev/null
+++ b/bench/mri/bm_vm2_defined_method.rb
@@ -0,0 +1,9 @@
+class Object
+ define_method(:m){}
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m; m; m; m; m; m; m; m;
+end
diff --git a/bench/mri/bm_vm2_dstr.rb b/bench/mri/bm_vm2_dstr.rb
new file mode 100644
index 00000000000..58c0f7bbc3d
--- /dev/null
+++ b/bench/mri/bm_vm2_dstr.rb
@@ -0,0 +1,6 @@
+i = 0
+x = y = 'z'
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ str = "foo#{x}bar#{y}baz"
+end
diff --git a/bench/mri/bm_vm2_eval.rb b/bench/mri/bm_vm2_eval.rb
new file mode 100644
index 00000000000..307cfc28efe
--- /dev/null
+++ b/bench/mri/bm_vm2_eval.rb
@@ -0,0 +1,6 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ eval("1")
+end
+
diff --git a/bench/mri/bm_vm2_method.rb b/bench/mri/bm_vm2_method.rb
new file mode 100644
index 00000000000..a8ccff7138d
--- /dev/null
+++ b/bench/mri/bm_vm2_method.rb
@@ -0,0 +1,9 @@
+def m
+ nil
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m; m; m; m; m; m; m; m;
+end
diff --git a/bench/mri/bm_vm2_method_missing.rb b/bench/mri/bm_vm2_method_missing.rb
new file mode 100644
index 00000000000..2badc73101a
--- /dev/null
+++ b/bench/mri/bm_vm2_method_missing.rb
@@ -0,0 +1,12 @@
+class C
+ def method_missing mid
+ end
+end
+
+obj = C.new
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ obj.m; obj.m; obj.m; obj.m; obj.m; obj.m; obj.m; obj.m;
+end
diff --git a/bench/mri/bm_vm2_method_with_block.rb b/bench/mri/bm_vm2_method_with_block.rb
new file mode 100644
index 00000000000..b4efb4f5207
--- /dev/null
+++ b/bench/mri/bm_vm2_method_with_block.rb
@@ -0,0 +1,9 @@
+def m
+ nil
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m{}; m{}; m{}; m{}; m{}; m{}; m{}; m{};
+end
diff --git a/bench/yarv/bm_vm2_mutex.rb b/bench/mri/bm_vm2_mutex.rb
similarity index 51%
rename from bench/yarv/bm_vm2_mutex.rb
rename to bench/mri/bm_vm2_mutex.rb
index 9ec1a0f1368..7362f738c59 100644
--- a/bench/yarv/bm_vm2_mutex.rb
+++ b/bench/mri/bm_vm2_mutex.rb
@@ -2,8 +2,8 @@
m = Mutex.new
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
m.synchronize{}
end
diff --git a/bench/mri/bm_vm2_newlambda.rb b/bench/mri/bm_vm2_newlambda.rb
new file mode 100644
index 00000000000..6422c9b0d09
--- /dev/null
+++ b/bench/mri/bm_vm2_newlambda.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ lambda {}
+end
diff --git a/bench/yarv/bm_vm2_poly_method.rb b/bench/mri/bm_vm2_poly_method.rb
similarity index 76%
rename from bench/yarv/bm_vm2_poly_method.rb
rename to bench/mri/bm_vm2_poly_method.rb
index ac9953ce5f4..c82c0e4bce3 100644
--- a/bench/yarv/bm_vm2_poly_method.rb
+++ b/bench/mri/bm_vm2_poly_method.rb
@@ -12,9 +12,9 @@ def m
o1 = C1.new
o2 = C2.new
-i=0
-while i<6000000 # benchmark loop 2
+i = 0
+while i<6_000_000 # benchmark loop 2
o = (i % 2 == 0) ? o1 : o2
o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i+=1
+ i += 1
end
diff --git a/bench/yarv/bm_vm2_poly_method_ov.rb b/bench/mri/bm_vm2_poly_method_ov.rb
similarity index 76%
rename from bench/yarv/bm_vm2_poly_method_ov.rb
rename to bench/mri/bm_vm2_poly_method_ov.rb
index 856ba9b1616..aa5fd1dd386 100644
--- a/bench/yarv/bm_vm2_poly_method_ov.rb
+++ b/bench/mri/bm_vm2_poly_method_ov.rb
@@ -12,9 +12,9 @@ def m
o1 = C1.new
o2 = C2.new
-i=0
-while i<6000000 # benchmark loop 2
+i = 0
+while i<6_000_000 # benchmark loop 2
o = (i % 2 == 0) ? o1 : o2
# o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i+=1
+ i += 1
end
diff --git a/bench/yarv/bm_vm2_proc.rb b/bench/mri/bm_vm2_proc.rb
similarity index 50%
rename from bench/yarv/bm_vm2_proc.rb
rename to bench/mri/bm_vm2_proc.rb
index 0bd05b9544c..65e52173717 100644
--- a/bench/yarv/bm_vm2_proc.rb
+++ b/bench/mri/bm_vm2_proc.rb
@@ -6,9 +6,9 @@ def m &b
a = 1
}
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
pr.call
end
diff --git a/bench/mri/bm_vm2_raise1.rb b/bench/mri/bm_vm2_raise1.rb
new file mode 100644
index 00000000000..aa5387987fc
--- /dev/null
+++ b/bench/mri/bm_vm2_raise1.rb
@@ -0,0 +1,18 @@
+def rec n
+ if n > 0
+ rec n-1
+ else
+ raise
+ end
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+
+ begin
+ rec 1
+ rescue
+ # ignore
+ end
+end
diff --git a/bench/mri/bm_vm2_raise2.rb b/bench/mri/bm_vm2_raise2.rb
new file mode 100644
index 00000000000..1f61c631579
--- /dev/null
+++ b/bench/mri/bm_vm2_raise2.rb
@@ -0,0 +1,18 @@
+def rec n
+ if n > 0
+ rec n-1
+ else
+ raise
+ end
+end
+
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+
+ begin
+ rec 10
+ rescue
+ # ignore
+ end
+end
diff --git a/bench/mri/bm_vm2_regexp.rb b/bench/mri/bm_vm2_regexp.rb
new file mode 100644
index 00000000000..55f9e957a36
--- /dev/null
+++ b/bench/mri/bm_vm2_regexp.rb
@@ -0,0 +1,6 @@
+i = 0
+str = 'xxxhogexxx'
+while i<6_000_000 # benchmark loop 2
+ /hoge/ =~ str
+ i += 1
+end
diff --git a/bench/yarv/bm_vm2_send.rb b/bench/mri/bm_vm2_send.rb
similarity index 52%
rename from bench/yarv/bm_vm2_send.rb
rename to bench/mri/bm_vm2_send.rb
index c20dbdd26cb..6a3ab6fdabc 100644
--- a/bench/yarv/bm_vm2_send.rb
+++ b/bench/mri/bm_vm2_send.rb
@@ -5,8 +5,8 @@ def m
o = C.new
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
o.__send__ :m
end
diff --git a/bench/mri/bm_vm2_string_literal.rb b/bench/mri/bm_vm2_string_literal.rb
new file mode 100644
index 00000000000..1d730368497
--- /dev/null
+++ b/bench/mri/bm_vm2_string_literal.rb
@@ -0,0 +1,5 @@
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+end
diff --git a/bench/mri/bm_vm2_struct_big_aref_hi.rb b/bench/mri/bm_vm2_struct_big_aref_hi.rb
new file mode 100644
index 00000000000..22cb26b0a53
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_big_aref_hi.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.z # x[25]
+end
diff --git a/bench/mri/bm_vm2_struct_big_aref_lo.rb b/bench/mri/bm_vm2_struct_big_aref_lo.rb
new file mode 100644
index 00000000000..5e61a7087e4
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_big_aref_lo.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.k # x[10]
+end
diff --git a/bench/mri/bm_vm2_struct_big_aset.rb b/bench/mri/bm_vm2_struct_big_aset.rb
new file mode 100644
index 00000000000..5a1c3d16f30
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_big_aset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.k = i # x[10] = i
+end
diff --git a/bench/mri/bm_vm2_struct_big_href_hi.rb b/bench/mri/bm_vm2_struct_big_href_hi.rb
new file mode 100644
index 00000000000..fff940a80a6
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_big_href_hi.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:z]
+end
diff --git a/bench/mri/bm_vm2_struct_big_href_lo.rb b/bench/mri/bm_vm2_struct_big_href_lo.rb
new file mode 100644
index 00000000000..5e4085d59d1
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_big_href_lo.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:k]
+end
diff --git a/bench/mri/bm_vm2_struct_big_hset.rb b/bench/mri/bm_vm2_struct_big_hset.rb
new file mode 100644
index 00000000000..9c0cee41413
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_big_hset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(*('a'..'z').map { |x| x.to_sym })
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:k] = i
+end
diff --git a/bench/mri/bm_vm2_struct_small_aref.rb b/bench/mri/bm_vm2_struct_small_aref.rb
new file mode 100644
index 00000000000..8eaa555b416
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_small_aref.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.a
+end
diff --git a/bench/mri/bm_vm2_struct_small_aset.rb b/bench/mri/bm_vm2_struct_small_aset.rb
new file mode 100644
index 00000000000..ecd0f95669c
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_small_aset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x.a = i
+end
diff --git a/bench/mri/bm_vm2_struct_small_href.rb b/bench/mri/bm_vm2_struct_small_href.rb
new file mode 100644
index 00000000000..2c88fee6bf2
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_small_href.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:a]
+end
diff --git a/bench/mri/bm_vm2_struct_small_hset.rb b/bench/mri/bm_vm2_struct_small_hset.rb
new file mode 100644
index 00000000000..33c36d20f13
--- /dev/null
+++ b/bench/mri/bm_vm2_struct_small_hset.rb
@@ -0,0 +1,7 @@
+s = Struct.new(:a, :b, :c)
+x = s.new
+i = 0
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ x[:a] = 1
+end
diff --git a/bench/yarv/bm_vm2_super.rb b/bench/mri/bm_vm2_super.rb
similarity index 70%
rename from bench/yarv/bm_vm2_super.rb
rename to bench/mri/bm_vm2_super.rb
index 70c86b376f7..afd8579e7b3 100644
--- a/bench/yarv/bm_vm2_super.rb
+++ b/bench/mri/bm_vm2_super.rb
@@ -14,7 +14,7 @@ def m
obj = CC.new
i = 0
-while i<6000000 # benchmark loop 2
+while i<6_000_000 # benchmark loop 2
obj.m
- i+=1
+ i += 1
end
diff --git a/bench/mri/bm_vm2_unif1.rb b/bench/mri/bm_vm2_unif1.rb
new file mode 100644
index 00000000000..1774625942d
--- /dev/null
+++ b/bench/mri/bm_vm2_unif1.rb
@@ -0,0 +1,8 @@
+i = 0
+def m a, b
+end
+
+while i<6_000_000 # benchmark loop 2
+ i += 1
+ m 100, 200
+end
diff --git a/bench/yarv/bm_vm2_zsuper.rb b/bench/mri/bm_vm2_zsuper.rb
similarity index 71%
rename from bench/yarv/bm_vm2_zsuper.rb
rename to bench/mri/bm_vm2_zsuper.rb
index 3a759604030..2a43e62217c 100644
--- a/bench/yarv/bm_vm2_zsuper.rb
+++ b/bench/mri/bm_vm2_zsuper.rb
@@ -14,7 +14,7 @@ def m a
obj = CC.new
-while i<6000000 # benchmark loop 2
+while i<6_000_000 # benchmark loop 2
obj.m 10
- i+=1
+ i += 1
end
diff --git a/bench/mri/bm_vm3_backtrace.rb b/bench/mri/bm_vm3_backtrace.rb
new file mode 100644
index 00000000000..0fbf73e1cae
--- /dev/null
+++ b/bench/mri/bm_vm3_backtrace.rb
@@ -0,0 +1,22 @@
+# get last backtrace
+
+begin
+ caller(0, 0)
+rescue ArgumentError
+ alias caller_orig caller
+ def caller lev, n
+ caller_orig(lev)[0..n]
+ end
+end
+
+def rec n
+ if n < 0
+ 100_000.times{
+ caller(0, 1)
+ }
+ else
+ rec(n-1)
+ end
+end
+
+rec 50
diff --git a/bench/mri/bm_vm3_clearmethodcache.rb b/bench/mri/bm_vm3_clearmethodcache.rb
new file mode 100644
index 00000000000..9661323cd2c
--- /dev/null
+++ b/bench/mri/bm_vm3_clearmethodcache.rb
@@ -0,0 +1,8 @@
+i = 0
+while i<200_000
+ i += 1
+
+ Class.new{
+ def m; end
+ }
+end
diff --git a/bench/mri/bm_vm3_gc.rb b/bench/mri/bm_vm3_gc.rb
new file mode 100644
index 00000000000..e668026915a
--- /dev/null
+++ b/bench/mri/bm_vm3_gc.rb
@@ -0,0 +1,6 @@
+5000.times do
+ 100.times do
+ {"xxxx"=>"yyyy"}
+ end
+ GC.start
+end
diff --git a/bench/mri/bm_vm3_gc_old_full.rb b/bench/mri/bm_vm3_gc_old_full.rb
new file mode 100644
index 00000000000..cfdfc8c5a5e
--- /dev/null
+++ b/bench/mri/bm_vm3_gc_old_full.rb
@@ -0,0 +1,4 @@
+old_object = Array.new(1_000_000){''}
+100.times do
+ GC.start
+end
diff --git a/bench/mri/bm_vm3_gc_old_immediate.rb b/bench/mri/bm_vm3_gc_old_immediate.rb
new file mode 100644
index 00000000000..ad22feb6556
--- /dev/null
+++ b/bench/mri/bm_vm3_gc_old_immediate.rb
@@ -0,0 +1,4 @@
+old_object = Array.new(1_000_000){''}
+30_000.times do
+ GC.start(full_mark: false, immediate_sweep: true)
+end
diff --git a/bench/mri/bm_vm3_gc_old_lazy.rb b/bench/mri/bm_vm3_gc_old_lazy.rb
new file mode 100644
index 00000000000..b74d44baf12
--- /dev/null
+++ b/bench/mri/bm_vm3_gc_old_lazy.rb
@@ -0,0 +1,4 @@
+old_object = Array.new(1_000_000){''}
+30_000.times do
+ GC.start(full_mark: false, immediate_sweep: false)
+end
diff --git a/bench/yarv/bm_vm3_thread_create_join.rb b/bench/mri/bm_vm3_thread_create_join.rb
similarity index 100%
rename from bench/yarv/bm_vm3_thread_create_join.rb
rename to bench/mri/bm_vm3_thread_create_join.rb
diff --git a/bench/yarv/bm_vm3_thread_mutex.rb b/bench/mri/bm_vm3_thread_mutex.rb
similarity index 100%
rename from bench/yarv/bm_vm3_thread_mutex.rb
rename to bench/mri/bm_vm3_thread_mutex.rb
diff --git a/bench/mri/bm_vm_symbol_block_pass.rb b/bench/mri/bm_vm_symbol_block_pass.rb
new file mode 100644
index 00000000000..1d433353e1f
--- /dev/null
+++ b/bench/mri/bm_vm_symbol_block_pass.rb
@@ -0,0 +1,13 @@
+class C
+ 1000.times {|i|
+ eval("def i#{i};end")
+ }
+end
+
+c = C.new
+m = C.instance_methods(false)
+5_000.times do
+ m.each do |n|
+ c.tap(&n)
+ end
+end
diff --git a/bench/mri/bm_vm_thread_alive_check1.rb b/bench/mri/bm_vm_thread_alive_check1.rb
new file mode 100644
index 00000000000..c993accddaa
--- /dev/null
+++ b/bench/mri/bm_vm_thread_alive_check1.rb
@@ -0,0 +1,6 @@
+5_000.times{
+ t = Thread.new{}
+ while t.alive?
+ Thread.pass
+ end
+}
diff --git a/bench/mri/bm_vm_thread_close.rb b/bench/mri/bm_vm_thread_close.rb
new file mode 100644
index 00000000000..3e9a265ce8c
--- /dev/null
+++ b/bench/mri/bm_vm_thread_close.rb
@@ -0,0 +1,6 @@
+1000.times { Thread.new { sleep } }
+i = 0
+while i<100_000 # benchmark loop 3
+ i += 1
+ IO.pipe.each(&:close)
+end
diff --git a/bench/mri/bm_vm_thread_create_join.rb b/bench/mri/bm_vm_thread_create_join.rb
new file mode 100644
index 00000000000..393cd45df95
--- /dev/null
+++ b/bench/mri/bm_vm_thread_create_join.rb
@@ -0,0 +1,6 @@
+i = 0
+while i<100_000 # benchmark loop 3
+ i += 1
+ Thread.new{
+ }.join
+end
diff --git a/bench/mri/bm_vm_thread_mutex1.rb b/bench/mri/bm_vm_thread_mutex1.rb
new file mode 100644
index 00000000000..5c9f85dfb7c
--- /dev/null
+++ b/bench/mri/bm_vm_thread_mutex1.rb
@@ -0,0 +1,21 @@
+# one thread, one mutex (no contention)
+
+require 'thread'
+m = Mutex.new
+r = 0
+max = 2000
+lmax = max * max
+(1..1).map{
+ Thread.new{
+ i = 0
+ while i 1
+ output "minimum results in each #{@repeat} measurements."
+ end
+
+ output({
+ real: "Execution time (sec)",
+ peak: "Memory usage (peak) (B)",
+ size: "Memory usage (last size) (B)",
+ }[@measure_target])
+ output if markdown
+ output ["name".ljust(name_width), @execs.map.with_index{|(_, v), i| sprintf(strformat, v, width[i])}].join("").rstrip
+ output ["-"*name_width, width.map{|n|":".rjust(n, "-")}].join("|") if markdown
+ @results.each{|v, result|
+ rets = []
+ s = adjusted_results(v, result){|r|
+ rets << sprintf(numformat, r, width[rets.size])
+ }
+ v += s if s
+ output [v.ljust(name_width), rets].join("")
+ }
+
+ if @execs.size > 1
+ output
+ output({
+ real: "Speedup ratio: compare with the result of `#{@execs[0][1]}' (greater is better)",
+ peak: "Memory consuming ratio (peak) with the result of `#{@execs[0][1]}' (greater is better)",
+ size: "Memory consuming ratio (size) with the result of `#{@execs[0][1]}' (greater is better)",
+ }[@measure_target])
+ output if markdown
+ output ["name".ljust(name_width), @execs[1..-1].map.with_index{|(_, v), i| sprintf(strformat, v, width[i])}].join("").rstrip
+ output ["-"*name_width, width[1..-1].map{|n|":".rjust(n, "-")}].join("|") if markdown
+ @results.each{|v, result|
+ rets = []
+ first_value = nil
+ s = adjusted_results(v, result){|r|
+ if first_value
+ if r == 0
+ rets << "Error"
+ else
+ rets << sprintf(numformat, first_value/Float(r), width[rets.size+1])
+ end
+ else
+ first_value = r
+ end
+ }
+ v += s if s
+ output [v.ljust(name_width), rets].join("")
+ }
+ end
+
+ if @opt[:output]
+ output
+ output "Log file: #{@opt[:output]}"
+ end
+ end
+
+ def files
+ flag = {}
+ @files = Dir.glob(File.join(@dir, 'bm*.rb')).map{|file|
+ next if @pattern && /#{@pattern}/ !~ File.basename(file)
+ next if @exclude && /#{@exclude}/ =~ File.basename(file)
+ case file
+ when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/
+ flag[$1] = true
+ end
+ file
+ }.compact
+
+ if flag['vm1'] && !flag['whileloop']
+ @files << File.join(@dir, 'bm_loop_whileloop.rb')
+ elsif flag['vm2'] && !flag['whileloop2']
+ @files << File.join(@dir, 'bm_loop_whileloop2.rb')
+ end
+
+ @files.sort!
+ progress_message "total: #{@files.size * @repeat} trial(s) (#{@repeat} trial(s) for #{@files.size} benchmark(s))\n"
+ @files
+ end
+
+ def run
+ files.each_with_index{|file, i|
+ @i = i
+ r = measure_file(file)
+
+ if /bm_loop_whileloop.rb/ =~ file
+ @loop_wl1 = r[1].map{|e| e.min}
+ elsif /bm_loop_whileloop2.rb/ =~ file
+ @loop_wl2 = r[1].map{|e| e.min}
+ end
+ }
+ end
+
+ def measure_file file
+ name = File.basename(file, '.rb').sub(/^bm_/, '')
+ prepare_file = File.join(File.dirname(file), "prepare_#{name}.rb")
+ load prepare_file if FileTest.exist?(prepare_file)
+
+ if @verbose
+ output
+ output '-----------------------------------------------------------'
+ output name
+ output
+ output File.read(file)
+ output
+ end
+
+ result = [name]
+ result << @execs.map{|(e, v)|
+ (0...@repeat).map{
+ message_print "#{v}\t"
+ progress_message '.'
+
+ m = measure(e, file)
+ message "#{m}"
+ m
+ }
+ }
+ @results << result
+ result
+ end
+
+ unless defined?(File::NULL)
+ if File.exist?('/dev/null')
+ File::NULL = '/dev/null'
+ end
+ end
+
+ def measure executable, file
+ case @measure_target
+ when :real
+ cmd = "#{executable} #{@ruby_arg} #{file}"
+ m = Benchmark.measure{
+ system(cmd, out: File::NULL)
+ }
+ result = m.real
+ when :peak, :size
+ tmp = Tempfile.new("benchmark-memory-wrapper-data")
+ wrapper = "#{File.join(__dir__, 'memory_wrapper.rb')} #{tmp.path} #{@measure_target}"
+ cmd = "#{executable} #{@ruby_arg} #{wrapper} #{file}"
+ system(cmd, out: File::NULL)
+ result = tmp.read.to_i
+ tmp.close
+ else
+ raise "unknown measure target"
+ end
+
+ if $? != 0
+ raise $?.inspect if $? && $?.signaled?
+ output "\`#{cmd}\' exited with abnormal status (#{$?})"
+ 0
+ else
+ result
+ end
+ end
+end
+
+if __FILE__ == $0
+ opt = {
+ :execs => [],
+ :dir => File.dirname(__FILE__),
+ :repeat => 1,
+ :measure_target => :real,
+ :output => nil,
+ :raw_output => nil,
+ :format => :tsv,
+ }
+ formats = {
+ :tsv => ".tsv",
+ :markdown => ".md",
+ :plain => ".txt",
+ }
+
+ parser = OptionParser.new{|o|
+ o.on('-e', '--executables [EXECS]',
+ "Specify benchmark one or more targets (e1::path1; e2::path2; e3::path3;...)"){|e|
+ e.split(/;/).each{|path|
+ opt[:execs] << path
+ }
+ }
+ o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d|
+ opt[:dir] = d
+ }
+ o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p|
+ opt[:pattern] = p
+ }
+ o.on('-x', '--exclude [PATTERN]', "Benchmark exclude pattern"){|e|
+ opt[:exclude] = e
+ }
+ o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n|
+ opt[:repeat] = n.to_i
+ }
+ o.on('-o', '--output-file [FILE]', "Output file"){|f|
+ opt[:output] = f
+ }
+ o.on('--ruby-arg [ARG]', "Optional argument for ruby"){|a|
+ opt[:ruby_arg] = a
+ }
+ o.on('--measure-target [TARGET]', 'real (execution time), peak, size (memory)'){|mt|
+ opt[:measure_target] = mt.to_sym
+ }
+ o.on('--rawdata-output [FILE]', 'output rawdata'){|r|
+ opt[:rawdata_output] = r
+ }
+ o.on('--load-rawdata=FILE', 'input rawdata'){|r|
+ opt[:rawdata_input] = r
+ }
+ o.on('-f', "--format=FORMAT", "output format (#{formats.keys.join(",")})", formats.keys){|r|
+ opt[:format] = r
+ }
+ o.on('-v', '--verbose'){|v|
+ opt[:verbose] = v
+ }
+ o.on('-q', '--quiet', "Run without notify information except result table."){|q|
+ opt[:quiet] = q
+ opt[:verbose] = false
+ }
+ }
+
+ parser.parse!(ARGV)
+ opt[:output] ||= "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}#{formats[opt[:format]]}"
+
+ if input = opt[:rawdata_input]
+ b = open(input) {|f|
+ BenchmarkDriver.load(f, File.extname(input)[1..-1], opt)
+ }
+ b.show_results
+ else
+ BenchmarkDriver.benchmark(opt)
+ end
+end
+
diff --git a/bench/mri/gc/aobench.rb b/bench/mri/gc/aobench.rb
new file mode 100644
index 00000000000..2eed7abc835
--- /dev/null
+++ b/bench/mri/gc/aobench.rb
@@ -0,0 +1 @@
+require_relative '../bm_app_aobench.rb'
diff --git a/bench/mri/gc/binary_trees.rb b/bench/mri/gc/binary_trees.rb
new file mode 100644
index 00000000000..af8ea722aa5
--- /dev/null
+++ b/bench/mri/gc/binary_trees.rb
@@ -0,0 +1 @@
+require_relative '../bm_so_binary_trees.rb'
diff --git a/bench/mri/gc/gcbench.rb b/bench/mri/gc/gcbench.rb
new file mode 100644
index 00000000000..09a404466a1
--- /dev/null
+++ b/bench/mri/gc/gcbench.rb
@@ -0,0 +1,56 @@
+require 'benchmark'
+require 'pp'
+require 'optparse'
+
+$list = true
+$gcprof = true
+
+opt = OptionParser.new
+opt.on('-q'){$list = false}
+opt.on('-d'){$gcprof = false}
+opt.parse!(ARGV)
+
+script = File.join(File.dirname(__FILE__), ARGV.shift)
+script += '.rb' unless FileTest.exist?(script)
+raise "#{script} not found" unless FileTest.exist?(script)
+
+puts "Script: #{script}"
+
+if $gcprof
+ GC::Profiler.enable
+end
+
+tms = Benchmark.measure{|x|
+ load script
+}
+
+gc_time = 0
+
+if $gcprof
+ gc_time = GC::Profiler.total_time
+ GC::Profiler.report if $list and RUBY_VERSION >= '2.0.0' # before 1.9.3, report() may run infinite loop
+ GC::Profiler.disable
+end
+
+pp GC.stat
+
+puts "#{RUBY_DESCRIPTION} #{GC::OPTS.inspect}" if defined?(GC::OPTS)
+
+desc = "#{RUBY_VERSION}#{RUBY_PATCHLEVEL >= 0 ? "p#{RUBY_PATCHLEVEL}" : "dev"}"
+name = File.basename(script, '.rb')
+
+puts
+puts script
+puts Benchmark::CAPTION
+puts tms
+puts "GC total time (sec): #{gc_time}"
+
+# show High-Water Mark on Linux
+if File.exist?('/proc/self/status') && /VmHWM:\s*(\d+.+)/ =~ File.read('/proc/self/status')
+ puts
+ puts "VmHWM: #{$1.chomp}"
+end
+
+puts
+puts "Summary of #{name} on #{desc}\t#{tms.real}\t#{gc_time}\t#{GC.count}"
+puts " (real time in sec, GC time in sec, GC count)"
diff --git a/bench/mri/gc/hash1.rb b/bench/mri/gc/hash1.rb
new file mode 100644
index 00000000000..cb030d458dd
--- /dev/null
+++ b/bench/mri/gc/hash1.rb
@@ -0,0 +1,11 @@
+value = 0.01
+h = {}
+n = 50_000
+
+1.upto(n){|i|
+ h["%020d" % i] = "v-#{i}"
+}
+
+(n * 1_000).times{
+ ''
+}
diff --git a/bench/mri/gc/hash2.rb b/bench/mri/gc/hash2.rb
new file mode 100644
index 00000000000..e8c943fb212
--- /dev/null
+++ b/bench/mri/gc/hash2.rb
@@ -0,0 +1,7 @@
+value = 0.01
+h = {}
+n = 4*(10**6)
+
+1.upto(n){|i|
+ h["%020d" % i] = value * i
+}
diff --git a/bench/mri/gc/null.rb b/bench/mri/gc/null.rb
new file mode 100644
index 00000000000..c05a79f5613
--- /dev/null
+++ b/bench/mri/gc/null.rb
@@ -0,0 +1 @@
+# null
diff --git a/bench/mri/gc/pentomino.rb b/bench/mri/gc/pentomino.rb
new file mode 100644
index 00000000000..94ba74be891
--- /dev/null
+++ b/bench/mri/gc/pentomino.rb
@@ -0,0 +1 @@
+require_relative '../bm_app_pentomino.rb'
diff --git a/bench/mri/gc/rdoc.rb b/bench/mri/gc/rdoc.rb
new file mode 100644
index 00000000000..14c89f5611e
--- /dev/null
+++ b/bench/mri/gc/rdoc.rb
@@ -0,0 +1,13 @@
+require 'rdoc/rdoc'
+require 'tmpdir'
+
+srcdir = File.expand_path('../..', __dir__)
+
+Dir.mktmpdir('rdocbench-'){|d|
+ dir = File.join(d, 'rdocbench')
+ args = %W(--root #{srcdir} --page-dir #{srcdir}/doc --encoding=UTF-8 --no-force-update --all --ri --debug --quiet #{srcdir})
+ args << '--op' << dir
+
+ r = RDoc::RDoc.new
+ r.document args
+}
diff --git a/bench/mri/gc/redblack.rb b/bench/mri/gc/redblack.rb
new file mode 100644
index 00000000000..c66290140a7
--- /dev/null
+++ b/bench/mri/gc/redblack.rb
@@ -0,0 +1,366 @@
+# This benchmark is imported from https://github.com/jruby/rubybench/blob/master/time/bench_red_black.rb
+# License is License is Apache-2
+
+require 'benchmark'
+
+# Algorithm based on "Introduction to Algorithms" by Cormen and others
+class RedBlackTree
+ class Node
+ attr_accessor :color
+ attr_accessor :key
+ attr_accessor :left
+ attr_accessor :right
+ attr_accessor :parent
+
+ RED = :red
+ BLACK = :black
+ COLORS = [RED, BLACK].freeze
+
+ def initialize(key, color = RED)
+ raise ArgumentError, "Bad value for color parameter" unless COLORS.include?(color)
+ @color = color
+ @key = key
+ @left = @right = @parent = NilNode.instance
+ end
+
+ def black?
+ return color == BLACK
+ end
+
+ def red?
+ return color == RED
+ end
+ end
+
+ class NilNode < Node
+ class << self
+ private :new
+
+ # it's not thread safe
+ def instance
+ @instance ||= begin
+ def instance
+ return @instance
+ end
+
+ new
+ end
+ end
+ end
+
+ def initialize
+ self.color = BLACK
+ self.key = 0
+ self.left = nil
+ self.right = nil
+ self.parent = nil
+ end
+
+ def nil?
+ return true
+ end
+ end
+
+ include Enumerable
+
+ attr_accessor :root
+ attr_accessor :size
+
+ def initialize
+ self.root = NilNode.instance
+ self.size = 0
+ end
+
+ def add(key)
+ insert(Node.new(key))
+ end
+
+ def insert(x)
+ insert_helper(x)
+
+ x.color = Node::RED
+ while x != root && x.parent.color == Node::RED
+ if x.parent == x.parent.parent.left
+ y = x.parent.parent.right
+ if !y.nil? && y.color == Node::RED
+ x.parent.color = Node::BLACK
+ y.color = Node::BLACK
+ x.parent.parent.color = Node::RED
+ x = x.parent.parent
+ else
+ if x == x.parent.right
+ x = x.parent
+ left_rotate(x)
+ end
+ x.parent.color = Node::BLACK
+ x.parent.parent.color = Node::RED
+ right_rotate(x.parent.parent)
+ end
+ else
+ y = x.parent.parent.left
+ if !y.nil? && y.color == Node::RED
+ x.parent.color = Node::BLACK
+ y.color = Node::BLACK
+ x.parent.parent.color = Node::RED
+ x = x.parent.parent
+ else
+ if x == x.parent.left
+ x = x.parent
+ right_rotate(x)
+ end
+ x.parent.color = Node::BLACK
+ x.parent.parent.color = Node::RED
+ left_rotate(x.parent.parent)
+ end
+ end
+ end
+ root.color = Node::BLACK
+ end
+
+ alias << insert
+
+ def delete(z)
+ y = (z.left.nil? || z.right.nil?) ? z : successor(z)
+ x = y.left.nil? ? y.right : y.left
+ x.parent = y.parent
+
+ if y.parent.nil?
+ self.root = x
+ else
+ if y == y.parent.left
+ y.parent.left = x
+ else
+ y.parent.right = x
+ end
+ end
+
+ z.key = y.key if y != z
+
+ if y.color == Node::BLACK
+ delete_fixup(x)
+ end
+
+ self.size -= 1
+ return y
+ end
+
+ def minimum(x = root)
+ while !x.left.nil?
+ x = x.left
+ end
+ return x
+ end
+
+ def maximum(x = root)
+ while !x.right.nil?
+ x = x.right
+ end
+ return x
+ end
+
+ def successor(x)
+ if !x.right.nil?
+ return minimum(x.right)
+ end
+ y = x.parent
+ while !y.nil? && x == y.right
+ x = y
+ y = y.parent
+ end
+ return y
+ end
+
+ def predecessor(x)
+ if !x.left.nil?
+ return maximum(x.left)
+ end
+ y = x.parent
+ while !y.nil? && x == y.left
+ x = y
+ y = y.parent
+ end
+ return y
+ end
+
+ def inorder_walk(x = root)
+ x = self.minimum
+ while !x.nil?
+ yield x.key
+ x = successor(x)
+ end
+ end
+
+ alias each inorder_walk
+
+ def reverse_inorder_walk(x = root)
+ x = self.maximum
+ while !x.nil?
+ yield x.key
+ x = predecessor(x)
+ end
+ end
+
+ alias reverse_each reverse_inorder_walk
+
+ def search(key, x = root)
+ while !x.nil? && x.key != key
+ key < x.key ? x = x.left : x = x.right
+ end
+ return x
+ end
+
+ def empty?
+ return self.root.nil?
+ end
+
+ def black_height(x = root)
+ height = 0
+ while !x.nil?
+ x = x.left
+ height +=1 if x.nil? || x.black?
+ end
+ return height
+ end
+
+private
+
+ def left_rotate(x)
+ raise "x.right is nil!" if x.right.nil?
+ y = x.right
+ x.right = y.left
+ y.left.parent = x if !y.left.nil?
+ y.parent = x.parent
+ if x.parent.nil?
+ self.root = y
+ else
+ if x == x.parent.left
+ x.parent.left = y
+ else
+ x.parent.right = y
+ end
+ end
+ y.left = x
+ x.parent = y
+ end
+
+ def right_rotate(x)
+ raise "x.left is nil!" if x.left.nil?
+ y = x.left
+ x.left = y.right
+ y.right.parent = x if !y.right.nil?
+ y.parent = x.parent
+ if x.parent.nil?
+ self.root = y
+ else
+ if x == x.parent.left
+ x.parent.left = y
+ else
+ x.parent.right = y
+ end
+ end
+ y.right = x
+ x.parent = y
+ end
+
+ def insert_helper(z)
+ y = NilNode.instance
+ x = root
+ while !x.nil?
+ y = x
+ z.key < x.key ? x = x.left : x = x.right
+ end
+ z.parent = y
+ if y.nil?
+ self.root = z
+ else
+ z.key < y.key ? y.left = z : y.right = z
+ end
+ self.size += 1
+ end
+
+ def delete_fixup(x)
+ while x != root && x.color == Node::BLACK
+ if x == x.parent.left
+ w = x.parent.right
+ if w.color == Node::RED
+ w.color = Node::BLACK
+ x.parent.color = Node::RED
+ left_rotate(x.parent)
+ w = x.parent.right
+ end
+ if w.left.color == Node::BLACK && w.right.color == Node::BLACK
+ w.color = Node::RED
+ x = x.parent
+ else
+ if w.right.color == Node::BLACK
+ w.left.color = Node::BLACK
+ w.color = Node::RED
+ right_rotate(w)
+ w = x.parent.right
+ end
+ w.color = x.parent.color
+ x.parent.color = Node::BLACK
+ w.right.color = Node::BLACK
+ left_rotate(x.parent)
+ x = root
+ end
+ else
+ w = x.parent.left
+ if w.color == Node::RED
+ w.color = Node::BLACK
+ x.parent.color = Node::RED
+ right_rotate(x.parent)
+ w = x.parent.left
+ end
+ if w.right.color == Node::BLACK && w.left.color == Node::BLACK
+ w.color = Node::RED
+ x = x.parent
+ else
+ if w.left.color == Node::BLACK
+ w.right.color = Node::BLACK
+ w.color = Node::RED
+ left_rotate(w)
+ w = x.parent.left
+ end
+ w.color = x.parent.color
+ x.parent.color = Node::BLACK
+ w.left.color = Node::BLACK
+ right_rotate(x.parent)
+ x = root
+ end
+ end
+ end
+ x.color = Node::BLACK
+ end
+end
+
+def rbt_bm
+ n = 100_000
+ a1 = []; n.times { a1 << rand(999_999) }
+ a2 = []; n.times { a2 << rand(999_999) }
+
+ start = Time.now
+
+ tree = RedBlackTree.new
+
+ n.times {|i| tree.add(i) }
+ n.times { tree.delete(tree.root) }
+
+ tree = RedBlackTree.new
+ a1.each {|e| tree.add(e) }
+ a2.each {|e| tree.search(e) }
+ tree.inorder_walk {|key| key + 1 }
+ tree.reverse_inorder_walk {|key| key + 1 }
+ n.times { tree.minimum }
+ n.times { tree.maximum }
+
+ return Time.now - start
+end
+
+N = (ARGV[0] || 10).to_i
+
+N.times do
+ # puts rbt_bm.to_f
+ rbt_bm.to_f
+ # puts "GC.count = #{GC.count}" if GC.respond_to?(:count)
+end
diff --git a/bench/mri/gc/ring.rb b/bench/mri/gc/ring.rb
new file mode 100644
index 00000000000..be2c7b7250c
--- /dev/null
+++ b/bench/mri/gc/ring.rb
@@ -0,0 +1,29 @@
+# create many old objects
+
+max = 30_000_000
+
+class Ring
+ attr_reader :next_ring
+ def initialize n = nil
+ @next_ring = n
+ end
+
+
+ def size
+ s = 1
+ ring = self
+ while ring.next_ring
+ s += 1
+ ring = ring.next_ring
+ end
+ s
+ end
+end
+
+ring = Ring.new
+
+max.times{
+ ring = Ring.new(ring)
+}
+
+# p ring.size
diff --git a/bench/yarv/make_fasta_output.rb b/bench/mri/make_fasta_output.rb
similarity index 95%
rename from bench/yarv/make_fasta_output.rb
rename to bench/mri/make_fasta_output.rb
index 158d8fd1614..b6d787ae273 100644
--- a/bench/yarv/make_fasta_output.rb
+++ b/bench/mri/make_fasta_output.rb
@@ -1,19 +1,19 @@
-# prepare 'fasta.output'
-
-def prepare_fasta_output n
- filebase = File.join(File.dirname($0), 'fasta.output')
- script = File.join(File.dirname($0), 'bm_so_fasta.rb')
- file = "#{filebase}.#{n}"
-
- unless FileTest.exist?(file)
- STDERR.puts "preparing #{file}"
-
- open(file, 'w'){|f|
- ARGV[0] = n
- $stdout = f
- load script
- $stdout = STDOUT
- }
- end
-end
-
+# prepare 'fasta.output'
+
+def prepare_fasta_output n
+ filebase = File.join(File.dirname($0), 'fasta.output')
+ script = File.join(File.dirname($0), 'bm_so_fasta.rb')
+ file = "#{filebase}.#{n}"
+
+ unless FileTest.exist?(file)
+ STDERR.puts "preparing #{file}"
+
+ open(file, 'w'){|f|
+ ARGV[0] = n
+ $stdout = f
+ load script
+ $stdout = STDOUT
+ }
+ end
+end
+
diff --git a/bench/mri/memory_wrapper.rb b/bench/mri/memory_wrapper.rb
new file mode 100644
index 00000000000..3f4451a037c
--- /dev/null
+++ b/bench/mri/memory_wrapper.rb
@@ -0,0 +1,16 @@
+
+write_file, target, script_file = ARGV
+
+load(script_file)
+require_relative '../test/lib/memory_status'
+open(write_file, 'wb'){|f|
+ ms = Memory::Status.new
+ case target.to_sym
+ when :peak
+ key = ms.respond_to?(:hwm) ? :hwm : :peak
+ when :size
+ key = ms.respond_to?(:rss) ? :rss : :size
+ end
+
+ f.puts ms[key]
+}
diff --git a/bench/mri/prepare_require.rb b/bench/mri/prepare_require.rb
new file mode 100644
index 00000000000..c4786f04ad3
--- /dev/null
+++ b/bench/mri/prepare_require.rb
@@ -0,0 +1,25 @@
+require "fileutils"
+
+def prepare
+ num_files = 10000
+
+ basename = File.dirname($0)
+ data_dir = File.join(basename, "bm_require.data")
+
+ # skip if all of files exists
+ if File.exist?(File.join(data_dir, "c#{num_files}.rb"))
+ return
+ end
+
+ FileUtils.mkdir_p(data_dir)
+
+ 1.upto(num_files) do |i|
+ f = File.open("#{data_dir}/c#{i}.rb", "w")
+ f.puts <<-END
+ class C#{i}
+ end
+ END
+ end
+end
+
+prepare
diff --git a/bench/mri/prepare_require_thread.rb b/bench/mri/prepare_require_thread.rb
new file mode 100644
index 00000000000..339ecb8b393
--- /dev/null
+++ b/bench/mri/prepare_require_thread.rb
@@ -0,0 +1,2 @@
+load File.join(File.dirname(__FILE__), "prepare_require.rb")
+
diff --git a/bench/yarv/prepare_so_count_words.rb b/bench/mri/prepare_so_count_words.rb
similarity index 95%
rename from bench/yarv/prepare_so_count_words.rb
rename to bench/mri/prepare_so_count_words.rb
index 54ea72b8ed8..ee2138cdb24 100644
--- a/bench/yarv/prepare_so_count_words.rb
+++ b/bench/mri/prepare_so_count_words.rb
@@ -1,15 +1,15 @@
-# prepare 'wc.input'
-
-def prepare_wc_input
- wcinput = File.join(File.dirname($0), 'wc.input')
- wcbase = File.join(File.dirname($0), 'wc.input.base')
- unless FileTest.exist?(wcinput)
- data = File.read(wcbase)
- 13.times{
- data << data
- }
- open(wcinput, 'w'){|f| f.write data}
- end
-end
-
-prepare_wc_input
+# prepare 'wc.input'
+
+def prepare_wc_input
+ wcinput = File.join(File.dirname($0), 'wc.input')
+ wcbase = File.join(File.dirname($0), 'wc.input.base')
+ unless FileTest.exist?(wcinput)
+ data = File.read(wcbase)
+ 13.times{
+ data << data
+ }
+ open(wcinput, 'w'){|f| f.write data}
+ end
+end
+
+prepare_wc_input
diff --git a/bench/mri/prepare_so_k_nucleotide.rb b/bench/mri/prepare_so_k_nucleotide.rb
new file mode 100644
index 00000000000..d83aeb7a7e7
--- /dev/null
+++ b/bench/mri/prepare_so_k_nucleotide.rb
@@ -0,0 +1,2 @@
+require_relative 'make_fasta_output'
+prepare_fasta_output(100_000)
diff --git a/bench/mri/prepare_so_reverse_complement.rb b/bench/mri/prepare_so_reverse_complement.rb
new file mode 100644
index 00000000000..da3ec2df141
--- /dev/null
+++ b/bench/mri/prepare_so_reverse_complement.rb
@@ -0,0 +1,2 @@
+require_relative 'make_fasta_output'
+prepare_fasta_output(2_500_000)
diff --git a/bench/yarv/report.rb b/bench/mri/report.rb
similarity index 88%
rename from bench/yarv/report.rb
rename to bench/mri/report.rb
index e931966cca5..d2dc56b1e14 100644
--- a/bench/yarv/report.rb
+++ b/bench/mri/report.rb
@@ -24,10 +24,8 @@ def exec_command type, file, w
end
def benchmark cmd
- rubybin = ENV['RUBY'] || File.join(
- RbConfig::CONFIG["bindir"],
- RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"])
-
+ rubybin = ENV['RUBY'] || RbConfig.ruby
+
IO.popen(rubybin, 'r+'){|io|
io.write cmd
io.close_write
diff --git a/bench/yarv/run.rb b/bench/mri/run.rb
similarity index 99%
rename from bench/yarv/run.rb
rename to bench/mri/run.rb
index 6ef29436425..0cd23638495 100644
--- a/bench/yarv/run.rb
+++ b/bench/mri/run.rb
@@ -33,8 +33,8 @@ def bm file
bm_name = $1
puts '-----------------------------------------------------------' unless $rubyonly || $matzrubyonly
puts "#{bm_name}: "
-
-
+
+
puts < 1
- output "minimum results in each #{@repeat} measurements."
- end
-
- output "name\t#{@execs.map{|(e, v)| v}.join("\t")}"
- @results.each{|v, result|
- rets = []
- s = nil
- result.each_with_index{|e, i|
- r = e.min
- case v
- when /^vm1_/
- if @loop_wl1
- r -= @loop_wl1[i]
- s = '*'
- end
- when /^vm2_/
- if @loop_wl2
- r -= @loop_wl2[i]
- s = '*'
- end
- end
- rets << sprintf("%.3f", r)
- }
- output "#{v}#{s}\t#{rets.join("\t")}"
- }
- end
-
- def files
- flag = {}
- vm1 = vm2 = wl1 = wl2 = false
- @files = Dir.glob(File.join(@dir, 'bm*.rb')).map{|file|
- next if @pattern && /#{@pattern}/ !~ File.basename(file)
- case file
- when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/
- flag[$1] = true
- end
- file
- }.compact
-
- if flag['vm1'] && !flag['whileloop']
- @files << File.join(@dir, 'bm_loop_whileloop.rb')
- elsif flag['vm2'] && !flag['whileloop2']
- @files << File.join(@dir, 'bm_loop_whileloop2.rb')
- end
-
- @files.sort!
- progress_message "total: #{@files.size * @repeat} trial(s) (#{@repeat} trial(s) for #{@files.size} benchmark(s))\n"
- @files
- end
-
- def run
- files.each_with_index{|file, i|
- @i = i
- r = measure_file(file)
-
- if /bm_loop_whileloop.rb/ =~ file
- @loop_wl1 = r[1].map{|e| e.min}
- elsif /bm_loop_whileloop2.rb/ =~ file
- @loop_wl2 = r[1].map{|e| e.min}
- end
- }
- end
-
- def measure_file file
- name = File.basename(file, '.rb').sub(/^bm_/, '')
- prepare_file = File.join(File.dirname(file), "prepare_#{name}.rb")
- load prepare_file if FileTest.exist?(prepare_file)
-
- if @verbose
- output
- output '-----------------------------------------------------------'
- output name
- output
- output File.read(file)
- output
- end
-
- result = [name]
- result << @execs.map{|(e, v)|
- (0...@repeat).map{
- message_print "#{v}\t"
- progress_message '.'
-
- m = measure(e, file)
- message "#{m}"
- m
- }
- }
- @results << result
- result
- end
-
- def measure executable, file
- cmd = "#{executable} #{file}"
- m = Benchmark.measure{
- `#{cmd}`
- }
-
- if $? != 0
- raise "Benchmark process exited with abnormal status (#{$?})"
- end
-
- m.real
- end
-end
-
-if __FILE__ == $0
- opt = {
- :execs => ['ruby'],
- :dir => './',
- :repeat => 1,
- :output => "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}",
- }
-
- parser = OptionParser.new{|o|
- o.on('-e', '--executables [EXECS]',
- "Specify benchmark one or more targets. (exec1; exec2; exec3, ...)"){|e|
- opt[:execs] = e.split(/;/)
- }
- o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d|
- opt[:dir] = d
- }
- o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p|
- opt[:pattern] = p
- }
- o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n|
- opt[:repeat] = n.to_i
- }
- o.on('-o', '--output-file [FILE]', "Output file"){|o|
- opt[:output] = o
- }
- o.on('-q', '--quiet', "Run without notify information except result table."){|q|
- opt[:quiet] = q
- }
- o.on('-v', '--verbose'){|v|
- opt[:verbose] = v
- }
- }
-
- parser.parse!(ARGV)
- BenchmarkDriver.benchmark(opt)
-end
-
diff --git a/bench/yarv/prepare_so_k_nucleotide.rb b/bench/yarv/prepare_so_k_nucleotide.rb
deleted file mode 100644
index 62e0c76fb9b..00000000000
--- a/bench/yarv/prepare_so_k_nucleotide.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require File.join(File.dirname(__FILE__), 'make_fasta_output')
-prepare_fasta_output(100_000)
diff --git a/bench/yarv/prepare_so_reverse_complement.rb b/bench/yarv/prepare_so_reverse_complement.rb
deleted file mode 100644
index b1cd837626f..00000000000
--- a/bench/yarv/prepare_so_reverse_complement.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require File.join(File.dirname(__FILE__), 'make_fasta_output')
-prepare_fasta_output(2_500_000)
diff --git a/ci.hocon b/ci.hocon
index d7cf8a12485..0f544520d9f 100644
--- a/ci.hocon
+++ b/ci.hocon
@@ -12,6 +12,7 @@ common: {
}
environment: {
+ CI: "true",
PATH: "$JAVA_HOME/bin:$PATH"
}
@@ -34,5 +35,7 @@ builds = [
{name: "ruby-test-specs-language"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":language"]]},
{name: "ruby-test-specs-core"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":core"]]},
{name: "ruby-test-specs-library"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":library"]]},
- {name: "ruby-test-specs-truffle"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":truffle"]]}
+ {name: "ruby-test-specs-truffle"} ${common} ${gate_caps} {run: [${jt} [test, specs, ":truffle"]]},
+ {name: "ruby-test-integration"} ${common} ${gate_caps} {run: [${jt} [test, integration]]},
+ {name: "ruby-tarball"} ${common} ${gate_caps} {run: [${jt} [tarball]]}
]
diff --git a/core/pom.xml b/core/pom.xml
index 03683f3b75d..633086c8363 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
org.jruby
jruby-parent
- 9.1.0.0
+ 9.1.1.0-SNAPSHOT
jruby-core
JRuby Core
diff --git a/core/src/main/java/org/jruby/Ruby.java b/core/src/main/java/org/jruby/Ruby.java
index ad2916baf76..ea02df7daf0 100644
--- a/core/src/main/java/org/jruby/Ruby.java
+++ b/core/src/main/java/org/jruby/Ruby.java
@@ -912,6 +912,14 @@ public JRubyTruffleInterface getTruffleContext() {
private JRubyTruffleInterface loadTruffle() {
Main.printTruffleTimeMetric("before-load-context");
+ String javaVersion = System.getProperty("java.version");
+ String[] parts = javaVersion.split("\\D+");
+ int firstPart = Integer.valueOf(parts[0]);
+ if (!(firstPart >= 9 || Integer.valueOf(parts[1]) >= 8)) {
+ System.err.println("JRuby+Truffle needs Java 8 to run (found " + javaVersion + ").");
+ System.exit(1);
+ }
+
final Class> clazz;
try {
diff --git a/core/src/main/java/org/jruby/RubyArray.java b/core/src/main/java/org/jruby/RubyArray.java
index 24342e9da6b..3330ab0d9d6 100644
--- a/core/src/main/java/org/jruby/RubyArray.java
+++ b/core/src/main/java/org/jruby/RubyArray.java
@@ -4206,9 +4206,10 @@ public IRubyObject max(ThreadContext context, Block block) {
int i;
if (block.isGiven()) {
+ Ruby runtime = context.runtime;
for (i = 0; i < realLength; i++) {
v = eltOk(i);
- if (result == UNDEF || RubyComparable.cmpint(context, block.yieldSpecific(context, v, result), v, result) > 0) {
+ if (result == UNDEF || RubyComparable.cmpint(context, block.yieldArray(context, runtime.newArray(v, result), null), v, result) > 0) {
result = v;
}
}
@@ -4241,9 +4242,10 @@ public IRubyObject min(ThreadContext context, Block block) {
int i;
if (block.isGiven()) {
+ Ruby runtime = context.runtime;
for (i = 0; i < realLength; i++) {
v = eltOk(i);
- if (result == UNDEF || RubyComparable.cmpint(context, block.yieldSpecific(context, v, result), v, result) < 0) {
+ if (result == UNDEF || RubyComparable.cmpint(context, block.yieldArray(context, runtime.newArray(v, result), null), v, result) < 0) {
result = v;
}
}
diff --git a/core/src/main/java/org/jruby/RubyFile.java b/core/src/main/java/org/jruby/RubyFile.java
index 2d626a937c8..c5efbcd4575 100644
--- a/core/src/main/java/org/jruby/RubyFile.java
+++ b/core/src/main/java/org/jruby/RubyFile.java
@@ -47,7 +47,6 @@
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
-import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
@@ -80,7 +79,6 @@
import org.jruby.util.TypeConverter;
import org.jruby.util.io.EncodingUtils;
import org.jruby.util.io.IOEncodable;
-import org.jruby.util.io.ModeFlags;
import org.jruby.util.io.OpenFile;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.encoding.EncodingService;
@@ -786,7 +784,6 @@ public static IRubyObject expand_path(ThreadContext context, IRubyObject recv, I
@JRubyMethod(name = "expand_path", required = 1, optional = 1, meta = true)
public static IRubyObject expand_path19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
RubyString path = (RubyString) expandPathInternal(context, recv, args, true, false);
- path.force_encoding(context, context.runtime.getEncodingService().getDefaultExternal());
return path;
}
@@ -1561,9 +1558,23 @@ private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject
RubyString origPath = StringSupport.checkEmbeddedNulls(runtime, get_path(context, args[0]));
String relativePath = origPath.getUnicodeValue();
+ // Encoding logic lives in MRI's rb_file_expand_path_internal and should roughly equate to the following:
+ // * Paths expanded from the system, like ~ expanding to the user's home dir, should be filesystem-encoded.
+ // * Calls with a relative directory should use the encoding of that string.
+ // * Remaining calls should use the encoding of the incoming path string.
+ //
+ // We have our own system-like cases (e.g. URI expansion) that we do not set to the filesystem encoding
+ // because they are not really filesystem paths; they're in-process or network paths.
+ //
+ // See dac9850 and jruby/jruby#3849.
+
+ Encoding enc = origPath.getEncoding();
+ // for special paths like ~
+ Encoding fsenc = runtime.getEncodingService().getFileSystemEncoding();
+
// Special /dev/null of windows
if (Platform.IS_WINDOWS && ("NUL:".equalsIgnoreCase(relativePath) || "NUL".equalsIgnoreCase(relativePath))) {
- return runtime.newString("//./" + relativePath.substring(0, 3));
+ return RubyString.newString(runtime, "//./" + relativePath.substring(0, 3), fsenc);
}
// treat uri-like and jar-like path as absolute
@@ -1613,21 +1624,22 @@ else if ( ( preFix.equals("uri:classloader:") || preFix.equals("classpath:") )
// this is basically for classpath:/ and uri:classloader:/
relativePath = relativePath.substring(2).replace('\\', '/');
}
- return concatStrings(runtime, preFix, extra, relativePath);
+ return concatStrings(runtime, preFix, extra, relativePath, enc);
}
String[] uriParts = splitURI(relativePath);
String cwd;
// Handle ~user paths
- if (expandUser) {
+ if (expandUser && startsWith(relativePath, '~')) {
+ enc = fsenc;
relativePath = expandUserPath(context, relativePath, true);
}
if (uriParts != null) {
//If the path was an absolute classpath path, return it as-is.
if (uriParts[0].equals("classpath:")) {
- return concatStrings(runtime, preFix, relativePath, postFix);
+ return concatStrings(runtime, preFix, relativePath, postFix, enc);
}
relativePath = uriParts[1];
}
@@ -1640,6 +1652,7 @@ else if ( ( preFix.equals("uri:classloader:") || preFix.equals("classpath:") )
if (args.length == 2 && !args[1].isNil()) {
// TODO maybe combine this with get_path method
String path = args[1].toString();
+ enc = fsenc;
if (path.startsWith("uri:")) {
cwd = path;
} else {
@@ -1745,13 +1758,14 @@ else if ( ( preFix.equals("uri:classloader:") || preFix.equals("classpath:") )
}
}
}
- return concatStrings(runtime, preFix, realPath, postFix);
+ return concatStrings(runtime, preFix, realPath, postFix, enc);
}
- private static RubyString concatStrings(final Ruby runtime, String s1, String s2, String s3) {
+ private static RubyString concatStrings(final Ruby runtime, String s1, String s2, String s3, Encoding enc) {
return RubyString.newString(runtime,
new StringBuilder(s1.length() + s2.length() + s3.length()).
- append(s1).append(s2).append(s3)
+ append(s1).append(s2).append(s3).toString(),
+ enc
);
}
@@ -1808,7 +1822,7 @@ public static String expandUserPath(ThreadContext context, String path) {
public static String expandUserPath(ThreadContext context, String path, final boolean raiseOnRelativePath) {
int pathLength = path.length();
- if (pathLength >= 1 && path.charAt(0) == '~') {
+ if (startsWith(path, '~')) {
// Enebo : Should ~frogger\\foo work (it doesnt in linux ruby)?
int userEnd = path.indexOf('/');
@@ -2049,11 +2063,11 @@ private static boolean startsWith(final CharSequence str, final String prefix) {
}
private static boolean startsWith(final CharSequence str, final char c) {
- return ( str.length() < 1 ) ? false : str.charAt(0) == c;
+ return str.length() >= 1 && str.charAt(0) == c;
}
private static boolean startsWith(final CharSequence str, final char c1, final char c2) {
- return ( str.length() < 2 ) ? false : str.charAt(0) == c1 && str.charAt(1) == c2;
+ return str.length() >= 2 && str.charAt(0) == c1 && str.charAt(1) == c2;
}
// without any char[] array copying, also StringBuilder only has lastIndexOf(String)
diff --git a/core/src/main/java/org/jruby/RubyStruct.java b/core/src/main/java/org/jruby/RubyStruct.java
index 4bbfc5d6c7b..f8e3418515d 100644
--- a/core/src/main/java/org/jruby/RubyStruct.java
+++ b/core/src/main/java/org/jruby/RubyStruct.java
@@ -63,6 +63,9 @@
*/
@JRubyClass(name="Struct")
public class RubyStruct extends RubyObject {
+ public static final String NO_MEMBER_IN_STRUCT = "no member '%s' in struct";
+ public static final String IDENTIFIER_NEEDS_TO_BE_CONSTANT = "identifier %s needs to be constant";
+ public static final String UNINITIALIZED_CONSTANT = "uninitialized constant %s";
private final IRubyObject[] values;
/**
@@ -203,7 +206,7 @@ public static RubyClass newInstance(IRubyObject recv, IRubyObject[] args, Block
newStruct.inherit(superClass);
} else {
if (!IdUtil.isConstant(name)) {
- throw runtime.newNameError("identifier " + name + " needs to be constant", name);
+ throw runtime.newNameError(IDENTIFIER_NEEDS_TO_BE_CONSTANT, recv, name);
}
IRubyObject type = superClass.getConstantAt(name);
@@ -466,7 +469,7 @@ public IRubyObject set(IRubyObject value, int index) {
}
private RaiseException notStructMemberError(String name) {
- return getRuntime().newNameError("no member '" + name + "' in struct", name);
+ return getRuntime().newNameError(NO_MEMBER_IN_STRUCT, this, name);
}
public final IRubyObject get(int index) {
@@ -765,7 +768,7 @@ public static RubyStruct unmarshalFrom(UnmarshalStream input) throws java.io.IOE
RubySymbol className = (RubySymbol) input.unmarshalObject(false);
RubyClass rbClass = pathToClass(runtime, className.asJavaString());
if (rbClass == null) {
- throw runtime.newNameError("uninitialized constant " + className, className.asJavaString());
+ throw runtime.newNameError(UNINITIALIZED_CONSTANT, runtime.getStructClass(), className);
}
final RubyArray member = __member__(rbClass);
diff --git a/core/src/main/java/org/jruby/RubyThread.java b/core/src/main/java/org/jruby/RubyThread.java
index f545116d5a4..183e25d88c1 100644
--- a/core/src/main/java/org/jruby/RubyThread.java
+++ b/core/src/main/java/org/jruby/RubyThread.java
@@ -876,11 +876,8 @@ private IRubyObject getSymbolKey(IRubyObject originalKey) {
return originalKey;
} else if (originalKey instanceof RubyString) {
return getRuntime().newSymbol(originalKey.asJavaString());
- } else if (originalKey instanceof RubyFixnum) {
- getRuntime().getWarnings().warn(ID.FIXNUMS_NOT_SYMBOLS, "Do not use Fixnums as Symbols");
- throw getRuntime().newArgumentError(originalKey + " is not a symbol");
} else {
- throw getRuntime().newTypeError(originalKey + " is not a symbol");
+ throw getRuntime().newTypeError(originalKey + " is not a symbol nor a string");
}
}
diff --git a/core/src/main/java/org/jruby/ext/socket/RubySocket.java b/core/src/main/java/org/jruby/ext/socket/RubySocket.java
index 4d5cff12848..6ffa10a9ab1 100644
--- a/core/src/main/java/org/jruby/ext/socket/RubySocket.java
+++ b/core/src/main/java/org/jruby/ext/socket/RubySocket.java
@@ -202,18 +202,14 @@ public IRubyObject connect_nonblock(ThreadContext context, IRubyObject arg, IRub
boolean exception = ArgsUtil.extractKeywordArg(context, "exception", opts) != runtime.getFalse();
- doConnectNonblock(context, getChannel(), addr, exception);
-
- return RubyFixnum.zero(context.runtime);
+ return doConnectNonblock(context, getChannel(), addr, exception);
}
@JRubyMethod()
public IRubyObject connect(ThreadContext context, IRubyObject arg) {
SocketAddress addr = addressForChannel(context, arg);
- doConnect(context, getChannel(), addr, true);
-
- return RubyFixnum.zero(context.runtime);
+ return doConnect(context, getChannel(), addr, true);
}
@JRubyMethod()
diff --git a/core/src/main/java/org/jruby/parser/ParserSupport.java b/core/src/main/java/org/jruby/parser/ParserSupport.java
index ff8a0f60e31..91f5f2bf1a1 100644
--- a/core/src/main/java/org/jruby/parser/ParserSupport.java
+++ b/core/src/main/java/org/jruby/parser/ParserSupport.java
@@ -1303,14 +1303,16 @@ private List allocateNamedLocals(RegexpNode regexpNode) {
for (int i = 0; i < length; i++) {
// TODO: Pass by non-local-varnamed things but make sure consistent with list we get from regexp
-
if (RubyLexer.getKeyword(names[i]) == null && !Character.isUpperCase(names[i].charAt(0))) {
int slot = scope.isDefined(names[i]);
if (slot >= 0) {
- if (warnings.isVerbose()) warn(ID.AMBIGUOUS_ARGUMENT, getPosition(regexpNode), "named capture conflicts a local variable - " + names[i]);
+ // If verbose and the variable is not just another named capture, warn
+ if (warnings.isVerbose() && !scope.isNamedCapture(slot)) {
+ warn(ID.AMBIGUOUS_ARGUMENT, getPosition(regexpNode), "named capture conflicts a local variable - " + names[i]);
+ }
locals.add(slot);
} else {
- locals.add(getCurrentScope().addVariableThisScope(names[i]));
+ locals.add(getCurrentScope().addNamedCaptureVariable(names[i]));
}
}
}
diff --git a/core/src/main/java/org/jruby/parser/StaticScope.java b/core/src/main/java/org/jruby/parser/StaticScope.java
index cf8c47cce69..108a71bef09 100644
--- a/core/src/main/java/org/jruby/parser/StaticScope.java
+++ b/core/src/main/java/org/jruby/parser/StaticScope.java
@@ -76,6 +76,9 @@ public class StaticScope implements Serializable {
// Our name holder (offsets are assigned as variables are added)
private String[] variableNames;
+ // A list of booleans indicating which variables are named captures from regexp
+ private boolean[] namedCaptures;
+
// Arity of this scope if there is one
private Signature signature;
@@ -185,7 +188,7 @@ private static boolean namesAreInterned(String[] names) {
* current scope.
*
* @param name of new variable
- * @return index+depth merged location of scope
+ * @return index of variable
*/
public int addVariableThisScope(String name) {
// Ignore duplicate "_" args in blocks
@@ -206,6 +209,20 @@ public int addVariableThisScope(String name) {
return variableNames.length - 1;
}
+ /**
+ * Add a new named capture variable to this (current) scope.
+ *
+ * @param name name of variable.
+ * @return index of variable
+ */
+ public int addNamedCaptureVariable(String name) {
+ int index = addVariableThisScope(name);
+
+ growNamedCaptures(index);
+
+ return index;
+ }
+
/**
* Add a new variable to this (current) scope unless it is already defined in any
* reachable scope.
@@ -509,6 +526,24 @@ private void growVariableNames(String name) {
variableNames[variableNames.length - 1] = name;
}
+ private void growNamedCaptures(int index) {
+ boolean[] namedCaptures = this.namedCaptures;
+ boolean[] newNamedCaptures;
+ if (namedCaptures != null) {
+ newNamedCaptures = new boolean[Math.max(index + 1, namedCaptures.length)];
+ System.arraycopy(namedCaptures, 0, newNamedCaptures, 0, namedCaptures.length);
+ } else {
+ newNamedCaptures = new boolean[index + 1];
+ }
+ newNamedCaptures[index] = true;
+ this.namedCaptures = newNamedCaptures;
+ }
+
+ public boolean isNamedCapture(int index) {
+ boolean[] namedCaptures = this.namedCaptures;
+ return namedCaptures != null && index < namedCaptures.length && namedCaptures[index];
+ }
+
@Override
public String toString() {
// FIXME: Do we need to persist cref as well?
diff --git a/core/src/main/java/org/jruby/runtime/encoding/EncodingService.java b/core/src/main/java/org/jruby/runtime/encoding/EncodingService.java
index dd7a6023635..d0b0fea4a0b 100644
--- a/core/src/main/java/org/jruby/runtime/encoding/EncodingService.java
+++ b/core/src/main/java/org/jruby/runtime/encoding/EncodingService.java
@@ -97,7 +97,7 @@ public Encoding getAscii8bitEncoding() {
}
// mri: rb_filesystem_encoding
- public Encoding getFileSystemEncoding(Ruby runtime) {
+ public Encoding getFileSystemEncoding() {
return SpecialEncoding.FILESYSTEM.toEncoding(runtime);
}
@@ -579,4 +579,9 @@ private Entry findEntryFromEncoding(Encoding e) {
if (e == null) return null;
return findEncodingEntry(new ByteList(e.getName()));
}
+
+ @Deprecated
+ public Encoding getFileSystemEncoding(Ruby runtime) {
+ return getFileSystemEncoding();
+ }
}
\ No newline at end of file
diff --git a/core/src/main/java/org/jruby/util/io/FilenoUtil.java b/core/src/main/java/org/jruby/util/io/FilenoUtil.java
index a9e4441572c..44ca73a705d 100644
--- a/core/src/main/java/org/jruby/util/io/FilenoUtil.java
+++ b/core/src/main/java/org/jruby/util/io/FilenoUtil.java
@@ -65,6 +65,10 @@ public void unregisterWrapper(int fileno) {
filenoMap.remove(fileno);
}
+ public int getNumberOfWrappers() {
+ return filenoMap.size();
+ }
+
public int getNewFileno() {
return internalFilenoIndex.getAndIncrement();
}
diff --git a/lib/pom.xml b/lib/pom.xml
index 4a23f389fe6..74b10db6232 100644
--- a/lib/pom.xml
+++ b/lib/pom.xml
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
org.jruby
jruby-parent
- 9.1.0.0
+ 9.1.1.0-SNAPSHOT
jruby-stdlib
JRuby Lib Setup
@@ -28,7 +28,7 @@ DO NOT MODIFIY - GENERATED CODE
org.jruby
jruby-core
- 9.1.0.0
+ 9.1.1.0-SNAPSHOT
test
diff --git a/lib/ruby/stdlib/bigdecimal/ludcmp.rb b/lib/ruby/stdlib/bigdecimal/ludcmp.rb
index dd265e482a3..1cab9a22d00 100644
--- a/lib/ruby/stdlib/bigdecimal/ludcmp.rb
+++ b/lib/ruby/stdlib/bigdecimal/ludcmp.rb
@@ -76,13 +76,13 @@ def lusolve(a,b,ps,zero=0.0)
end
x <<= b[ps[i]] - dot
end
- (n-1).downto(0) do |i|
+ (n-1).downto(0) do |i2|
dot = zero
- psin = ps[i]*n
- for j in (i+1)...n do
+ psin = ps[i2]*n
+ for j in (i2+1)...n do
dot = a[psin+j].mult(x[j],prec) + dot
end
- x[i] = (x[i]-dot).div(a[psin+i],prec)
+ x[i2] = (x[i2]-dot).div(a[psin+i2],prec)
end
x
end
diff --git a/lib/ruby/stdlib/jruby/compiler.rb b/lib/ruby/stdlib/jruby/compiler.rb
index 00f28c4be4e..ca716193cd3 100644
--- a/lib/ruby/stdlib/jruby/compiler.rb
+++ b/lib/ruby/stdlib/jruby/compiler.rb
@@ -52,8 +52,8 @@ def compile_argv(argv)
options[:target] = tgt
end
- opts.on("-J OPTION", "Pass OPTION to javac for javac compiles") do |opts|
- options[:javac_options] << opts
+ opts.on("-J OPTION", "Pass OPTION to javac for javac compiles") do |o|
+ options[:javac_options] << o
end
#opts.on("-5"," --jdk5", "Generate JDK 5 classes (version 49)") do |x|
@@ -287,8 +287,8 @@ def compile_files_with_options(filenames, options = default_options)
if File.directory?(filename)
puts "Compiling **/*.rb in '#{File.expand_path(filename)}'..." if options[:verbose]
- Dir.glob(File.join(filename, "/**/*.rb")).each do |filename|
- errors += compile_proc[filename]
+ Dir.glob(File.join(filename, "/**/*.rb")).each do |f|
+ errors += compile_proc[f]
end
else
if filename.end_with?('.java')
diff --git a/lib/ruby/truffle/truffle/coverage.rb b/lib/ruby/truffle/truffle/coverage.rb
index 7ee74e20a54..9558e611c7c 100644
--- a/lib/ruby/truffle/truffle/coverage.rb
+++ b/lib/ruby/truffle/truffle/coverage.rb
@@ -9,10 +9,16 @@
module Coverage
def self.start
- Truffle::Coverage.start
+ Truffle::Coverage.enable
end
def self.result
+ result = peek_result
+ Truffle::Coverage.disable
+ result
+ end
+
+ def self.peek_result
Truffle::Coverage.result_array.to_h
end
diff --git a/pom.rb b/pom.rb
index c1299e0a694..56f0913c376 100644
--- a/pom.rb
+++ b/pom.rb
@@ -66,10 +66,11 @@
'jruby.plugins.version' => '1.0.10',
'json.version' => '1.8.3',
- 'rspec.version' => '3.3.0',
- 'rspec-core.version' => '3.3.2',
- 'rspec-expectations.version' => '3.3.1',
- 'rspec-mocks.version' => '3.3.2',
+ 'rspec.version' => '3.4.0',
+ 'rspec-core.version' => '3.4.4',
+ 'rspec-expectations.version' => '3.4.0',
+ 'rspec-mocks.version' => '3.4.1',
+ 'rspec-support.version' => '3.4.1',
'minitest.version' => '5.4.1',
'test-unit.version' => '3.1.1',
'power_assert.version' => '0.2.3',
@@ -88,8 +89,6 @@
'bouncy-castle.version' => '1.47',
'joda.time.version' => '2.8.2' )
- modules [ 'truffle', 'core', 'lib' ]
-
plugin_management do
jar( 'junit:junit:4.11',
:scope => 'test' )
@@ -171,6 +170,15 @@
:phase => 'site-deploy' )
end
+ modules [ 'core', 'lib' ]
+
+ # Truffle is by default only built if a JDK 8+ is available
+ profile 'truffle' do
+ activation do
+ jdk '[1.8,)' # 1.8+
+ end
+ modules [ 'truffle' ]
+ end
build do
default_goal 'install'
@@ -181,19 +189,7 @@
modules [ 'test' ]
end
- [
- 'rake',
- 'exec',
- 'truffle-specs-language',
- 'truffle-specs-core',
- 'truffle-specs-library',
- 'truffle-specs-truffle',
- 'truffle-specs-language-report',
- 'truffle-specs-core-report',
- 'truffle-specs-library-report',
- 'truffle-test-pe',
- 'truffle-mri-tests'
- ].each do |name|
+ [ 'rake', 'exec' ].each do |name|
profile name do
modules [ 'test' ]
@@ -259,7 +255,7 @@
end
end
- all_modules = [ 'test', 'maven' ]
+ all_modules = [ 'truffle', 'test', 'maven' ]
profile 'all' do
@@ -280,13 +276,13 @@
end
profile 'release' do
- modules [ 'test', 'maven' ]
+ modules [ 'truffle', 'test', 'maven' ]
properties 'invoker.skip' => true
end
profile 'snapshots' do
- modules [ 'maven' ]
+ modules [ 'truffle', 'maven' ]
distribution_management do
repository( :url => "file:${project.build.directory}/maven", :id => 'local releases' )
diff --git a/pom.xml b/pom.xml
index 8a30788da61..ffd8018f644 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@ DO NOT MODIFIY - GENERATED CODE
org.jruby
jruby-parent
- 9.1.0.0
+ 9.1.1.0-SNAPSHOT
pom
JRuby
JRuby is the effort to recreate the Ruby (http://www.ruby-lang.org) interpreter in Java.
@@ -84,7 +84,6 @@ DO NOT MODIFIY - GENERATED CODE
- truffle
core
lib
@@ -105,7 +104,7 @@ DO NOT MODIFIY - GENERATED CODE
- 3.3.2
+ 3.4.4
true
1.4.13
j2ee*/pom.xml
@@ -118,14 +117,14 @@ DO NOT MODIFIY - GENERATED CODE
1.1.1
utf-8
5.0.4
- 3.3.1
+ 3.4.0
osgi*/pom.xml
1.7
3.1.1
4.2.0
- 3.3.0
+ 3.4.0
1.7
- 3.3.2
+ 3.4.1
1.0.10
true
1.8.3
@@ -136,6 +135,7 @@ DO NOT MODIFIY - GENERATED CODE
${project.basedir}
github
2.8.2
+ 3.4.1
pom.xml
@@ -525,6 +525,15 @@ DO NOT MODIFIY - GENERATED CODE
+
+ truffle
+
+ [1.8,)
+
+
+ truffle
+
+
test
@@ -552,87 +561,6 @@ DO NOT MODIFIY - GENERATED CODE
test
-
- truffle-specs-language
-
- package
-
-
- test
-
-
-
- truffle-specs-core
-
- package
-
-
- test
-
-
-
- truffle-specs-library
-
- package
-
-
- test
-
-
-
- truffle-specs-truffle
-
- package
-
-
- test
-
-
-
- truffle-specs-language-report
-
- package
-
-
- test
-
-
-
- truffle-specs-core-report
-
- package
-
-
- test
-
-
-
- truffle-specs-library-report
-
- package
-
-
- test
-
-
-
- truffle-test-pe
-
- package
-
-
- test
-
-
-
- truffle-mri-tests
-
- package
-
-
- test
-
-
bootstrap
@@ -796,6 +724,7 @@ DO NOT MODIFIY - GENERATED CODE
install
+ truffle
test
maven
@@ -806,6 +735,7 @@ DO NOT MODIFIY - GENERATED CODE
clean
+ truffle
test
maven
@@ -813,6 +743,7 @@ DO NOT MODIFIY - GENERATED CODE
release
+ truffle
test
maven
@@ -850,6 +781,7 @@ DO NOT MODIFIY - GENERATED CODE
+ truffle
maven
diff --git a/spec/java_integration/fixtures/Reflector.java b/spec/java_integration/fixtures/Reflector.java
index 18f1b66754c..cd8d542607d 100644
--- a/spec/java_integration/fixtures/Reflector.java
+++ b/spec/java_integration/fixtures/Reflector.java
@@ -27,7 +27,7 @@ public static Object invoke(final Object obj, final Method method, Object arg) t
return method.invoke(obj, arg);
}
- public static Object invoke(final Object obj, final Class klass, final String method) throws Exception {
+ public static Object invoke(final Object obj, final Class> klass, final String method) throws Exception {
Method instanceMethod = klass.getMethod(method, (Class[]) null);
return instanceMethod.invoke(obj, (Object[]) null);
}
diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb
index e138bca32e7..612d5a6c61d 100644
--- a/spec/mspec/lib/mspec/matchers/raise_error.rb
+++ b/spec/mspec/lib/mspec/matchers/raise_error.rb
@@ -57,7 +57,7 @@ def failure_message
if @actual then
message << "but got #{format_exception(@actual)}"
else
- message << "but no exception was raised (#{@result} was returned)"
+ message << "but no exception was raised (#{@result.pretty_inspect.chomp} was returned)"
end
message
diff --git a/spec/mspec/spec/matchers/raise_error_spec.rb b/spec/mspec/spec/matchers/raise_error_spec.rb
index f659d79029b..88aab34d531 100644
--- a/spec/mspec/spec/matchers/raise_error_spec.rb
+++ b/spec/mspec/spec/matchers/raise_error_spec.rb
@@ -82,6 +82,14 @@ class UnexpectedException < Exception; end
["Expected ExpectedException (expected)", "but no exception was raised (120 was returned)"]
end
+ it "provides a useful failure message when no exception is raised and nil is returned" do
+ proc = Proc.new { nil }
+ matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
+ matcher.matches?(proc)
+ matcher.failure_message.should ==
+ ["Expected ExpectedException (expected)", "but no exception was raised (nil was returned)"]
+ end
+
it "provides a useful negative failure message" do
proc = Proc.new { raise ExpectedException, "expected" }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
diff --git a/spec/ruby/core/array/max_spec.rb b/spec/ruby/core/array/max_spec.rb
new file mode 100644
index 00000000000..f4617433855
--- /dev/null
+++ b/spec/ruby/core/array/max_spec.rb
@@ -0,0 +1,13 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Array#max" do
+ describe "given a block with one argument" do
+ it "yields in turn the last length-1 values from the array" do
+ ary = []
+ result = [1,2,3,4,5].max {|x| ary << x; x}
+
+ ary.should == [2,3,4,5]
+ result.should == 5
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/ruby/core/array/min_spec.rb b/spec/ruby/core/array/min_spec.rb
new file mode 100644
index 00000000000..fa70e07524c
--- /dev/null
+++ b/spec/ruby/core/array/min_spec.rb
@@ -0,0 +1,13 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Array#min" do
+ describe "given a block with one argument" do
+ it "yields in turn the last length-1 values from the array" do
+ ary = []
+ result = [1,2,3,4,5].min {|x| ary << x; x}
+
+ ary.should == [2,3,4,5]
+ result.should == 1
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb
index 17b820a6c08..7924d430818 100644
--- a/spec/ruby/core/process/getrlimit_spec.rb
+++ b/spec/ruby/core/process/getrlimit_spec.rb
@@ -1,5 +1,16 @@
require File.expand_path('../../../spec_helper', __FILE__)
+platform_is :aix do
+ # In AIX, if getrlimit(2) is called multiple times with RLIMIT_DATA,
+ # the first call and the subequent calls return slightly different
+ # values of rlim_cur, even if the process does nothing between
+ # the calls. This behavior causes some of the tests in this spec
+ # to fail, so call Process.getrlimit(:DATA) once and discard the result.
+ # Subsequent calls to Process.getrlimit(:DATA) should return
+ # a consistent value of rlim_cur.
+ Process.getrlimit(:DATA)
+end
+
platform_is_not :windows do
describe "Process.getrlimit" do
it "returns a two-element Array of Integers" do
diff --git a/spec/ruby/core/process/groups_spec.rb b/spec/ruby/core/process/groups_spec.rb
index 4cea049c04e..787f9d47fe6 100644
--- a/spec/ruby/core/process/groups_spec.rb
+++ b/spec/ruby/core/process/groups_spec.rb
@@ -19,7 +19,30 @@
Process.groups = groups
Process.groups.sort.should == groups.sort
else
- lambda { Process.groups = [] }.should raise_error(Errno::EPERM)
+ platform_is :aix do
+ # setgroups() is not part of the POSIX standard,
+ # so its behavior varies from OS to OS. AIX allows a non-root
+ # process to set the supplementary group IDs, as long as
+ # they are presently in its supplementary group IDs.
+ # The order of the following tests matters.
+ # After this process executes "Process.groups = []"
+ # it should no longer be able to set any supplementary
+ # group IDs, even if it originally belonged to them.
+ # It should only be able to set its primary group ID.
+ Process.groups = groups
+ Process.groups.sort.should == groups.sort
+ Process.groups = []
+ Process.groups.should == []
+ Process.groups = [ Process.gid ]
+ Process.groups.should == [ Process.gid ]
+ supplementary = groups - [ Process.gid ]
+ if supplementary.length > 0
+ lambda { Process.groups = supplementary }.should raise_error(Errno::EPERM)
+ end
+ end
+ platform_is_not :aix do
+ lambda { Process.groups = [] }.should raise_error(Errno::EPERM)
+ end
end
end
end
diff --git a/spec/ruby/core/process/setrlimit_spec.rb b/spec/ruby/core/process/setrlimit_spec.rb
index 9e0cd41c46c..8ce89abc4ae 100644
--- a/spec/ruby/core/process/setrlimit_spec.rb
+++ b/spec/ruby/core/process/setrlimit_spec.rb
@@ -74,8 +74,10 @@
end
platform_is_not :solaris do
- it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do
- Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
+ platform_is_not :aix do
+ it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do
+ Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
+ end
end
it "coerces :NPROC into RLIMIT_NPROC" do
@@ -154,8 +156,10 @@
end
platform_is_not :solaris do
- it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do
- Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
+ platform_is_not :aix do
+ it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do
+ Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil
+ end
end
it "coerces 'NPROC' into RLIMIT_NPROC" do
diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb
index f374f35a52d..e94ba4f0f82 100644
--- a/spec/ruby/language/class_spec.rb
+++ b/spec/ruby/language/class_spec.rb
@@ -58,6 +58,76 @@ class ClassSpecsNumber::MyClass
}.should raise_error(TypeError)
end
+ it "inherits from Object by default" do
+ ClassSpecs::A.superclass.should == Object
+ end
+
+ it "raises an error when trying to change the superclass" do
+ module ClassSpecs
+ class SuperclassResetToSubclass < L
+ end
+ lambda {
+ class SuperclassResetToSubclass < M
+ end
+ }.should raise_error(TypeError, /superclass mismatch/)
+ end
+ end
+
+ it "raises an error when reopening a class with BasicObject as superclass" do
+ module ClassSpecs
+ class SuperclassReopenedBasicObject < A
+ end
+ SuperclassReopenedBasicObject.superclass.should == A
+
+ lambda {
+ class SuperclassReopenedBasicObject < BasicObject
+ end
+ }.should raise_error(TypeError, /superclass mismatch/)
+ SuperclassReopenedBasicObject.superclass.should == A
+ end
+ end
+
+ # [Bug #12367] [ruby-core:75446]
+ ruby_version_is "2.4" do # Until backported
+ it "raises an error when reopening a class with Object as superclass" do
+ module ClassSpecs
+ class SuperclassReopenedObject < A
+ end
+ SuperclassReopenedObject.superclass.should == A
+
+ lambda {
+ class SuperclassReopenedObject < Object
+ end
+ }.should raise_error(TypeError, /superclass mismatch/)
+ SuperclassReopenedObject.superclass.should == A
+ end
+ end
+ end
+
+ it "allows reopening a class without specifying the superclass" do
+ module ClassSpecs
+ class SuperclassNotGiven < A
+ end
+ SuperclassNotGiven.superclass.should == A
+
+ class SuperclassNotGiven
+ end
+ SuperclassNotGiven.superclass.should == A
+ end
+ end
+
+ it "does not allow to set the superclass even if it was not specified by the first declaration" do
+ module ClassSpecs
+ class NoSuperclassSet
+ end
+
+ lambda {
+ class NoSuperclassSet < String
+ end
+ }.should raise_error(TypeError, /superclass mismatch/)
+ end
+ end
+
it "allows using self as the superclass if self is a class" do
ClassSpecs::I::J.superclass.should == ClassSpecs::I
@@ -66,6 +136,19 @@ class ShouldNotWork < self; end
}.should raise_error(TypeError)
end
+ it "first evaluates the superclass before checking if the class already exists" do
+ module ClassSpecs
+ class SuperclassEvaluatedFirst
+ end
+ a = SuperclassEvaluatedFirst
+
+ class SuperclassEvaluatedFirst < remove_const(:SuperclassEvaluatedFirst)
+ end
+ b = SuperclassEvaluatedFirst
+ b.superclass.should == a
+ end
+ end
+
it "raises a TypeError if inheriting from a metaclass" do
obj = mock("metaclass super")
meta = obj.singleton_class
diff --git a/spec/tags/ruby/core/file/expand_path_tags.txt b/spec/tags/ruby/core/file/expand_path_tags.txt
index 17b5dc76a3d..943b93bebf5 100644
--- a/spec/tags/ruby/core/file/expand_path_tags.txt
+++ b/spec/tags/ruby/core/file/expand_path_tags.txt
@@ -1,5 +1,4 @@
fails:File.expand_path raises an Encoding::CompatibilityError if the external encoding is not compatible
-fails:File.expand_path returns a String in the same encoding as the argument
fails:File.expand_path expands a path when the default external encoding is ASCII-8BIT
windows:File.expand_path expands a path with multi-byte characters
windows:File.expand_path does not modify a HOME string argument
diff --git a/spec/truffle/tags/language/class_tags.txt b/spec/truffle/tags/language/class_tags.txt
new file mode 100644
index 00000000000..c4ae2fef029
--- /dev/null
+++ b/spec/truffle/tags/language/class_tags.txt
@@ -0,0 +1 @@
+fails:A class definition raises an error when reopening a class with Object as superclass
diff --git a/spec/truffle/tags/library/coverage/peek_result_tags.txt b/spec/truffle/tags/library/coverage/peek_result_tags.txt
deleted file mode 100644
index 8219d0ec680..00000000000
--- a/spec/truffle/tags/library/coverage/peek_result_tags.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-fails:Coverage.peek_result returns the result so far
-fails:Coverage.peek_result immediate second call returns same result
-fails:Coverage.peek_result second call after require returns accumulated result
-fails:Coverage.peek_result call right before Coverage.result should give equal result
diff --git a/spec/truffle/tags/library/coverage/result_tags.txt b/spec/truffle/tags/library/coverage/result_tags.txt
deleted file mode 100644
index dc60862c681..00000000000
--- a/spec/truffle/tags/library/coverage/result_tags.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-fails:Coverage.result gives the covered files as a hash with arrays of count or nil
-fails:Coverage.result no requires/loads should give empty hash
-fails:Coverage.result second call should give exception
-fails:Coverage.result second run should give same result
-fails:Coverage.result second run without load/require should give empty hash
-fails:Coverage.result second Coverage.start does nothing
-fails:Coverage.result should list coverage for the required file starting coverage
-fails:Coverage.result should list coverage for the loaded file starting coverage
-fails:Coverage.result does not include the file starting coverage since it is not tracked
diff --git a/test/jruby.index b/test/jruby.index
index 8189155bcae..5baf69c00ba 100644
--- a/test/jruby.index
+++ b/test/jruby.index
@@ -50,6 +50,7 @@ jruby/test_jruby_internals
jruby/test_marshal_with_instance_variables
jruby/test_marshal_gemspec
jruby/test_method_missing
+jruby/test_name_error
jruby/test_no_stack_trace_stomp
jruby/test_pack
jruby/test_primitive_to_java
diff --git a/test/jruby/test_array.rb b/test/jruby/test_array.rb
index a90d4a18696..712ae3dbd64 100644
--- a/test/jruby/test_array.rb
+++ b/test/jruby/test_array.rb
@@ -33,7 +33,7 @@ def test_shared_ary_slice
def test_map
methods = %w{map map! collect collect!}
methods.each { |method|
- assert_no_match /Enumerable/, [].method(method).to_s
+ assert_no_match(/Enumerable/, [].method(method).to_s)
}
end
end
diff --git a/test/jruby/test_backquote.rb b/test/jruby/test_backquote.rb
index 5103dcb7018..2e3eeef0079 100644
--- a/test/jruby/test_backquote.rb
+++ b/test/jruby/test_backquote.rb
@@ -13,20 +13,20 @@ def test_backquote_special_commands
end
end
- def test_backquote_special_commands_and_cwd_inside_classloader
- # not sure why it fails with java-1.6 - assume it is rare feature
- # and works for java-1.7+
- if File.exists?("/bin/echo") and not ENV_JAVA['java.version'].start_with?("1.6.")
- begin
- cwd = Dir.pwd
- Dir.chdir('uri:classloader:/')
- output = `/bin/echo hello`
- assert_equal("hello\n", output)
- ensure
- Dir.chdir(cwd)
- end
- end
- end
+# def test_backquote_special_commands_and_cwd_inside_classloader
+# # not sure why it fails with java-1.6 - assume it is rare feature
+# # and works for java-1.7+
+# if File.exists?("/bin/echo") and not ENV_JAVA['java.version'].start_with?("1.6.")
+# begin
+# cwd = Dir.pwd
+# Dir.chdir('uri:classloader:/')
+# output = `/bin/echo hello`
+# assert_equal("hello\n", output)
+# ensure
+# Dir.chdir(cwd)
+# end
+# end
+# end
def test_system_special_commands
if File.exists?("/bin/true")
diff --git a/test/jruby/test_backtraces.rb b/test/jruby/test_backtraces.rb
index ed3b6d95df6..95ad478c5a9 100644
--- a/test/jruby/test_backtraces.rb
+++ b/test/jruby/test_backtraces.rb
@@ -56,7 +56,7 @@ def test_native_java_backtrace2
constructor = sample_class.constructor(Java::int)
constructor.new_instance 0
begin
- constructor.new_instance -1
+ constructor.new_instance(-1)
fail 'did no raise exception'
rescue NativeException => ex
assert_equal 'java.lang.IllegalStateException: param == -1', ex.message
@@ -323,7 +323,7 @@ def test_throwing_runnable_backtrace # GH-3177
begin
throwing.doRun( (i += 1) > 0 )
rescue java.lang.Exception
- assert e = $!.backtrace.find { |e| e.index('org.jruby.RubyFixnum.times') }
+ assert e = $!.backtrace.find { |e2| e2.index('org.jruby.RubyFixnum.times') }
assert_equal fixnum_times_, e[ 0...fixnum_times_.size ]
backtrace = $!.backtrace.dup
raise
@@ -336,7 +336,7 @@ def test_throwing_runnable_backtrace # GH-3177
rescue java.lang.Exception
# puts $!.backtrace
# second rewriting of the same exception :
- assert e = $!.backtrace.find { |e| e.index('org.jruby.RubyFixnum.times') }
+ assert e = $!.backtrace.find { |e2| e2.index('org.jruby.RubyFixnum.times') }
assert_equal fixnum_times_, e[ 0...fixnum_times_.size ]
# NOTE back-trace gets duplicate .rb calls - seems not necessary to fix?!
# assert_equal backtrace, $!.backtrace # expect the same back-trace
@@ -367,7 +367,7 @@ def assert_exception_backtrace(expectations, exception)
line.strip!
# if line starts with +nnn, we prepend the current file and offset
- if line.match /^\+(\d+)(:.*)/
+ if line.match(/^\+(\d+)(:.*)/)
flunk("@offset is not defined in the test case") unless @offset ||= nil
# For JRuby, we soften this requirement, since native calls will
# show their actual .java file and line, rather than the caller.
diff --git a/test/jruby/test_big_decimal.rb b/test/jruby/test_big_decimal.rb
index 5b48ddbc148..28247a8ec03 100644
--- a/test/jruby/test_big_decimal.rb
+++ b/test/jruby/test_big_decimal.rb
@@ -368,12 +368,12 @@ def infinite?; false end
def test_subclass
a = BigDeci.new 1.to_s
- assert_equal -1, a.abs
+ assert_equal(-1, a.abs)
assert_equal false, a.infinite?
a = BigDeci.new '-100'
- assert_equal -5, a.div(20)
- assert_equal -100, a.abs
+ assert_equal(-5, a.div(20))
+ assert_equal(-100, a.abs)
assert a.inspect.index('# 1, "caller(0) is not > 1: #{trace0.inspect}")
trace = caller
- assert_not_match /test\/jruby\/test_caller\.rb\:16\:in `test_normal_caller'/, trace[0]
+ assert_not_match(/test\/jruby\/test_caller\.rb\:16\:in `test_normal_caller'/, trace[0])
assert_equal trace0[1..-1], trace
end
@@ -22,8 +22,8 @@ def test_evaled_caller_has_full_trace
# simple test, make sure the trace is more than one entry
assert(trace.length > 1, "caller(0) is not > 1: #{trace.inspect}")
- assert_match /test\/jruby\/test_caller\.rb\:\d\d\:in `eval'/, trace[1]
- assert_match /test\/jruby\/test_caller\.rb\:\d\d\:in `foo0'/, trace[2]
+ assert_match(/test\/jruby\/test_caller\.rb\:\d\d\:in `eval'/, trace[1])
+ assert_match(/test\/jruby\/test_caller\.rb\:\d\d\:in `foo0'/, trace[2])
end
def test_jitted_caller_excludes_abstractscript
diff --git a/test/jruby/test_class.rb b/test/jruby/test_class.rb
index 076cc9f43bf..d66466bd984 100644
--- a/test/jruby/test_class.rb
+++ b/test/jruby/test_class.rb
@@ -285,7 +285,7 @@ def test_eval_class_as_module_should_raise_type_exception
class Foo
def self.action(name, &block)
define_method(name) {
- instance_eval &block
+ instance_eval(&block)
}
end
diff --git a/test/jruby/test_cvars_in_odd_scopes.rb b/test/jruby/test_cvars_in_odd_scopes.rb
index 373b12105eb..f7fcc3691df 100644
--- a/test/jruby/test_cvars_in_odd_scopes.rb
+++ b/test/jruby/test_cvars_in_odd_scopes.rb
@@ -3,7 +3,6 @@
# JRUBY-3714: ActiveMessaging poller stops silently with JRuby 1.3.0RC1 and RC2.
class TestCvarsInOddScopes < Test::Unit::TestCase
def test_lambda_in_eigenclass
- $result
Class.new do
@@running = true
class << self
@@ -17,7 +16,6 @@ class << self
end
def test_proc_in_eigenclass
- $result
Class.new do
@@running = true
class << self
diff --git a/test/jruby/test_file.rb b/test/jruby/test_file.rb
index 3c2dcf375d4..67a0583f1c2 100644
--- a/test/jruby/test_file.rb
+++ b/test/jruby/test_file.rb
@@ -98,6 +98,14 @@ def test_expand_path_cross_platform
}
end
+ # JRUBY-3849
+ def test_expand_path_encoding
+ assert_equal(Encoding.find('UTF-8'), File.expand_path('/'.force_encoding('UTF-8')).encoding)
+ assert_equal(Encoding.find('US-ASCII'), File.expand_path('/'.force_encoding('US-ASCII')).encoding)
+ assert_equal(Encoding.find('UTF-8'), File.expand_path(Pathname.new('/'.force_encoding('UTF-8'))).encoding)
+ assert_equal(Encoding.find('US-ASCII'), File.expand_path(Pathname.new('/'.force_encoding('US-ASCII'))).encoding)
+ end
+
def test_expand_path_nil
assert_raise(TypeError) { File.expand_path(nil) }
assert_raise(TypeError) { File.expand_path(nil, "/") }
@@ -792,12 +800,12 @@ def test_file_truncated_after_changing_directory
Dir.mkdir(subdir)
Dir.chdir(subdir) { |dir|
begin
- file = File.open("__dummy_file.txt", "wb") { |file|
- file.write("dummy text")
- file
- }
+ file = File.open("__dummy_file.txt", "wb")
+ file.write("dummy text")
+ file.close
assert_nothing_raised { File.truncate(file.path, 0) }
ensure
+ file.close rescue nil
File.unlink(file.path)
end
}
diff --git a/test/jruby/test_helper.rb b/test/jruby/test_helper.rb
index 194b83b8574..1ee366881fc 100644
--- a/test/jruby/test_helper.rb
+++ b/test/jruby/test_helper.rb
@@ -82,7 +82,7 @@ def jruby_with_pipe(pipe, *args)
end
def sh(cmd)
- puts cmd if $VERBOSE
+ puts cmd if $DEBUG
return `#{cmd}`
end
private :sh
diff --git a/test/jruby/test_higher_javasupport.rb b/test/jruby/test_higher_javasupport.rb
index 897bdf3d27f..b5c71b13761 100644
--- a/test/jruby/test_higher_javasupport.rb
+++ b/test/jruby/test_higher_javasupport.rb
@@ -1394,7 +1394,8 @@ def test_java_methods_have_arity
# JRUBY-3476
def test_object_with_singleton_returns_java_class
- x = java.lang.Object.new
+ java.util.ArrayList.__persistent__ = true
+ x = java.util.ArrayList.new
def x.foo; end
assert(x.java_class.kind_of?Java::JavaClass)
end
diff --git a/test/jruby/test_ifaddr.rb b/test/jruby/test_ifaddr.rb
index 23d685830dc..678da0fc607 100644
--- a/test/jruby/test_ifaddr.rb
+++ b/test/jruby/test_ifaddr.rb
@@ -4,8 +4,6 @@
require 'test/jruby/test_helper'
require 'ipaddr'
-WINDOWS = RbConfig::CONFIG['host_os'] =~ /Windows|mswin/
-
class IfaddrTest < Test::Unit::TestCase
include TestHelper
diff --git a/test/jruby/test_io.rb b/test/jruby/test_io.rb
index f68a3eac81b..8d92ffe866e 100644
--- a/test/jruby/test_io.rb
+++ b/test/jruby/test_io.rb
@@ -70,7 +70,13 @@ def test_premature_close_raises_appropriate_errors
assert_nothing_raised { g.write "" }
assert_nothing_raised { g.puts "" }
assert_nothing_raised { g.putc 'c' }
- assert_raises(Errno::EBADF) { g.syswrite "" }
+ begin
+ # silence "syswrite for buffered IO" warning
+ verbose, $VERBOSE = $VERBOSE, nil
+ assert_raises(Errno::EBADF) { g.syswrite "" }
+ ensure
+ $VERBOSE = verbose
+ end
f = File.open(@file, "w")
@to_close << g = IO.new(f.fileno)
@@ -483,16 +489,20 @@ def test_stringio_gets_separator
end
# JRUBY-6137
- def test_rubyio_fileno_mapping_leak; require 'jruby'
- pend "TODO: refactor JRuby.runtime.fileno_int_map_size"
- starting_count = JRuby.runtime.fileno_int_map_size
- io = org.jruby.RubyIO.new(JRuby.runtime, org.jruby.util.io.STDIO::ERR)
- open_io_count = JRuby.runtime.fileno_int_map_size
+ def test_rubyio_fileno_mapping_leak
+ fileno_util = JRuby.runtime.fileno_util
+ starting_count = fileno_util.number_of_wrappers
+
+ # use a non-channel stream to ensure we use our mapping
+ io = org.jruby.RubyIO.new(JRuby.runtime, java.io.ByteArrayOutputStream.new)
+
+ open_io_count = fileno_util.number_of_wrappers
assert_equal(starting_count + 1, open_io_count)
+
io.close
- closed_io_count = JRuby.runtime.fileno_int_map_size
+ closed_io_count = fileno_util.number_of_wrappers
assert_equal(starting_count, closed_io_count)
- end if defined? JRUBY_VERSION
+ end if RUBY_ENGINE == 'jruby'
# JRUBY-1222
def test_stringio_gets_utf8
diff --git a/test/jruby/test_ivar_table_integrity.rb b/test/jruby/test_ivar_table_integrity.rb
index 664f772ebdf..b6e4e95afad 100644
--- a/test/jruby/test_ivar_table_integrity.rb
+++ b/test/jruby/test_ivar_table_integrity.rb
@@ -3,11 +3,10 @@
class TestIvarTableIntegrity < Test::Unit::TestCase
def test_ivar_table_integrity
cls = Class.new do
- def foo=(a); @foo = a; end
+ def initialize; @foo = nil; end
+ attr_accessor :foo
+ attr_accessor :bar
def remove_foo; remove_instance_variable :@foo; end
- def foo; @foo; end
- def bar=(a); @bar = a; end
- def bar; @bar; end
end
obj = cls.new
diff --git a/test/jruby/test_java_extension.rb b/test/jruby/test_java_extension.rb
index 50f66125dd6..9f957bc9fb0 100644
--- a/test/jruby/test_java_extension.rb
+++ b/test/jruby/test_java_extension.rb
@@ -284,7 +284,7 @@ def test_ruby_block_duck_typed_as_runnable_last_argument
def test_ruby_block_with_args_as_interface
file = java.io.File.new(".")
- listing = file.list {|file,str| !!(str =~ /\./) }
+ listing = file.list {|_,str| !!(str =~ /\./) }
assert listing.size >= 0
end
@@ -303,18 +303,6 @@ def test_overriding_protected_method
end
end
- class CallAbstractInConstructor < org.jruby.test.Abstract
- def initialize; super("call protected method in constructor!") end
-
- def protected_method; "HELLO!" end
- end
-
- def test_calling_abstract_method_in_java_constructor
- return skip('this leaking in super constructor (calling Ruby implemented methods)')
- a = CallAbstractInConstructor.new
- assert_equal "HELLO!", a.result
- end
-
def test_map_interface_to_array
hash = {"one"=>"two","three"=>"four"}
map = java.util.HashMap.new(hash)
diff --git a/test/jruby/test_kernel.rb b/test/jruby/test_kernel.rb
index c83378f294f..480e2ed5f50 100644
--- a/test/jruby/test_kernel.rb
+++ b/test/jruby/test_kernel.rb
@@ -7,7 +7,7 @@ class TestKernel < Test::Unit::TestCase
include TestHelper
def log(msg)
- $stderr.puts msg if $VERBOSE
+ $stderr.puts msg if $DEBUG
end
TESTAPP_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'testapp'))
@@ -432,42 +432,36 @@ def test_system_empty
assert !system('')
end
- unless false # FIXME figure out why this doesn't pass in 1.9+
- def test_system_existing
- quiet do
- if (WINDOWS)
- res = system('cd')
- else
- res = system('pwd')
- end
- assert_equal true, res
+ def test_system_existing
+ quiet do
+ if (WINDOWS)
+ res = system('cd')
+ else
+ res = system('true')
end
+ assert_equal true, res
end
end
- unless false # FIXME figure out why this doesn't pass in 1.9+
- def test_system_existing_with_leading_space
- quiet do
- if (WINDOWS)
- res = system(' cd')
- else
- res = system(' pwd')
- end
- assert_equal true, res
+ def test_system_existing_with_leading_space
+ quiet do
+ if (WINDOWS)
+ res = system(' cd')
+ else
+ res = system(' true')
end
+ assert_equal true, res
end
end
- unless false # FIXME figure out why this doesn't pass in 1.9+
- def test_system_existing_with_trailing_space
- quiet do
- if (WINDOWS)
- res = system('cd ')
- else
- res = system('pwd ')
- end
- assert_equal true, res
+ def test_system_existing_with_trailing_space
+ quiet do
+ if (WINDOWS)
+ res = system('cd ')
+ else
+ res = system('true ')
end
+ assert_equal true, res
end
end
@@ -780,7 +774,7 @@ def test_exec_rubyopt
ENV['RUBYOPT'] = "-v"
result = `bin/jruby -e "a=1"`
assert_equal 0, $?.exitstatus
- assert_match /ruby/i, result
+ assert_match(/ruby/i, result)
ensure
ENV['RUBYOPT'] = old
end
diff --git a/test/jruby/test_load.rb b/test/jruby/test_load.rb
index 1a780d90d6c..31b93a8a769 100644
--- a/test/jruby/test_load.rb
+++ b/test/jruby/test_load.rb
@@ -319,8 +319,9 @@ def test_symlinked_jar
end
def test_load_wrapped
- pend 'TODO: fix load module wrapping'
load(File.expand_path('hello_dummy.rb', File.dirname(__FILE__)), true)
+ assert !defined?(::Hello)
+ assert !defined?(::Dummy)
end
end
diff --git a/test/jruby/test_load_compiled_ruby_class_from_classpath.rb b/test/jruby/test_load_compiled_ruby_class_from_classpath.rb
index 76d46a4659f..b1b95b92618 100644
--- a/test/jruby/test_load_compiled_ruby_class_from_classpath.rb
+++ b/test/jruby/test_load_compiled_ruby_class_from_classpath.rb
@@ -75,7 +75,7 @@ def test_loading_compiled_ruby_class_from_jar
javac = ENV['JAVA_HOME'] ? "#{ENV['JAVA_HOME']}/bin/javac" : "javac"
javac_cmd = "#{javac} -cp #{jruby_jar} #{StarterSource}"
- puts javac_cmd if $VERBOSE; `#{javac_cmd}`
+ `#{javac_cmd}`
assert_equal 0, $?.exitstatus, "javac failed to compile #{StarterSource}"
jar = ENV['JAVA_HOME'] ? "#{ENV['JAVA_HOME']}/bin/jar" : "jar"
@@ -86,7 +86,7 @@ def test_loading_compiled_ruby_class_from_jar
java = ENV['JAVA_HOME'] ? "#{ENV['JAVA_HOME']}/bin/java" : "java"
java_cmd = "#{java} -jar -Djruby.aot.loadClasses=true #{JarFile}"
- puts java_cmd if $VERBOSE; result = `#{java_cmd}`
+ result = `#{java_cmd}`
assert_equal 0, $?.exitstatus, "did not get 0 for exit status from running java against the jar"
assert_equal "hello from runner", result, "wrong text from runner"
end
diff --git a/test/jruby/test_method_missing.rb b/test/jruby/test_method_missing.rb
index b95840e0062..fac70c7be0d 100644
--- a/test/jruby/test_method_missing.rb
+++ b/test/jruby/test_method_missing.rb
@@ -103,6 +103,7 @@ def inspect
end
def test_inspect_not_called_on_method_missing
+ $inspect_not_called = nil
TestInspectNotCalled.new.foo rescue nil
assert_equal nil, $inspect_not_called
end
diff --git a/test/jruby/test_name_error.rb b/test/jruby/test_name_error.rb
new file mode 100644
index 00000000000..55883207e9d
--- /dev/null
+++ b/test/jruby/test_name_error.rb
@@ -0,0 +1,10 @@
+require 'test/unit'
+
+class TestNameError < Test::Unit::TestCase
+ def test_receiver_on_name_error_coming_from_struct
+ obj = Struct.new(:does_exist).new(nil)
+ name_error = assert_raise(NameError) { obj[:doesnt_exist] }
+
+ assert_equal obj, name_error.receiver
+ end
+end
diff --git a/test/jruby/test_no_stack_trace_stomp.rb b/test/jruby/test_no_stack_trace_stomp.rb
index 1bb840c60a5..9983aac968f 100644
--- a/test/jruby/test_no_stack_trace_stomp.rb
+++ b/test/jruby/test_no_stack_trace_stomp.rb
@@ -17,7 +17,7 @@ def test_good_stack_trace
begin
rescue_an_error
rescue RuntimeError => e
- assert_match /`raise_an_error'/, e.backtrace[0]
+ assert_match(/`raise_an_error'/, e.backtrace[0])
end
end
end
diff --git a/test/jruby/test_process.rb b/test/jruby/test_process.rb
index 2b97a72bacd..e7b6c676e91 100644
--- a/test/jruby/test_process.rb
+++ b/test/jruby/test_process.rb
@@ -25,8 +25,8 @@ def test_process_status_to_i
end
def test_process_status_to_s
- assert_match /exit 1/, @first_status.to_s
- assert_match /exit 2/, @second_status.to_s
+ assert_match(/exit 1/, @first_status.to_s)
+ assert_match(/exit 2/, @second_status.to_s)
end
def test_process_status_exitstatus
diff --git a/test/jruby/test_socket.rb b/test/jruby/test_socket.rb
index df0b57a9734..6d0c3db2c7e 100644
--- a/test/jruby/test_socket.rb
+++ b/test/jruby/test_socket.rb
@@ -145,8 +145,8 @@ def test_raises_socket_error_on_out_of_range_port
# SocketError()
error = defined?(JRUBY_VERSION) ? SocketError : Errno::ECONNREFUSED
- [ 2**16, 2**16 + 1, 2**17, 2**30 - 1 ].each do |port|
- assert_raises(error) { TCPSocket.new('localhost', port) }
+ [ 2**16, 2**16 + 1, 2**17, 2**30 - 1 ].each do |p|
+ assert_raises(error) { TCPSocket.new('localhost', p) }
end
end
@@ -224,10 +224,10 @@ def test_udp_socket_bind
def test_tcp_socket_errors
begin
- TCPSocket.new('127.0.0.10', 42)
+ TCPSocket.new('0.0.0.0', 42)
rescue Errno::ECONNREFUSED => e
- # Connection refused - connect(2) for "127.0.0.1" port 42
- assert_equal 'Connection refused - connect(2) for "127.0.0.10" port 42', e.message
+ # Connection refused - connect(2) for "0.0.0.0" port 42
+ assert_equal 'Connection refused - connect(2) for "0.0.0.0" port 42', e.message
else; fail 'not raised'
end
@@ -570,9 +570,9 @@ def test_server_close_interrupts_pending_accepts
# JRUBY-2874
def test_raises_socket_error_on_out_of_range_port
- [-2**16, -2**8, -2, -1, 2**16, 2**16 + 1, 2**17, 2**30 -1].each do |port|
+ [-2**16, -2**8, -2, -1, 2**16, 2**16 + 1, 2**17, 2**30 - 1].each do |p|
assert_raises(SocketError) do
- TCPServer.new('localhost', port)
+ TCPServer.new('localhost', p)
end
end
end
diff --git a/test/jruby/test_system.rb b/test/jruby/test_system.rb
index 13cb4e2d30d..dac77b6d54f 100644
--- a/test/jruby/test_system.rb
+++ b/test/jruby/test_system.rb
@@ -2,6 +2,7 @@
require 'test/unit'
require 'rbconfig'
+require 'open3'
class TestSystem < Test::Unit::TestCase
# JRUBY-5110
@@ -15,10 +16,15 @@ def test_system_on_windows
# JRUBY-6960
def test_system_with_conflicting_dir
FileUtils.mkdir_p 'extra_path/java'
- ENV['PATH'] = "extra_path#{File::PATH_SEPARATOR}#{ENV['PATH']}"
- assert(system 'java -version')
+ path = ENV['PATH']
+ ENV['PATH'] = "extra_path#{File::PATH_SEPARATOR}#{path}"
+ Open3.popen3('java -version') do |i, o, e, t|
+ assert_match(/java/, e.read)
+ assert_equal(t.value, 0)
+ end
ensure
FileUtils.rm_rf 'extra_path'
+ ENV['PATH'] = path
end
end
diff --git a/test/jruby/test_system_error.rb b/test/jruby/test_system_error.rb
index a307489a395..d69a704e52d 100644
--- a/test/jruby/test_system_error.rb
+++ b/test/jruby/test_system_error.rb
@@ -51,10 +51,6 @@ def setup
["EOPNOTSUPP", 102, "Operation not supported"], ["ENOSTR", 99, /Not a STREAM/i],
["ENOTTY", 25, "Inappropriate ioctl for device"],
["EALREADY", 37, "Operation already in progress"]].sort_by{|v| v[1] }
-
- if ($VERBOSE)
- print_report
- end
end
# def test_has_186_ERRNO_constants
diff --git a/test/jruby/test_thread.rb b/test/jruby/test_thread.rb
index f12e5d265e1..08f187021ed 100644
--- a/test/jruby/test_thread.rb
+++ b/test/jruby/test_thread.rb
@@ -48,8 +48,8 @@ def test_thread_local_variables
assert_equal([:x, :y], Thread.current.keys.sort {|x, y| x.to_s <=> y.to_s} & [:x, :y])
assert_raises(TypeError) { Thread.current[Object.new] }
assert_raises(TypeError) { Thread.current[Object.new] = 1 }
- assert_raises(ArgumentError) { Thread.current[1] }
- assert_raises(ArgumentError) { Thread.current[1] = 1}
+ assert_raises(TypeError) { Thread.current[1] }
+ assert_raises(TypeError) { Thread.current[1] = 1}
end
def test_status
@@ -96,7 +96,7 @@ def test_joining_itself
e = error
end
assert(! e.nil?)
- assert_match /thread [0-9a-z]+ tried to join itself/, e.message
+ assert_match(/thread [0-9a-z]+ tried to join itself/, e.message)
end
def test_raise
@@ -344,39 +344,39 @@ def test_sleep_wakeup_interlacing
def test_inspect_and_to_s
t = Thread.new {}.join
- assert_match /#/, t.to_s
+ assert_match(/#/, t.to_s)
# TODO we do not have file/line right :
# MRI: #
- #assert_match /#/, t.inspect
- assert_match /#/, t.inspect
+ #assert_match(/#/, t.inspect)
+ assert_match(/#/, t.inspect)
assert_nil t.name
t = Thread.new {}.join
t.name = 'universal'
- assert_match /#/, t.to_s
- assert_match /#/, t.inspect
+ assert_match(/#/, t.to_s)
+ assert_match(/#/, t.inspect)
end
def test_thread_name
Thread.new do
- assert_match /\#\/, Thread.current.inspect
+ assert_match(/\#\/, Thread.current.inspect)
# TODO? currently in JIT file comes as "" and line as 0
- assert_match /Ruby\-\d+\-Thread\-\d+\:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current) if defined? JRUBY_VERSION
+ assert_match(/Ruby\-\d+\-Thread\-\d+\:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current)) if defined? JRUBY_VERSION
end.join
Thread.new do
Thread.current.name = 'foo'
- assert_match /\#\/, Thread.current.inspect
- assert_match /Ruby\-\d+\-Thread\-\d+\@foo:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current) if defined? JRUBY_VERSION
+ assert_match(/\#\/, Thread.current.inspect)
+ assert_match(/Ruby\-\d+\-Thread\-\d+\@foo:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current)) if defined? JRUBY_VERSION
Thread.current.name = 'bar'
- assert_match /\#\/, Thread.current.inspect
- assert_match /Ruby\-\d+\-Thread\-\d+\@bar:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current) if defined? JRUBY_VERSION
+ assert_match(/\#\/, Thread.current.inspect)
+ assert_match(/Ruby\-\d+\-Thread\-\d+\@bar:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current)) if defined? JRUBY_VERSION
Thread.current.name = nil
- assert_match /\#\/, Thread.current.inspect
- assert_match /Ruby\-\d+\-Thread\-\d+\:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current) if defined? JRUBY_VERSION
+ assert_match(/\#\/, Thread.current.inspect)
+ assert_match(/Ruby\-\d+\-Thread\-\d+\:\s(.*\.rb)?\:\d+/, native_thread_name(Thread.current)) if defined? JRUBY_VERSION
end.join
diff --git a/test/jruby/test_time_nil_ops.rb b/test/jruby/test_time_nil_ops.rb
index 320f16ce052..f745a81b3a5 100644
--- a/test/jruby/test_time_nil_ops.rb
+++ b/test/jruby/test_time_nil_ops.rb
@@ -19,7 +19,7 @@ def test_plus
def test_times
t = Time.now
begin
- t * ()
+ _ = t * ()
fail "bleh"
rescue NoMethodError=>x
assert x
@@ -29,7 +29,7 @@ def test_times
def test_div
t = Time.now
begin
- t / ()
+ _ = t / ()
fail "bleh"
rescue NoMethodError=>x
assert x
diff --git a/test/jruby/test_timeout.rb b/test/jruby/test_timeout.rb
index 33724a8095b..ab7a044626b 100644
--- a/test/jruby/test_timeout.rb
+++ b/test/jruby/test_timeout.rb
@@ -11,7 +11,7 @@ class TestTimeout < Test::Unit::TestCase
def test_timeout_for_loop
n = 10000000
assert_raises(Timeout::Error) do
- Timeout::timeout(1) { for i in 0..n do; (i + i % (i+1)) % (i + 10) ; end }
+ Timeout.timeout(1) { for i in 0..n do; (i + i % (i+1)) % (i + 10) ; end }
end
end
@@ -19,7 +19,7 @@ def do_timeout(time, count, pass_expected, timeout_expected = 0, &block)
pass = timeout = error = 0
count.times do
begin
- Timeout::timeout(time, &block)
+ Timeout.timeout(time, &block)
pass += 1
rescue Timeout::Error => e
timeout += 1
@@ -51,7 +51,7 @@ def test_timeout_sysread_socket
client = TCPSocket.new('localhost', port)
server.accept
begin
- timeout(0.1) { client.sysread(1024) }
+ Timeout.timeout(0.1) { client.sysread(1024) }
rescue Timeout::Error
ok = true
end
@@ -85,7 +85,7 @@ def test_net_http_timeout
def test_timeout_raises_anon_class_to_unroll
begin
quiet do
- timeout(0.1) { foo }
+ Timeout.timeout(0.1) { foo }
end
rescue Timeout::Error
ok = true
@@ -97,7 +97,7 @@ def test_timeout_raises_anon_class_to_unroll
# JRUBY-3928: Net::HTTP doesn't timeout as expected when using timeout.rb
def test_timeout_socket_connect
assert_raises(Timeout::Error) do
- timeout(0.1) do
+ Timeout.timeout(0.1) do
TCPSocket.new('google.com', 12345)
end
end
@@ -183,9 +183,9 @@ def method_missing(method, *args, &block)
end
def test_timeout_interval_argument
- assert_equal 42, Timeout::timeout(Seconds.new(2)) { 42 }
+ assert_equal 42, Timeout.timeout(Seconds.new(2)) { 42 }
assert_raises(Timeout::Error) do
- Timeout::timeout(Seconds.new(0.3)) { sleep(0.5) }
+ Timeout.timeout(Seconds.new(0.3)) { sleep(0.5) }
end
end
diff --git a/test/jruby/test_zlib.rb b/test/jruby/test_zlib.rb
index c4431685ce0..2bc61e86849 100644
--- a/test/jruby/test_zlib.rb
+++ b/test/jruby/test_zlib.rb
@@ -7,7 +7,9 @@
class TestZlib < Test::Unit::TestCase
include TestHelper
- def teardown; File.unlink @filename if @filename; end
+ def teardown
+ File.unlink @filename if defined?(@filename)
+ end
def test_inflate_deflate
s = "test comression string"
@@ -350,6 +352,7 @@ def z.write(arg)
def z.buf
@buf
end
+ z.instance_variable_set(:@buf, nil)
assert_nil z.buf
Zlib::GzipWriter.wrap(z) { |io| io.write("hello") }
assert_not_nil z.buf
diff --git a/test/truffle/integration/execjs.sh b/test/truffle/gems/execjs.sh
similarity index 70%
rename from test/truffle/integration/execjs.sh
rename to test/truffle/gems/execjs.sh
index c5bdf37d5f4..a87fae80434 100755
--- a/test/truffle/integration/execjs.sh
+++ b/test/truffle/gems/execjs.sh
@@ -3,6 +3,6 @@
set -e
bin/jruby bin/gem install execjs -v 2.6.0
-ruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test/truffle/integration/execjs/checkruntime.rb
-ruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test/truffle/integration/execjs/simple.rb
-ruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test/truffle/integration/execjs/coffeescript.rb
+ruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test/truffle/gems/execjs/checkruntime.rb
+ruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test/truffle/gems/execjs/simple.rb
+ruby -X+T -Ilib/ruby/gems/shared/gems/execjs-2.6.0/lib test/truffle/gems/execjs/coffeescript.rb
diff --git a/test/truffle/integration/execjs/checkruntime.rb b/test/truffle/gems/execjs/checkruntime.rb
similarity index 100%
rename from test/truffle/integration/execjs/checkruntime.rb
rename to test/truffle/gems/execjs/checkruntime.rb
diff --git a/test/truffle/integration/execjs/coffeescript.js b/test/truffle/gems/execjs/coffeescript.js
similarity index 100%
rename from test/truffle/integration/execjs/coffeescript.js
rename to test/truffle/gems/execjs/coffeescript.js
diff --git a/test/truffle/integration/execjs/coffeescript.rb b/test/truffle/gems/execjs/coffeescript.rb
similarity index 100%
rename from test/truffle/integration/execjs/coffeescript.rb
rename to test/truffle/gems/execjs/coffeescript.rb
diff --git a/test/truffle/integration/execjs/simple.rb b/test/truffle/gems/execjs/simple.rb
similarity index 100%
rename from test/truffle/integration/execjs/simple.rb
rename to test/truffle/gems/execjs/simple.rb
diff --git a/test/truffle/gems/gem-testing.sh b/test/truffle/gems/gem-testing.sh
new file mode 100755
index 00000000000..9f88482214e
--- /dev/null
+++ b/test/truffle/gems/gem-testing.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+gem install bundler
+
+mkdir -p test/truffle/gems/gem-testing
+jruby+truffle --dir test/truffle/gems/gem-testing ci --batch lib/ruby/truffle/jruby+truffle/gem_ci/travis.txt
diff --git a/test/truffle/integration/rack-server.sh b/test/truffle/gems/rack-server.sh
similarity index 54%
rename from test/truffle/integration/rack-server.sh
rename to test/truffle/gems/rack-server.sh
index d58de6c0bc2..63a0f4ae37e 100755
--- a/test/truffle/integration/rack-server.sh
+++ b/test/truffle/gems/rack-server.sh
@@ -3,5 +3,5 @@
set -e
bin/jruby bin/gem install rack -v 1.6.1
-source test/truffle/integration/common/test_server.sh.inc
-ruby -X+T -Ilib/ruby/gems/shared/gems/rack-1.6.1/lib test/truffle/integration/rack-server/rack-server.rb & test_server
+source test/truffle/gems/common/test_server.sh.inc
+ruby -X+T -Ilib/ruby/gems/shared/gems/rack-1.6.1/lib test/truffle/gems/rack-server/rack-server.rb & test_server
diff --git a/test/truffle/integration/rack-server/rack-server.rb b/test/truffle/gems/rack-server/rack-server.rb
similarity index 100%
rename from test/truffle/integration/rack-server/rack-server.rb
rename to test/truffle/gems/rack-server/rack-server.rb
diff --git a/test/truffle/integration/rails-app.sh b/test/truffle/gems/rails-app.sh
similarity index 96%
rename from test/truffle/integration/rails-app.sh
rename to test/truffle/gems/rails-app.sh
index c0b000908cb..f1beb805e01 100755
--- a/test/truffle/integration/rails-app.sh
+++ b/test/truffle/gems/rails-app.sh
@@ -2,7 +2,7 @@
set -e
-cd test/truffle/integration/rails-app
+cd test/truffle/gems/rails-app
JRUBY_BIN=../../../../bin
JRUBY=$JRUBY_BIN/jruby
diff --git a/test/truffle/integration/rails-app/.gitignore b/test/truffle/gems/rails-app/.gitignore
similarity index 100%
rename from test/truffle/integration/rails-app/.gitignore
rename to test/truffle/gems/rails-app/.gitignore
diff --git a/test/truffle/integration/rails-app/.jruby+truffle.yaml b/test/truffle/gems/rails-app/.jruby+truffle.yaml
similarity index 100%
rename from test/truffle/integration/rails-app/.jruby+truffle.yaml
rename to test/truffle/gems/rails-app/.jruby+truffle.yaml
diff --git a/test/truffle/integration/rails-app/Gemfile b/test/truffle/gems/rails-app/Gemfile
similarity index 100%
rename from test/truffle/integration/rails-app/Gemfile
rename to test/truffle/gems/rails-app/Gemfile
diff --git a/test/truffle/integration/rails-app/Gemfile.lock b/test/truffle/gems/rails-app/Gemfile.lock
similarity index 100%
rename from test/truffle/integration/rails-app/Gemfile.lock
rename to test/truffle/gems/rails-app/Gemfile.lock
diff --git a/test/truffle/integration/rails-app/Rakefile b/test/truffle/gems/rails-app/Rakefile
similarity index 100%
rename from test/truffle/integration/rails-app/Rakefile
rename to test/truffle/gems/rails-app/Rakefile
diff --git a/test/truffle/integration/rails-app/app/assets/images/.keep b/test/truffle/gems/rails-app/app/assets/images/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/app/assets/images/.keep
rename to test/truffle/gems/rails-app/app/assets/images/.keep
diff --git a/test/truffle/integration/rails-app/app/assets/stylesheets/application.css b/test/truffle/gems/rails-app/app/assets/stylesheets/application.css
similarity index 100%
rename from test/truffle/integration/rails-app/app/assets/stylesheets/application.css
rename to test/truffle/gems/rails-app/app/assets/stylesheets/application.css
diff --git a/test/truffle/integration/rails-app/app/controllers/application_controller.rb b/test/truffle/gems/rails-app/app/controllers/application_controller.rb
similarity index 100%
rename from test/truffle/integration/rails-app/app/controllers/application_controller.rb
rename to test/truffle/gems/rails-app/app/controllers/application_controller.rb
diff --git a/test/truffle/integration/rails-app/app/controllers/concerns/.keep b/test/truffle/gems/rails-app/app/controllers/concerns/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/app/controllers/concerns/.keep
rename to test/truffle/gems/rails-app/app/controllers/concerns/.keep
diff --git a/test/truffle/integration/rails-app/app/controllers/people_controller.rb b/test/truffle/gems/rails-app/app/controllers/people_controller.rb
similarity index 100%
rename from test/truffle/integration/rails-app/app/controllers/people_controller.rb
rename to test/truffle/gems/rails-app/app/controllers/people_controller.rb
diff --git a/test/truffle/integration/rails-app/app/helpers/application_helper.rb b/test/truffle/gems/rails-app/app/helpers/application_helper.rb
similarity index 100%
rename from test/truffle/integration/rails-app/app/helpers/application_helper.rb
rename to test/truffle/gems/rails-app/app/helpers/application_helper.rb
diff --git a/test/truffle/integration/rails-app/app/models/concerns/.keep b/test/truffle/gems/rails-app/app/models/concerns/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/app/models/concerns/.keep
rename to test/truffle/gems/rails-app/app/models/concerns/.keep
diff --git a/test/truffle/integration/rails-app/app/models/person.rb b/test/truffle/gems/rails-app/app/models/person.rb
similarity index 100%
rename from test/truffle/integration/rails-app/app/models/person.rb
rename to test/truffle/gems/rails-app/app/models/person.rb
diff --git a/test/truffle/integration/rails-app/app/views/layouts/application.html.erb b/test/truffle/gems/rails-app/app/views/layouts/application.html.erb
similarity index 100%
rename from test/truffle/integration/rails-app/app/views/layouts/application.html.erb
rename to test/truffle/gems/rails-app/app/views/layouts/application.html.erb
diff --git a/test/truffle/integration/rails-app/app/views/people/index.erb b/test/truffle/gems/rails-app/app/views/people/index.erb
similarity index 100%
rename from test/truffle/integration/rails-app/app/views/people/index.erb
rename to test/truffle/gems/rails-app/app/views/people/index.erb
diff --git a/test/truffle/integration/rails-app/bin/bundle b/test/truffle/gems/rails-app/bin/bundle
similarity index 100%
rename from test/truffle/integration/rails-app/bin/bundle
rename to test/truffle/gems/rails-app/bin/bundle
diff --git a/test/truffle/integration/rails-app/bin/rails b/test/truffle/gems/rails-app/bin/rails
similarity index 100%
rename from test/truffle/integration/rails-app/bin/rails
rename to test/truffle/gems/rails-app/bin/rails
diff --git a/test/truffle/integration/rails-app/bin/rake b/test/truffle/gems/rails-app/bin/rake
similarity index 100%
rename from test/truffle/integration/rails-app/bin/rake
rename to test/truffle/gems/rails-app/bin/rake
diff --git a/test/truffle/integration/rails-app/bin/setup b/test/truffle/gems/rails-app/bin/setup
similarity index 100%
rename from test/truffle/integration/rails-app/bin/setup
rename to test/truffle/gems/rails-app/bin/setup
diff --git a/test/truffle/integration/rails-app/config.ru b/test/truffle/gems/rails-app/config.ru
similarity index 100%
rename from test/truffle/integration/rails-app/config.ru
rename to test/truffle/gems/rails-app/config.ru
diff --git a/test/truffle/integration/rails-app/config/application.rb b/test/truffle/gems/rails-app/config/application.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/application.rb
rename to test/truffle/gems/rails-app/config/application.rb
diff --git a/test/truffle/integration/rails-app/config/boot.rb b/test/truffle/gems/rails-app/config/boot.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/boot.rb
rename to test/truffle/gems/rails-app/config/boot.rb
diff --git a/test/truffle/integration/rails-app/config/database.yml b/test/truffle/gems/rails-app/config/database.yml
similarity index 100%
rename from test/truffle/integration/rails-app/config/database.yml
rename to test/truffle/gems/rails-app/config/database.yml
diff --git a/test/truffle/integration/rails-app/config/environment.rb b/test/truffle/gems/rails-app/config/environment.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/environment.rb
rename to test/truffle/gems/rails-app/config/environment.rb
diff --git a/test/truffle/integration/rails-app/config/environments/development.rb b/test/truffle/gems/rails-app/config/environments/development.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/environments/development.rb
rename to test/truffle/gems/rails-app/config/environments/development.rb
diff --git a/test/truffle/integration/rails-app/config/environments/production.rb b/test/truffle/gems/rails-app/config/environments/production.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/environments/production.rb
rename to test/truffle/gems/rails-app/config/environments/production.rb
diff --git a/test/truffle/integration/rails-app/config/environments/test.rb b/test/truffle/gems/rails-app/config/environments/test.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/environments/test.rb
rename to test/truffle/gems/rails-app/config/environments/test.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/backtrace_silencers.rb b/test/truffle/gems/rails-app/config/initializers/backtrace_silencers.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/backtrace_silencers.rb
rename to test/truffle/gems/rails-app/config/initializers/backtrace_silencers.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/cookies_serializer.rb b/test/truffle/gems/rails-app/config/initializers/cookies_serializer.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/cookies_serializer.rb
rename to test/truffle/gems/rails-app/config/initializers/cookies_serializer.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/filter_parameter_logging.rb b/test/truffle/gems/rails-app/config/initializers/filter_parameter_logging.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/filter_parameter_logging.rb
rename to test/truffle/gems/rails-app/config/initializers/filter_parameter_logging.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/inflections.rb b/test/truffle/gems/rails-app/config/initializers/inflections.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/inflections.rb
rename to test/truffle/gems/rails-app/config/initializers/inflections.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/mime_types.rb b/test/truffle/gems/rails-app/config/initializers/mime_types.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/mime_types.rb
rename to test/truffle/gems/rails-app/config/initializers/mime_types.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/session_store.rb b/test/truffle/gems/rails-app/config/initializers/session_store.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/session_store.rb
rename to test/truffle/gems/rails-app/config/initializers/session_store.rb
diff --git a/test/truffle/integration/rails-app/config/initializers/wrap_parameters.rb b/test/truffle/gems/rails-app/config/initializers/wrap_parameters.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/initializers/wrap_parameters.rb
rename to test/truffle/gems/rails-app/config/initializers/wrap_parameters.rb
diff --git a/test/truffle/integration/rails-app/config/locales/en.yml b/test/truffle/gems/rails-app/config/locales/en.yml
similarity index 100%
rename from test/truffle/integration/rails-app/config/locales/en.yml
rename to test/truffle/gems/rails-app/config/locales/en.yml
diff --git a/test/truffle/integration/rails-app/config/routes.rb b/test/truffle/gems/rails-app/config/routes.rb
similarity index 100%
rename from test/truffle/integration/rails-app/config/routes.rb
rename to test/truffle/gems/rails-app/config/routes.rb
diff --git a/test/truffle/integration/rails-app/config/secrets.yml b/test/truffle/gems/rails-app/config/secrets.yml
similarity index 100%
rename from test/truffle/integration/rails-app/config/secrets.yml
rename to test/truffle/gems/rails-app/config/secrets.yml
diff --git a/test/truffle/integration/rails-app/lib/assets/.keep b/test/truffle/gems/rails-app/lib/assets/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/lib/assets/.keep
rename to test/truffle/gems/rails-app/lib/assets/.keep
diff --git a/test/truffle/integration/rails-app/lib/tasks/.keep b/test/truffle/gems/rails-app/lib/tasks/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/lib/tasks/.keep
rename to test/truffle/gems/rails-app/lib/tasks/.keep
diff --git a/test/truffle/integration/rails-app/log/.keep b/test/truffle/gems/rails-app/log/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/log/.keep
rename to test/truffle/gems/rails-app/log/.keep
diff --git a/test/truffle/integration/rails-app/public/404.html b/test/truffle/gems/rails-app/public/404.html
similarity index 100%
rename from test/truffle/integration/rails-app/public/404.html
rename to test/truffle/gems/rails-app/public/404.html
diff --git a/test/truffle/integration/rails-app/public/422.html b/test/truffle/gems/rails-app/public/422.html
similarity index 100%
rename from test/truffle/integration/rails-app/public/422.html
rename to test/truffle/gems/rails-app/public/422.html
diff --git a/test/truffle/integration/rails-app/public/500.html b/test/truffle/gems/rails-app/public/500.html
similarity index 100%
rename from test/truffle/integration/rails-app/public/500.html
rename to test/truffle/gems/rails-app/public/500.html
diff --git a/test/truffle/integration/rails-app/public/favicon.ico b/test/truffle/gems/rails-app/public/favicon.ico
similarity index 100%
rename from test/truffle/integration/rails-app/public/favicon.ico
rename to test/truffle/gems/rails-app/public/favicon.ico
diff --git a/test/truffle/integration/rails-app/public/robots.txt b/test/truffle/gems/rails-app/public/robots.txt
similarity index 100%
rename from test/truffle/integration/rails-app/public/robots.txt
rename to test/truffle/gems/rails-app/public/robots.txt
diff --git a/test/truffle/integration/rails-app/public/stylesheets/application.css b/test/truffle/gems/rails-app/public/stylesheets/application.css
similarity index 100%
rename from test/truffle/integration/rails-app/public/stylesheets/application.css
rename to test/truffle/gems/rails-app/public/stylesheets/application.css
diff --git a/test/truffle/integration/rails-app/public/stylesheets/kube.css b/test/truffle/gems/rails-app/public/stylesheets/kube.css
similarity index 100%
rename from test/truffle/integration/rails-app/public/stylesheets/kube.css
rename to test/truffle/gems/rails-app/public/stylesheets/kube.css
diff --git a/test/truffle/integration/rails-app/test/controllers/.keep b/test/truffle/gems/rails-app/test/controllers/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/test/controllers/.keep
rename to test/truffle/gems/rails-app/test/controllers/.keep
diff --git a/test/truffle/integration/rails-app/test/fixtures/.keep b/test/truffle/gems/rails-app/test/fixtures/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/test/fixtures/.keep
rename to test/truffle/gems/rails-app/test/fixtures/.keep
diff --git a/test/truffle/integration/rails-app/test/helpers/.keep b/test/truffle/gems/rails-app/test/helpers/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/test/helpers/.keep
rename to test/truffle/gems/rails-app/test/helpers/.keep
diff --git a/test/truffle/integration/rails-app/test/integration/.keep b/test/truffle/gems/rails-app/test/integration/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/test/integration/.keep
rename to test/truffle/gems/rails-app/test/integration/.keep
diff --git a/test/truffle/integration/rails-app/test/mailers/.keep b/test/truffle/gems/rails-app/test/mailers/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/test/mailers/.keep
rename to test/truffle/gems/rails-app/test/mailers/.keep
diff --git a/test/truffle/integration/rails-app/test/models/.keep b/test/truffle/gems/rails-app/test/models/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/test/models/.keep
rename to test/truffle/gems/rails-app/test/models/.keep
diff --git a/test/truffle/integration/rails-app/test/test_helper.rb b/test/truffle/gems/rails-app/test/test_helper.rb
similarity index 100%
rename from test/truffle/integration/rails-app/test/test_helper.rb
rename to test/truffle/gems/rails-app/test/test_helper.rb
diff --git a/test/truffle/integration/rails-app/vendor/assets/javascripts/.keep b/test/truffle/gems/rails-app/vendor/assets/javascripts/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/vendor/assets/javascripts/.keep
rename to test/truffle/gems/rails-app/vendor/assets/javascripts/.keep
diff --git a/test/truffle/integration/rails-app/vendor/assets/stylesheets/.keep b/test/truffle/gems/rails-app/vendor/assets/stylesheets/.keep
similarity index 100%
rename from test/truffle/integration/rails-app/vendor/assets/stylesheets/.keep
rename to test/truffle/gems/rails-app/vendor/assets/stylesheets/.keep
diff --git a/test/truffle/integration/sinatra-server.sh b/test/truffle/gems/sinatra-server.sh
similarity index 74%
rename from test/truffle/integration/sinatra-server.sh
rename to test/truffle/gems/sinatra-server.sh
index 621f8f4e611..c9ea848e103 100755
--- a/test/truffle/integration/sinatra-server.sh
+++ b/test/truffle/gems/sinatra-server.sh
@@ -6,5 +6,5 @@ bin/jruby bin/gem install rack -v 1.6.1
bin/jruby bin/gem install tilt -v 2.0.1
bin/jruby bin/gem install rack-protection -v 1.5.3
bin/jruby bin/gem install sinatra -v 1.4.6
-source test/truffle/integration/common/test_server.sh.inc
-ruby -X+T -Ilib/ruby/gems/shared/gems/rack-1.6.1/lib -Ilib/ruby/gems/shared/gems/tilt-2.0.1/lib -Ilib/ruby/gems/shared/gems/rack-protection-1.5.3/lib -Ilib/ruby/gems/shared/gems/sinatra-1.4.6/lib test/truffle/integration/sinatra-server/sinatra-server.rb & test_server
+source test/truffle/gems/common/test_server.sh.inc
+ruby -X+T -Ilib/ruby/gems/shared/gems/rack-1.6.1/lib -Ilib/ruby/gems/shared/gems/tilt-2.0.1/lib -Ilib/ruby/gems/shared/gems/rack-protection-1.5.3/lib -Ilib/ruby/gems/shared/gems/sinatra-1.4.6/lib test/truffle/gems/sinatra-server/sinatra-server.rb & test_server
diff --git a/test/truffle/integration/sinatra-server/sinatra-server.rb b/test/truffle/gems/sinatra-server/sinatra-server.rb
similarity index 100%
rename from test/truffle/integration/sinatra-server/sinatra-server.rb
rename to test/truffle/gems/sinatra-server/sinatra-server.rb
diff --git a/test/truffle/integration/coverage.sh_excluded b/test/truffle/integration/coverage.sh
similarity index 100%
rename from test/truffle/integration/coverage.sh_excluded
rename to test/truffle/integration/coverage.sh
diff --git a/test/truffle/integration/gem-testing.sh b/test/truffle/integration/gem-testing.sh
deleted file mode 100755
index 2edb38a1640..00000000000
--- a/test/truffle/integration/gem-testing.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-gem install bundler
-
-mkdir -p test/truffle/integration/gem-testing
-jruby+truffle --dir test/truffle/integration/gem-testing ci --batch lib/ruby/truffle/jruby+truffle/gem_ci/travis.txt
-
diff --git a/test/truffle/integration/instrumentation-server.sh_excluded b/test/truffle/integration/instrumentation-server.sh
similarity index 100%
rename from test/truffle/integration/instrumentation-server.sh_excluded
rename to test/truffle/integration/instrumentation-server.sh
diff --git a/test/truffle/integration/long-tests.txt b/test/truffle/integration/long-tests.txt
deleted file mode 100644
index d72d927d061..00000000000
--- a/test/truffle/integration/long-tests.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-rails-app.sh
-gem-testing.sh
diff --git a/test/truffle/integration/tracing.sh_excluded b/test/truffle/integration/tracing.sh
similarity index 100%
rename from test/truffle/integration/tracing.sh_excluded
rename to test/truffle/integration/tracing.sh
diff --git a/test/truffle/tarball.sh b/test/truffle/tarball.sh
index 4e6d901ae8a..d025559ff55 100755
--- a/test/truffle/tarball.sh
+++ b/test/truffle/tarball.sh
@@ -5,9 +5,6 @@
set -e
set -x
-TAR_BALL=$1
-BASE=$(dirname $0)
-
tar -zxf $1
if [ -f */bin/jruby ]
@@ -15,13 +12,10 @@ then
# JRuby tarball
RUBY=`echo */bin/jruby`
FLAGS='-X+T'
- TOOL=`echo */bin/jruby+truffle`
- $RUBY `dirname $RUBY`/gem install bundler
else
# GraalVM tarball
RUBY=`echo */bin/ruby`
FLAGS=
- TOOL=`echo */bin/ruby-tool`
fi
if [ ! -f $RUBY ]
@@ -59,19 +53,3 @@ then
echo Standard library test failed
exit 1
fi
-
-rm -rf openweather
-git clone https://github.com/lucasocon/openweather.git
-pushd openweather
-rm -rf .jruby+truffle
-git checkout 87e49710c9130107acb13a0dda92ec4bb0db70b0
-../$TOOL setup
-LONDON=`../$TOOL --no-use-fs-core run examples/temperature.rb London | grep London:`
-if [[ "$LONDON" =~ London:\ [0-9]+\.[0-9]+\ ℃ ]]
-then
- echo Passed, and the temperature in $LONDON
-else
- echo Gem test failed
- exit 1
-fi
-popd
diff --git a/tool/jt.rb b/tool/jt.rb
index f9cb197d7c8..014b5d1808e 100755
--- a/tool/jt.rb
+++ b/tool/jt.rb
@@ -304,8 +304,8 @@ def help
puts 'jt test spec/ruby/language/while_spec.rb run specs in this file'
puts 'jt test compiler run compiler tests (uses the same logic as --graal to find Graal)'
puts ' --no-java-cmd don\'t set JAVACMD - rely on bin/jruby or RUBY_BIN to have Graal already'
- puts 'jt test integration [fast|long|all] runs bigger integration tests (fast is default)'
- puts ' --no-gems don\'t run tests that install gems'
+ puts 'jt test integration runs bigger integration tests'
+ puts 'jt test gems tests installing and using gems'
puts 'jt test cexts run C extension tests (set SULONG_DIR)'
puts 'jt tag spec/ruby/language tag failing specs in this directory'
puts 'jt tag spec/ruby/language/while_spec.rb tag failing specs in this file'
@@ -324,7 +324,7 @@ def help
puts ' --score name report results as scores'
puts 'jt metrics ... minheap ... what is the smallest heap you can use to run an application'
puts 'jt metrics ... time ... how long does it take to run a command, broken down into different phases'
- puts 'jt install ..../graal/mx/suite.py install a JRuby distribution into an mx suite'
+ puts 'jt tarball build the and test the distribution tarball'
puts
puts 'you can also put build or rebuild in front of any command'
puts
@@ -471,6 +471,7 @@ def test(*args)
when 'compiler' then test_compiler(*rest)
when 'cexts' then test_cexts(*rest)
when 'integration' then test_integration({}, *rest)
+ when 'gems' then test_gems({}, *rest)
when 'specs' then test_specs('run', *rest)
when 'tck' then
args = []
@@ -542,13 +543,24 @@ def test_cexts(*args)
private :test_cexts
def test_integration(env, *args)
- no_gems = args.delete('--no-gems')
+ env_vars = env
+ jruby_opts = []
+
+ jruby_opts << '-Xtruffle.graal.warn_unless=false'
+ env_vars["JRUBY_OPTS"] = jruby_opts.join(' ')
+
+ env_vars["PATH"] = "#{Utilities.find_jruby_bin_dir}:#{ENV["PATH"]}"
+ tests_path = "#{JRUBY_DIR}/test/truffle/integration"
+ single_test = !args.empty?
+ test_names = single_test ? '{' + args.join(',') + '}' : '*'
- all = args.delete('all')
- long = args.delete('long') || all
- fast = args.delete('fast') || all ||
- !long # fast is the default
+ Dir["#{tests_path}/#{test_names}.sh"].each do |test_script|
+ sh env_vars, test_script
+ end
+ end
+ private :test_integration
+ def test_gems(env, *args)
env_vars = env
jruby_opts = []
@@ -562,21 +574,15 @@ def test_integration(env, *args)
env_vars["JRUBY_OPTS"] = jruby_opts.join(' ')
env_vars["PATH"] = "#{Utilities.find_jruby_bin_dir}:#{ENV["PATH"]}"
- integration_path = "#{JRUBY_DIR}/test/truffle/integration"
- long_tests = File.read("#{integration_path}/long-tests.txt").lines.map(&:chomp)
+ tests_path = "#{JRUBY_DIR}/test/truffle/gems"
single_test = !args.empty?
test_names = single_test ? '{' + args.join(',') + '}' : '*'
- Dir["#{integration_path}/#{test_names}.sh"].each do |test_script|
- is_long = long_tests.include?(File.basename(test_script))
- gem_check = !(no_gems && File.read(test_script).include?('gem install'))
- group_check = (is_long && long) || (!is_long && fast)
- run = single_test || group_check && gem_check
-
- sh env_vars, test_script if run
+ Dir["#{tests_path}/#{test_names}.sh"].each do |test_script|
+ sh env_vars, test_script
end
end
- private :test_integration
+ private :test_gems
def test_specs(command, *args)
env_vars = {}
@@ -619,7 +625,7 @@ def test_specs(command, *args)
options += %w[--format spec/truffle/truffle_formatter.rb]
end
- if ENV['TRAVIS']
+ if ENV['CI']
# Need lots of output to keep Travis happy
options += %w[--format specdoc]
end
@@ -858,6 +864,15 @@ def human_size(bytes)
end
end
+ def tarball
+ mvn '-Pdist'
+ generated_file = "#{JRUBY_DIR}/maven/jruby-dist/target/jruby-dist-#{Utilities.jruby_version}-bin.tar.gz"
+ final_file = "#{JRUBY_DIR}/jruby-bin-#{Utilities.jruby_version}.tar.gz"
+ FileUtils.copy generated_file, final_file
+ FileUtils.copy "#{generated_file}.sha256", "#{final_file}.sha256"
+ sh 'test/truffle/tarball.sh', final_file
+ end
+
def log(tty_message, full_message)
if STDOUT.tty?
print(tty_message) unless tty_message.nil?
@@ -885,37 +900,6 @@ def check_ambiguous_arguments
run({ "TRUFFLE_CHECK_AMBIGUOUS_OPTIONAL_ARGS" => "true" }, '-e', 'exit')
end
- def install(arg)
- case arg
- when /.*suite.*\.py$/
- rebuild
- mvn '-Pcomplete'
-
- suite_file = arg
- suite_lines = File.readlines(suite_file)
- version = Utilities.jruby_version
-
- [
- ['maven/jruby-complete/target', "jruby-complete"],
- ['truffle/target', "jruby-truffle"]
- ].each do |dir, name|
- jar_name = "#{name}-#{version}.jar"
- source_jar_path = "#{dir}/#{jar_name}"
- shasum = Digest::SHA1.hexdigest File.read(source_jar_path)
- jar_shasum_name = "#{name}-#{version}-#{shasum}.jar"
- FileUtils.cp source_jar_path, "#{File.expand_path('../..', suite_file)}/lib/#{jar_shasum_name}"
- line_index = suite_lines.find_index { |line| line.start_with? " \"path\" : \"lib/#{name}" }
- suite_lines[line_index] = " \"path\" : \"lib/#{jar_shasum_name}\",\n"
- suite_lines[line_index + 1] = " \#\"urls\" : [\"http://lafo.ssw.uni-linz.ac.at/truffle/ruby/#{jar_shasum_name}\"],\n"
- suite_lines[line_index + 2] = " \"sha1\" : \"#{shasum}\"\n"
- end
-
- File.write(suite_file, suite_lines.join())
- else
- raise ArgumentError, kind
- end
- end
-
end
class JT
diff --git a/tool/travis_runner.sh b/tool/travis_runner.sh
index 07aad4591fc..7e17b717ec8 100755
--- a/tool/travis_runner.sh
+++ b/tool/travis_runner.sh
@@ -3,9 +3,15 @@
set -e
set -x
-if [ -z "$SKIP_BUILD" ]
+if [[ -v PHASE ]]
then
- ./mvnw install -B -Dinvoker.skip=false $PHASE | egrep -v 'Download|\\[exec\\] [[:digit:]]+/[[:digit:]]+|^[[:space:]]*\\[exec\\][[:space:]]*$'
+ DOWNLOAD_OUTPUT_FILTER='Download|\\[exec\\] [[:digit:]]+/[[:digit:]]+|^[[:space:]]*\\[exec\\][[:space:]]*$'
+ if [[ $JAVA_HOME == *"java-8"* ]]
+ then
+ ./mvnw package -B --projects '!truffle' -Dinvoker.skip=false $PHASE | egrep -v "$DOWNLOAD_OUTPUT_FILTER"
+ else
+ ./mvnw package -B -Dinvoker.skip=false $PHASE | egrep -v "$DOWNLOAD_OUTPUT_FILTER"
+ fi
MVN_STATUS=${PIPESTATUS[0]}
diff --git a/truffle/pom.rb b/truffle/pom.rb
index c48e6cd99ff..9b88c5b3cce 100644
--- a/truffle/pom.rb
+++ b/truffle/pom.rb
@@ -38,8 +38,8 @@
'verbose' => 'false',
'showWarnings' => 'true',
'showDeprecation' => 'true',
- 'source' => [ '${base.java.version}', '1.7' ],
- 'target' => [ '${base.javac.version}', '1.7' ],
+ 'source' => '1.8',
+ 'target' => '1.8',
'useIncrementalCompilation' => 'false' ) do
execute_goals( 'compile',
:id => 'default-compile',
diff --git a/truffle/pom.xml b/truffle/pom.xml
index 04b5d44b3e1..fef39080ace 100644
--- a/truffle/pom.xml
+++ b/truffle/pom.xml
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
org.jruby
jruby-parent
- 9.1.0.0
+ 9.1.1.0-SNAPSHOT
jruby-truffle
JRuby Truffle
@@ -142,10 +142,8 @@ DO NOT MODIFIY - GENERATED CODE
false
true
true
-
-
- ${base.javac.version}
- 1.7
+
+ 1.8
false
diff --git a/truffle/src/main/java/org/jruby/truffle/Layouts.java b/truffle/src/main/java/org/jruby/truffle/Layouts.java
index 82d770b0246..122e459f22a 100644
--- a/truffle/src/main/java/org/jruby/truffle/Layouts.java
+++ b/truffle/src/main/java/org/jruby/truffle/Layouts.java
@@ -18,6 +18,7 @@
import org.jruby.truffle.core.basicobject.BasicObjectLayoutImpl;
import org.jruby.truffle.core.binding.BindingLayout;
import org.jruby.truffle.core.binding.BindingLayoutImpl;
+import org.jruby.truffle.core.dir.DirLayout;
import org.jruby.truffle.core.dir.DirLayoutImpl;
import org.jruby.truffle.core.encoding.EncodingConverterLayout;
import org.jruby.truffle.core.encoding.EncodingConverterLayoutImpl;
@@ -61,7 +62,6 @@
import org.jruby.truffle.core.rubinius.AtomicReferenceLayoutImpl;
import org.jruby.truffle.core.rubinius.ByteArrayLayout;
import org.jruby.truffle.core.rubinius.ByteArrayLayoutImpl;
-import org.jruby.truffle.core.dir.DirLayout;
import org.jruby.truffle.core.rubinius.IOBufferLayout;
import org.jruby.truffle.core.rubinius.IOBufferLayoutImpl;
import org.jruby.truffle.core.rubinius.IOLayout;
diff --git a/truffle/src/main/java/org/jruby/truffle/RubyContext.java b/truffle/src/main/java/org/jruby/truffle/RubyContext.java
index f9847e89bea..1465531d390 100644
--- a/truffle/src/main/java/org/jruby/truffle/RubyContext.java
+++ b/truffle/src/main/java/org/jruby/truffle/RubyContext.java
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.instrumentation.Instrumenter;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.Ruby;
+import org.jruby.truffle.builtins.PrimitiveManager;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.exception.CoreExceptions;
import org.jruby.truffle.core.kernel.AtExitManager;
@@ -24,7 +25,6 @@
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.core.objectspace.ObjectSpaceManager;
import org.jruby.truffle.core.rope.RopeTable;
-import org.jruby.truffle.builtins.PrimitiveManager;
import org.jruby.truffle.core.string.CoreStrings;
import org.jruby.truffle.core.string.FrozenStrings;
import org.jruby.truffle.core.symbol.SymbolTable;
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/AmbiguousOptionalArgumentChecker.java b/truffle/src/main/java/org/jruby/truffle/builtins/AmbiguousOptionalArgumentChecker.java
new file mode 100644
index 00000000000..f1290030c25
--- /dev/null
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/AmbiguousOptionalArgumentChecker.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
+ * code is released under a tri EPL/GPL/LGPL license. You can use it,
+ * redistribute it and/or modify it under the terms of the:
+ *
+ * Eclipse Public License version 1.0
+ * GNU General Public License version 2
+ * GNU Lesser General Public License version 2.1
+ */
+package org.jruby.truffle.builtins;
+
+import com.oracle.truffle.api.dsl.Specialization;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+
+public class AmbiguousOptionalArgumentChecker {
+
+ public static boolean SUCCESS = true;
+
+ public static void verifyNoAmbiguousOptionalArguments(CoreMethodNodeManager.MethodDetails methodDetails) {
+ try {
+ verifyNoAmbiguousOptionalArgumentsWithReflection(methodDetails);
+ } catch (Exception e) {
+ e.printStackTrace();
+ SUCCESS = false;
+ }
+ }
+
+ private static void verifyNoAmbiguousOptionalArgumentsWithReflection(CoreMethodNodeManager.MethodDetails methodDetails) throws ReflectiveOperationException {
+ final CoreMethod methodAnnotation = methodDetails.getMethodAnnotation();
+ if (methodAnnotation.optional() > 0 || methodAnnotation.needsBlock()) {
+ int opt = methodAnnotation.optional();
+ if (methodAnnotation.needsBlock()) {
+ opt++;
+ }
+
+ Class> node = methodDetails.getNodeFactory().getNodeClass();
+
+ for (int i = 1; i <= opt; i++) {
+ boolean unguardedObjectArgument = false;
+ StringBuilder errors = new StringBuilder();
+ for (Method method : node.getDeclaredMethods()) {
+ if (method.isAnnotationPresent(Specialization.class)) {
+ // count from the end to ignore optional VirtualFrame in front.
+ Class>[] parameterTypes = method.getParameterTypes();
+ int n = parameterTypes.length - i;
+ if (methodAnnotation.rest()) {
+ n--; // ignore final Object[] argument
+ }
+ Class> parameterType = parameterTypes[n];
+ Parameter[] parameters = method.getParameters();
+
+ Parameter parameter = parameters[n];
+ boolean isNamePresent = parameter.isNamePresent();
+ if (!isNamePresent) {
+ System.err.println("Method parameters names are not available for " + method);
+ System.exit(1);
+ }
+ String name = parameter.getName();
+
+ if (parameterType == Object.class && !name.startsWith("unused") && !name.equals("maybeBlock")) {
+ String[] guards = method.getAnnotation(Specialization.class).guards();
+ if (!isGuarded(name, guards)) {
+ unguardedObjectArgument = true;
+ errors.append("\"").append(name).append("\" in ").append(methodToString(method, parameterTypes, parameters)).append("\n");
+ }
+ }
+ }
+ }
+
+ if (unguardedObjectArgument) {
+ SUCCESS = false;
+ System.err.println("Ambiguous optional argument in " + node.getCanonicalName() + ":");
+ System.err.println(errors);
+ }
+ }
+ }
+ }
+
+ private static boolean isGuarded(String name, String[] guards) {
+ for (String guard : guards) {
+ if (guard.equals("wasProvided(" + name + ")") ||
+ guard.equals("wasNotProvided(" + name + ")") ||
+ guard.equals("wasNotProvided(" + name + ") || isRubiniusUndefined(" + name + ")") ||
+ guard.equals("isNil(" + name + ")")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String methodToString(Method method, Class>[] parameterTypes, Parameter[] parameters) throws ReflectiveOperationException {
+ StringBuilder str = new StringBuilder();
+ str.append(method.getName()).append("(");
+ for (int i = 0; i < parameters.length; i++) {
+ Parameter parameter = parameters[i];
+ String name = parameter.getName();
+ str.append(parameterTypes[i].getSimpleName()).append(" ").append(name);
+ if (i < parameters.length - 1) {
+ str.append(", ");
+ }
+ }
+ str.append(")");
+ return str.toString();
+ }
+}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/BinaryCoreMethodNode.java b/truffle/src/main/java/org/jruby/truffle/builtins/BinaryCoreMethodNode.java
deleted file mode 100644
index 3759880db2a..00000000000
--- a/truffle/src/main/java/org/jruby/truffle/builtins/BinaryCoreMethodNode.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
- * code is released under a tri EPL/GPL/LGPL license. You can use it,
- * redistribute it and/or modify it under the terms of the:
- *
- * Eclipse Public License version 1.0
- * GNU General Public License version 2
- * GNU Lesser General Public License version 2.1
- */
-package org.jruby.truffle.builtins;
-
-import com.oracle.truffle.api.dsl.NodeChild;
-import com.oracle.truffle.api.dsl.NodeChildren;
-import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
-import org.jruby.truffle.language.RubyNode;
-
-@NodeChildren({
- @NodeChild(value = "left", type = RubyNode.class),
- @NodeChild(value = "right", type = RubyNode.class)})
-public abstract class BinaryCoreMethodNode extends CoreMethodNode {
-
- public BinaryCoreMethodNode() {
- }
-
- public BinaryCoreMethodNode(RubyContext context, SourceSection sourceSection) {
- super(context, sourceSection);
- }
-
- public abstract RubyNode getLeft();
-
- public abstract RubyNode getRight();
-
-}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/CallPrimitiveNode.java b/truffle/src/main/java/org/jruby/truffle/builtins/CallPrimitiveNode.java
index 28c38e3133e..9b6e706ae60 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/CallPrimitiveNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/CallPrimitiveNode.java
@@ -17,16 +17,12 @@
import org.jruby.truffle.language.control.ReturnException;
import org.jruby.truffle.language.control.ReturnID;
-/**
- * Node which wraps a {@link PrimitiveNode}, providing the implicit control flow that you get with calls to
- * Rubinius primitives.
- */
public class CallPrimitiveNode extends RubyNode {
@Child private RubyNode primitive;
private final ReturnID returnID;
- private final ConditionProfile primitiveSucceededCondition = ConditionProfile.createBinaryProfile();
+ private final ConditionProfile failedProfile = ConditionProfile.createBinaryProfile();
public CallPrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode primitive, ReturnID returnID) {
super(context, sourceSection);
@@ -35,22 +31,17 @@ public CallPrimitiveNode(RubyContext context, SourceSection sourceSection, RubyN
}
@Override
- public void executeVoid(VirtualFrame frame) {
+ public Object execute(VirtualFrame frame) {
final Object value = primitive.execute(frame);
- if (primitiveSucceededCondition.profile(value != null)) {
+ // Primitives fail by returning null, allowing the method to continue (the fallback)
+ if (failedProfile.profile(value == null)) {
+ return nil();
+ } else {
// If the primitive didn't fail its value is returned in the calling method
-
throw new ReturnException(returnID, value);
}
- // Primitives may return null to indicate that they have failed, in which case we continue with the fallback
- }
-
- @Override
- public Object execute(VirtualFrame frame) {
- executeVoid(frame);
- return nil();
}
}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethod.java b/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethod.java
index 47a1884b019..7d80f3fee18 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethod.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethod.java
@@ -24,14 +24,12 @@
String[] names();
- // where the method is to be defined
Visibility visibility() default Visibility.PUBLIC;
/**
- * Defines the method on the singleton class.
- * {@link #needsSelf() needsSelf} is always false.
- * See {@link #constructor() constructor} if you need self.
- * */
+ * Defines the method on the singleton class. {@link #needsSelf() needsSelf} is always false. See
+ * {@link #constructor() constructor} if you need self.
+ */
boolean onSingleton() default false;
/**
@@ -40,31 +38,23 @@
boolean constructor() default false;
/**
- * Defines the method as public on the singleton class
- * and as a private instance method.
- * {@link #needsSelf() needsSelf} is always false
- * as it could be either a module or any receiver.
+ * Defines the method as public on the singleton class and as a private instance method.
+ * {@link #needsSelf() needsSelf} is always false as it could be either a module or any receiver.
*/
boolean isModuleFunction() default false;
boolean needsCallerFrame() default false;
- // arguments specification
- /** Whether self
is passed as first argument to specializations. */
boolean needsSelf() default true;
int required() default 0;
int optional() default 0;
- /**
- * Give the remaining arguments as a Object[] and allows unlimited arguments.
- */
boolean rest() default false;
boolean needsBlock() default false;
- // arguments transformation
boolean lowerFixnumSelf() default false;
int[] lowerFixnumParameters() default {};
@@ -77,7 +67,6 @@
int[] raiseIfFrozenParameters() default {};
- // extra behavior
UnsupportedOperationBehavior unsupportedOperationBehavior() default UnsupportedOperationBehavior.TYPE_ERROR;
boolean returnsEnumeratorIfNoBlock() default false;
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java b/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java
index 359fbe32080..6194438af46 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/CoreMethodNodeManager.java
@@ -12,15 +12,13 @@
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.NodeFactory;
-import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.Visibility;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.RaiseIfFrozenNode;
-import org.jruby.truffle.core.ReturnEnumeratorIfNoBlockNode;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.core.cast.TaintResultNode;
import org.jruby.truffle.core.module.ModuleOperations;
@@ -46,7 +44,6 @@
import org.jruby.truffle.language.parser.jruby.Translator;
import org.jruby.truffle.platform.UnsafeGroup;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -157,7 +154,7 @@ private static void addMethod(RubyContext context, DynamicObject module, RubyRoo
private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails methodDetails) {
final CoreMethod method = methodDetails.getMethodAnnotation();
- final SourceSection sourceSection = CoreSourceSection.createCoreSourceSection(methodDetails.getClassAnnotation().value(), method.names()[0]);
+ final SourceSection sourceSection = SourceSection.createUnavailable(null, String.format("%s#%s", methodDetails.getClassAnnotation().value(), method.names()[0]));
final int required = method.required();
final int optional = method.optional();
@@ -166,7 +163,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
final Arity arity = new Arity(required, optional, method.rest());
- final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, method.names()[0], methodDetails.getIndicativeName(), false, null, context.getOptions().CORE_ALWAYS_CLONE, alwaysInline, needsCallerFrame);
+ final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, method.names()[0], false, null, context.getOptions().CORE_ALWAYS_CLONE, alwaysInline, needsCallerFrame);
final List argumentsNodes = new ArrayList<>();
@@ -355,108 +352,4 @@ public String getIndicativeName() {
}
}
- private static class AmbiguousOptionalArgumentChecker {
-
- private static final Method GET_PARAMETERS = checkParametersNamesAvailable();
- private static boolean SUCCESS = true;
-
- private static Method checkParametersNamesAvailable() {
- try {
- return Method.class.getMethod("getParameters");
- } catch (NoSuchMethodException | SecurityException e) {
- // Java 7 or could not find how to get names of method parameters
- System.err.println("Could not find method Method.getParameters()");
- System.exit(1);
- return null;
- }
- }
-
- private static void verifyNoAmbiguousOptionalArguments(MethodDetails methodDetails) {
- try {
- verifyNoAmbiguousOptionalArgumentsWithReflection(methodDetails);
- } catch (Exception e) {
- e.printStackTrace();
- SUCCESS = false;
- }
- }
-
- private static void verifyNoAmbiguousOptionalArgumentsWithReflection(MethodDetails methodDetails) throws ReflectiveOperationException {
- final CoreMethod methodAnnotation = methodDetails.getMethodAnnotation();
- if (methodAnnotation.optional() > 0 || methodAnnotation.needsBlock()) {
- int opt = methodAnnotation.optional();
- if (methodAnnotation.needsBlock()) {
- opt++;
- }
-
- Class> node = methodDetails.getNodeFactory().getNodeClass();
-
- for (int i = 1; i <= opt; i++) {
- boolean unguardedObjectArgument = false;
- StringBuilder errors = new StringBuilder();
- for (Method method : node.getDeclaredMethods()) {
- if (method.isAnnotationPresent(Specialization.class)) {
- // count from the end to ignore optional VirtualFrame in front.
- Class>[] parameterTypes = method.getParameterTypes();
- int n = parameterTypes.length - i;
- if (methodAnnotation.rest()) {
- n--; // ignore final Object[] argument
- }
- Class> parameterType = parameterTypes[n];
- Object[] parameters = (Object[]) GET_PARAMETERS.invoke(method);
-
- Object parameter = parameters[n];
- boolean isNamePresent = (boolean) parameter.getClass().getMethod("isNamePresent").invoke(parameter);
- if (!isNamePresent) {
- System.err.println("Method parameters names are not available for " + method);
- System.exit(1);
- }
- String name = (String) parameter.getClass().getMethod("getName").invoke(parameter);
-
- if (parameterType == Object.class && !name.startsWith("unused") && !name.equals("maybeBlock")) {
- String[] guards = method.getAnnotation(Specialization.class).guards();
- if (!isGuarded(name, guards)) {
- unguardedObjectArgument = true;
- errors.append("\"").append(name).append("\" in ").append(methodToString(method, parameterTypes, parameters)).append("\n");
- }
- }
- }
- }
-
- if (unguardedObjectArgument) {
- SUCCESS = false;
- System.err.println("Ambiguous optional argument in " + node.getCanonicalName() + ":");
- System.err.println(errors);
- }
- }
- }
- }
-
- private static boolean isGuarded(String name, String[] guards) {
- for (String guard : guards) {
- if (guard.equals("wasProvided(" + name + ")") ||
- guard.equals("wasNotProvided(" + name + ")") ||
- guard.equals("wasNotProvided(" + name + ") || isRubiniusUndefined(" + name + ")") ||
- guard.equals("isNil(" + name + ")")) {
- return true;
- }
- }
- return false;
- }
-
- private static String methodToString(Method method, Class>[] parameterTypes, Object[] parameters) throws ReflectiveOperationException {
- StringBuilder str = new StringBuilder();
- str.append(method.getName()).append("(");
- for (int i = 0; i < parameters.length; i++) {
- Object parameter = parameters[i];
- String name = (String) parameter.getClass().getMethod("getName").invoke(parameter);
- str.append(parameterTypes[i].getSimpleName()).append(" ").append(name);
- if (i < parameters.length - 1) {
- str.append(", ");
- }
- }
- str.append(")");
- return str.toString();
- }
- }
-
}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/CoreSourceSection.java b/truffle/src/main/java/org/jruby/truffle/builtins/CoreSourceSection.java
deleted file mode 100644
index 250a20c2b52..00000000000
--- a/truffle/src/main/java/org/jruby/truffle/builtins/CoreSourceSection.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
- * code is released under a tri EPL/GPL/LGPL license. You can use it,
- * redistribute it and/or modify it under the terms of the:
- *
- * Eclipse Public License version 1.0
- * GNU General Public License version 2
- * GNU Lesser General Public License version 2.1
- */
-package org.jruby.truffle.builtins;
-
-import com.oracle.truffle.api.source.SourceSection;
-
-public abstract class CoreSourceSection {
-
- public static SourceSection createCoreSourceSection(String className, String methodName) {
- return SourceSection.createUnavailable("core", String.format("%s#%s", className, methodName));
- }
-
- public static boolean isCoreSourceSection(SourceSection sourceSection) {
- return sourceSection.getShortDescription().startsWith("core: ");
- }
-
-}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/InvokeRubiniusPrimitiveNode.java b/truffle/src/main/java/org/jruby/truffle/builtins/InvokePrimitiveNode.java
similarity index 88%
rename from truffle/src/main/java/org/jruby/truffle/builtins/InvokeRubiniusPrimitiveNode.java
rename to truffle/src/main/java/org/jruby/truffle/builtins/InvokePrimitiveNode.java
index 4de649db8eb..1c3a44776fd 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/InvokeRubiniusPrimitiveNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/InvokePrimitiveNode.java
@@ -15,13 +15,13 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
-public class InvokeRubiniusPrimitiveNode extends RubyNode {
+public class InvokePrimitiveNode extends RubyNode {
@Child private RubyNode primitive;
private final ConditionProfile primitiveSucceededCondition = ConditionProfile.createBinaryProfile();
- public InvokeRubiniusPrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode primitive) {
+ public InvokePrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode primitive) {
super(context, sourceSection);
this.primitive = primitive;
}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveArrayArgumentsNode.java b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveArrayArgumentsNode.java
index 6e795f561f0..1cf12dfe143 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveArrayArgumentsNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveArrayArgumentsNode.java
@@ -13,7 +13,6 @@
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
-import org.jruby.truffle.builtins.PrimitiveNode;
import org.jruby.truffle.language.RubyNode;
@GenerateNodeFactory
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveCallConstructor.java b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveCallConstructor.java
index 241d5a98fcc..15f93dbc9ce 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveCallConstructor.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveCallConstructor.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.method.MethodNodesFactory;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveConstructor.java b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveConstructor.java
index cf4dd6fccf6..de8499cfeb9 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveConstructor.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveConstructor.java
@@ -15,9 +15,11 @@
import org.jruby.truffle.language.control.ReturnID;
public interface PrimitiveConstructor {
- public int getPrimitiveArity();
- public RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourceSection, ReturnID returnID);
+ int getPrimitiveArity();
+
+ RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourceSection, ReturnID returnID);
+
+ RubyNode createInvokePrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode[] arguments);
- public RubyNode createInvokePrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode[] arguments);
}
diff --git a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveNodeConstructor.java b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveNodeConstructor.java
index 05c3f95054b..203f0e26e61 100644
--- a/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveNodeConstructor.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/PrimitiveNodeConstructor.java
@@ -99,10 +99,10 @@ public RubyNode createInvokePrimitiveNode(RubyContext context, SourceSection sou
List> signature = signatures.get(0);
if (signature.get(0) == RubyContext.class) {
- return new InvokeRubiniusPrimitiveNode(context, sourceSection,
+ return new InvokePrimitiveNode(context, sourceSection,
factory.createNode(context, sourceSection, arguments));
} else {
- return new InvokeRubiniusPrimitiveNode(context, sourceSection,
+ return new InvokePrimitiveNode(context, sourceSection,
factory.createNode(new Object[]{arguments}));
}
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/ReturnEnumeratorIfNoBlockNode.java b/truffle/src/main/java/org/jruby/truffle/builtins/ReturnEnumeratorIfNoBlockNode.java
similarity index 98%
rename from truffle/src/main/java/org/jruby/truffle/core/ReturnEnumeratorIfNoBlockNode.java
rename to truffle/src/main/java/org/jruby/truffle/builtins/ReturnEnumeratorIfNoBlockNode.java
index 9b1de03b4af..3a0530d5126 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/ReturnEnumeratorIfNoBlockNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/builtins/ReturnEnumeratorIfNoBlockNode.java
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
-package org.jruby.truffle.core;
+package org.jruby.truffle.builtins;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java b/truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
index 4e772caf38d..a72816ac246 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
@@ -18,7 +18,6 @@
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.object.Layout;
import com.oracle.truffle.api.object.Property;
-import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
import org.jcodings.EncodingDB;
import org.jcodings.specific.UTF8Encoding;
@@ -31,7 +30,6 @@
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreMethodNodeManager;
-import org.jruby.truffle.builtins.CoreSourceSection;
import org.jruby.truffle.core.array.ArrayNodes;
import org.jruby.truffle.core.array.ArrayNodesFactory;
import org.jruby.truffle.core.basicobject.BasicObjectNodesFactory;
@@ -103,10 +101,10 @@
import org.jruby.truffle.language.parser.ParserContext;
import org.jruby.truffle.platform.RubiniusTypes;
import org.jruby.truffle.platform.signal.SignalManager;
-import org.jruby.truffle.stdlib.bigdecimal.BigDecimalNodesFactory;
import org.jruby.truffle.stdlib.CoverageNodesFactory;
import org.jruby.truffle.stdlib.EtcNodesFactory;
import org.jruby.truffle.stdlib.ObjSpaceNodesFactory;
+import org.jruby.truffle.stdlib.bigdecimal.BigDecimalNodesFactory;
import org.jruby.truffle.stdlib.digest.DigestNodesFactory;
import org.jruby.truffle.stdlib.psych.PsychEmitterNodesFactory;
import org.jruby.truffle.stdlib.psych.PsychParserNodesFactory;
@@ -346,10 +344,10 @@ private static class CoreLibraryNode extends RubyNode {
@Child SingletonClassNode singletonClassNode;
@Child FreezeNode freezeNode;
- public CoreLibraryNode(RubyContext context, SourceSection sourceSection) {
- super(context, sourceSection);
- this.singletonClassNode = SingletonClassNodeGen.create(context, sourceSection, null);
- this.freezeNode = FreezeNodeGen.create(context, sourceSection, null);
+ public CoreLibraryNode(RubyContext context) {
+ super(context, null);
+ this.singletonClassNode = SingletonClassNodeGen.create(context, null, null);
+ this.freezeNode = FreezeNodeGen.create(context, null, null);
adoptChildren();
}
@@ -368,7 +366,7 @@ public Object execute(VirtualFrame frame) {
public CoreLibrary(RubyContext context) {
this.context = context;
- this.node = new CoreLibraryNode(context, CoreSourceSection.createCoreSourceSection("CoreLibrary", "initialize"));
+ this.node = new CoreLibraryNode(context);
// Nothing in this constructor can use RubyContext.getCoreLibrary() as we are building it!
// Therefore, only initialize the core classes and modules here.
@@ -545,7 +543,7 @@ public CoreLibrary(RubyContext context) {
Layouts.CLASS.setInstanceFactoryUnsafe(ioClass, Layouts.IO.createIOShape(ioClass, ioClass));
internalBufferClass = defineClass(ioClass, objectClass, "InternalBuffer");
Layouts.CLASS.setInstanceFactoryUnsafe(internalBufferClass, Layouts.IO_BUFFER.createIOBufferShape(internalBufferClass, internalBufferClass));
- weakRefClass = defineClass("WeakRef");
+ weakRefClass = defineClass(basicObjectClass, "WeakRef");
weakRefFactory = Layouts.WEAK_REF_LAYOUT.createWeakRefShape(weakRefClass, weakRefClass);
Layouts.CLASS.setInstanceFactoryUnsafe(weakRefClass, weakRefFactory);
final DynamicObject tracePointClass = defineClass("TracePoint");
diff --git a/truffle/src/main/java/org/jruby/truffle/core/MainNodes.java b/truffle/src/main/java/org/jruby/truffle/core/MainNodes.java
index 0efeca048b9..028abe5f0cc 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/MainNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/MainNodes.java
@@ -32,7 +32,7 @@ public abstract static class PublicNode extends CoreMethodArrayArgumentsNode {
public PublicNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- publicNode = ModuleNodesFactory.PublicNodeFactory.create(context, sourceSection, new RubyNode[]{null, null});
+ publicNode = ModuleNodesFactory.PublicNodeFactory.create(context, sourceSection, null);
}
@Specialization
@@ -49,7 +49,7 @@ public abstract static class PrivateNode extends CoreMethodArrayArgumentsNode {
public PrivateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- privateNode = ModuleNodesFactory.PrivateNodeFactory.create(context, sourceSection, new RubyNode[]{null, null});
+ privateNode = ModuleNodesFactory.PrivateNodeFactory.create(context, sourceSection, null);
}
@Specialization
diff --git a/truffle/src/main/java/org/jruby/truffle/core/ObjectNodes.java b/truffle/src/main/java/org/jruby/truffle/core/ObjectNodes.java
index 17d7f2c072e..683b3b36875 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/ObjectNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/ObjectNodes.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.language.objects.IsTaintedNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/adapaters/OutputStreamAdapter.java b/truffle/src/main/java/org/jruby/truffle/core/adapaters/OutputStreamAdapter.java
index e3a9c7f994a..67bc5c9f9c6 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/adapaters/OutputStreamAdapter.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/adapaters/OutputStreamAdapter.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendManyNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendManyNode.java
index e4ecd367ac1..a0daba81155 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendManyNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendManyNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import static org.jruby.truffle.core.array.ArrayHelpers.getSize;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendOneNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendOneNode.java
index 2859e3debdc..a6fb8b43502 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendOneNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendOneNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayBuilderNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayBuilderNode.java
index 0560c1a9328..6bed8804863 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayBuilderNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayBuilderNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
/*
* TODO(CS): how does this work when when multithreaded? Could a node get replaced by someone else and
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayConcatNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayConcatNode.java
index 970dc6c1a43..2f2b3e81907 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayConcatNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayConcatNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDropTailNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDropTailNode.java
index c3fae520b39..f650b2be77a 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDropTailNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDropTailNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import static org.jruby.truffle.core.array.ArrayHelpers.createArray;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDupNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDupNode.java
index 008fc40aec0..b0aa829c7ad 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDupNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayDupNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayEnsureCapacityNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayEnsureCapacityNode.java
index f9bc122c243..506f2bd09b5 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayEnsureCapacityNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayEnsureCapacityNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGeneralizeNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGeneralizeNode.java
index c9259c029d4..9569ec5ed59 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGeneralizeNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGeneralizeNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGetTailNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGetTailNode.java
index 78b37d93933..675eb19a70d 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGetTailNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayGetTailNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import static org.jruby.truffle.core.array.ArrayHelpers.createArray;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayHelpers.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayHelpers.java
index 59f9a29fb05..38fd6ca9ac2 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayHelpers.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayHelpers.java
@@ -10,8 +10,8 @@
package org.jruby.truffle.core.array;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
public abstract class ArrayHelpers {
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayLiteralNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayLiteralNode.java
index ae94b499e30..4b0e96dcd35 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayLiteralNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayLiteralNode.java
@@ -16,9 +16,9 @@
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.CoreLibrary;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
index 3f762d72059..803b1300fc0 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
@@ -31,13 +31,12 @@
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.builtins.CoreSourceSection;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
@@ -697,7 +696,7 @@ public abstract static class DeleteNode extends ArrayCoreMethodNode {
public DeleteNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(new RubyNode[]{null,null});
+ equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(null);
}
@Specialization(guards = "isNullArray(array)")
@@ -892,7 +891,7 @@ public abstract static class IncludeNode extends ArrayCoreMethodNode {
public IncludeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(new RubyNode[]{null,null});
+ equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(null);
}
@Specialization(guards = "isNullArray(array)")
@@ -1355,15 +1354,13 @@ public static class MaxBlock {
private final CallTarget callTarget;
public MaxBlock(RubyContext context) {
- final SourceSection sourceSection = CoreSourceSection.createCoreSourceSection("Array", "max");
-
frameDescriptor = new FrameDescriptor(context.getCoreLibrary().getNilObject());
frameSlot = frameDescriptor.addFrameSlot("maximum_memo");
- sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "max", false, null, false, false, false);
+ sharedMethodInfo = new SharedMethodInfo(SourceSection.createUnavailable(null, "Array#max block"), null, Arity.NO_ARGUMENTS, "max", false, null, false, false, false);
- callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, MaxBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
- new ReadDeclarationVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
+ callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, null, null, sharedMethodInfo, MaxBlockNodeFactory.create(context, null, new RubyNode[]{
+ new ReadDeclarationVariableNode(context, null, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
new ReadPreArgumentNode(0, MissingArgumentBehavior.RUNTIME_ERROR)
}), false));
}
@@ -1477,15 +1474,13 @@ public static class MinBlock {
private final CallTarget callTarget;
public MinBlock(RubyContext context) {
- final SourceSection sourceSection = CoreSourceSection.createCoreSourceSection("Array", "min");
-
frameDescriptor = new FrameDescriptor(context.getCoreLibrary().getNilObject());
frameSlot = frameDescriptor.addFrameSlot("minimum_memo");
- sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "min", false, null, false, false, false);
+ sharedMethodInfo = new SharedMethodInfo(SourceSection.createUnavailable(null, "Array#min block"), null, Arity.NO_ARGUMENTS, "min", false, null, false, false, false);
- callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, MinBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
- new ReadDeclarationVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
+ callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, null, null, sharedMethodInfo, MinBlockNodeFactory.create(context, null, new RubyNode[]{
+ new ReadDeclarationVariableNode(context, null, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
new ReadPreArgumentNode(0, MissingArgumentBehavior.RUNTIME_ERROR)
}), false));
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayPopOneNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayPopOneNode.java
index c1af09dc40e..e7dfd63507f 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayPopOneNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayPopOneNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadDenormalizedNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadDenormalizedNode.java
index 7692c320fc1..516c552b1ac 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadDenormalizedNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadDenormalizedNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadNormalizedNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadNormalizedNode.java
index 7bf353789e9..f0828cba494 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadNormalizedNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadNormalizedNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceDenormalizedNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceDenormalizedNode.java
index e492addc360..300be9904f9 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceDenormalizedNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceDenormalizedNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChildren({
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceNormalizedNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceNormalizedNode.java
index 03dd7782f3b..28b50c07b1e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceNormalizedNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayReadSliceNormalizedNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArraySliceNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArraySliceNode.java
index 11b478d335d..c1d18df1f27 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArraySliceNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArraySliceNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import static org.jruby.truffle.core.array.ArrayHelpers.createArray;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayWriteNormalizedNode.java b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayWriteNormalizedNode.java
index 487b4d6fb45..295a94b0009 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/array/ArrayWriteNormalizedNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/array/ArrayWriteNormalizedNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import static org.jruby.truffle.core.array.ArrayHelpers.getSize;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/basicobject/BasicObjectNodes.java b/truffle/src/main/java/org/jruby/truffle/core/basicobject/BasicObjectNodes.java
index 6e1265c290c..1279bffe620 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/basicobject/BasicObjectNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/basicobject/BasicObjectNodes.java
@@ -24,7 +24,6 @@
import org.jcodings.specific.ASCIIEncoding;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.RubyContext;
-import org.jruby.truffle.builtins.BinaryCoreMethodNode;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
@@ -93,7 +92,7 @@ public boolean equal(VirtualFrame frame, Object a, Object b) {
}
@CoreMethod(names = { "equal?", "==" }, required = 1)
- public abstract static class ReferenceEqualNode extends BinaryCoreMethodNode {
+ public abstract static class ReferenceEqualNode extends CoreMethodArrayArgumentsNode {
public abstract boolean executeReferenceEqual(VirtualFrame frame, Object a, Object b);
diff --git a/truffle/src/main/java/org/jruby/truffle/core/binding/BindingNodes.java b/truffle/src/main/java/org/jruby/truffle/core/binding/BindingNodes.java
index 53b218a762c..d892dcc9830 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/binding/BindingNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/binding/BindingNodes.java
@@ -20,11 +20,11 @@
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.array.ArrayHelpers;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ArrayCastNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ArrayCastNode.java
index d7839e02f84..7c21a04a6f4 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ArrayCastNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ArrayCastNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/CmpIntNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/CmpIntNode.java
index 86397d462a7..6935e027dc0 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/CmpIntNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/CmpIntNode.java
@@ -28,8 +28,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/NameToJavaStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/NameToJavaStringNode.java
index 517e92ce4c8..176ea5db977 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/NameToJavaStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/NameToJavaStringNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/NameToSymbolOrStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/NameToSymbolOrStringNode.java
index da6f8733c66..9cde25c0357 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/NameToSymbolOrStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/NameToSymbolOrStringNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/SingleValueCastNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/SingleValueCastNode.java
index f78a3db9a16..15dc3e4aeab 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/SingleValueCastNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/SingleValueCastNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChild(value = "child", type = RubyNode.class)
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/SplatCastNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/SplatCastNode.java
index d8e3ab87224..b8eed415ff4 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/SplatCastNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/SplatCastNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayDupNode;
import org.jruby.truffle.core.array.ArrayDupNodeGen;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/StringToSymbolNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/StringToSymbolNode.java
index f15711fff12..2b822f2aaf7 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/StringToSymbolNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/StringToSymbolNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
/**
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ToAryNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ToAryNode.java
index 5cf6f4f05b6..90c623c6106 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ToAryNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ToAryNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ToFNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ToFNode.java
index 8ba50086be1..d8b7b7188ec 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ToFNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ToFNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ToIntNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ToIntNode.java
index 216aa6ef39a..2ff83f301cd 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ToIntNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ToIntNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
-import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.numeric.FloatNodes;
import org.jruby.truffle.core.numeric.FloatNodesFactory;
import org.jruby.truffle.language.RubyGuards;
@@ -86,7 +86,7 @@ public DynamicObject coerceRubyBignum(DynamicObject value) {
public Object coerceDouble(VirtualFrame frame, double value) {
if (floatToIntNode == null) {
CompilerDirectives.transferToInterpreter();
- floatToIntNode = insert(FloatNodesFactory.ToINodeFactory.create(getContext(), getSourceSection(), new RubyNode[] { null }));
+ floatToIntNode = insert(FloatNodesFactory.ToINodeFactory.create(getContext(), getSourceSection(), null));
}
return floatToIntNode.executeToI(frame, value);
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ToProcNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ToProcNode.java
index 2fa6d28d00b..b1c621616cb 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ToProcNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ToProcNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ToSNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ToSNode.java
index 19ab897319b..fa9b3ab62d1 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ToSNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ToSNode.java
@@ -38,7 +38,7 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
protected DynamicObject kernelToS(VirtualFrame frame, Object object) {
if (kernelToSNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- kernelToSNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(), getSourceSection(), new RubyNode[] {null}));
+ kernelToSNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(), getSourceSection(), null));
}
return kernelToSNode.executeToS(frame, object);
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/cast/ToStrNode.java b/truffle/src/main/java/org/jruby/truffle/core/cast/ToStrNode.java
index 3dcca512b05..0dbce20ab20 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/cast/ToStrNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/cast/ToStrNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/dir/DirNodes.java b/truffle/src/main/java/org/jruby/truffle/core/dir/DirNodes.java
index 2bb7d45abe3..52519a4531d 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/dir/DirNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/dir/DirNodes.java
@@ -43,8 +43,8 @@
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingConverterNodes.java b/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingConverterNodes.java
index 9771945f641..ec890835ac5 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingConverterNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingConverterNodes.java
@@ -29,11 +29,11 @@
import org.jruby.Ruby;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingNodes.java b/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingNodes.java
index ef72945a6a4..0136f59f97e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/encoding/EncodingNodes.java
@@ -24,11 +24,11 @@
import org.jcodings.specific.UTF8Encoding;
import org.jcodings.util.CaseInsensitiveBytesHash;
import org.jcodings.util.Hash;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/exception/CoreExceptions.java b/truffle/src/main/java/org/jruby/truffle/core/exception/CoreExceptions.java
index cc6e48c9e79..bb66d15273d 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/exception/CoreExceptions.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/exception/CoreExceptions.java
@@ -15,8 +15,8 @@
import jnr.constants.platform.Errno;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.Visibility;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.encoding.EncodingOperations;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.core.rope.Rope;
@@ -137,6 +137,10 @@ public DynamicObject runtimeErrorCompiled(Node currentNode) {
return runtimeError("Truffle::Graal.assert_not_compiled can only be called lexically", currentNode);
}
+ public DynamicObject runtimeErrorCoverageNotEnabled(Node currentNode) {
+ return runtimeError("coverage measurement is not enabled", currentNode);
+ }
+
@TruffleBoundary
public DynamicObject runtimeError(String message, Node currentNode) {
return ExceptionOperations.createRubyException(
diff --git a/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionNodes.java b/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionNodes.java
index abdafd4bd64..93c6ff75a5c 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionNodes.java
@@ -17,11 +17,11 @@
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionOperations.java b/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionOperations.java
index 489dbaf7ba7..51b2c3be2c1 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/exception/ExceptionOperations.java
@@ -12,8 +12,8 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.backtrace.Backtrace;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberManager.java b/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberManager.java
index 07598ef3a37..de0dc0f6fd7 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberManager.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import java.util.Collections;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java b/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
index 8b873438de3..6ad0986c76c 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
@@ -18,12 +18,12 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.cast.SingleValueCastNode;
import org.jruby.truffle.core.cast.SingleValueCastNodeGen;
@@ -260,7 +260,7 @@ public abstract static class ResumeNode extends CoreMethodArrayArgumentsNode {
public ResumeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(new RubyNode[] { null, null, null });
+ fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(null);
}
@Specialization
@@ -277,7 +277,7 @@ public abstract static class YieldNode extends CoreMethodArrayArgumentsNode {
public YieldNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(new RubyNode[] { null, null, null });
+ fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(null);
}
@Specialization
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToLongNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToLongNode.java
index 07bd597aee8..e8c0cb4bac3 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToLongNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToLongNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.CantConvertException;
import org.jruby.truffle.core.format.exceptions.NoImplicitConversionException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToStringNode.java
index 102dd38f227..9c3b8886f39 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/convert/ToStringNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.NoImplicitConversionException;
import org.jruby.truffle.core.kernel.KernelNodes;
@@ -138,7 +138,7 @@ public byte[] toString(VirtualFrame frame, Object object) {
if (inspectNode == null) {
CompilerDirectives.transferToInterpreter();
inspectNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(),
- getEncapsulatingSourceSection(), new RubyNode[]{null}));
+ getEncapsulatingSourceSection(), null));
}
return Layouts.STRING.getRope(inspectNode.toS(frame, object)).getBytes();
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/format/FormatIntegerNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/format/FormatIntegerNode.java
index 056a49a8924..b9e432af337 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/format/FormatIntegerNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/format/FormatIntegerNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.printf.PrintfTreeBuilder;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBase64StringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBase64StringNode.java
index ebba43c9b8e..eea511a0808 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBase64StringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBase64StringNode.java
@@ -51,8 +51,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jcodings.specific.ASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.InvalidFormatException;
import org.jruby.truffle.core.format.read.SourceNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBinaryStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBinaryStringNode.java
index e1990bb87c5..34990bfff67 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBinaryStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBinaryStringNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.specific.ASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.read.SourceNode;
import org.jruby.truffle.core.rope.AsciiOnlyLeafRope;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBitStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBitStringNode.java
index d068b9a712d..c699b4fe9e4 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBitStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBitStringNode.java
@@ -50,8 +50,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jcodings.specific.USASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.read.SourceNode;
import org.jruby.truffle.core.rope.AsciiOnlyLeafRope;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadHexStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadHexStringNode.java
index 44df4f8c10e..3b922dcb418 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadHexStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadHexStringNode.java
@@ -50,8 +50,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jcodings.specific.USASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.read.SourceNode;
import org.jruby.truffle.core.rope.AsciiOnlyLeafRope;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadMIMEStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadMIMEStringNode.java
index 0dfb46ed28a..fdd1ef2eb59 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadMIMEStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadMIMEStringNode.java
@@ -50,8 +50,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jcodings.specific.USASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.read.SourceNode;
import org.jruby.truffle.core.rope.AsciiOnlyLeafRope;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUUStringNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUUStringNode.java
index 73badcb3312..61851da1da3 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUUStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUUStringNode.java
@@ -50,8 +50,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jcodings.specific.USASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.read.SourceNode;
import org.jruby.truffle.core.rope.AsciiOnlyLeafRope;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBERNode.java b/truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBERNode.java
index e9109036530..1451056f3a3 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBERNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBERNode.java
@@ -52,8 +52,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatGuards;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.CantCompressNegativeException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/BucketsStrategy.java b/truffle/src/main/java/org/jruby/truffle/core/hash/BucketsStrategy.java
index f03606e80f3..9cc17df65ae 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/BucketsStrategy.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/BucketsStrategy.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import java.util.Arrays;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/HashLiteralNode.java b/truffle/src/main/java/org/jruby/truffle/core/hash/HashLiteralNode.java
index 43bbe4a3fe0..8741b1bb00b 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/HashLiteralNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/HashLiteralNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java b/truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java
index 70d430bd1cc..94f1c20f4b1 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java
@@ -24,12 +24,12 @@
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
import org.jruby.truffle.core.array.ArrayBuilderNode;
@@ -185,7 +185,7 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
- equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null);
+ equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null);
callDefaultNode = DispatchHeadNodeFactory.createMethodCall(context);
lookupEntryNode = new LookupEntryNode(context, sourceSection);
}
@@ -375,7 +375,7 @@ public abstract static class GetOrUndefinedNode extends CoreMethodArrayArguments
public GetOrUndefinedNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- getIndexNode = HashNodesFactory.GetIndexNodeFactory.create(context, sourceSection, new RubyNode[]{null, null});
+ getIndexNode = HashNodesFactory.GetIndexNodeFactory.create(context, sourceSection, null);
getIndexNode.setUndefinedValue(context.getCoreLibrary().getRubiniusUndefined());
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/HashOperations.java b/truffle/src/main/java/org/jruby/truffle/core/hash/HashOperations.java
index 2c510cfee4b..8fb771d139e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/HashOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/HashOperations.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import java.util.Collections;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/LookupEntryNode.java b/truffle/src/main/java/org/jruby/truffle/core/hash/LookupEntryNode.java
index 687542e9aed..16768be6905 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/LookupEntryNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/LookupEntryNode.java
@@ -13,11 +13,12 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.basicobject.BasicObjectNodes;
import org.jruby.truffle.core.basicobject.BasicObjectNodesFactory;
import org.jruby.truffle.language.RubyBaseNode;
+import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.language.dispatch.DispatchHeadNodeFactory;
@@ -33,7 +34,7 @@ public LookupEntryNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
- equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null);
+ equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null);
}
public HashLookupResult lookup(VirtualFrame frame, DynamicObject hash, Object key) {
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/PackedArrayStrategy.java b/truffle/src/main/java/org/jruby/truffle/core/hash/PackedArrayStrategy.java
index 9ee21c89f9d..3c01bfdf8be 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/PackedArrayStrategy.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/PackedArrayStrategy.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import java.util.Iterator;
import java.util.Map;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/hash/SetNode.java b/truffle/src/main/java/org/jruby/truffle/core/hash/SetNode.java
index c466d9daafd..e494ea98092 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/hash/SetNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/hash/SetNode.java
@@ -20,8 +20,8 @@
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.basicobject.BasicObjectNodes;
import org.jruby.truffle.core.basicobject.BasicObjectNodesFactory;
import org.jruby.truffle.language.RubyNode;
@@ -59,7 +59,7 @@ public SetNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
- equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null);
+ equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null);
}
public abstract Object executeSet(VirtualFrame frame, DynamicObject hash, Object key, Object value, boolean byIdentity);
diff --git a/truffle/src/main/java/org/jruby/truffle/core/kernel/AtExitManager.java b/truffle/src/main/java/org/jruby/truffle/core/kernel/AtExitManager.java
index 34d903473ed..bb48ba7f8d3 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/kernel/AtExitManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/kernel/AtExitManager.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.proc.ProcOperations;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java b/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
index f56e32c13fd..c8ed9bfcdcd 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
@@ -40,12 +40,12 @@
import org.jcodings.specific.UTF8Encoding;
import org.jruby.common.IRubyWarnings;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.ObjectNodes;
import org.jruby.truffle.core.ObjectNodesFactory;
@@ -231,7 +231,7 @@ public boolean sameOrEqual(VirtualFrame frame, Object a, Object b) {
private boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null));
+ referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
@@ -282,7 +282,7 @@ public abstract static class CompareNode extends CoreMethodArrayArgumentsNode {
public CompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- equalNode = SameOrEqualNodeFactory.create(new RubyNode[]{ null, null });
+ equalNode = SameOrEqualNodeFactory.create(null);
}
@Specialization
@@ -1931,8 +1931,8 @@ public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {
public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
classNode = LogicalClassNodeGen.create(context, sourceSection, null);
- objectIDNode = ObjectNodesFactory.ObjectIDPrimitiveNodeFactory.create(new RubyNode[]{ null });
- toHexStringNode = KernelNodesFactory.ToHexStringNodeFactory.create(new RubyNode[]{ null });
+ objectIDNode = ObjectNodesFactory.ObjectIDPrimitiveNodeFactory.create(null);
+ toHexStringNode = KernelNodesFactory.ToHexStringNodeFactory.create(null);
}
public abstract DynamicObject executeToS(VirtualFrame frame, Object self);
diff --git a/truffle/src/main/java/org/jruby/truffle/core/kernel/TraceManager.java b/truffle/src/main/java/org/jruby/truffle/core/kernel/TraceManager.java
index 1644537698f..af5ba21df33 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/kernel/TraceManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/kernel/TraceManager.java
@@ -24,8 +24,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.arguments.RubyArguments;
@@ -74,21 +74,21 @@ public void setTraceFunc(final DynamicObject traceFunc) {
instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(LineTag.class).build(), new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext eventContext) {
- return new BaseEventEventNode(context, traceFunc, context.getCoreStrings().LINE.createInstance());
+ return new BaseEventEventNode(context, eventContext, traceFunc, context.getCoreStrings().LINE.createInstance());
}
}));
instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(CallTag.class).build(), new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext eventContext) {
- return new CallEventEventNode(context, traceFunc, context.getCoreStrings().CALL.createInstance());
+ return new CallEventEventNode(context, eventContext, traceFunc, context.getCoreStrings().CALL.createInstance());
}
}));
instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(ClassTag.class).build(), new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext eventContext) {
- return new BaseEventEventNode(context, traceFunc, context.getCoreStrings().CLASS.createInstance());
+ return new BaseEventEventNode(context, eventContext, traceFunc, context.getCoreStrings().CLASS.createInstance());
}
}));
@@ -99,6 +99,7 @@ private class BaseEventEventNode extends ExecutionEventNode {
protected final ConditionProfile inTraceFuncProfile = ConditionProfile.createBinaryProfile();
protected final RubyContext context;
+ protected final EventContext eventContext;
protected final DynamicObject traceFunc;
protected final Object event;
@@ -107,8 +108,9 @@ private class BaseEventEventNode extends ExecutionEventNode {
@CompilationFinal private DynamicObject file;
@CompilationFinal private int line;
- public BaseEventEventNode(RubyContext context, DynamicObject traceFunc, Object event) {
+ public BaseEventEventNode(RubyContext context, EventContext eventContext, DynamicObject traceFunc, Object event) {
this.context = context;
+ this.eventContext = eventContext;
this.traceFunc = traceFunc;
this.event = event;
}
@@ -137,7 +139,7 @@ protected void onEnter(VirtualFrame frame) {
private DynamicObject getFile() {
if (file == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- file = StringOperations.createString(context, context.getRopeTable().getRopeUTF8(getEncapsulatingSourceSection().getSource().getName()));
+ file = StringOperations.createString(context, context.getRopeTable().getRopeUTF8(eventContext.getInstrumentedSourceSection().getSource().getName()));
}
return file;
@@ -146,7 +148,7 @@ private DynamicObject getFile() {
private int getLine() {
if (line == 0) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- line = getEncapsulatingSourceSection().getStartLine();
+ line = eventContext.getInstrumentedSourceSection().getStartLine();
}
return line;
@@ -167,8 +169,8 @@ private class CallEventEventNode extends BaseEventEventNode {
@Child private LogicalClassNode logicalClassNode;
- public CallEventEventNode(RubyContext context, DynamicObject traceFunc, Object event) {
- super(context, traceFunc, event);
+ public CallEventEventNode(RubyContext context, EventContext eventContext, DynamicObject traceFunc, Object event) {
+ super(context, eventContext, traceFunc, event);
}
@Override
diff --git a/truffle/src/main/java/org/jruby/truffle/core/klass/ClassNodes.java b/truffle/src/main/java/org/jruby/truffle/core/klass/ClassNodes.java
index db071ea6a80..0a345b33cc1 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/klass/ClassNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/klass/ClassNodes.java
@@ -20,11 +20,11 @@
import com.oracle.truffle.api.object.ObjectType;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.module.ModuleFields;
import org.jruby.truffle.core.module.ModuleNodes;
import org.jruby.truffle.core.module.ModuleNodesFactory;
@@ -277,7 +277,7 @@ void triggerInheritedHook(VirtualFrame frame, DynamicObject subClass, DynamicObj
void moduleInitialize(VirtualFrame frame, DynamicObject rubyClass, DynamicObject block) {
if (moduleInitializeNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- moduleInitializeNode = insert(ModuleNodesFactory.InitializeNodeFactory.create(new RubyNode[]{ null, null }));
+ moduleInitializeNode = insert(ModuleNodesFactory.InitializeNodeFactory.create(null));
}
moduleInitializeNode.executeInitialize(frame, rubyClass, block);
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/method/MethodNodes.java b/truffle/src/main/java/org/jruby/truffle/core/method/MethodNodes.java
index b57732b0555..f32c2420341 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/method/MethodNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/method/MethodNodes.java
@@ -23,11 +23,11 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.ArgumentDescriptor;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.basicobject.BasicObjectNodes.ReferenceEqualNode;
import org.jruby.truffle.core.basicobject.BasicObjectNodesFactory;
@@ -58,7 +58,7 @@ public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {
protected boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null));
+ referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/method/UnboundMethodNodes.java b/truffle/src/main/java/org/jruby/truffle/core/method/UnboundMethodNodes.java
index 1c8a6082dae..c8b359eee6c 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/method/UnboundMethodNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/method/UnboundMethodNodes.java
@@ -17,11 +17,11 @@
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/module/ModuleFields.java b/truffle/src/main/java/org/jruby/truffle/core/module/ModuleFields.java
index 595516e9ec6..00ea6291b88 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/module/ModuleFields.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/module/ModuleFields.java
@@ -17,18 +17,15 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.utilities.CyclicAssumption;
import org.jruby.runtime.Visibility;
-import org.jruby.truffle.RubyContext;
-import org.jruby.truffle.builtins.CoreSourceSection;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.klass.ClassNodes;
import org.jruby.truffle.core.method.MethodFilter;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyGuards;
-import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.methods.InternalMethod;
import org.jruby.truffle.language.objects.IsFrozenNode;
-import org.jruby.truffle.language.objects.IsFrozenNodeGen;
import org.jruby.truffle.language.objects.ObjectGraphNode;
import org.jruby.truffle.language.objects.ObjectIDOperations;
@@ -313,7 +310,7 @@ public void addMethod(RubyContext context, Node currentNode, InternalMethod meth
if (context.getCoreLibrary().isLoadingRubyCore()) {
final InternalMethod currentMethod = methods.get(method.getName());
- if (currentMethod != null && CoreSourceSection.isCoreSourceSection(currentMethod.getSharedMethodInfo().getSourceSection())) {
+ if (currentMethod != null && currentMethod.getSharedMethodInfo().getSourceSection().getSource() == null) {
return;
}
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java b/truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java
index 2e962bff67a..b0ea516c5ae 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java
@@ -28,23 +28,20 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.object.DynamicObject;
-import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.RaiseIfFrozenNode;
import org.jruby.truffle.core.array.ArrayHelpers;
-import org.jruby.truffle.core.cast.BooleanCastNode;
-import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.core.cast.BooleanCastWithDefaultNodeGen;
import org.jruby.truffle.core.cast.NameToJavaStringNode;
import org.jruby.truffle.core.cast.NameToJavaStringNodeGen;
@@ -98,6 +95,7 @@
import org.jruby.truffle.language.yield.YieldNode;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.util.IdUtil;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -258,7 +256,7 @@ public abstract static class CompareNode extends CoreMethodArrayArgumentsNode {
private Object isSubclass(DynamicObject self, DynamicObject other) {
if (subclassNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- subclassNode = insert(ModuleNodesFactory.IsSubclassOfOrEqualToNodeFactory.create(new RubyNode[]{null, null}));
+ subclassNode = insert(ModuleNodesFactory.IsSubclassOfOrEqualToNodeFactory.create(null));
}
return subclassNode.executeIsSubclassOfOrEqualTo(self, other);
}
@@ -1134,7 +1132,7 @@ public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode
void classEval(VirtualFrame frame, DynamicObject module, DynamicObject block) {
if (classExecNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- classExecNode = insert(ModuleNodesFactory.ClassExecNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{null,null,null}));
+ classExecNode = insert(ModuleNodesFactory.ClassExecNodeFactory.create(getContext(), getSourceSection(), null));
}
classExecNode.executeClassExec(frame, module, new Object[]{}, block);
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/module/ModuleOperations.java b/truffle/src/main/java/org/jruby/truffle/core/module/ModuleOperations.java
index b2b39c4f281..bb31654d751 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/module/ModuleOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/module/ModuleOperations.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.runtime.Visibility;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexNodes.java b/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexNodes.java
index 8823c0073aa..ada65b6a1c0 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexNodes.java
@@ -15,11 +15,11 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.kernel.KernelNodes;
import org.jruby.truffle.language.NotProvided;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexOperations.java b/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexOperations.java
index c9e0647c920..5bf367beccd 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/mutex/MutexOperations.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.thread.ThreadManager;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumNodes.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumNodes.java
index e7d976413dd..b803b7bcafe 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumNodes.java
@@ -18,15 +18,15 @@
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.USASCIIEncoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
-import org.jruby.truffle.builtins.Primitive;
-import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
-import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
+import org.jruby.truffle.builtins.Primitive;
+import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
+import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.cast.BooleanCastNode;
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.core.cast.ToIntNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumOperations.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumOperations.java
index 464ab16cc0b..9473ba45073 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/BignumOperations.java
@@ -1,8 +1,8 @@
package org.jruby.truffle.core.numeric;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import java.math.BigInteger;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/FixnumNodes.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/FixnumNodes.java
index 7e4c037a572..23e0c34a6e5 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/FixnumNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/FixnumNodes.java
@@ -21,14 +21,14 @@
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.USASCIIEncoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
+import org.jruby.truffle.builtins.CoreMethod;
+import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.CoreLibrary;
-import org.jruby.truffle.builtins.CoreMethod;
-import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.rope.LazyIntRope;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;
@@ -880,7 +880,7 @@ public Object leftShiftWithOverflow(long a, int b) {
public Object leftShiftNeg(VirtualFrame frame, long a, int b) {
if (rightShiftNode == null) {
CompilerDirectives.transferToInterpreter();
- rightShiftNode = insert(FixnumNodesFactory.RightShiftNodeFactory.create(new RubyNode[]{ null, null }));
+ rightShiftNode = insert(FixnumNodesFactory.RightShiftNodeFactory.create(null));
}
return rightShiftNode.executeRightShift(frame, a, -b);
}
@@ -940,7 +940,7 @@ public Object rightShift(VirtualFrame frame, long a, int b,
public Object rightShiftNeg(VirtualFrame frame, long a, int b) {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
- leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(new RubyNode[]{ null, null }));
+ leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(null));
}
return leftShiftNode.executeLeftShift(frame, a, -b);
}
@@ -960,7 +960,7 @@ public int rightShift(long a, DynamicObject b) {
public Object rightShiftNeg(VirtualFrame frame, long a, DynamicObject b) {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
- leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(new RubyNode[]{ null, null }));
+ leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(null));
}
return leftShiftNode.executeLeftShift(frame, a, Layouts.BIGNUM.getValue(b).negate());
}
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/FloatNodes.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/FloatNodes.java
index 0e7b899abac..e86764cbe24 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/FloatNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/FloatNodes.java
@@ -21,11 +21,11 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.language.NotProvided;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/GeneralDivModNode.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/GeneralDivModNode.java
index 1b4994dc811..3aba7067de7 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/GeneralDivModNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/GeneralDivModNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyBaseNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/IntegerNodes.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/IntegerNodes.java
index c6698da38ba..3135ab8ee6b 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/IntegerNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/IntegerNodes.java
@@ -16,10 +16,10 @@
import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.LoopConditionProfile;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/numeric/TruffleFixnumNodes.java b/truffle/src/main/java/org/jruby/truffle/core/numeric/TruffleFixnumNodes.java
index 4dee1aebc53..de18d036be9 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/numeric/TruffleFixnumNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/numeric/TruffleFixnumNodes.java
@@ -11,9 +11,9 @@
import com.oracle.truffle.api.dsl.Specialization;
import org.jruby.truffle.builtins.CoreClass;
-import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
+import org.jruby.truffle.core.CoreLibrary;
@CoreClass("Truffle::Fixnum")
public abstract class TruffleFixnumNodes {
diff --git a/truffle/src/main/java/org/jruby/truffle/core/objectspace/ObjectSpaceNodes.java b/truffle/src/main/java/org/jruby/truffle/core/objectspace/ObjectSpaceNodes.java
index 4df847a339a..699d441758d 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/objectspace/ObjectSpaceNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/objectspace/ObjectSpaceNodes.java
@@ -17,11 +17,11 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.NotProvided;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/proc/ProcNodes.java b/truffle/src/main/java/org/jruby/truffle/core/proc/ProcNodes.java
index 61c20d0b07b..d959d6399af 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/proc/ProcNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/proc/ProcNodes.java
@@ -21,10 +21,10 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.ArgumentDescriptor;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
import org.jruby.truffle.core.binding.BindingNodes;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/proc/ProcSignalHandler.java b/truffle/src/main/java/org/jruby/truffle/core/proc/ProcSignalHandler.java
index c69114a6fc8..886017cf630 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/proc/ProcSignalHandler.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/proc/ProcSignalHandler.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.SafepointAction;
import org.jruby.truffle.platform.signal.Signal;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/queue/QueueNodes.java b/truffle/src/main/java/org/jruby/truffle/core/queue/QueueNodes.java
index 64fccb49c1a..3ba90528e46 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/queue/QueueNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/queue/QueueNodes.java
@@ -18,12 +18,12 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.core.cast.BooleanCastWithDefaultNodeGen;
import org.jruby.truffle.core.thread.ThreadManager.BlockingAction;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/queue/SizedQueueNodes.java b/truffle/src/main/java/org/jruby/truffle/core/queue/SizedQueueNodes.java
index 9bd4008c13f..f1052187a0d 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/queue/SizedQueueNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/queue/SizedQueueNodes.java
@@ -17,11 +17,11 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.cast.BooleanCastWithDefaultNodeGen;
import org.jruby.truffle.core.thread.ThreadManager.BlockingAction;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/range/RangeNodes.java b/truffle/src/main/java/org/jruby/truffle/core/range/RangeNodes.java
index d53881cedd4..1a758ccac55 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/range/RangeNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/range/RangeNodes.java
@@ -19,16 +19,16 @@
import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
-import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
+import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.array.ArrayBuilderNode;
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.core.cast.BooleanCastWithDefaultNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/regexp/InterpolatedRegexpNode.java b/truffle/src/main/java/org/jruby/truffle/core/regexp/InterpolatedRegexpNode.java
index 62987aa4640..996555a97fb 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/regexp/InterpolatedRegexpNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/regexp/InterpolatedRegexpNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/regexp/MatchDataNodes.java b/truffle/src/main/java/org/jruby/truffle/core/regexp/MatchDataNodes.java
index 62ab5c2364e..1de622054e6 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/regexp/MatchDataNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/regexp/MatchDataNodes.java
@@ -19,11 +19,11 @@
import org.jcodings.Encoding;
import org.joni.Region;
import org.joni.exception.ValueException;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.array.ArrayOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/regexp/RegexpNodes.java b/truffle/src/main/java/org/jruby/truffle/core/regexp/RegexpNodes.java
index 93a3f00da9f..46c26203964 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/regexp/RegexpNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/regexp/RegexpNodes.java
@@ -41,11 +41,11 @@
import org.joni.Syntax;
import org.joni.exception.SyntaxException;
import org.joni.exception.ValueException;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.core.cast.ToStrNode;
import org.jruby.truffle.core.cast.ToStrNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
index 697b7294d01..d7f6a595f7d 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
@@ -17,7 +17,11 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.ExactMath;
-import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.dsl.Cached;
+import com.oracle.truffle.api.dsl.ImportStatic;
+import com.oracle.truffle.api.dsl.NodeChild;
+import com.oracle.truffle.api.dsl.NodeChildren;
+import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rope/RopeOperations.java b/truffle/src/main/java/org/jruby/truffle/core/rope/RopeOperations.java
index 92d0417f96a..549f18968d7 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rope/RopeOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rope/RopeOperations.java
@@ -30,8 +30,8 @@
import org.jcodings.specific.UTF8Encoding;
import org.jruby.Ruby;
import org.jruby.RubyEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.util.ByteList;
@@ -120,6 +120,10 @@ public static String decodeUTF8(Rope rope) {
@TruffleBoundary
public static String decodeRope(Ruby runtime, Rope value) {
+ // TODO CS 9-May-16 having recursive problems with this, so flatten up front for now
+
+ value = flatten(value);
+
if (value instanceof LeafRope) {
int begin = 0;
int length = value.byteLength();
@@ -146,26 +150,6 @@ public static String decodeRope(Ruby runtime, Rope value) {
}
return RubyEncoding.decode(value.getBytes(), begin, length, charset);
- } else if (value instanceof SubstringRope) {
- final SubstringRope substringRope = (SubstringRope) value;
-
- return decodeRope(runtime, substringRope.getChild()).substring(substringRope.getOffset(), substringRope.getOffset() + substringRope.characterLength());
- } else if (value instanceof ConcatRope) {
- final ConcatRope concatRope = (ConcatRope) value;
-
- return decodeRope(runtime, concatRope.getLeft()) + decodeRope(runtime, concatRope.getRight());
- } else if (value instanceof RepeatingRope) {
- final RepeatingRope repeatingRope = (RepeatingRope) value;
-
- final String childString = decodeRope(runtime, repeatingRope.getChild());
- final StringBuilder builder = new StringBuilder(childString.length() * repeatingRope.getTimes());
- for (int i = 0; i < repeatingRope.getTimes(); i++) {
- builder.append(childString);
- }
-
- return builder.toString();
- } else if (value instanceof LazyIntRope) {
- return Integer.toString(((LazyIntRope) value).getValue());
} else {
throw new RuntimeException("Decoding to String is not supported for rope of type: " + value.getClass().getName());
}
@@ -222,77 +206,9 @@ public static void visitBytes(Rope rope, BytesVisitor visitor) {
@TruffleBoundary
public static void visitBytes(Rope rope, BytesVisitor visitor, int offset, int length) {
- /*
- * TODO: CS-7-Apr-16 rewrite this to be iterative as flattenBytes is, but with new logic for offset and length
- * creating a range, then write flattenBytes in terms of visitBytes.
- */
-
- assert length <= rope.byteLength();
-
- if (rope.getRawBytes() != null) {
- visitor.accept(rope.getRawBytes(), offset, length);
- } else if (rope instanceof ConcatRope) {
- final ConcatRope concat = (ConcatRope) rope;
-
- final int leftLength = concat.getLeft().byteLength();
-
- if (offset < leftLength) {
- /*
- * The left branch might not be large enough to extract the full byte range we want. In that case,
- * we'll extract what we can and extract the difference from the right side.
- */
-
- final int leftUsed;
-
- if (offset + length > leftLength) {
- leftUsed = leftLength - offset;
- } else {
- leftUsed = length;
- }
+ // TODO CS 9-May-16 make this the primitive, and have flatten use it
- visitBytes(concat.getLeft(), visitor, offset, leftUsed);
-
- if (leftUsed < length) {
- visitBytes(concat.getRight(), visitor, 0, length - leftUsed);
- }
- } else {
- visitBytes(concat.getRight(), visitor, offset - leftLength, length);
- }
- } else if (rope instanceof SubstringRope) {
- final SubstringRope substring = (SubstringRope) rope;
-
- visitBytes(substring.getChild(), visitor, substring.getOffset() + offset, length);
- } else if (rope instanceof RepeatingRope) {
- final RepeatingRope repeating = (RepeatingRope) rope;
- final Rope child = repeating.getChild();
-
- final int start = offset % child.byteLength();
- final int firstPartLength = Math.min(child.byteLength() - start, length);
-
- visitBytes(child, visitor, start, firstPartLength);
-
- final int lengthMinusFirstPart = length - firstPartLength;
- final int remainingEnd = lengthMinusFirstPart % child.byteLength();
-
- if (lengthMinusFirstPart >= child.byteLength()) {
- final byte[] secondPart = child.getBytes();
-
- final int repeatPartCount = lengthMinusFirstPart / child.byteLength();
- for (int i = 0; i < repeatPartCount; i++) {
- visitBytes(child, visitor, 0, secondPart.length);
- }
-
- if (remainingEnd > 0) {
- visitBytes(child, visitor, 0, remainingEnd);
- }
- } else if (remainingEnd > 0) {
- visitBytes(child, visitor, 0, remainingEnd);
- }
- } else if (rope instanceof LazyRope) {
- visitor.accept(rope.getBytes(), offset, length);
- } else {
- throw new UnsupportedOperationException("Don't know how to visit rope of type: " + rope.getClass().getName());
- }
+ visitor.accept(flattenBytes(rope), offset, length);
}
@TruffleBoundary
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/AtomicReferenceNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/AtomicReferenceNodes.java
index cca9e326863..03e49f3edc5 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/AtomicReferenceNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/AtomicReferenceNodes.java
@@ -12,11 +12,11 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/ByteArrayNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/ByteArrayNodes.java
index 3c8613e1f6b..7dc47e14bab 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/ByteArrayNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/ByteArrayNodes.java
@@ -16,10 +16,10 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.profiles.ConditionProfile;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOBufferPrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOBufferPrimitiveNodes.java
index f8c59c215f2..e8a17980399 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOBufferPrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOBufferPrimitiveNodes.java
@@ -44,8 +44,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.exception.ExceptionOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
index 610e4097db1..38c87e60db2 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
@@ -48,8 +48,8 @@
import jnr.constants.platform.Fcntl;
import jnr.posix.DefaultNativeTimeval;
import jnr.posix.Timeval;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.array.ArrayOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/PointerPrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/PointerPrimitiveNodes.java
index f2b63a8187f..5c41a20f913 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/PointerPrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/PointerPrimitiveNodes.java
@@ -18,8 +18,8 @@
import com.oracle.truffle.api.source.SourceSection;
import jnr.ffi.Pointer;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.rope.Rope;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/PosixNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/PosixNodes.java
index a5cd163be8e..43e50955f74 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/PosixNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/PosixNodes.java
@@ -19,11 +19,11 @@
import jnr.ffi.Pointer;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.platform.Platform;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.RopeNodes;
import org.jruby.truffle.core.rope.RopeNodesFactory;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/RegexpPrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/RegexpPrimitiveNodes.java
index 04abd8429ca..41a287d9c11 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/RegexpPrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/RegexpPrimitiveNodes.java
@@ -18,8 +18,8 @@
import org.jcodings.Encoding;
import org.joni.Matcher;
import org.joni.Regex;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.regexp.RegexpGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusSingleBlockArgNode.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusSingleBlockArgNode.java
index d85495af05f..d44c46dcf9c 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusSingleBlockArgNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusSingleBlockArgNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusTypeNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusTypeNodes.java
index b2366cb043a..b342aab408e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusTypeNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusTypeNodes.java
@@ -12,9 +12,9 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
@CoreClass("Rubinius::Type")
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/StatPrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/StatPrimitiveNodes.java
index 2b450e161b7..22c22f45719 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/StatPrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/StatPrimitiveNodes.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import jnr.posix.FileStat;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/rubinius/VMPrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/core/rubinius/VMPrimitiveNodes.java
index 80795169642..165c5a5eb7e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/rubinius/VMPrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/rubinius/VMPrimitiveNodes.java
@@ -48,8 +48,8 @@
import jnr.posix.Passwd;
import jnr.posix.Times;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.basicobject.BasicObjectNodes;
@@ -107,7 +107,7 @@ public CatchNode(RubyContext context, SourceSection sourceSection) {
private boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
- referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null));
+ referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
}
@@ -237,7 +237,7 @@ public static abstract class VMObjectEqualPrimitiveNode extends PrimitiveArrayAr
public VMObjectEqualPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- referenceEqualNode = ReferenceEqualNodeFactory.create(null, null);
+ referenceEqualNode = ReferenceEqualNodeFactory.create(null);
}
@Specialization
@@ -288,7 +288,7 @@ public static abstract class VMObjectSingletonClassPrimitiveNode extends Primiti
public VMObjectSingletonClassPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
- singletonClassNode = KernelNodesFactory.SingletonClassMethodNodeFactory.create(context, sourceSection, new RubyNode[]{ null });
+ singletonClassNode = KernelNodesFactory.SingletonClassMethodNodeFactory.create(context, sourceSection, null);
}
@Specialization
diff --git a/truffle/src/main/java/org/jruby/truffle/core/string/FrozenStrings.java b/truffle/src/main/java/org/jruby/truffle/core/string/FrozenStrings.java
index 6e680066320..698d6949cdf 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/string/FrozenStrings.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/string/FrozenStrings.java
@@ -10,8 +10,8 @@
package org.jruby.truffle.core.string;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.Rope;
import java.util.Map;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java b/truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
index 3c8867c03db..f9e73076d24 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
@@ -83,12 +83,12 @@
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.builtin.IRubyObject;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
@@ -615,9 +615,7 @@ private ToIntNode getToIntNode() {
private StringSubstringPrimitiveNode getSubstringNode() {
if (substringNode == null) {
CompilerDirectives.transferToInterpreter();
-
- substringNode = insert(StringNodesFactory.StringSubstringPrimitiveNodeFactory.create(
- new RubyNode[] { null, null, null }));
+ substringNode = insert(StringNodesFactory.StringSubstringPrimitiveNodeFactory.create(null));
}
return substringNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/string/StringOperations.java b/truffle/src/main/java/org/jruby/truffle/core/string/StringOperations.java
index 16c255e5ec3..6659cda14c0 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/string/StringOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/string/StringOperations.java
@@ -39,8 +39,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.Encoding;
import org.jruby.RubyEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.core.encoding.EncodingNodes;
import org.jruby.truffle.core.rope.CodeRange;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolNodes.java b/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolNodes.java
index 075c37ef9b0..08aaab5cc7e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolNodes.java
@@ -20,11 +20,10 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.ArgumentDescriptor;
-import org.jruby.truffle.builtins.BinaryCoreMethodNode;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
@@ -58,7 +57,7 @@ public DynamicObject allSymbols() {
}
@CoreMethod(names = { "==", "eql?" }, required = 1)
- public abstract static class EqualNode extends BinaryCoreMethodNode {
+ public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {
@Specialization(guards = "isRubySymbol(b)")
public boolean equal(DynamicObject a, DynamicObject b) {
@@ -112,9 +111,7 @@ protected DynamicObject createProc(VirtualFrame frame, DynamicObject symbol) {
final SourceSection sourceSection = getContext().getCallStack().getCallerFrameIgnoringSend()
.getCallNode().getEncapsulatingSourceSection();
- final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(
- sourceSection, null, Arity.AT_LEAST_ONE, Layouts.SYMBOL.getString(symbol),
- true, ArgumentDescriptor.ANON_REST, false, false, false);
+ final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.AT_LEAST_ONE, Layouts.SYMBOL.getString(symbol), true, ArgumentDescriptor.ANON_REST, false, false, false);
final RubyRootNode rootNode = new RubyRootNode(getContext(), sourceSection, new FrameDescriptor(nil()), sharedMethodInfo, Translator.sequence(getContext(), sourceSection, Arrays.asList(Translator.createCheckArityNode(getContext(), sourceSection, Arity.AT_LEAST_ONE), new SymbolProcNode(getContext(), sourceSection, Layouts.SYMBOL.getString(symbol)))), false);
diff --git a/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolTable.java b/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolTable.java
index e4b3890477f..9c352b9caac 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolTable.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/symbol/SymbolTable.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.specific.USASCIIEncoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadManager.java b/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadManager.java
index 38afa5d86bb..e37ac483942 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadManager.java
@@ -16,9 +16,9 @@
import jnr.posix.DefaultNativeTimeval;
import jnr.posix.Timeval;
import org.jruby.RubyThread.Status;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.InterruptMode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.fiber.FiberManager;
import org.jruby.truffle.core.fiber.FiberNodes;
import org.jruby.truffle.core.proc.ProcOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadNodes.java b/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadNodes.java
index 9e9ce6338fd..3c68d5c1676 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/thread/ThreadNodes.java
@@ -18,16 +18,16 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.RubyThread.Status;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
+import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
-import org.jruby.truffle.core.InterruptMode;
-import org.jruby.truffle.Layouts;
-import org.jruby.truffle.builtins.NonStandard;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
+import org.jruby.truffle.core.InterruptMode;
import org.jruby.truffle.core.exception.ExceptionOperations;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java b/truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java
index 5d8b1b8c572..5d60143e2b2 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java
@@ -24,12 +24,12 @@
import org.joda.time.tz.FixedDateTimeZone;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointEventNode.java b/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointEventNode.java
index c6c23f31368..02237507c4e 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointEventNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointEventNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.instrumentation.ExecutionEventNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.yield.YieldNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointNodes.java b/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointNodes.java
index a2562df2b99..b460d032480 100644
--- a/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/core/tracepoint/TracePointNodes.java
@@ -19,11 +19,11 @@
import com.oracle.truffle.api.instrumentation.SourceSectionFilter;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.UnaryCoreMethodNode;
import org.jruby.truffle.builtins.YieldingCoreMethodNode;
import org.jruby.truffle.core.kernel.TraceManager;
diff --git a/truffle/src/main/java/org/jruby/truffle/debug/DebugHelpers.java b/truffle/src/main/java/org/jruby/truffle/debug/DebugHelpers.java
index afb4113c180..ae914eb32df 100644
--- a/truffle/src/main/java/org/jruby/truffle/debug/DebugHelpers.java
+++ b/truffle/src/main/java/org/jruby/truffle/debug/DebugHelpers.java
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.debug;
-import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.FrameDescriptor;
diff --git a/truffle/src/main/java/org/jruby/truffle/debug/TruffleDebugNodes.java b/truffle/src/main/java/org/jruby/truffle/debug/TruffleDebugNodes.java
index e7e62943bb3..e2befabcfb4 100644
--- a/truffle/src/main/java/org/jruby/truffle/debug/TruffleDebugNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/debug/TruffleDebugNodes.java
@@ -17,11 +17,11 @@
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.array.ArrayStrategy;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
diff --git a/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsInternalNodes.java b/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsInternalNodes.java
index 0c4602e863c..c266e0b34a9 100644
--- a/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsInternalNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsInternalNodes.java
@@ -13,10 +13,10 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.instrumentation.EventBinding;
import com.oracle.truffle.api.object.DynamicObject;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
@CoreClass("Truffle::Attachments::Internal")
public abstract class AttachmentsInternalNodes {
diff --git a/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsManager.java b/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsManager.java
index 25a0bdf3c55..1dfa73da905 100644
--- a/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/extra/AttachmentsManager.java
@@ -21,8 +21,8 @@
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.binding.BindingNodes;
import org.jruby.truffle.core.proc.ProcOperations;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/interop/ForeignExecuteHelperNode.java b/truffle/src/main/java/org/jruby/truffle/interop/ForeignExecuteHelperNode.java
index ac731b60874..21e175b5089 100644
--- a/truffle/src/main/java/org/jruby/truffle/interop/ForeignExecuteHelperNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/interop/ForeignExecuteHelperNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.methods.CallBoundMethodNode;
import org.jruby.truffle.language.methods.CallBoundMethodNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/interop/ForeignReadStringCachingHelperNode.java b/truffle/src/main/java/org/jruby/truffle/interop/ForeignReadStringCachingHelperNode.java
index 0e58ac74caa..1ea2fcf1aa0 100644
--- a/truffle/src/main/java/org/jruby/truffle/interop/ForeignReadStringCachingHelperNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/interop/ForeignReadStringCachingHelperNode.java
@@ -9,6 +9,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
+
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -17,8 +18,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringCachingGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/interop/InteropNodes.java b/truffle/src/main/java/org/jruby/truffle/interop/InteropNodes.java
index 164928362a2..c269b566b3e 100644
--- a/truffle/src/main/java/org/jruby/truffle/interop/InteropNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/interop/InteropNodes.java
@@ -30,10 +30,10 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.Source;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringCachingGuards;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/interop/RubyMessageResolution.java b/truffle/src/main/java/org/jruby/truffle/interop/RubyMessageResolution.java
index a0712840c3a..6fdf0b7f891 100644
--- a/truffle/src/main/java/org/jruby/truffle/interop/RubyMessageResolution.java
+++ b/truffle/src/main/java/org/jruby/truffle/interop/RubyMessageResolution.java
@@ -21,9 +21,9 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/interop/ToJavaStringNode.java b/truffle/src/main/java/org/jruby/truffle/interop/ToJavaStringNode.java
index 7af0a4f61b3..9e99382585c 100644
--- a/truffle/src/main/java/org/jruby/truffle/interop/ToJavaStringNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/interop/ToJavaStringNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringCachingGuards;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/CallStackManager.java b/truffle/src/main/java/org/jruby/truffle/language/CallStackManager.java
index da06de43768..ea4d41ad99a 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/CallStackManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/CallStackManager.java
@@ -16,9 +16,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
-import org.jruby.truffle.builtins.CoreSourceSection;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.backtrace.Activation;
@@ -84,7 +83,7 @@ public Node visitFrame(FrameInstance frameInstance) {
final SourceSection sourceSection = frameInstance.getCallNode().getEncapsulatingSourceSection();
- if (CoreSourceSection.isCoreSourceSection(sourceSection)) {
+ if (sourceSection.getSource() == null) {
return null;
} else {
return frameInstance.getCallNode();
diff --git a/truffle/src/main/java/org/jruby/truffle/language/DataNode.java b/truffle/src/main/java/org/jruby/truffle/language/DataNode.java
index 8105b93bb86..d87c40d1362 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/DataNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/DataNode.java
@@ -12,8 +12,8 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.util.ByteList;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/RubyBaseNode.java b/truffle/src/main/java/org/jruby/truffle/language/RubyBaseNode.java
index a24f61aad7e..5226c55c0fb 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/RubyBaseNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/RubyBaseNode.java
@@ -20,9 +20,9 @@
import com.oracle.truffle.api.source.SourceSection;
import jnr.ffi.provider.MemoryManager;
import org.jcodings.Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.CoreLibrary;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.exception.CoreExceptions;
import org.jruby.truffle.core.kernel.TraceManager;
import org.jruby.truffle.core.numeric.BignumOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/RubyConstant.java b/truffle/src/main/java/org/jruby/truffle/language/RubyConstant.java
index 5719e847cda..1d804b3adb3 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/RubyConstant.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/RubyConstant.java
@@ -11,8 +11,8 @@
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
public class RubyConstant {
diff --git a/truffle/src/main/java/org/jruby/truffle/language/RubyObjectType.java b/truffle/src/main/java/org/jruby/truffle/language/RubyObjectType.java
index b28ca44d1a8..cf7bb0943c5 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/RubyObjectType.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/RubyObjectType.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.ObjectType;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.interop.RubyMessageResolutionAccessor;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/SafepointManager.java b/truffle/src/main/java/org/jruby/truffle/language/SafepointManager.java
index be883334b16..eee71cc4743 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/SafepointManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/SafepointManager.java
@@ -18,9 +18,9 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.RubyThread.Status;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.InterruptMode;
-import org.jruby.truffle.Layouts;
import java.util.Collections;
import java.util.Set;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/TruffleBootNodes.java b/truffle/src/main/java/org/jruby/truffle/language/TruffleBootNodes.java
index 8249fce8332..8e751377065 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/TruffleBootNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/TruffleBootNodes.java
@@ -20,13 +20,13 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import org.jcodings.specific.UTF8Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreClass;
-import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.builtins.CoreMethodNode;
-import org.jruby.truffle.Layouts;
+import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.loader.CodeLoader;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/arguments/ArgumentDescriptorUtils.java b/truffle/src/main/java/org/jruby/truffle/language/arguments/ArgumentDescriptorUtils.java
index 00d815f5229..20fd4a9e1c6 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/arguments/ArgumentDescriptorUtils.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/arguments/ArgumentDescriptorUtils.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.runtime.ArgumentType;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
public class ArgumentDescriptorUtils {
diff --git a/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadKeywordRestArgumentNode.java b/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadKeywordRestArgumentNode.java
index 5717adb6dea..8a9ccc97095 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadKeywordRestArgumentNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadKeywordRestArgumentNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.hash.BucketsStrategy;
import org.jruby.truffle.core.hash.HashOperations;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadOptionalArgumentNode.java b/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadOptionalArgumentNode.java
index 6554c185c35..98ffdcd1ec1 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadOptionalArgumentNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadOptionalArgumentNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayReadNormalizedNode;
import org.jruby.truffle.core.array.ArrayReadNormalizedNodeGen;
import org.jruby.truffle.language.RubyGuards;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadRestArgumentNode.java b/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadRestArgumentNode.java
index f20399b09cd..64fb64ff1ea 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadRestArgumentNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/arguments/ReadRestArgumentNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java b/truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java
index bbe59c363bf..9b9e53d0a1c 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/backtrace/BacktraceFormatter.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyRootNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/constants/GetConstantNode.java b/truffle/src/main/java/org/jruby/truffle/language/constants/GetConstantNode.java
index fece49035c5..4fcd1184d86 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/constants/GetConstantNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/constants/GetConstantNode.java
@@ -19,8 +19,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.kernel.KernelNodes.RequireNode;
import org.jruby.truffle.core.kernel.KernelNodesFactory;
import org.jruby.truffle.language.RubyConstant;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantNode.java b/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantNode.java
index e702e6d1f70..17730228b6b 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantNode.java
@@ -20,8 +20,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyConstant;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantWithLexicalScopeNode.java b/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantWithLexicalScopeNode.java
index fcc34874002..f61a4019342 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantWithLexicalScopeNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantWithLexicalScopeNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyConstant;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/constants/ReadConstantWithLexicalScopeNode.java b/truffle/src/main/java/org/jruby/truffle/language/constants/ReadConstantWithLexicalScopeNode.java
index 5aed2823d46..28ef4d4a2ac 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/constants/ReadConstantWithLexicalScopeNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/constants/ReadConstantWithLexicalScopeNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/constants/ReadLiteralConstantNode.java b/truffle/src/main/java/org/jruby/truffle/language/constants/ReadLiteralConstantNode.java
index 3b056134966..b883bf24298 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/constants/ReadLiteralConstantNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/constants/ReadLiteralConstantNode.java
@@ -12,8 +12,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedDispatchNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedDispatchNode.java
index 27573d755d2..c533d7bbd71 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedDispatchNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedDispatchNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.methods.InternalMethod;
public class CachedBoxedDispatchNode extends CachedDispatchNode {
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedSymbolDispatchNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedSymbolDispatchNode.java
index c913b105d08..9180027ca12 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedSymbolDispatchNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedBoxedSymbolDispatchNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.methods.InternalMethod;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedMethodMissingDispatchNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedMethodMissingDispatchNode.java
index 3a24de3d2d2..5ad0b46c512 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedMethodMissingDispatchNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedMethodMissingDispatchNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.language.methods.InternalMethod;
import org.jruby.truffle.language.objects.MetaClassNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedReturnMissingDispatchNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedReturnMissingDispatchNode.java
index 5a7ae976572..028cd39c046 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedReturnMissingDispatchNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedReturnMissingDispatchNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.objects.MetaClassNode;
import org.jruby.truffle.language.objects.MetaClassNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedSingletonDispatchNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedSingletonDispatchNode.java
index 4c8f0ceebfc..0def3034047 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedSingletonDispatchNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/CachedSingletonDispatchNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.methods.InternalMethod;
/**
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/RubyCallNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/RubyCallNode.java
index de8f8f33508..e23bcd0b4da 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/RubyCallNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/RubyCallNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.core.cast.BooleanCastNode;
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/dispatch/UnresolvedDispatchNode.java b/truffle/src/main/java/org/jruby/truffle/language/dispatch/UnresolvedDispatchNode.java
index 4d85323efd4..88cc2073dd9 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/dispatch/UnresolvedDispatchNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/dispatch/UnresolvedDispatchNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/exceptions/TopLevelRaiseHandler.java b/truffle/src/main/java/org/jruby/truffle/language/exceptions/TopLevelRaiseHandler.java
index c489f0b94cc..fd97aaea867 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/exceptions/TopLevelRaiseHandler.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/exceptions/TopLevelRaiseHandler.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.cast.IntegerCastNode;
import org.jruby.truffle.core.cast.IntegerCastNodeGen;
import org.jruby.truffle.core.kernel.AtExitManager;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/globals/ReadMatchReferenceNode.java b/truffle/src/main/java/org/jruby/truffle/language/globals/ReadMatchReferenceNode.java
index cf916a74ee2..7e9ac584868 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/globals/ReadMatchReferenceNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/globals/ReadMatchReferenceNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
public class ReadMatchReferenceNode extends RubyNode {
diff --git a/truffle/src/main/java/org/jruby/truffle/language/loader/CodeLoader.java b/truffle/src/main/java/org/jruby/truffle/language/loader/CodeLoader.java
index 6548485f34c..5ff22cbef56 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/loader/CodeLoader.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/loader/CodeLoader.java
@@ -12,9 +12,7 @@
import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
-import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.FrameDescriptor;
-import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.IndirectCallNode;
@@ -22,10 +20,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import org.jcodings.Encoding;
-import org.jcodings.specific.UTF8Encoding;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.RubyContext;
-import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyRootNode;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.methods.DeclarationContext;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/loader/FeatureLoader.java b/truffle/src/main/java/org/jruby/truffle/language/loader/FeatureLoader.java
index 2953aaf24f7..d35045f3432 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/loader/FeatureLoader.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/loader/FeatureLoader.java
@@ -22,9 +22,9 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import org.jcodings.specific.UTF8Encoding;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.core.string.StringOperations;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/methods/AddMethodNode.java b/truffle/src/main/java/org/jruby/truffle/language/methods/AddMethodNode.java
index c0fd3e8dabc..6b1d87960aa 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/methods/AddMethodNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/methods/AddMethodNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.Visibility;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.objects.SingletonClassNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/methods/CallBoundMethodNode.java b/truffle/src/main/java/org/jruby/truffle/language/methods/CallBoundMethodNode.java
index 2d1ce3fe4a6..2cca50a534f 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/methods/CallBoundMethodNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/methods/CallBoundMethodNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java b/truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java
index 84ed95fea18..9950054da0f 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/methods/ExceptionTranslatingNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/methods/LookupMethodNode.java b/truffle/src/main/java/org/jruby/truffle/language/methods/LookupMethodNode.java
index 2d0bf831cd5..0b0c222a760 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/methods/LookupMethodNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/methods/LookupMethodNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/methods/SharedMethodInfo.java b/truffle/src/main/java/org/jruby/truffle/language/methods/SharedMethodInfo.java
index 3d510dcea40..c4b069c784a 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/methods/SharedMethodInfo.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/methods/SharedMethodInfo.java
@@ -13,11 +13,9 @@
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.truffle.language.LexicalScope;
-import java.util.Arrays;
-
/**
- * {@link InternalMethod} objects are copied as properties such as visibility are changed. {@link SharedMethodInfo} stores
- * the state that does not change, such as where the method was defined.
+ * {@link InternalMethod} objects are copied as properties such as visibility are changed.
+ * {@link SharedMethodInfo} stores the state that does not change, such as where the method was defined.
*/
public class SharedMethodInfo {
@@ -26,28 +24,32 @@ public class SharedMethodInfo {
private final Arity arity;
/** The original name of the method. Does not change when aliased. */
private final String name;
- private final String indicativeName;
private final boolean isBlock;
private final ArgumentDescriptor[] argumentDescriptors;
private final boolean alwaysClone;
private final boolean alwaysInline;
private final boolean needsCallerFrame;
- public SharedMethodInfo(SourceSection sourceSection, LexicalScope lexicalScope, Arity arity, String name, boolean isBlock, ArgumentDescriptor[] argumentDescriptors, boolean alwaysClone, boolean alwaysInline, boolean needsCallerFrame) {
- this(sourceSection, lexicalScope, arity, name, name, isBlock, argumentDescriptors, alwaysClone, alwaysInline, needsCallerFrame);
- }
-
- public SharedMethodInfo(SourceSection sourceSection, LexicalScope lexicalScope, Arity arity, String name, String indicativeName, boolean isBlock, ArgumentDescriptor[] argumentDescriptors, boolean alwaysClone, boolean alwaysInline, boolean needsCallerFrame) {
- assert sourceSection != null;
- assert name != null;
+ public SharedMethodInfo(
+ SourceSection sourceSection,
+ LexicalScope lexicalScope,
+ Arity arity,
+ String name,
+ boolean isBlock,
+ ArgumentDescriptor[] argumentDescriptors,
+ boolean alwaysClone,
+ boolean alwaysInline,
+ boolean needsCallerFrame) {
+ if (argumentDescriptors == null) {
+ argumentDescriptors = new ArgumentDescriptor[]{};
+ }
this.sourceSection = sourceSection;
this.lexicalScope = lexicalScope;
this.arity = arity;
this.name = name;
- this.indicativeName = indicativeName;
this.isBlock = isBlock;
- this.argumentDescriptors = argumentDescriptors == null ? new ArgumentDescriptor[] {} : argumentDescriptors;
+ this.argumentDescriptors = argumentDescriptors;
this.alwaysClone = alwaysClone;
this.alwaysInline = alwaysInline;
this.needsCallerFrame = needsCallerFrame;
@@ -69,16 +71,12 @@ public String getName() {
return name;
}
- public String getIndicativeName() {
- return indicativeName;
- }
-
public boolean isBlock() {
return isBlock;
}
public ArgumentDescriptor[] getArgumentDescriptors() {
- return Arrays.copyOf(argumentDescriptors, argumentDescriptors.length);
+ return argumentDescriptors;
}
public boolean shouldAlwaysClone() {
@@ -94,22 +92,39 @@ public boolean needsCallerFrame() {
}
public SharedMethodInfo withName(String newName) {
- return new SharedMethodInfo(sourceSection, lexicalScope, arity, newName, isBlock, argumentDescriptors, alwaysClone, alwaysInline, needsCallerFrame);
+ return new SharedMethodInfo(
+ sourceSection,
+ lexicalScope,
+ arity,
+ newName,
+ isBlock,
+ argumentDescriptors,
+ alwaysClone,
+ alwaysInline,
+ needsCallerFrame);
}
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final String prefix;
if (isBlock) {
- builder.append("block in ");
+ prefix = "block in ";
+ } else {
+ prefix = "";
}
- builder.append(name);
- builder.append(":");
- builder.append(sourceSection.getShortDescription());
+ final String suffix;
+
+ if (sourceSection == null) {
+ suffix = name;
+ } else if (sourceSection.getSource() == null) {
+ suffix = sourceSection.getIdentifier();
+ } else {
+ suffix = name + " " + sourceSection.getShortDescription();
+ }
- return builder.toString();
+ return prefix + suffix;
}
}
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/AllocateObjectNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/AllocateObjectNode.java
index a41cf103a77..7cca92c3af1 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/AllocateObjectNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/AllocateObjectNode.java
@@ -24,8 +24,8 @@
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.hash.Entry;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java
index 23a3f074a83..e17b1c6ab7b 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/DefineClassNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.klass.ClassNodes;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyGuards;
@@ -30,7 +30,7 @@ public class DefineClassNode extends RubyNode {
protected final String name;
- @Child private RubyNode superClass;
+ @Child private RubyNode superClassNode;
@Child private CallDispatchHeadNode inheritedNode;
@Child private RubyNode lexicalParentModule;
@Child private IndirectCallNode indirectCallNode;
@@ -43,7 +43,7 @@ public DefineClassNode(RubyContext context, SourceSection sourceSection, String
super(context, sourceSection);
this.name = name;
this.lexicalParentModule = lexicalParent;
- this.superClass = superClass;
+ this.superClassNode = superClass;
indirectCallNode = IndirectCallNode.create();
}
@@ -58,60 +58,63 @@ public Object execute(VirtualFrame frame) {
DynamicObject lexicalParentModule = (DynamicObject) lexicalParentObject;
- final Object superClassObject = superClass.execute(frame);
-
- if (!RubyGuards.isRubyClass(superClassObject)) {
- errorProfile.enter();
- throw new RaiseException(coreExceptions().typeError("superclass must be a Class", this));
- }
-
- final DynamicObject superClassModule = (DynamicObject) superClassObject;
-
- if (Layouts.CLASS.getIsSingleton(superClassModule)) {
- errorProfile.enter();
- throw new RaiseException(coreExceptions().typeError("can't make subclass of virtual class", this));
- }
+ final DynamicObject superClass = executeSuperClass(frame);
final RubyConstant constant = DefineModuleNode.lookupForExistingModule(
frame, getContext(), name, lexicalParentModule, indirectCallNode);
- final DynamicObject definingClass;
+ final DynamicObject definedClass;
if (needToDefineProfile.profile(constant == null)) {
- definingClass = ClassNodes.createInitializedRubyClass(getContext(), lexicalParentModule, superClassModule, name);
+ definedClass = ClassNodes.createInitializedRubyClass(getContext(), lexicalParentModule, superClass, name);
- if (inheritedNode == null) {
- CompilerDirectives.transferToInterpreterAndInvalidate();
- inheritedNode = insert(DispatchHeadNodeFactory.createMethodCallOnSelf(getContext()));
- }
-
- inheritedNode.call(frame, superClassModule, "inherited", null, definingClass);
+ callInherited(frame, superClass, definedClass);
} else {
if (!RubyGuards.isRubyClass(constant.getValue())) {
errorProfile.enter();
throw new RaiseException(coreExceptions().typeErrorIsNotA(constant.getValue(), "class", this));
}
- definingClass = (DynamicObject) constant.getValue();
+ definedClass = (DynamicObject) constant.getValue();
- final DynamicObject currentSuperClass = ClassNodes.getSuperClass(definingClass);
+ final DynamicObject currentSuperClass = ClassNodes.getSuperClass(definedClass);
- if (!isBlankOrRootClass(superClassModule)
- && !isBlankOrRootClass(definingClass)
- && currentSuperClass != superClassModule
- && (superClassModule != definingClass || currentSuperClass == coreLibrary().getObjectClass())) {
+ if (currentSuperClass != superClass
+ && superClass != coreLibrary().getObjectClass()) { // bug-compat with MRI https://bugs.ruby-lang.org/issues/12367
errorProfile.enter();
-
throw new RaiseException(coreExceptions().superclassMismatch(
- Layouts.MODULE.getFields(definingClass).getName(), this));
+ Layouts.MODULE.getFields(definedClass).getName(), this));
}
}
- return definingClass;
+ return definedClass;
}
- private boolean isBlankOrRootClass(DynamicObject rubyClass) {
- return rubyClass == coreLibrary().getBasicObjectClass() || rubyClass == coreLibrary().getObjectClass();
+ private DynamicObject executeSuperClass(VirtualFrame frame) {
+ final Object superClassObject = superClassNode.execute(frame);
+
+ if (!RubyGuards.isRubyClass(superClassObject)) {
+ errorProfile.enter();
+ throw new RaiseException(coreExceptions().typeError("superclass must be a Class", this));
+ }
+
+ final DynamicObject superClass = (DynamicObject) superClassObject;
+
+ if (Layouts.CLASS.getIsSingleton(superClass)) {
+ errorProfile.enter();
+ throw new RaiseException(coreExceptions().typeError("can't make subclass of virtual class", this));
+ }
+
+ return superClass;
+ }
+
+ private void callInherited(VirtualFrame frame, DynamicObject superClass, DynamicObject childClass) {
+ if (inheritedNode == null) {
+ CompilerDirectives.transferToInterpreterAndInvalidate();
+ inheritedNode = insert(DispatchHeadNodeFactory.createMethodCallOnSelf(getContext()));
+ }
+
+ inheritedNode.call(frame, superClass, "inherited", null, childClass);
}
}
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/DefineModuleNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/DefineModuleNode.java
index 287179ad76d..765c06c8d7a 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/DefineModuleNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/DefineModuleNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleNodes;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyConstant;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/FreezeNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/FreezeNode.java
index 31e4f1ed1c3..654bb48bed0 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/FreezeNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/FreezeNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChild(value = "child")
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/IsANode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/IsANode.java
index 129d92efe24..b1123077dff 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/IsANode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/IsANode.java
@@ -18,8 +18,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/IsFrozenNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/IsFrozenNode.java
index f4f401ed8c0..551d8b07693 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/IsFrozenNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/IsFrozenNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/IsTaintedNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/IsTaintedNode.java
index 1319ca2ae93..75e11b1e9e9 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/IsTaintedNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/IsTaintedNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@NodeChild(value = "child", type = RubyNode.class)
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/LogicalClassNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/LogicalClassNode.java
index d4eadb21bbc..f0e78f9e44e 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/LogicalClassNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/LogicalClassNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@ImportStatic(ShapeCachingGuards.class)
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/MetaClassNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/MetaClassNode.java
index 541ce30688d..140a8bf1734 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/MetaClassNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/MetaClassNode.java
@@ -16,8 +16,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
@ImportStatic(ShapeCachingGuards.class)
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectGraph.java b/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectGraph.java
index 1bea5a7d78e..0926a09f9f9 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectGraph.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectGraph.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Property;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.hash.Entry;
import org.jruby.truffle.language.SafepointAction;
import org.jruby.truffle.language.arguments.RubyArguments;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectIDOperations.java b/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectIDOperations.java
index 4d1b9346d83..795b330e0b9 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectIDOperations.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/ObjectIDOperations.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.ExactMath;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Property;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.numeric.BignumOperations;
import java.math.BigInteger;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/RunModuleDefinitionNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/RunModuleDefinitionNode.java
index 59c45992a65..b4fc2d689c2 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/RunModuleDefinitionNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/RunModuleDefinitionNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/SingletonClassNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/SingletonClassNode.java
index a2f6eea7fc1..96b96531178 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/SingletonClassNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/SingletonClassNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.klass.ClassNodes;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/objects/TaintNode.java b/truffle/src/main/java/org/jruby/truffle/language/objects/TaintNode.java
index af10ba57cd5..9d495da448c 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/objects/TaintNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/objects/TaintNode.java
@@ -15,8 +15,8 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/parser/jruby/BodyTranslator.java b/truffle/src/main/java/org/jruby/truffle/language/parser/jruby/BodyTranslator.java
index 118ac0ad2c3..76715d6f814 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/parser/jruby/BodyTranslator.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/parser/jruby/BodyTranslator.java
@@ -27,10 +27,11 @@
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.Visibility;
+import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
+import org.jruby.truffle.builtins.PrimitiveConstructor;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.IsRubiniusUndefinedNode;
-import org.jruby.truffle.Layouts;
import org.jruby.truffle.core.RaiseIfFrozenNode;
import org.jruby.truffle.core.array.ArrayAppendOneNodeGen;
import org.jruby.truffle.core.array.ArrayConcatNode;
@@ -65,7 +66,6 @@
import org.jruby.truffle.core.rope.RopeConstants;
import org.jruby.truffle.core.rubinius.RubiniusLastStringReadNode;
import org.jruby.truffle.core.rubinius.RubiniusLastStringWriteNodeGen;
-import org.jruby.truffle.builtins.PrimitiveConstructor;
import org.jruby.truffle.core.rubinius.RubiniusSingleBlockArgNode;
import org.jruby.truffle.core.string.InterpolatedStringNode;
import org.jruby.truffle.core.string.StringNodesFactory;
@@ -593,7 +593,7 @@ private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, o
*
* into
*
- * InvokeRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
+ * InvokePrimitiveNode(FooNode(arg1, arg2, ..., argN))
*
* or
*
@@ -1962,8 +1962,7 @@ private RubyNode translateBlockLikeNode(org.jruby.ast.IterNode node, boolean isL
final String name = isLambda ? "(lambda)" : currentCallMethodName;
final boolean isProc = !isLambda;
- final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), name, true,
- Helpers.argsNodeToArgumentDescriptors(argsNode), false, false, false);
+ final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), name, true, Helpers.argsNodeToArgumentDescriptors(argsNode), false, false, false);
final String namedMethodName = isLambda ? sharedMethodInfo.getName(): environment.getNamedMethodName();
diff --git a/truffle/src/main/java/org/jruby/truffle/language/supercall/LookupSuperMethodNode.java b/truffle/src/main/java/org/jruby/truffle/language/supercall/LookupSuperMethodNode.java
index d90b718cd0f..1b6eaf62bb2 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/supercall/LookupSuperMethodNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/supercall/LookupSuperMethodNode.java
@@ -17,8 +17,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/threadlocal/ThreadLocalObjectNode.java b/truffle/src/main/java/org/jruby/truffle/language/threadlocal/ThreadLocalObjectNode.java
index 7140a1c2af9..2993b4088f5 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/threadlocal/ThreadLocalObjectNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/threadlocal/ThreadLocalObjectNode.java
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
public abstract class ThreadLocalObjectNode extends RubyNode {
diff --git a/truffle/src/main/java/org/jruby/truffle/language/yield/CallBlockNode.java b/truffle/src/main/java/org/jruby/truffle/language/yield/CallBlockNode.java
index 89488d3d129..d454838530e 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/yield/CallBlockNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/yield/CallBlockNode.java
@@ -20,8 +20,8 @@
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.methods.DeclarationContext;
diff --git a/truffle/src/main/java/org/jruby/truffle/language/yield/YieldNode.java b/truffle/src/main/java/org/jruby/truffle/language/yield/YieldNode.java
index bb54c0a5471..7943c67f798 100644
--- a/truffle/src/main/java/org/jruby/truffle/language/yield/YieldNode.java
+++ b/truffle/src/main/java/org/jruby/truffle/language/yield/YieldNode.java
@@ -13,8 +13,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
-import org.jruby.truffle.RubyContext;
import org.jruby.truffle.Layouts;
+import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.methods.DeclarationContext;
public class YieldNode extends Node {
diff --git a/truffle/src/main/java/org/jruby/truffle/stdlib/CoverageManager.java b/truffle/src/main/java/org/jruby/truffle/stdlib/CoverageManager.java
index c75e563b6c6..36308e1651d 100644
--- a/truffle/src/main/java/org/jruby/truffle/stdlib/CoverageManager.java
+++ b/truffle/src/main/java/org/jruby/truffle/stdlib/CoverageManager.java
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.frame.VirtualFrame;
+import com.oracle.truffle.api.instrumentation.EventBinding;
import com.oracle.truffle.api.instrumentation.EventContext;
import com.oracle.truffle.api.instrumentation.ExecutionEventNode;
import com.oracle.truffle.api.instrumentation.ExecutionEventNodeFactory;
@@ -39,6 +40,7 @@ public class LineTag {
public static final long NO_CODE = -1;
private final Instrumenter instrumenter;
+ private EventBinding> binding;
private final Map