Skip to content

Instantly share code, notes, and snippets.

Charles Oliver Nutter headius

Block or report user

Report or block headius

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@headius
headius / output.txt
Last active Sep 19, 2019
JRuby's new --environment flag
View output.txt
[] ~/projects/jruby $ jruby.bash --environment --dev
JRuby Environment
=================
JRuby executable:
/Users/headius/projects/jruby/bin/jruby.bash
JRuby command line options:
--environment --dev
Environment:
@headius
headius / gist:571cf242714b95f690e059b999088feb
Last active Sep 18, 2019
JRuby -e startup times on JDK8 and JDK13
View gist:571cf242714b95f690e059b999088feb
$ pickjdk 4 ; time jruby -e 1
New JDK: jdk-08-u202-b08-hotspot
real 0m1.601s
user 0m4.434s
sys 0m0.234s
$ pickjdk 4 ; time jruby --dev -e 1
New JDK: jdk-08-u202-b08-hotspot
View gist:ddea3e163d661be3fe980e78daa811ca
[] ~/projects/jruby $ pickjdk
1) adoptopenjdk-12.jdk
2) graalvm-ee-19.1.0
3) jdk-08-u202-b08-hotspot
4) jdk-08-u222-b10-openj9.jdk
5) jdk-09.0.4.jdk
6) jdk-10.0.1.jdk
7) jdk-11.0.2+9-hotspot
8) jdk-11.0.2+9_openj9-0.12.1
9) labsjdk1.8.0_172-jvmci-0.46
@headius
headius / foo.diff
Created Aug 9, 2019
Pooled object array for interpreter
View foo.diff
diff --git a/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java b/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
index ef1c033c63..afcca68f54 100644
--- a/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
@@ -44,9 +44,9 @@ public class AliasInstr extends TwoOperandInstr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject newName = (IRubyObject) getNewName().retrieve(context, self, currScope, currDynScope, temp);
View gist:467a12f8cfc1ae2195060008185fbd0a
diff --git a/core/src/main/java/org/jruby/javasupport/JavaUtil.java b/core/src/main/java/org/jruby/javasupport/JavaUtil.java
index 85e6e4acbd..05935c5bde 100644
--- a/core/src/main/java/org/jruby/javasupport/JavaUtil.java
+++ b/core/src/main/java/org/jruby/javasupport/JavaUtil.java
@@ -59,6 +59,8 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
+import org.jruby.MetaClass;
View 1.trivial deep method chain.rb
def foo1; foo2; end
def foo2; foo3; end
def foo3; foo4; end
def foo4; foo5; end
def foo5; foo6; end
def foo6; foo7; end
def foo7; foo8; end
def foo8; foo9; end
def foo9; self; end
loop { foo1 }
@headius
headius / gist:a867e0831dc1c3375ec1874e5529e724
Created Aug 2, 2019
Using JVM tools to profile Ruby objects with JRuby 9.2.8
View gist:a867e0831dc1c3375ec1874e5529e724
$ jruby -J-Xrunhprof:depth=0 -Xreify.variables.name -S gem list > /dev/null
Dumping Java heap ... allocation sites ... done.
$ grep ' org.jruby.gen' java.hprof.txt
56 0.24% 83.26% 325440 5803 328520 5858 300000 org.jruby.gen.Gem.Dependency
59 0.22% 83.93% 299248 9336 333840 10417 300000 org.jruby.gen.Gem.Requirement
60 0.22% 84.15% 294472 1268 294472 1268 300000 org.jruby.gen.Gem.Specification
99 0.08% 89.15% 111320 1260 111408 1261 300000 org.jruby.gen.Gem.StubSpecification
142 0.05% 92.03% 71032 1260 71088 1261 300000 org.jruby.gen.Gem.StubSpecification.StubLine
197 0.03% 94.14% 33960 598 33960 598 300000 org.jruby.gen.Gem.Version
View .rb
# Import Java packages
include Java
java_import javax.swing.JFrame
frame = JFrame.new("Hello Swing")
button = javax.swing.JButton.new("Klick Me!")
button.add_action_listener do |evt|
javax.swing.JOptionPane.showMessageDialog(nil, <<~EOS)
@headius
headius / BRANCH
Created Jun 25, 2019
Latest startup comparison with load service branch
View BRANCH
[--dev] ~/projects/jruby $ time jruby -e 1 > /dev/null
real 0m2.086s
user 0m2.063s
sys 0m0.322s
[--dev] ~/projects/jruby $ time jruby -e 1 > /dev/null
real 0m1.482s
user 0m2.029s
View ConditionVariable#broadcast as JVM (+indy) bytecode
// access flags 0x9
public static RUBY$method$broadcast$7(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/parser/StaticScope;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;Lorg/jruby/RubyModule;Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;
TRYCATCHBLOCK L0 L1 L1 java/lang/Throwable
TRYCATCHBLOCK L1 L2 L2 java/lang/Throwable
L3
NOP
ALOAD 0
ALOAD 4
ALOAD 5
ALOAD 2
You can’t perform that action at this time.