Skip to content

Instantly share code, notes, and snippets.

View headius's full-sized avatar

Charles Oliver Nutter headius

View GitHub Profile
@headius
headius / activerecord_jdbc_sqlit.diff
Created July 11, 2024 16:32
A diff of the ActiveRecord SQLite3 adapter and the same in ActiveRecord-JDBC-Adapter
--- ../rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb 2024-07-11 11:27:35
+++ ../activerecord-jdbc-adapter/lib/arjdbc/sqlite3/adapter.rb 2024-07-11 11:27:27
@@ -1,753 +1,884 @@
# frozen_string_literal: true
+ArJdbc.load_java_part :SQLite3
+
+require "arjdbc/abstract/core"
+require "arjdbc/abstract/database_statements"
+require 'arjdbc/abstract/statement_cache'
@headius
headius / gist:d3138efa52eed9c678414c8cfe08af27
Last active July 8, 2024 15:58
jruby + leyden cds + --dev flag crash
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000104119800, pid=99782, tid=9475
#
# JRE version: OpenJDK Runtime Environment (24.0) (build 24-internal-adhoc.headius.jdk-iklam)
# Java VM: OpenJDK 64-Bit Server VM (24-internal-adhoc.headius.jdk-iklam, mixed mode, emulated-client, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# V [libjvm.dylib+0x2c9800] CompileBroker::compile_method(methodHandle const&, int, int, methodHandle const&, int, bool, CompileTask::CompileReason, JavaThread*)+0x94
#
diff --git a/core/src/main/java/org/jruby/ParseResult.java b/core/src/main/java/org/jruby/ParseResult.java
index febaa15f82..216450f580 100644
--- a/core/src/main/java/org/jruby/ParseResult.java
+++ b/core/src/main/java/org/jruby/ParseResult.java
@@ -9,6 +9,9 @@ public interface ParseResult {
DynamicScope getDynamicScope();
int getLine();
String getFile();
+ default String getBaseName() {
+ return getFile();
diff --git a/core/src/main/java/org/jruby/RubyString.java b/core/src/main/java/org/jruby/RubyString.java
index 2b42e03515..3c2dd7dc11 100644
--- a/core/src/main/java/org/jruby/RubyString.java
+++ b/core/src/main/java/org/jruby/RubyString.java
@@ -1102,12 +1102,16 @@ public class RubyString extends RubyObject implements CharSequence, EncodingCapa
*/
public static class FString extends RubyString {
private IRubyObject converted;
+ private final RubyFixnum hash;
+ private final int hashCode;
@headius
headius / fix_8178_attempt_2.diff
Created May 7, 2024 22:39
Fix for jruby/jruby#8178 by only allowing a RubyArray into Argv
diff --git a/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java b/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java
index 46177487d7..3c5f9cb821 100644
--- a/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java
+++ b/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java
@@ -94,7 +94,7 @@ abstract class AbstractVariable implements BiVariable {
return (RubyObject) receiver.getRuntime().getTopSelf();
}
- protected void updateByJavaObject(final Ruby runtime, Object... values) {
+ protected synchronized void updateByJavaObject(final Ruby runtime, Object... values) {
@headius
headius / fix_8718_attempt_1.diff
Last active May 7, 2024 22:39
Fix for jruby/jruby#8178 by only allowing a RubyArray into Argv
diff --git a/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java b/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java
index 46177487d7..85ede943b4 100644
--- a/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java
+++ b/core/src/main/java/org/jruby/embed/variable/AbstractVariable.java
@@ -104,8 +104,15 @@ abstract class AbstractVariable implements BiVariable {
} else {
javaType = javaObject.getClass();
}
+
+ updateRubyObjectFromJavaObject(runtime);
@headius
headius / prism_chicory.rb
Last active January 19, 2024 15:28
Attempting to use Chicory (JVM WASM runtime) to run Prism (C-based Ruby language parser)
%w[runtime wasm wasi].each {|pkg| require "/Users/headius/.m2/repository/com/dylibso/chicory/#{pkg}/0.0.3/#{pkg}-0.0.3.jar"}
module Chicory
%w[
runtime.Module
runtime.HostImports
runtime.wasi.WasiOptions
runtime.wasi.WasiPreview1
wasm.types.Value].each do |cls|
java_import "com.dylibso.chicory.#{cls}"
@headius
headius / jruby_criu.patch
Last active April 26, 2023 16:37
JRuby CRIU proof-of-concept patch
commit dac864582a44da0017fdc5b85d431c05f40eb675
Author: Charles Oliver Nutter <headius@headius.com>
Date: Sat Apr 22 12:40:27 2023 -0500
criu testing
diff --git a/bin/jruby.sh b/bin/jruby.sh
index 00903f0ba8..fd62212a07 100755
--- a/bin/jruby.sh
+++ b/bin/jruby.sh
@headius
headius / jruby_criu.txt
Last active April 26, 2023 16:02
JRuby using Checkpoint and Restore In Userspace to start up fast
root@e7fc053b9e41:/instantOnDemo/jruby# time jruby -e 'puts "hello!"'
hello!
real 0m5.546s
user 0m9.524s
sys 0m0.796s
root@e7fc053b9e41:/instantOnDemo/jruby# jruby --checkpoint -e 'puts "hello!"'
Warming up JRuby... done! Saving checkpoint.
Killed
root@e7fc053b9e41:/instantOnDemo/jruby# time jruby --restore
diff --git a/core/src/main/java/org/jruby/parser/StaticScope.java b/core/src/main/java/org/jruby/parser/StaticScope.java
index 66c9b71c61..32c644f730 100644
--- a/core/src/main/java/org/jruby/parser/StaticScope.java
+++ b/core/src/main/java/org/jruby/parser/StaticScope.java
@@ -37,6 +37,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Map;
import java.util.function.BiConsumer;