Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ea4441377e74
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6d513f4027f8
Choose a head ref
  • 6 commits
  • 17 files changed
  • 1 contributor

Commits on Apr 25, 2016

  1. Copy the full SHA
    f2a2842 View commit details
  2. 1
    Copy the full SHA
    aa6b9f6 View commit details
  3. [Truffle] JS PE test.

    chrisseaton committed Apr 25, 2016
    Copy the full SHA
    5018c16 View commit details
  4. Copy the full SHA
    399e706 View commit details
  5. Copy the full SHA
    0ca3c62 View commit details
  6. Copy the full SHA
    6d513f4 View commit details
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe/core/array_pe.rb
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@
example "[3, 1, 2].sort[1]", 2

# I think this fails due to our iterative partial escape issue
tagged_example "[14].pack('C').getbyte(0)", 14
tagged example "[14].pack('C').getbyte(0)", 14
12 changes: 6 additions & 6 deletions test/truffle/compiler/pe/core/binding_pe.rb
Original file line number Diff line number Diff line change
@@ -9,19 +9,19 @@
# TODO CS 8-Nov-15 fail due to a boundary and control flow diverge

# Kernel#binding
tagged_example "x = 14; binding.local_variable_get(:x)", 14
tagged example "x = 14; binding.local_variable_get(:x)", 14

# Proc#binding
tagged_example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x)", 14
tagged example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x)", 14

# set + get
tagged_example "b = binding; b.local_variable_set(:x, 14); b.local_variable_get(:x)", 14
tagged example "b = binding; b.local_variable_set(:x, 14); b.local_variable_get(:x)", 14

# get (2 levels)
tagged_example "x = 14; y = nil; 1.times { y = binding.local_variable_get(:x) }; y", 14
tagged example "x = 14; y = nil; 1.times { y = binding.local_variable_get(:x) }; y", 14

# set (2 levels)
tagged_example "x = 14; 1.times { binding.local_variable_set(:x, 15) }; x", 15
tagged example "x = 14; 1.times { binding.local_variable_set(:x, 15) }; x", 15

# get + set (2 levels)
tagged_example "x = 14; y = nil; 1.times { binding.local_variable_set(:x, 15); y = binding.local_variable_get(:x) }; y", 15
tagged example "x = 14; y = nil; 1.times { binding.local_variable_set(:x, 15); y = binding.local_variable_get(:x) }; y", 15
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe/core/eval_pe.rb
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@

example "eval([1, 2, 3].inspect)[1]", 2

tagged_counter_example "eval(rand.to_s)"
tagged counter example "eval(rand.to_s)"
10 changes: 5 additions & 5 deletions test/truffle/compiler/pe/core/fixnum_pe.rb
Original file line number Diff line number Diff line change
@@ -9,18 +9,18 @@
example "14", 14

example "14 + 2", 16
tagged_counter_example "14 + 0xfffffffffffffffffffffffffffffff" # Graal error
tagged counter example "14 + 0xfffffffffffffffffffffffffffffff" # Graal error
example "14 + 2.0", 16.0
counter_example "14 + rand"
counter example "14 + rand"

example "14 * 2", 28
counter_example "14 * 0xfffffffffffffffffffffffffffffff"
counter example "14 * 0xfffffffffffffffffffffffffffffff"
example "14 * 2.0", 28.0
counter_example "14 * rand"
counter example "14 * rand"

example "14 / 2", 7
example "14 / 0xfffffffffffffffffffffffffffffff", 0
example "14 / 2.0", 7.0
counter_example "14 / rand"
counter example "14 / rand"

example "14 <=> 2", 1
12 changes: 6 additions & 6 deletions test/truffle/compiler/pe/core/float_pe.rb
Original file line number Diff line number Diff line change
@@ -9,16 +9,16 @@
example "14.2", 14.2

example "14.0 + 2", 16.0
counter_example "14.0 + 0xfffffffffffffffffffffffffffffff"
counter example "14.0 + 0xfffffffffffffffffffffffffffffff"
example "14.0 + 2.0", 16.0
counter_example "14.0 + rand"
counter example "14.0 + rand"

example "14.0 * 2", 28.0
counter_example "14.0 * 0xfffffffffffffffffffffffffffffff"
counter example "14.0 * 0xfffffffffffffffffffffffffffffff"
example "14.0 * 2.0", 28.0
counter_example "14.0 * rand"
counter example "14.0 * rand"

example "14.0 / 2", 7.0
counter_example "14.0 / 0xfffffffffffffffffffffffffffffff"
counter example "14.0 / 0xfffffffffffffffffffffffffffffff"
example "14.0 / 2.0", 7.0
counter_example "14.0 / rand"
counter example "14.0 / rand"
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe/core/string_pe.rb
Original file line number Diff line number Diff line change
@@ -51,4 +51,4 @@
example "'abc'.getbyte(10_000) == nil", true

example "14.to_s.length", 2
counter_example "14.to_s.getbyte(0)" # Doesn't work becuase the bytes are only populated on demand and so aren't constant
counter example "14.to_s.getbyte(0)" # Doesn't work becuase the bytes are only populated on demand and so aren't constant
9 changes: 9 additions & 0 deletions test/truffle/compiler/pe/js.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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

main_thread example "Truffle::Interop.eval('application/javascript', '14 + 2')", 16
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe/language/controlflow_pe.rb
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@
# GNU Lesser General Public License version 2.1

example "rand < 0.5 ? 14 : 16 - 2", 14
counter_example "rand < 0.5 ? 14 : 16 + 2"
counter example "rand < 0.5 ? 14 : 16 + 2"
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe/language/defined_pe.rb
Original file line number Diff line number Diff line change
@@ -10,4 +10,4 @@
example "defined?(false) == 'false'", true
example "defined?(self) == 'self'", true
example "defined?(14) == 'expression'", true
tagged_example "defined?(14 + 2) == 'method'", true
tagged example "defined?(14 + 2) == 'method'", true
56 changes: 39 additions & 17 deletions test/truffle/compiler/pe/pe.rb
Original file line number Diff line number Diff line change
@@ -35,29 +35,34 @@

EXAMPLES = []

Example = Struct.new(:code, :expected_value, :expected_constant, :tagged)
Example = Struct.new(:code, :expected_value, :expected_constant, :tagged, :main_thread)

def example(code, expected_value, expected_constant=true, tagged=false)
EXAMPLES << Example.new(code, expected_value, expected_constant, tagged)
def example(code, expected_value=nil)
example = Example.new(code, expected_value, true, false, false)
EXAMPLES << example
example
end

def tagged_example(code, expected_value)
example(code, expected_value, true, true)
def main_thread(example)
example.main_thread = true
example
end

def counter_example(code)
example(code, nil, false, false)
def tagged(example)
example.tagged = true
example
end

def tagged_counter_example(code)
example(code, nil, false, true)
def counter(example)
example.expected_constant = false
example
end

if ARGV.first
require File.expand_path(ARGV.first)
else
example "14", 14
counter_example "rand"
example '14', 14
counter example 'rand'

require_relative 'language/controlflow_pe.rb'
require_relative 'language/closures_pe.rb'
@@ -82,6 +87,15 @@ def tagged_counter_example(code)
require_relative 'core/string_pe.rb'
require_relative 'core/class_pe'
require_relative 'macro/pushing_pixels_pe.rb'

if Truffle::Interop.mime_type_supported?('application/javascript')
require_relative 'js.rb'
end

if Truffle::Interop.mime_type_supported?('application/x-r')
require_relative 'r.rb'
end

end

tested = 0
@@ -98,8 +112,8 @@ def report(status, code, message = nil)
next if example.tagged

finished = false

test_thread = Thread.new do
runner = proc do
begin
tested += 1
$value = nil
@@ -150,11 +164,19 @@ def test_pe_code
end
end

test_thread.join(TIMEOUT)
if example.main_thread
runner.call
else
test_thread = Thread.new do
runner.call
end

test_thread.join(TIMEOUT)

unless finished
report 'TIMEOUT', example.code, "didn't compile in time so I don't know if it's constant or not"
timedout += 1
unless finished
report 'TIMEOUT', example.code, "didn't compile in time so I don't know if it's constant or not"
timedout += 1
end
end
end

10 changes: 10 additions & 0 deletions test/truffle/compiler/pe/r.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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

# Either R's eval or R expressions in general do not PE yet
tagged main_thread example "Truffle::Interop.eval('application/x-r', '14 + 2')", 16.0
2 changes: 1 addition & 1 deletion test/truffle/integration/execjs/checkruntime.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

unless defined?(Truffle) && Truffle::Interop.mime_type_supported?('application/javascript')
unless Truffle::Interop.mime_type_supported?('application/javascript')
puts "JavaScript doesn't appear to be available - skipping execjs test"
exit
end
2 changes: 1 addition & 1 deletion test/truffle/integration/execjs/coffeescript.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

unless defined?(Truffle) && Truffle::Interop.mime_type_supported?('application/javascript')
unless Truffle::Interop.mime_type_supported?('application/javascript')
puts "JavaScript doesn't appear to be available - skipping execjs test"
exit
end
2 changes: 1 addition & 1 deletion test/truffle/integration/execjs/simple.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

unless defined?(Truffle) && Truffle::Interop.mime_type_supported?('application/javascript')
unless Truffle::Interop.mime_type_supported?('application/javascript')
puts "JavaScript doesn't appear to be available - skipping execjs test"
exit
end
5 changes: 5 additions & 0 deletions test/truffle/integration/r.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

ruby -X+T test/truffle/integration/r/eval.rb
16 changes: 16 additions & 0 deletions test/truffle/integration/r/eval.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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

unless Truffle::Interop.mime_type_supported?('application/x-r')
puts "R doesn't appear to be available - skipping R test"
exit
end

if Truffle::Interop.eval('application/x-r', '14 + 2') != 16
abort 'result not as expected'
end
15 changes: 13 additions & 2 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -499,11 +499,22 @@ def test_mri(*args)
private :test_mri

def test_compiler(*args)
jruby_opts = []
jruby_opts << '-J-Djvmci.Compiler=graal'
jruby_opts << '-Xtruffle.graal.warn_unless=false'

if ENV['GRAAL_JS_JAR']
jruby_opts << '-J-classpath'
jruby_opts << Utilities.find_graal_js
end

jruby_opts << '-Xtruffle.exceptions.print_java=true'

env_vars = {}
env_vars["JRUBY_OPTS"] = '-Xtruffle.graal.warn_unless=false'
env_vars["JAVACMD"] = Utilities.find_graal unless args.delete('--no-java-cmd')
env_vars["JRUBY_OPTS"] = '-J-Djvmci.Compiler=graal'
env_vars["JRUBY_OPTS"] = jruby_opts.join(' ')
env_vars["PATH"] = "#{Utilities.find_jruby_bin_dir}:#{ENV["PATH"]}"

Dir["#{JRUBY_DIR}/test/truffle/compiler/*.sh"].each do |test_script|
sh env_vars, test_script
end