Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into packed_arrays
Browse files Browse the repository at this point in the history
headius committed Jun 10, 2016
2 parents f90a818 + cd36d12 commit d0c42df
Showing 612 changed files with 4,312 additions and 9,475 deletions.
110 changes: 110 additions & 0 deletions bench/truffle/metrics/mandelbrot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright © 2004-2013 Brent Fulgham
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of "The Computer Language Benchmarks Game" nor the name
# of "The Computer Language Shootout Benchmarks" nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
# modified by Detlef Reichl
# modified by Joseph LaFata
# modified by Peter Zotov

# http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=yarv&id=3

def mandelbrot(size)
Truffle::Graal.assert_not_compiled

sum = 0

byte_acc = 0
bit_num = 0

y = 0
while y < size
ci = (2.0*y/size)-1.0

x = 0
while x < size
zrzr = zr = 0.0
zizi = zi = 0.0
cr = (2.0*x/size)-1.5
escape = 0b1

z = 0
while z < 50
tr = zrzr - zizi + cr
ti = 2.0*zr*zi + ci
zr = tr
zi = ti
# preserve recalculation
zrzr = zr*zr
zizi = zi*zi
if zrzr+zizi > 4.0
escape = 0b0
break
end
z += 1
end

byte_acc = (byte_acc << 1) | escape
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
sum ^= byte_acc
byte_acc = 0
bit_num = 0
elsif (x == size - 1)
byte_acc <<= (8 - bit_num)
#print byte_acc.chr
sum ^= byte_acc
byte_acc = 0
bit_num = 0
end
x += 1
end
y += 1
end

sum
end

start = Time.now

begin
loop do
mandelbrot 750
end
rescue RubyTruffleError
puts Time.now - start
end
88 changes: 81 additions & 7 deletions ci.hocon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
jt: [ruby, tool/jt.rb]

common-setup: [
[rm, -rf, mx.jruby],
[mx, sclone, --kind, git, "https://github.com/jruby/jruby-build-pack.git", jruby-build-pack],
[cp, bin/jruby.bash, bin/jruby],
[chmod, +x, bin/jruby],
@@ -19,49 +18,118 @@ common: {

environment: {
CI: "true",
JRUBY_NO_ANT: "true"
JAVA_OPTS: -Xmx2G
}

setup: ${common-setup}

timelimit: "30:00"
}

no-graal: {
environment: {
HOST_VM: server,
HOST_VM_CONFIG: default
}
}

graal-core: {
setup: ${common-setup} [
[rm, -rf, mx.jruby],
[mkdir, graal-workspace],
[cd, graal-workspace],
[mx, sclone, --kind, git, "https://github.com/graalvm/graal-core.git", graal-core],
[cd, graal-core],
[git, checkout, "3a28fca1b331f9912dabd231052354cffa9dee9c"],
[git, checkout, graal-vm-0.12],
[mx, sforceimports],
[mx, --vm, server, build],
[cd, ../..]
]

environment: {
GRAAL_BIN: graal-workspace/jvmci/jdk1.8.0_60/product/bin/java
GRAAL_BIN: graal-workspace/jvmci/jdk1.8.0_60/product/bin/java,
HOST_VM: server,
HOST_VM_CONFIG: graal-core
}
}

graalvm: {
downloads: {
GRAALVM_DIR: {
name: graalvm-release,
version: "0.11",
version: "0.12",
platformspecific: true
}
}

environment: {
GRAAL_BIN: "$GRAALVM_DIR/bin/java"
HOST_VM: server,
HOST_VM_CONFIG: graal-enterprise
}
}

jruby-noindy: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: noindy,
JRUBY_OPTS: "-X-T -Xcompile.invokedynamic=false"
}
}

jruby-indy: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: indy,
JRUBY_OPTS: "-X-T -Xcompile.invokedynamic=true"
}
}

jruby-truffle: {
environment: {
GUEST_VM: jruby,
GUEST_VM_CONFIG: truffle,
}
}

gate-caps: {
capabilities: [linux, amd64, gate, post-push]
}

bench-caps: {
capabilities: [x52, linux, amd64, bench, post-push]
}

daily-bench-caps: {
capabilities: [x52, linux, amd64, daily]
}

post-process-and-upload-results: [
[tool/truffle/post-process-results-json.rb, bench-results.json, bench-results-processed.json],
[cat, bench-results-processed.json],
[bench-uploader.py, bench-results-processed.json]
]

metrics: {
run: [
[mx, benchmark, allocation]
] ${post-process-and-upload-results} [
[mx, benchmark, minheap]
] ${post-process-and-upload-results} [
[mx, benchmark, time]
] ${post-process-and-upload-results}
}

compiler-metrics: {
run: [
[mx, benchmark, "allocation:compile-mandelbrot"]
] ${post-process-and-upload-results} [
[mx, benchmark, "minheap:compile-mandelbrot"]
] ${post-process-and-upload-results} [
[mx, benchmark, "time:compile-mandelbrot"]
] ${post-process-and-upload-results}
}

builds: [
{name: ruby-test-fast} ${common} ${gate-caps} {run: [${jt} [test, fast]]},
{name: ruby-test-specs-command-line} ${common} ${gate-caps} {run: [${jt} [test, specs, ":command_line"]]},
@@ -71,7 +139,13 @@ builds: [
{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-test-tck} ${common} ${gate-caps} {run: [${jt} [test, tck]]},
{name: ruby-tarball} ${common} ${gate-caps} {run: [${jt} [tarball]]},
{name: ruby-test-tarball} ${common} ${gate-caps} {run: [${jt} [tarball]]},

{name: ruby-test-compiler-graal-core} ${common} ${graal-core} ${gate-caps} {run: [${jt} [test, compiler]]},
{name: ruby-test-compiler-graalvm} ${common} ${graalvm} ${gate-caps} {run: [${jt} [test, compiler]]}
{name: ruby-test-compiler-graalvm} ${common} ${graalvm} ${gate-caps} {run: [${jt} [test, compiler]]},

{name: ruby-metrics-noindy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-noindy} ${metrics},
{name: ruby-metrics-indy} ${common} ${no-graal} ${daily-bench-caps} ${jruby-indy} ${metrics},
{name: ruby-metrics-truffle} ${common} ${no-graal} ${bench-caps} ${jruby-truffle} ${metrics},
{name: ruby-metrics-compiler} ${common} ${graalvm} ${bench-caps} ${jruby-truffle} ${compiler-metrics}
]
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1777,6 +1777,7 @@ private void initBuiltins() {
addLazyBuiltin("digest/rmd160.jar", "digest/rmd160", "org.jruby.ext.digest.RMD160");
addLazyBuiltin("digest/sha1.jar", "digest/sha1", "org.jruby.ext.digest.SHA1");
addLazyBuiltin("digest/sha2.jar", "digest/sha2", "org.jruby.ext.digest.SHA2");
addLazyBuiltin("digest/bubblebabble.jar", "digest/bubblebabble", "org.jruby.ext.digest.BubbleBabble");
addLazyBuiltin("bigdecimal.jar", "bigdecimal", "org.jruby.ext.bigdecimal.BigDecimalLibrary");
addLazyBuiltin("io/wait.jar", "io/wait", "org.jruby.ext.io.wait.IOWaitLibrary");
addLazyBuiltin("etc.jar", "etc", "org.jruby.ext.etc.EtcLibrary");
63 changes: 30 additions & 33 deletions core/src/main/java/org/jruby/RubyObjectSpace.java
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@
package org.jruby;

import java.util.ArrayList;
import java.util.Collection;
import static org.jruby.RubyEnumerator.enumeratorize;

import java.util.Iterator;
@@ -67,7 +66,7 @@ public static RubyModule createObjectSpaceModule(Ruby runtime) {
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE)
public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) {
Ruby runtime = recv.getRuntime();
IRubyObject finalizer = null;
IRubyObject finalizer;
if (args.length == 2) {
finalizer = args[1];
if (!finalizer.respondsTo("call")) {
@@ -90,7 +89,7 @@ public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject arg1,

@JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
Ruby runtime = id.getRuntime();
final Ruby runtime = id.getRuntime();
if (!(id instanceof RubyFixnum)) {
throw recv.getRuntime().newTypeError(id, recv.getRuntime().getFixnum());
}
@@ -120,63 +119,61 @@ public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
}

public static IRubyObject each_objectInternal(final ThreadContext context, IRubyObject recv, IRubyObject[] args, final Block block) {
RubyModule tmpClass;
final Ruby runtime = context.runtime;
final RubyModule rubyClass;
if (args.length == 0) {
tmpClass = recv.getRuntime().getObject();
rubyClass = runtime.getObject();
} else {
if (!(args[0] instanceof RubyModule)) throw recv.getRuntime().newTypeError("class or module required");
tmpClass = (RubyModule) args[0];
if (!(args[0] instanceof RubyModule)) throw runtime.newTypeError("class or module required");
rubyClass = (RubyModule) args[0];
}
final RubyModule rubyClass = tmpClass;
Ruby runtime = recv.getRuntime();
final int[] count = {0};
if (rubyClass == runtime.getClassClass() ||
rubyClass == runtime.getModule()) {
final Collection<IRubyObject> modules = new ArrayList<IRubyObject>();
if (rubyClass == runtime.getClassClass() || rubyClass == runtime.getModule()) {

final ArrayList<IRubyObject> modules = new ArrayList<>(96);
runtime.eachModule(new Function1<Object, IRubyObject>() {
public Object apply(IRubyObject arg1) {
if (rubyClass.isInstance(arg1)) {
if (arg1 instanceof IncludedModule) {
// do nothing for included wrappers or singleton classes
} else {
count[0]++;
modules.add(arg1); // store the module to avoid concurrent modification exceptions
}
}
return null;
}
});

for (IRubyObject arg : modules) {
block.yield(context, arg);
final int count = modules.size();
for (int i = 0; i<count; i++) {
block.yield(context, modules.get(i));
}
} else if (args[0].getClass() == MetaClass.class) {
return runtime.newFixnum(count);
}
if (args[0].getClass() == MetaClass.class) {
// each_object(Cls.singleton_class) is basically a walk of Cls and all descendants of Cls.
// In other words, this is walking all instances of Cls's singleton class and its subclasses.
IRubyObject attached = ((MetaClass)args[0]).getAttached();
block.yield(context, attached);
IRubyObject attached = ((MetaClass) args[0]).getAttached();
block.yield(context, attached); int count = 1;
if (attached instanceof RubyClass) {
for (RubyClass child : ((RubyClass)attached).subclasses(true)) {
for (RubyClass child : ((RubyClass) attached).subclasses(true)) {
if (child instanceof IncludedModule) {
// do nothing for included wrappers or singleton classes
} else {
block.yield(context, child);
count++; block.yield(context, child);
}
}
}
} else {
if (!runtime.isObjectSpaceEnabled()) {
throw runtime.newRuntimeError("ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable");
}
Iterator iter = recv.getRuntime().getObjectSpace().iterator(rubyClass);

IRubyObject obj = null;
while ((obj = (IRubyObject)iter.next()) != null) {
count[0]++;
block.yield(context, obj);
}
return runtime.newFixnum(count);
}
if ( ! runtime.isObjectSpaceEnabled() ) {
throw runtime.newRuntimeError("ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable");
}
final Iterator iter = runtime.getObjectSpace().iterator(rubyClass);
IRubyObject obj; int count = 0;
while ((obj = (IRubyObject) iter.next()) != null) {
count++; block.yield(context, obj);
}
return recv.getRuntime().newFixnum(count[0]);
return runtime.newFixnum(count);
}

@JRubyMethod(name = "each_object", optional = 1, module = true, visibility = PRIVATE)
Loading

0 comments on commit d0c42df

Please sign in to comment.