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: b0221ffb81e7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 87f10669e9e6
Choose a head ref
  • 3 commits
  • 13 files changed
  • 1 contributor

Commits on Apr 25, 2016

  1. Copy the full SHA
    5b907d1 View commit details
  2. Copy the full SHA
    33b10b3 View commit details
  3. Copy the full SHA
    87f1066 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
2 changes: 1 addition & 1 deletion test/truffle/compiler/pe/js.rb
Original file line number Diff line number Diff line change
@@ -6,4 +6,4 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "Truffle::Interop.eval('application/javascript', '14 + 2')", 16
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
51 changes: 34 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'
@@ -86,6 +91,10 @@ def tagged_counter_example(code)
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

@@ -103,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
@@ -155,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
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