Skip to content

Instantly share code, notes, and snippets.

View rednaxelafx's full-sized avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / hsdis-ubuntu.patch
Created November 12, 2010 03:57
A quick-and-dirty patch to build hsdis (http://hg.openjdk.java.net/jdk7/hotspot/hotspot/file/c18cbe5936b8/src/share/tools/hsdis/) on 32-bit Ubuntu 10.04. Do `make ARCH=i386 all` on Ubuntu 64-bit to build hsdis-i386
diff -rupN original/hsdis.c hsdis.c
--- original/hsdis.c 2010-11-12 11:39:59.617873967 +0800
+++ hsdis.c 2010-11-12 11:42:00.566353179 +0800
@@ -29,7 +29,11 @@
#include "hsdis.h"
-#include <sysdep.h>
+#if 0
+ #include <sysdep.h>
@rednaxelafx
rednaxelafx / mrp-url-change.patch
Created November 12, 2010 04:29
A patch to reflect URL changes in Harmony that are depended on by MRP. This patch should apply to MRP branch a4170d982dd2319c4fd0a8a3fea1dda408eb71ec Applying this patch will fix build problems but not runtime problems. Still got more work to do.
diff --git a/build/components/harmony.xml b/build/components/harmony.xml
index 7ba9405..2e0ed25 100755
--- a/build/components/harmony.xml
+++ b/build/components/harmony.xml
@@ -18,6 +18,7 @@
<property name="harmony.version" value="5.0M10"/>
<property name="harmony.description" value="Apache Harmony class libraries"/>
<property name="harmony.svn.revision" value="782693"/>
+ <property name="harmony.base.url" value="http://svn.apache.org/repos/asf/harmony/enhanced/java/trunk/classlib"/>
<property name="harmony.patchlevel" value="0"/>
@rednaxelafx
rednaxelafx / mrp_gnu_source.patch
Created November 16, 2010 14:43
Fix MRP build problem on Ubuntu 10.10 x64, GCC 4.4.4-14ubuntu5. Defining __USE_GNU directly in source code apparently didn't work in this configuration.
diff --git a/tools/bootloader/sysSignal_Intel.c b/tools/bootloader/sysSignal_Intel.c
index c283e96..d7d04fa 100755
--- a/tools/bootloader/sysSignal_Intel.c
+++ b/tools/bootloader/sysSignal_Intel.c
@@ -14,6 +14,14 @@
*/
/*
+ * Define the _GNU_SOURCE macro before first include header,
+ * instead of defining glibc's internal macro __USE_GNU.
@rednaxelafx
rednaxelafx / ASTDotGenerator.java
Created November 18, 2010 06:36
Generate DOT graphs to visualize a Velocity template's AST. To run this program, the following dependencies are needed: velocity-1.6.4.jar/commons-collections-3.2.1.jar/commons-lang-2.5.jar
import static org.apache.commons.lang.StringEscapeUtils.escapeJava;
import static org.apache.commons.lang.StringUtils.isEmpty;
import java.util.HashMap;
import java.util.Map;
import org.apache.velocity.runtime.parser.node.ASTAddNode;
import org.apache.velocity.runtime.parser.node.ASTAndNode;
import org.apache.velocity.runtime.parser.node.ASTAssignment;
import org.apache.velocity.runtime.parser.node.ASTBlock;
@rednaxelafx
rednaxelafx / TestContext.java
Created November 20, 2010 17:11
Find out what's going on in Velocity, the interaction during rendering between a template and the context passed in. Bad news though, side-effects can happen which really forbids caching the variables locally.
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Arrays;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.context.Context;
/**
* Demonstrate interaction between a template and its context.
@rednaxelafx
rednaxelafx / check_jar.rb
Created November 25, 2010 04:21
A script to verify classes within a JAR file. Depends on the ASM, specifically asm-all-<ver>.jar. Edit the ASM_PATH constant to match your installation. Requires Ruby 1.9+
#!/usr/bin/env ruby
ASM_PATH = "asm-all-3.3.jar"
SEP = File::PATH_SEPARATOR
jar_file, additional_classpath = ARGV
raise "usage: check_jar <jar_file> <additional_classpath>" unless jar_file
`jar tf #{jar_file}`.lines.grep(/\.class$/i).
map {|s| s.chomp[0..-7].gsub '/', '.'}.
@rednaxelafx
rednaxelafx / gist:759495
Created December 30, 2010 05:21
A code snippet to show some relationship between JVM/HotSpot's and Dalvik's interpreter.
Java source code:
k = i + j;
May compile to Java bytecode:
iload_0
iload_1
iadd
istore_2
And may turn into Dalvik VM code:
@rednaxelafx
rednaxelafx / prettyprint.js
Created January 20, 2011 03:03
Pretty print JavaScript objects (does not conform to JSON, because we don't want escape sequences in string literals)
function isPlainObject(o) {
return o && toString.call(o) === '[object Object]' && 'isPrototypeOf' in o;
}
function isArray(o) {
return toString.call(o) == '[object Array]';
}
function objectToString(val) {
var INDENT = '&nbsp;&nbsp;';
@rednaxelafx
rednaxelafx / gist:825394
Created February 14, 2011 02:16
a few examples of the implicit null check generated by HotSpot's opto compiler
// java -XX:+UnlockDiagnosticVMOptions -XX:CompileCommand=compileonly,TestC2NullCheck.getValue -XX:-UseFastAccessorMethods -XX:+PrintAssembly TestC2NullCheck
public class TestC2NullCheck {
public static int getValue(Foo foo) {
return foo.value;
}
public static void main(String[] args) throws Exception {
for (int i = 0; i < 120000; i++) {
getValue(new Foo());
@rednaxelafx
rednaxelafx / VM arguments
Created February 14, 2011 12:03
A strange GC log that I'm investigating.
-Xmx1024m -Xms1024m -Xmn512m -Xss512k -XX:PermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100 -XX:+UseAdaptiveSizePolicy -XX:+DisableExplicitGC -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps