Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version the graph examples #85

Merged
merged 11 commits into from
Mar 21, 2024
Merged
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/Gemfile.lock
/.idea
graal_dumps/
tools/graalvm-*
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ task :specs do
end

task :rubocop do
sh "rubocop", "bin", "demos", "lib", "spec"
sh "rubocop", "bin", "demos", "lib", "spec", "tools/generate-examples.rb"
end
Binary file removed examples/fib-java.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/fib-java.bgv.gz
Binary file removed examples/fib-js-ast.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/fib-js-ast.bgv.gz
Binary file removed examples/fib-js.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/fib-js.bgv.gz
Binary file removed examples/fib-ruby-ast.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/fib-ruby-ast.bgv.gz
Binary file removed examples/fib-ruby.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/fib-ruby.bgv.gz
20 changes: 20 additions & 0 deletions examples/graalvm-ce-java11-21.2.0/ruby/clamps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ruby --experimental-options --engine.CompileOnly=clamp_low,clamp_high --vm.Dgraal.Dump=Truffle:2 clamps.rb

def clamp_high(min, max, value)
[min, max, value].sort[1]
end

def clamp_low(min, max, value)
if value > max
max
elsif value < min
min
else
value
end
end

loop do
clamp_high(10, 90, rand(100))
clamp_low(10, 90, rand(100))
end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
286 changes: 286 additions & 0 deletions examples/graalvm-ce-java11-21.2.0/ruby/ruby_examples.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
# truffleruby_primitives: true

# % ruby --jvm --experimental-options --engine.OSR=false --engine.MultiTier=false --engine.TraceCompilation --engine.InlineOnly=~Object#opaque_,~Object#static_call,~ExampleObject#instance_call --vm.Dgraal.Dump=Truffle:1 ruby_examples.rb

RANDOM = Random.new
EXCEPTION = Exception.new

def example_local_variables(x, y)
a = x + y
a * 2 + a
end

def example_local_variables_state(x, y)
a = x + y
opaque_call
a * 2 + a
end

def example_arith_operator(x, y)
x + y
end

def example_compare_operator(x, y)
x <= y
end

def example_phi(condition, x)
if condition
a = opaque_call_a
else
a = opaque_call_b
end
a + x
end

def example_simple_call(object, x)
object.instance_call(x)
end

def example_stamp(x)
x & 0x1234
end

def example_full_escape(x)
a = [x]
Primitive.blackhole a
a[0]
end

def example_no_escape(x)
a = [x]
a[0]
end

def example_partial_escape(condition, x)
a = [x]
if condition
Primitive.blackhole a
a[0]
else
a[0]
end
end

def example_if(condition, x, y)
if condition
Primitive.blackhole x
a = x
else
Primitive.blackhole y
a = y
end
a
end

def example_if_never_taken(condition, x, y)
if condition
Primitive.blackhole x
a = x
else
Primitive.blackhole y
a = y
end
a
end

def example_int_switch(value, x, y, z)
case value
when 0
Primitive.blackhole x
a = x
when 1
Primitive.blackhole y
a = y
else
Primitive.blackhole z
a = z
end
a
end

def example_string_switch(value, x, y, z)
case value
when 'foo'
Primitive.blackhole x
a = x
when 'bar'
Primitive.blackhole y
a = y
else
Primitive.blackhole z
a = z
end
a
end

def example_while(count)
a = count
while a > 0
Primitive.blackhole a
a -= 1
end
count
end

def example_for(count)
count.times do |a|
Primitive.blackhole a
end
end

def example_nested_while(count)
a = count
while (a > 0)
y = count
while (y > 0)
Primitive.blackhole a
y -= 1
end
a -= 1
end
count
end

def example_while_break(count)
a = count
while a > 0
if a == 4
break
end
Primitive.blackhole a
a -= 1
end
count
end

def example_raise
raise EXCEPTION
end

def example_rescue
begin
opaque_raise
rescue Exception => e
Primitive.blackhole e
end
end

def example_raise_rescue
begin
raise EXCEPTION
rescue Exception => e
Primitive.blackhole e
end
end

def example_object_allocation(x)
ExampleObject.new(x)
end

def example_array_allocation(x, y)
[x, y]
end

def example_field_write(object, x)
object.x = x
end

def example_field_read(object)
object.x
end

def example_array_write(array, n, x)
array[n] = x
end

def example_array_read(array, n)
array[n]
end

def example_instance_of(x)
x.is_a?(ExampleObject)
end

def example_polymorphic_receiver(receiver)
receiver.to_i
end

# no inline
def opaque_call
RANDOM.rand(1000)
end

# no inline
def opaque_call_a
opaque_call
end

# no inline
def opaque_call_b
opaque_call
end

# no inline
def opaque_raise
raise EXCEPTION
end

# no inline
def static_call(x)
x
end

def opaque_polymorphic_value
@polymorphic_value_flip = !@polymorphic_value_flip
@polymorphic_value_flip ? RANDOM.rand(100) : RANDOM.rand(100).to_s
end

class ExampleObject
attr_accessor :x

def initialize(x)
@x = x
end

# no inline
def instance_call(y)
@x + y
end
end

loop do
example_local_variables RANDOM.rand(1000), RANDOM.rand(1000)
example_local_variables_state RANDOM.rand(1000), RANDOM.rand(1000)
example_arith_operator RANDOM.rand(1000), RANDOM.rand(1000)
example_compare_operator RANDOM.rand(1000), RANDOM.rand(1000)
example_phi [true, false].sample, RANDOM.rand(1000)
example_simple_call ExampleObject.new(RANDOM.rand(1000)), RANDOM.rand(1000)
example_stamp RANDOM.rand(1000)
example_full_escape RANDOM.rand(1000)
example_no_escape RANDOM.rand(1000)
example_partial_escape [true, false].sample, RANDOM.rand(1000)
example_if [true, false].sample, RANDOM.rand(1000), RANDOM.rand(1000)
example_if_never_taken false, RANDOM.rand(1000), RANDOM.rand(1000)
example_int_switch RANDOM.rand(3), RANDOM.rand(1000), RANDOM.rand(1000), RANDOM.rand(1000)
example_string_switch ['foo', 'bar', 'baz'].sample, RANDOM.rand(1000), RANDOM.rand(1000), RANDOM.rand(1000)
example_while RANDOM.rand(10)
example_for RANDOM.rand(10)
example_nested_while RANDOM.rand(10)
example_while_break RANDOM.rand(10)
begin
example_raise
rescue Exception => e
#
end
example_rescue
example_raise_rescue
example_object_allocation RANDOM.rand(1000)
example_array_allocation RANDOM.rand(1000), RANDOM.rand(1000)
example_field_write ExampleObject.new(RANDOM.rand(1000)), RANDOM.rand(1000)
example_field_read ExampleObject.new(RANDOM.rand(1000))
example_array_write [RANDOM.rand(1000), RANDOM.rand(1000), RANDOM.rand(1000)], RANDOM.rand(3), RANDOM.rand(1000)
example_array_read [RANDOM.rand(1000), RANDOM.rand(1000), RANDOM.rand(1000)], RANDOM.rand(3)
example_instance_of [Object.new, ExampleObject.new(0)].sample
example_polymorphic_receiver(opaque_polymorphic_value)
end
Binary file added examples/graalvm-ce-java17-22.3.1/fib-java.bgv.gz
Binary file not shown.
Binary file not shown.
Binary file added examples/graalvm-ce-java17-22.3.1/fib-js.bgv.gz
Binary file not shown.
Binary file not shown.
Binary file added examples/graalvm-ce-java17-22.3.1/fib-ruby.bgv.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added examples/graalvm-ce-java21-23.1.2/fib-java.bgv.gz
Binary file not shown.
Binary file added examples/graalvm-ce-java21-23.1.2/fib-js.bgv.gz
Binary file not shown.
Binary file added examples/graalvm-ce-java21-23.1.2/fib-ruby.bgv.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added examples/graalvm-gftc-java21-23.1.2/fib-js.bgv.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed examples/java/exampleArithOperator.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleArithOperator.bgv.gz
Binary file removed examples/java/exampleArrayAllocation.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleArrayAllocation.bgv.gz
Binary file removed examples/java/exampleArrayRead.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleArrayRead.bgv.gz
Binary file removed examples/java/exampleArrayWrite.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleArrayWrite.bgv.gz
Binary file removed examples/java/exampleCatch.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleCatch.bgv.gz
Binary file removed examples/java/exampleCompareOperator.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleCompareOperator.bgv.gz
Binary file removed examples/java/exampleDoubleSynchronized.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleDoubleSynchronized.bgv.gz
Binary file removed examples/java/exampleExactArith.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleExactArith.bgv.gz
Binary file removed examples/java/exampleFieldRead.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleFieldRead.bgv.gz
Binary file removed examples/java/exampleFieldWrite.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleFieldWrite.bgv.gz
Binary file removed examples/java/exampleFor.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleFor.bgv.gz
Binary file removed examples/java/exampleFullEscape.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleFullEscape.bgv.gz
Binary file removed examples/java/exampleIf.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleIf.bgv.gz
Binary file removed examples/java/exampleIfNeverTaken.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleIfNeverTaken.bgv.gz
Binary file removed examples/java/exampleInstanceOfManyImpls.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleInstanceOfManyImpls.bgv.gz
Binary file removed examples/java/exampleInstanceOfOneImpl.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleInstanceOfOneImpl.bgv.gz
Binary file removed examples/java/exampleIntSwitch.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleIntSwitch.bgv.gz
Binary file removed examples/java/exampleInterfaceCallManyImpls.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleInterfaceCallManyImpls.bgv.gz
Binary file removed examples/java/exampleInterfaceCallOneImpl.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleInterfaceCallOneImpl.bgv.gz
Binary file removed examples/java/exampleLocalSynchronized.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleLocalSynchronized.bgv.gz
Binary file removed examples/java/exampleLocalVariables.bgv.gz
Binary file not shown.
1 change: 1 addition & 0 deletions examples/java/exampleLocalVariables.bgv.gz
Loading
Loading