There is something very suspicious happening with makeRestartFunction where the env and control are being munged, but I haven't been able to trace where yet.

This commit is contained in:
Danny Yoo 2011-12-09 20:40:10 -05:00
parent 7f0fe7516b
commit 23d4c27c2b
2 changed files with 94 additions and 82 deletions

View File

@ -194,9 +194,7 @@
var alreadyReleased = false; var alreadyReleased = false;
// Allow for re-entrancy if the id is the same as the if (this.locked === false) {
// entity who is locking.
if (this.locked === false || this.locked === id) {
this.locked = id; this.locked = id;
onAcquire.call( onAcquire.call(
that, that,
@ -455,9 +453,8 @@
MACHINE.exclusiveLock.acquire( MACHINE.exclusiveLock.acquire(
'scheduleTrampoline', 'scheduleTrampoline',
function(release) { function(release) {
release();
if (before) { before(); } if (before) { before(); }
MACHINE.trampoline(f); MACHINE._trampoline(f, false, release);
}); });
}, },
0); 0);
@ -468,8 +465,16 @@
// Meant to be used only by the trampoline. // Meant to be used only by the trampoline.
var makeRestartFunction = function(MACHINE) { var makeRestartFunction = function(MACHINE) {
var oldArgcount = MACHINE.a; var oldArgcount = MACHINE.a;
var oldEnv = MACHINE.e.slice();
var oldControl = MACHINE.c.slice();
return function(f) { return function(f) {
return scheduleTrampoline(MACHINE, f, function() { MACHINE.a = oldArgcount; }); MACHINE.exclusiveLock.acquire(undefined,
function(release) {
MACHINE.a = oldArgcount;
MACHINE.e = oldEnv;
MACHINE.c = oldControl;
MACHINE._trampoline(f, false, release);
});
}; };
}; };
@ -505,6 +510,12 @@
that.exclusiveLock.acquire( that.exclusiveLock.acquire(
'trampoline', 'trampoline',
function(release) { function(release) {
that._trampoline(initialJump, noJumpingOff, release);
});
};
Machine.prototype._trampoline = function(initialJump, noJumpingOff, release) {
var that = this;
var thunk = initialJump; var thunk = initialJump;
var startTime = (new Date()).valueOf(); var startTime = (new Date()).valueOf();
that.cbt = STACK_LIMIT_ESTIMATE; that.cbt = STACK_LIMIT_ESTIMATE;
@ -580,9 +591,10 @@
that.params.currentSuccessHandler(that); that.params.currentSuccessHandler(that);
release(); release();
return; return;
});
}; };
// recomputeGas: state number -> number // recomputeGas: state number -> number
recomputeMaxNumBouncesBeforeYield = function(MACHINE, observedDelay) { recomputeMaxNumBouncesBeforeYield = function(MACHINE, observedDelay) {
// We'd like to see a delay of DESIRED_DELAY_BETWEEN_BOUNCES so // We'd like to see a delay of DESIRED_DELAY_BETWEEN_BOUNCES so

View File

@ -7,4 +7,4 @@
(provide version) (provide version)
(: version String) (: version String)
(define version "1.101") (define version "1.102")