Skip to content

Commit

Permalink
Showing 412 changed files with 1,612 additions and 1,342 deletions.
3 changes: 1 addition & 2 deletions test/truffle/compiler/pe/core/eval_pe.rb
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@

example "eval('[1, 2, 3]')[1]", 2

# TODO (nirvdrum 27-Jan-16): This started timing out after moving some things to ropes. It's probably a matter of caching that generally needs to be fixed.
tagged_example "eval([1, 2, 3].inspect)[1]", 2
example "eval([1, 2, 3].inspect)[1]", 2

counter_example "eval(rand.to_s)"
1 change: 1 addition & 0 deletions test/truffle/compiler/pe/core/string_pe.rb
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

example "Truffle::Primitive.create_simple_string.length", simple_string.length
example "Truffle::Primitive.create_simple_string.getbyte(0)", simple_string.getbyte(0)
example "Truffle::Primitive.create_simple_string.ord", simple_string.ord

example "'abc'.length", 3
example "'こにちわ'.length", 4
8 changes: 7 additions & 1 deletion test/truffle/integration/backtraces.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/usr/bin/env bash

ruby -X+T test/truffle/integration/backtraces/backtraces.rb
set -e

for f in test/truffle/integration/backtraces/*.rb
do
echo $f
ruby -X+T $f
done
62 changes: 7 additions & 55 deletions test/truffle/integration/backtraces/backtraces.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,13 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

def check(expected)
def check(file)
expected = nil

File.open('test/truffle/integration/backtraces/' + file) do |f|
expected = f.lines.map(&:strip)
end

begin
yield
rescue Exception => exception
@@ -34,57 +40,3 @@ def check(expected)
exit 1
end
end

def m1(count)
if count.zero?
raise 'm1-message'
else
m1(count - 1)
end
end

expected = [
"/backtraces.rb:40:in `m1'",
"/backtraces.rb:42:in `m1'",
"/backtraces.rb:42:in `m1'",
"/backtraces.rb:42:in `m1'",
"/backtraces.rb:42:in `m1'",
"/backtraces.rb:42:in `m1'",
"/backtraces.rb:59:in `block in <main>'",
"/backtraces.rb:11:in `check'",
"/backtraces.rb:58:in `<main>'"
]

check(expected) do
m1(5)
end

expected = [
"/backtraces.rb:85:in `block (5 levels) in <main>'",
"/backtraces.rb:77:in `m2'",
"/backtraces.rb:84:in `block (4 levels) in <main>'",
"/backtraces.rb:83:in `tap'",
"/backtraces.rb:83:in `block (3 levels) in <main>'",
"/backtraces.rb:82:in `each'",
"/backtraces.rb:82:in `block (2 levels) in <main>'",
"/backtraces.rb:81:in `each'",
"/backtraces.rb:81:in `block in <main>'",
"/backtraces.rb:11:in `check'",
"/backtraces.rb:80:in `<main>'"
]

def m2
yield
end

check(expected) do
[1].each do |n|
{a: 1}.each do |k, v|
true.tap do |t|
m2 do
raise 'm2-message'
end
end
end
end
end
11 changes: 11 additions & 0 deletions test/truffle/integration/backtraces/blocks.backtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/blocks.rb:20:in `block (5 levels) in <main>'
/blocks.rb:12:in `m'
/blocks.rb:19:in `block (4 levels) in <main>'
/blocks.rb:18:in `tap'
/blocks.rb:18:in `block (3 levels) in <main>'
/blocks.rb:17:in `each'
/blocks.rb:17:in `block (2 levels) in <main>'
/blocks.rb:16:in `each'
/blocks.rb:16:in `block in <main>'
/backtraces.rb:17:in `check'
/blocks.rb:15:in `<main>'
25 changes: 25 additions & 0 deletions test/truffle/integration/backtraces/blocks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 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

require_relative 'backtraces'

def m
yield
end

check('blocks.backtrace') do
[1].each do |n|
{a: 1}.each do |k, v|
true.tap do |t|
m do
raise 'message'
end
end
end
end
end
9 changes: 9 additions & 0 deletions test/truffle/integration/backtraces/eval.backtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/eval.rb:18:in `<main>'
/eval.rb:18:in `eval'
/eval.rb:18:in `m2'
/eval.rb:14:in `<main>'
/eval.rb:14:in `eval'
/eval.rb:14:in `m1'
/eval.rb:22:in `block in <main>'
/backtraces.rb:17:in `check'
/eval.rb:21:in `<main>'
23 changes: 23 additions & 0 deletions test/truffle/integration/backtraces/eval.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 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

require_relative 'backtraces'

# TODO CS 3-Feb-16 Not compliant with MRI - here as a regression test

def m1
eval 'm2'
end

def m2
eval "raise 'message'"
end

check('eval.backtrace') do
m1
end
9 changes: 9 additions & 0 deletions test/truffle/integration/backtraces/javascript.backtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/javascript.rb:19:in `foo'
(eval):1
/javascript.rb:31:in `bar'
/javascript.rb:31:in `baz'
(eval):1
/javascript.rb:55:in `bob'
/javascript.rb:55:in `block in <main>'
/backtraces.rb:17:in `check'
/javascript.rb:54:in `<main>'
56 changes: 56 additions & 0 deletions test/truffle/integration/backtraces/javascript.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (c) 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

require_relative 'backtraces'

js = 'application/javascript'

unless defined?(Truffle) && Truffle::Interop.mime_type_supported?(js)
puts "JavaScript doesn't appear to be available - skipping polylgot backtrace tests"
exit
end

def foo(_)
raise 'foo-message'
end

Truffle::Interop.export_method :foo
Truffle::Interop.eval js, "foo = Interop.import('foo')"

Truffle::Interop.eval js, "function bar() { foo(); }"

Truffle::Interop.eval js, "Interop.export('bar', bar)"
Truffle::Interop.import_method :bar

def baz(_)
bar(self)
end

Truffle::Interop.export_method :baz
Truffle::Interop.eval js, "baz = Interop.import('baz')"

Truffle::Interop.eval js, "function bob() { baz(); }"

Truffle::Interop.eval js, "Interop.export('bob', bob)"
Truffle::Interop.import_method :bob

expected = [
"/backtraces.rb:96:in `foo'",
"(eval):1",
"/backtraces.rb:108:in `bar'",
"/backtraces.rb:108:in `baz'",
"(eval):1",
"/backtraces.rb:132:in `bob'",
"/backtraces.rb:132:in `block in <main>'",
"/backtraces.rb:11:in `check'",
"/backtraces.rb:131:in `<main>'"
]

check('javascript.backtrace') do
bob(self)
end
6 changes: 6 additions & 0 deletions test/truffle/integration/backtraces/send.backtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/send.rb:18:in `m2'
/send.rb:14:in `send'
/send.rb:14:in `m1'
/send.rb:22:in `block in <main>'
/backtraces.rb:17:in `check'
/send.rb:21:in `<main>'
23 changes: 23 additions & 0 deletions test/truffle/integration/backtraces/send.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 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

require_relative 'backtraces'

# TODO CS 3-Feb-16 Not compliant with MRI - here as a regression test

def m1
send :m2
end

def m2
raise 'message'
end

check('send.backtrace') do
m1
end
9 changes: 9 additions & 0 deletions test/truffle/integration/backtraces/simple.backtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/simple.rb:13:in `m'
/simple.rb:15:in `m'
/simple.rb:15:in `m'
/simple.rb:15:in `m'
/simple.rb:15:in `m'
/simple.rb:15:in `m'
/simple.rb:20:in `block in <main>'
/backtraces.rb:17:in `check'
/simple.rb:19:in `<main>'
21 changes: 21 additions & 0 deletions test/truffle/integration/backtraces/simple.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 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

require_relative 'backtraces'

def m(count)
if count.zero?
raise 'message'
else
m(count - 1)
end
end

check('simple.backtrace') do
m(5)
end
14 changes: 13 additions & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -52,6 +52,12 @@ def self.find_graal
end
end

def self.find_graal_js
jar = ENV['GRAAL_JS_JAR']
return jar if jar
raise "couldn't find trufflejs.jar - download GraalVM as described in https://github.com/jruby/jruby/wiki/Downloading-GraalVM and find it in there"
end

def self.find_jruby
if USE_JRUBY_ECLIPSE
"#{JRUBY_DIR}/tool/jruby_eclipse"
@@ -206,6 +212,7 @@ def help
puts 'jt rebuild clean and build'
puts 'jt run [options] args... run JRuby with -X+T and args'
puts ' --graal use Graal (set GRAAL_BIN or it will try to automagically find it)'
puts ' --js add Graal.js to the classpath (set GRAAL_JS_JAR)'
puts ' --asm show assembly (implies --graal)'
puts ' --server run an instrumentation server on port 8080'
puts ' --igv make sure IGV is running and dump Graal graphs after partial escape (implies --graal)'
@@ -247,10 +254,10 @@ def help
puts 'recognised environment variables:'
puts
puts ' RUBY_BIN The JRuby+Truffle executable to use (normally just bin/jruby)'
puts
puts ' GRAAL_BIN GraalVM executable (java command) to use'
puts ' GRAAL_BIN_...git_branch_name... GraalVM executable to use for a given branch'
puts ' branch names are mangled - eg truffle-head becomes GRAAL_BIN_TRUFFLE_HEAD'
puts ' GRAAL_JS_JAR The location of trufflejs.jar'
end

def checkout(branch)
@@ -297,6 +304,11 @@ def run(*args)
jruby_args << '-J-server'
end

if args.delete('--js')
jruby_args << '-J-classpath'
jruby_args << Utilities.find_graal_js
end

if args.delete('--asm')
jruby_args += %w[-J-XX:+UnlockDiagnosticVMOptions -J-XX:CompileCommand=print,*::callRoot]
end
Original file line number Diff line number Diff line change
@@ -17,8 +17,9 @@
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.interop.InteropNode;
import org.jruby.truffle.language.InternalRootNode;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.interop.InteropNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.RubyLanguage;

@@ -93,7 +94,7 @@ public CallTarget accessMessage(Message msg) {
return null;
}

protected static final class RubyInteropRootNode extends RootNode {
protected static final class RubyInteropRootNode extends RootNode implements InternalRootNode {

@Child private RubyNode node;

Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.core.array.ArrayReflector;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.runtime.layouts.Layouts;
Original file line number Diff line number Diff line change
@@ -17,8 +17,9 @@
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.interop.InteropNode;
import org.jruby.truffle.language.InternalRootNode;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.interop.InteropNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.RubyLanguage;

@@ -94,7 +95,7 @@ public CallTarget accessMessage(Message msg) {
return null;
}

protected static final class RubyInteropRootNode extends RootNode {
protected static final class RubyInteropRootNode extends RootNode implements InternalRootNode {

@Child private RubyNode node;

Loading

0 comments on commit b14e1cc

Please sign in to comment.