Skip to content

Instantly share code, notes, and snippets.

@bjfish
bjfish / gist:42eebb20cbcb311a6ffb
Created March 5, 2015 17:42
Most Undefined Methods
Count: 644, Method: `sysopen' for Class
Count: 183, Method: `compile' for Class
Count: 111, Method: `closed?' for Object
Count: 71, Method: `read' for Class
Count: 59, Method: `chmod' for Class
Count: 56, Method: `popen' for Class
Count: 54, Method: `pipe' for Class
Count: 45, Method: `lstat' for Class
Count: 42, Method: `primitive_convert' for Encoding::Converter
Count: 40, Method: `umask' for Class
@bjfish
bjfish / gist:19d8ae424678e1a1ff0a
Created March 6, 2015 13:35
json_pure graal errors
jruby: using Graal Truffle Runtime
[truffle] opt fail _scan:/Users/brandonfish/Documents/jruby-mine/lib/ruby/truffle/rubysl/rubysl-strscan/lib/rubysl/strscan/strscan.rb:280|Reason com.oracle.graal.nodes.util.GraphUtil$2: This code path should never be part of a compilation. []
[truffle] opt fail full:core:/core/shims.rb:177 <split-0-U> |Reason com.oracle.graal.nodes.util.GraphUtil$2: This code path should never be part of a compilation. []
[truffle] opt fail MatchData#begin(core):core: MatchData#begin <split-1-U> |Reason com.oracle.graal.nodes.util.GraphUtil$2: This code path should never be part of a compilation. []
[truffle] opt fail MatchData#end(core):core: MatchData#end <split-1-U> |Reason com.oracle.graal.nodes.util.GraphUtil$2: This code path should never be part of a compilation. []
[truffle] opt fail parse_string:json_test.rb:1068 |Reason com.oracle.graal.nodes.util.GraphUtil$2: This code path shou
@bjfish
bjfish / gist:f0d7bdbdc7d52150d409
Created March 6, 2015 17:00
Unique IDs in Graal Output
Add this method to RubyNode -
public static void notDesignedForCompilation(String message) {
CompilerAsserts.neverPartOfCompilation(message);
}
Add Unique ID to notDesignedForCompilation method in All Methods -
@Specialization(guards = {"!isRubyModule", "!isRubyBignum"})
public Object alias(RubyBasicObject object) {
notDesignedForCompilation("5c0619014d0a4e0f9880499ff32473e1");
@bjfish
bjfish / json_test.rb
Created March 7, 2015 14:41
json_pure smashed into one file for testing purposes
if ENV['SIMPLECOV_COVERAGE'].to_i == 1
require 'simplecov'
SimpleCov.start do
add_filter "/tests/"
end
end
module JSON
# JSON version
VERSION = '1.8.2'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
ore:/core/rubinius/bootstrap/time.rb:28:in `Time': internal implementation error - NoClassDefFoundError org/jruby/truffle/nodes/rubinius/TimePrimitiveNodesFactory$TimeSNowPrimitiveNodeFactory$TimeSNowPrimitiveRubyClassNode org.jruby.truffle.nodes.rubinius.TimePrimitiveNodesFactory$TimeSNowPrimitiveNodeFactory$TimeSNowPrimitiveBaseNode.specialize0(TimePrimitiveNodesFactory.java:140) (RubyTruffleError)
from json_test.rb:1784:in `<main>'
Truffle internal error: java.lang.NoClassDefFoundError: org/jruby/truffle/runtime/subsystems/ThreadManager$1
java.lang.NoClassDefFoundError: org/jruby/truffle/runtime/subsystems/ThreadManager$1
at org.jruby.truffle.runtime.subsystems.ThreadManager.shutdown(ThreadManager.java:150)
at org.jruby.truffle.runtime.RubyContext.shutdown(RubyContext.java:273)
at org.jruby.truffle.TruffleBridgeImpl.shutdown(TruffleBridgeImpl.java:198)
at org.jruby.Ruby.shutdownTruffleBridge(Ruby.java:948)
at org.jruby.Main.doRunFromMain(Main.java:406)
at org.jruby.Main.internalRun(Main.java:299)
a = "hello"
1001.times {
a.byteslice(1) #=> "e"
a.byteslice(-1) #=> "o"
a.byteslice(1, 2) #=> "el"
}
sleep 5
@bjfish
bjfish / gist:5f77ee3fc724c609853e
Created March 10, 2015 13:57
before and after tuple.rb method
# normal usage in array method
@tuple.swap i, random
# becomes
swap(@tuple, i, random)
# normally in tuple.rb
def swap(a, b)
temp = at(a)
self[a] = at(b)
@bjfish
bjfish / gist:f247a80ffd5b0fa2306a
Created March 10, 2015 13:57
before and after tuple.rb method
# normal usage in array method
@tuple.swap i, random
# becomes
swap(@tuple, i, random)
# normally in tuple.rb
def swap(a, b)
temp = at(a)
self[a] = at(b)
1)
Array#+ tries to convert the passed argument to an Array using #to_ary ERROR
RubyTruffleError: internal implementation error - UnsupportedOperationException null org.jruby.truffle.nodes.core.ArrayNodes$AddNode.addEmptyIntegerFixnum(ArrayNodes.java:146)
/Users/brandonfish/Documents/jruby-mine/spec/ruby/core/array/plus_spec.rb:20:in `+': internal implementation error - UnsupportedOperationException null org.jruby.truffle.nodes.core.ArrayNodes$AddNode.addEmptyIntegerFixnum(ArrayNodes.java:146) (RubyTruffleError)
from /Users/brandonfish/Documents/jruby-mine/spec/ruby/core/array/plus_spec.rb:20:in `block in <main>'
from /Users/brandonfish/Documents/jruby-mine/spec/mspec/lib/mspec/runner/mspec.rb:69:in `instance_eval'
from /Users/brandonfish/Documents/jruby-mine/spec/mspec/lib/mspec/runner/mspec.rb:69:in `protect'
from /Users/brandonfish/Documents/jruby-mine/spec/mspec/lib/mspec/runner/context.rb:179:in `block in protect'
from core:/core/rubinius/common/enumerable.rb:354:in `block in all?'
Brandons-MacBook-Pro:jruby-mine brandonfish$ jt bench debug classic-fannkuch-redux
bash -c "JAVACMD=/Users/brandonfish/Downloads/graalvm-jdk1.8.0/bin /Users/brandonfish/Documents/jruby-mine/bin/jruby -J-Xmx2G -J-d64 -J-server -J-G:+TruffleCompilationExceptionsAreFatal -X+T -I/Users/brandonfish/Documents/bench9000/lib/bench/.. /Users/brandonfish/Documents/bench9000/lib/bench/benchmarks/classic/fannkuch-redux.rb"
/Users/brandonfish/Documents/jruby-mine/bin/jruby: line 393: /Users/brandonfish/Downloads/graalvm-jdk1.8.0/bin: is a directory
/Users/brandonfish/Documents/jruby-mine/bin/jruby: line 393: exec: /Users/brandonfish/Downloads/graalvm-jdk1.8.0/bin: cannot execute: Undefined error: 0
/Users/brandonfish/Documents/bench9000/lib/bench/implementation.rb:42:in `block in measure': undefined method `start_with?' for nil:NilClass (NoMethodError)
from /Users/brandonfish/Documents/bench9000/lib/bench/implementation.rb:37:in `popen'
from /Users/brandonfish/Documents/bench9000/lib/bench/implementation.rb:37:in `meas