This commit is contained in:
Danny Yoo 2011-02-09 21:31:30 -05:00
parent 4c4b9219c8
commit e66cee7da1
6 changed files with 14 additions and 14 deletions

View File

@ -1,10 +1,10 @@
<html>
<head>
<script src="foo.js">
<script src="gauss.js">
</script>
<script>
invoke(function() {});
var f = MACHINE.env.globalBindings.factorial.adaptToJs();
var f = MACHINE.env.globalBindings.gauss.adaptToJs();
var startTime;
@ -14,11 +14,11 @@ startTime = new Date();
f([N], function(v) { console.log("functions", v, new Date() - startTime); });
var mul = function(x, y) { return x * y; }
var add = function(x, y) { return x + y; }
startTime = new Date();
var acc = 1;
var acc = 0;
for (var i = 1; i <= N; i++) {
acc = mul(acc, i);
acc = add(acc, i);
}
console.log("loops", acc, new Date() - startTime);
</script>

View File

@ -130,9 +130,9 @@ var entry1=function(){
if(--MACHINE.callsBeforeTrampoline < 0) { throw entry1; }
MACHINE.env=(MACHINE.proc.env);
MACHINE.env=new ExtendedEnvironment(MACHINE.env, MACHINE.argl);
if (! (MACHINE.env).globalBindings.hasOwnProperty("fact-iter")) { throw new Error("Not bound: " + "fact-iter"); }
MACHINE.proc=((MACHINE.env).globalBindings["fact-iter"]);
MACHINE.val=1;
if (! (MACHINE.env).globalBindings.hasOwnProperty("gauss-iter")) { throw new Error("Not bound: " + "gauss-iter"); }
MACHINE.proc=((MACHINE.env).globalBindings["gauss-iter"]);
MACHINE.val=0;
MACHINE.argl=[MACHINE.val, undefined];
MACHINE.val=(MACHINE.env).valss[0][0];
MACHINE.argl=[MACHINE.val,MACHINE.argl];
@ -145,7 +145,7 @@ return MACHINE.val();};
var afterLambda2=function(){
if(--MACHINE.callsBeforeTrampoline < 0) { throw afterLambda2; }
(MACHINE.env).globalBindings["factorial"] = MACHINE.val;
(MACHINE.env).globalBindings["gauss"] = MACHINE.val;
MACHINE.val="ok";
MACHINE.val=(new Closure(MACHINE.env, entry6));
return afterLambda7();};
@ -181,13 +181,13 @@ return MACHINE.cont();};
var falseBranch9=function(){
if(--MACHINE.callsBeforeTrampoline < 0) { throw falseBranch9; }
if (! (MACHINE.env).globalBindings.hasOwnProperty("fact-iter")) { throw new Error("Not bound: " + "fact-iter"); }
MACHINE.proc=((MACHINE.env).globalBindings["fact-iter"]);
if (! (MACHINE.env).globalBindings.hasOwnProperty("gauss-iter")) { throw new Error("Not bound: " + "gauss-iter"); }
MACHINE.proc=((MACHINE.env).globalBindings["gauss-iter"]);
MACHINE.stack.push(MACHINE.cont);
MACHINE.stack.push(MACHINE.proc);
MACHINE.stack.push(MACHINE.env);
if (! (MACHINE.env).globalBindings.hasOwnProperty("*")) { throw new Error("Not bound: " + "*"); }
MACHINE.proc=((MACHINE.env).globalBindings["*"]);
if (! (MACHINE.env).globalBindings.hasOwnProperty("+")) { throw new Error("Not bound: " + "+"); }
MACHINE.proc=((MACHINE.env).globalBindings["+"]);
MACHINE.val=(MACHINE.env).valss[0][0];
MACHINE.argl=[MACHINE.val, undefined];
MACHINE.val=(MACHINE.env).valss[0][1];
@ -235,7 +235,7 @@ return MACHINE.val();};
var afterLambda7=function(){
if(--MACHINE.callsBeforeTrampoline < 0) { throw afterLambda7; }
(MACHINE.env).globalBindings["fact-iter"] = MACHINE.val;
(MACHINE.env).globalBindings["gauss-iter"] = MACHINE.val;
MACHINE.val="ok";
return MACHINE.cont();};