Skip to content

Instantly share code, notes, and snippets.

Till Schneidereit tschneidereit

Block or report user

Report or block tschneidereit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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
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
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;
View Self-Hosting.md

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).

Why?

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

@tschneidereit
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
tschneidereit / CastingSpeed.as
Created Sep 28, 2010
Benchmark of several variants of type casting in AS3
View CastingSpeed.as
package
{
import flash.display.*;
import flash.text.*;
import flash.utils.*;
public class CastingSpeed extends Sprite
{
public function CastingSpeed()
{
@tschneidereit
tschneidereit / stagelistener_benchmarks.as
Created Apr 19, 2010
Benchmarks for various forms of listeners for ADDED_TO_STAGE and REMOVED_FROM_STAGE
View stagelistener_benchmarks.as
package
{
import com.gskinner.performance.TestSuite;
import com.gskinner.performance.ptest;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.utils.getQualifiedClassName;
View PublicDescribeType.as
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
You can’t perform that action at this time.