Skip to content

Instantly share code, notes, and snippets.


Till Schneidereit tschneidereit

View GitHub Profile
View ts-module-merger.js
var esprima = require('esprima');
var codegen = require('escodegen');
var fs = require('fs');
function optimizeFile(path) {
console.error("Optimizing file", path);
fs.readFile(path, function (err, data) {
if (err) {
throw err;
tschneidereit / iterable-weak-key-map.js
Created Nov 3, 2013
Iterable WeakMap implemented using Weak References
View iterable-weak-key-map.js
function IterableWeakKeyMap() {
const keyMap = new WeakMap();
const refValueMap = new Map();
return Object.freeze({
get: function(key) {
const entry = keyMap.get(key);
return entry && entry.value;
set: function(key, value) {
const ref = makeWeakRef(key);
tschneidereit / Lazy forwarding proxy.js
Last active Dec 19, 2015
More principled implementation
View Lazy forwarding proxy.js
LazySet_handlers = {
has: function(target, name) {
if (target.inHas) {
return true;
target.inHas = true;
var result = LazySet_installForwarder(target, name);
target.inHas = false;
target.hasCalled = true;
return result;

Self-Hosting in SpiderMonkey

Firefox has always contained large amounts of JavaScript in the application itself, and with each release, that amount usually grows. Some of the JS code that is contained in Firefox 21, released last Tuesday, is special, however: it forms part of SpiderMonkey itself, the virtual machine that runs all JS code in Firefox and on websites loaded into the browser.

Implementing parts or the whole of a runtime or compilation environment for a language in that very language itself is called self-hosting, and it isn't a new invention by any means. Examples of languages with (partly) self-hosted compilers include C/C++, Pascal and Rust. Partially self-hosted VMs exist, among others, for Lisps of all ages, Python, Ruby, Java, .Net, ActionScript3 - and JS. In fact, the V8 VM that executes JS in Chromium and Node.js has been partially self-hosted for a number of years now (maybe even from the outset, I don't know).


Various reasons. Code that is implemented in managed, memory-saf

tschneidereit / rl1-to-rl2-regex
Created Feb 27, 2012
Regular Expressions for porting Robotlegs 1 to Robotlegs 2
View rl1-to-rl2-regex
Converting Injector mappings:
mapValue\((\w+)\s*,\s*(.+?)(,\s*['"]\w+['"]|)\); -> map($1$3).toValue($2);
mapClass\((\w+)\s*,\s*(.+?)(,\s*['"]\w+['"]|)\); -> map($1$3).toType($2);
mapSingleton\((\w+)\s*(,\s*['"]\w+['"]|)\); -> map($1$2).asSingleton();
mapSingletonOf\((\w+)\s*,\s*(.+?)(,\s*['"]\w+['"]|)\); -> map($1$3).toSingleton($2);
// will be extended for Command- and MediatorMap
tschneidereit /
Created Sep 28, 2010
Benchmark of several variants of type casting in AS3
import flash.display.*;
import flash.text.*;
import flash.utils.*;
public class CastingSpeed extends Sprite
public function CastingSpeed()
tschneidereit /
Created Apr 19, 2010
Benchmarks for various forms of listeners for ADDED_TO_STAGE and REMOVED_FROM_STAGE
import com.gskinner.performance.TestSuite;
import com.gskinner.performance.ptest;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.getQualifiedClassName;
package avmplus
public class PublicDescribeType
public static function describeTypeJSON(target : Object, flags : uint) : Object
return DescribeType.describeTypeJSON(target, flags);
public function publicDescribeMetadata(xml : XML, metadata : Array) : void