Skip to content

Instantly share code, notes, and snippets.

View rednaxelafx's full-sized avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / .hotspot_compiler
Last active April 8, 2018 01:21
Demo of making an intrinsic method that takes pointer argument and returns an oop. This version doesn't work, though. Diff against hotspot-comp, changeset 446cb5d25d03. Discussion: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2013-August/011252.html
exclude Main main
dontinline Main doTest
compileonly Main doTest
compileonly FxIntrinsics *
@rednaxelafx
rednaxelafx / Test.java
Created August 1, 2013 06:44
Dynamic proxy in Java loses generic type information. Demo with CLHSDB, run on JDK8b99/Mac OS X 10.7.5. This gist is to answer question from https://gist.github.com/kdlan/6128766
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class Test {
public interface TestService{
@rednaxelafx
rednaxelafx / sajs.patch
Created July 29, 2013 07:19
Various fixes to sa.js to make it work with Nashorn in JDK8
diff -r d90d1b96b65b agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js
--- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Fri Jul 26 12:37:39 2013 -0700
+++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Mon Jul 29 15:18:50 2013 +0800
@@ -35,8 +35,9 @@
sapkg.code = sapkg.hotspot.code;
sapkg.compiler = sapkg.hotspot.compiler;
-// 'debugger' is a JavaScript keyword :-(
-// sapkg.debugger = sapkg.hotspot.debugger;
+// 'debugger' is a JavaScript keyword, but ES5 relaxes the
@rednaxelafx
rednaxelafx / chakra.reg
Created May 15, 2013 04:13
Running a simple microbenchmark on both 32-bit and 64-bit versions of JScript 5.8 and 9.0, on 64-bit Windodws 7
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="Chakra"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="Chakra"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra]
@="JScript Language"
@rednaxelafx
rednaxelafx / command_prompt_win7_x64
Created May 14, 2013 15:48
Ruby script to determine the architecture of a PE file. A port of the Perl version from http://stackoverflow.com/questions/495244/how-can-i-test-a-windows-dll-to-determine-if-it-is-32bit-or-64bit, courtesey of Paul Dixon
D:\temp>ruby petype.rb petype.rb
Not an executable
D:\temp>ruby petype.rb C:\Windows\system32\notepad.exe
amd64
D:\temp>ruby petype.rb C:\Windows\system32\jscript9.dll
amd64
D:\temp>ruby petype.rb C:\Windows\syswow64\jscript9.dll
@rednaxelafx
rednaxelafx / Main.java
Last active November 26, 2021 14:23
Code and session notes for blog post: Exploring HotSpot runtime data with HSDB http://rednaxelafx.iteye.com/blog/1847971
public class Main {
public static void main(String[] args) {
Test test = new Test();
test.fn();
}
}
@rednaxelafx
rednaxelafx / MysteryBox.java
Created February 20, 2013 04:20
SA demo from https://gist.github.com/rednaxelafx/4986917 without UseCompressedOops
public class MysteryBox {
private long x0, x1;
private boolean y0, y1, y2, y3;
private int z0;
private double[] a = new double[8];
}
@rednaxelafx
rednaxelafx / MysteryBox.java
Last active July 10, 2022 06:25
Very simple demo of using CLHSDB from HotSpot Serviceability Agent to inspect Java objects and class metadata
public class MysteryBox {
private long x0, x1;
private boolean y0, y1, y2, y3;
private int z0;
private double[] a = new double[8];
}
@rednaxelafx
rednaxelafx / Hello.java
Created November 26, 2012 15:24
Should restore FPU state on interpreter re-entry. This test case is from Xi Yang; it affects x86 HotSpot only, x64 is not affected.
public class Hello {
private static native void abc();
public static void main(String[] args) {
System.out.println("I am main");
System.loadLibrary("hello");
abc();
long a = 100;
double b = (double)a;
System.out.println("Double a is " + b);
}
@rednaxelafx
rednaxelafx / command_prompt
Created November 26, 2012 13:51
bash: ./java: No such file or directory. Caused by missing 32-bit libs on a 64-bit system. Installing ia32-libs fixes the problem. Install libc6-dev-i386 to fix gcc missing header; lib32stdc++6, g++-4.6-multilib. See also http://t.cn/zjGxUcX
kmo@ubuntu:~/sdk/jdk1.7.0_09_32/bin
$ ./java
bash: ./java: No such file or directory
kmo@ubuntu:~/sdk/jdk1.7.0_09_32/bin
$ file ./java
./java: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, BuildID[sha1]=0xb4f81805640a786538c721d745f97f3485d03e3c, not stripped
kmo@ubuntu:~/sdk/jdk1.7.0_09_32/bin
$ ldd ./java
not a dynamic executable
kmo@ubuntu:~/sdk/jdk1.7.0_09_32/bin