Skip to content

Instantly share code, notes, and snippets.

View headius's full-sized avatar

Charles Oliver Nutter headius

View GitHub Profile
@headius
headius / 1.patch.diff
Created September 3, 2020 18:10
Hacky patch for "unloaded classes" and resulting inlined code
diff --git a/core/src/main/java/org/jruby/ir/targets/JVM.java b/core/src/main/java/org/jruby/ir/targets/JVM.java
index c24a8524a9..a630941524 100644
--- a/core/src/main/java/org/jruby/ir/targets/JVM.java
+++ b/core/src/main/java/org/jruby/ir/targets/JVM.java
@@ -3,6 +3,7 @@ package org.jruby.ir.targets;
import com.headius.invokebinder.Signature;
import org.jruby.RubyInstanceConfig;
import org.jruby.RubyModule;
+import org.jruby.compiler.impl.SkinnyMethodAdapter;
import org.jruby.ir.IRScope;
Only in ../ruby/lib/webrick/: .document
diff -r -u lib/webrick/cgi.rb ../ruby/lib/webrick/cgi.rb
--- lib/webrick/cgi.rb 2020-06-29 08:32:08.000000000 -0500
+++ ../ruby/lib/webrick/cgi.rb 2020-06-29 07:03:43.000000000 -0500
@@ -265,6 +265,10 @@
@out_port << data
end
+ def write(data)
+ @out_port.write(data)
@headius
headius / webrick_1_4_2.diff
Last active June 29, 2020 11:35
Diffs from WEBrick 1.4.2 in the ruby/webrick repository versus CRuby's ruby_2_6 branch lib/webrick
diff --git a/../ruby/lib/webrick/.document b/../ruby/lib/webrick/.document
new file mode 100644
index 0000000..c62f890
--- /dev/null
+++ b/../ruby/lib/webrick/.document
@@ -0,0 +1,6 @@
+# Add files to this as they become documented
+
+*.rb
+
@headius
headius / .diff
Created June 22, 2020 22:37
Attempting to make JavaAccessibleObject use module logic
diff --git a/core/pom.rb b/core/pom.rb
index e782155852..db60cec60b 100644
--- a/core/pom.rb
+++ b/core/pom.rb
@@ -73,7 +73,7 @@ project 'JRuby Core' do
jar 'me.qmx.jitescript:jitescript:0.4.1', :exclusions => ['org.ow2.asm:asm-all']
- jar 'com.headius:backport9:1.7'
+ jar 'com.headius:backport9:1.8-SNAPSHOT'
JRuby 9.3 + invokedynamic + parallel GC on Java 13
Warming up --------------------------------------
fastrandom 435.445k i/100ms
random 578.741k i/100ms
Calculating -------------------------------------
fastrandom 13.264M (±26.4%) i/s - 56.172M in 5.002513s
random 24.357M (±27.6%) i/s - 94.335M in 5.000926s
CRuby 2.7 from RVM
@headius
headius / BrokenURLClassLoader.java
Last active June 6, 2020 00:54
Example case for how URLClassLoader breaks the JarFile cache
import java.net.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* To run, first create a jar file:
*
* $ touch blah.txt
* $ jar cf blah.jar blah.txt
@headius
headius / jffi.diff
Last active May 7, 2020 22:05
Naive support for LD_PRELOAD in jffi and jnr-posix
diff --git a/src/main/java/com/kenai/jffi/Library.java b/src/main/java/com/kenai/jffi/Library.java
index 9ce61fd..6ec78e3 100644
--- a/src/main/java/com/kenai/jffi/Library.java
+++ b/src/main/java/com/kenai/jffi/Library.java
@@ -149,12 +149,17 @@ public final class Library {
* null if the library cannot be opened.
*/
public static final Library openLibrary(String name, int flags) {
+ final Foreign foreign = Foreign.getInstance();
+
@headius
headius / example.txt
Last active April 28, 2020 11:01
Example of module appearing to be open when it is not (https://github.com/jruby/jruby/issues/6189)
[] ~/projects/jruby $ cat ModuleThing.java
public class ModuleThing {
public static void main(String[] args) throws Exception {
Class cls = sun.nio.ch.NativeThread.class;
java.lang.reflect.Method method = cls.getDeclaredMethod("signal", long.class);
System.out.println("isOpen: " + cls.getModule().isOpen(cls.getPackage().getName(), ModuleThing.class.getModule()));
method.setAccessible(true);
}
}
@headius
headius / gist:36cfe66789f9bc1cf98c0ffac0265271
Last active April 17, 2020 19:15
Zero-cost oneshot line coverage in JRuby 9.3
[] ~/projects/jruby $ jruby -Xcompile.invokedynamic -Xfixnum.cache=false -e 'load "../bench2018/bench_mandelbrot.rb"'
0.14059200000000002
0.14031
0.14225
0.139491
0.132145
0.143139
0.132212
0.134711
0.13967700000000002
@headius
headius / famous_chili.md
Last active April 15, 2020 01:20
Famous Chili by Marlys Nutter

Ingredients:

  • 1 lb ground meat
  • 30 oz canned kidney beans
  • (2) 14.5 oz cans Del Monte diced tomatoes with onion and green pepper
  • 1 1/2 tsp cumin
  • 1/2 tsp garlic powder
  • 1 green pepper chopped to taste
  • 1 onion chopped to taste
  • 1 can butter beans