Skip to content

Instantly share code, notes, and snippets.

View hns's full-sized avatar

Hannes Wallnoefer hns

View GitHub Profile
private boolean updateEntrySet(BitSet entrySet, BitSet exitSet,
BitSet useBeforeDef, BitSet notDef) {
int card = entrySet.cardinality();
entrySet.or(exitSet);
entrySet.and(notDef);
entrySet.or(useBeforeDef);
return entrySet.cardinality() != card;
}
case Do_getParamOrVarConst:
// Push name of parameter using another switch
// over paramAndVarCount
paramAndVarCount = n.getParamAndVarCount();
boolean [] constness = n.getParamAndVarConst();
if (paramAndVarCount == 0) {
// The runtime should never call the method in this
// case but to make bytecode verifier happy return null
// as throwing execption takes more code
cfw.add(ByteCode.ICONST_0);
@hns
hns / setprop.js
Created August 19, 2011 14:29
JS property read/write micro benchmark
function bench(x) {
for (var i = 0; i < 10000000; i++) {
x.foo = x.baz;
x.bar = x.mur;
x.dng = x.foo;
x.baz = x.bar;
x.mur = x.dng;
}
}
@hns
hns / getprop.js
Created July 30, 2011 13:33
micro-benchmark for property access
function bench(x) {
for (var i = 0; i < 10000000; i++) {
if (x.foo) x.baz;
if (x.bar) x.mur;
if (x.dng) x.foo;
if (x.baz) x.bar;
if (x.mur) x.dng;
}
}
@hns
hns / gist:1113191
Created July 29, 2011 05:35
JDK 7 startup comparison with tiered compilation
$ java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)
$ time ringo -J-client test/most.js
(...)
real 0m1.897s
user 0m2.140s
sys 0m0.156s
package jsr292.cookbook.lazyinit;
import sun.misc.BASE64Encoder;
import java.io.IOException;
import java.lang.invoke.CallSite;
import java.lang.invoke.MethodType;
import java.lang.invoke.MethodHandles.Lookup;
import java.nio.ByteBuffer;
import java.nio.file.Files;
@hns
hns / async-driver.js
Created June 7, 2011 07:46
Async I/O pattern using JS generators and promises
// Pseudo code for a driver that enables doing asynchronous I/O using generators and promises.
// See the following URLs for actual code:
// https://github.com/hns/stick/blob/master/lib/stick/middleware/continuation.js
// https://github.com/hns/stick/blob/master/examples/continuation/app.js
// If app is a generator and yields promises, the result of those promises
// will be passed back into the generator as soon as they're resolved.
function handle(app, request) {
@hns
hns / command line
Created April 1, 2011 01:45
launch script for running jack + narwhal on rhino shell
# run from the jack directory - adjust paths as necessary
java -cp ../rhino/js.jar:jars/simple-4.1.10.jar org.mozilla.javascript.tools.shell.Main \
-modules ../narwhal/engines/rhino/lib/ -modules ../narwhal/engines/default/lib/ \
-modules ../narwhal/lib/ -modules lib/ run-jack.js
Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(646,806),absolute(1092,919),button=1,modifiers=Button1,clickCount=1] on frame1
java.lang.NullPointerException
at com.intellij.openapi.roots.ModuleRootManager.getInstance(ModuleRootManager.java:35)
at com.intellij.openapi.roots.CompilerModuleExtension.getInstance(CompilerModuleExtension.java:34)
at org.objectweb.asm.idea.ShowBytecodeOutlineAction.actionPerformed(ShowBytecodeOutlineAction.java:89)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:242)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:645)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:104)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:228)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
<% subskin content %>
<p>Logs for the <a href="irc://irc.freenode.net/ringojs">RingoJS IRC channel</a>,
as logged by <a href="http://github.com/earl/ringobot"><code>ringostarr</code></a>.</p>
<h1><% day %></h1>
<% for record in <% records %> render record %>
<% subskin record %>
<p class="utterance">
<span class="time">[<% record.datetime | substring 11 16 %>]</span>