diff --git a/image/private/js-impl.js b/image/private/js-impl.js index 4ee947b..39e5f84 100644 --- a/image/private/js-impl.js +++ b/image/private/js-impl.js @@ -286,13 +286,11 @@ EXPORTS['bitmap/url'] = 1, function(MACHINE) { var url = checkString(MACHINE, 'bitmap/url', 0); - var oldArgcount = MACHINE.a; PAUSE( function(restart) { var rawImage = new Image(); rawImage.onload = function() { restart(function(MACHINE) { - MACHINE.a = oldArgcount; finalizeClosureCall( MACHINE, makeFileImage(url.toString(), diff --git a/js-assembler/runtime-src/runtime.js b/js-assembler/runtime-src/runtime.js index 78fe167..b7ede87 100644 --- a/js-assembler/runtime-src/runtime.js +++ b/js-assembler/runtime-src/runtime.js @@ -432,8 +432,14 @@ }, 0); }; + + // Creates a restarting function, that reschedules f in a context + // with the old argcount in place. + // Meant to be used only by the trampoline. var makeRestartFunction = function(MACHINE) { + var oldArgcount = MACHINE.a; return function(f) { + MACHINE.a = oldArgcount; return scheduleTrampoline(MACHINE, f); }; }; diff --git a/resource/specialize/js-impl.js b/resource/specialize/js-impl.js index 3fe23a9..4a6708b 100644 --- a/resource/specialize/js-impl.js +++ b/resource/specialize/js-impl.js @@ -71,7 +71,7 @@ EXPORTS['specialize!'] = makeClosure( 1, function(MACHINE) { var resource = checkResource(MACHINE, 'specialize!', 0); - var oldArgcount = MACHINE.a; + if (isImagePath(getResourceKey(resource).toString())) { return PAUSE( function(restart) { @@ -81,7 +81,6 @@ EXPORTS['specialize!'] = makeClosure( delete(rawImage.onerror); injectImageMethods(resource, rawImage); restart(function(MACHINE) { - MACHINE.a = oldArgcount; return finalizeClosureCall(MACHINE, resource); }); }; @@ -91,7 +90,6 @@ EXPORTS['specialize!'] = makeClosure( // on any kind of image-loading error, fail out and // just return the resource unchanged. restart(function(MACHINE) { - MACHINE.a = oldArgcount; return finalizeClosureCall(MACHINE, resource); }); } diff --git a/web-world/js-impl.js b/web-world/js-impl.js index 738424f..85b8741 100644 --- a/web-world/js-impl.js +++ b/web-world/js-impl.js @@ -1083,7 +1083,6 @@ // bigBang. var bigBang = function(MACHINE, world, handlers) { - var oldArgcount = MACHINE.a; var oldCurrentBigBangRecord = currentBigBangRecord; var running = true; @@ -1117,7 +1116,6 @@ running = false; stopEventHandlers(); restart(function(MACHINE) { - MACHINE.a = oldArgcount; MACHINE.params.currentOutputPort = oldOutputPort; currentBigBangRecord = oldCurrentBigBangRecord; finalizeClosureCall(MACHINE, world); @@ -1543,12 +1541,10 @@ 1, function(MACHINE) { var viewable = MACHINE.e[MACHINE.e.length - 1]; - var oldArgcount = MACHINE.a; PAUSE(function(restart) { coerseToView(viewable, function(v) { restart(function(MACHINE) { - MACHINE.a = oldArgcount; finalizeClosureCall(MACHINE, new InitialViewHandler(v)); }); @@ -1571,12 +1567,10 @@ 1, function(MACHINE) { var viewable = MACHINE.e[MACHINE.e.length - 1]; - var oldArgcount = MACHINE.a; PAUSE(function(restart) { coerseToMockView(viewable, function(v) { restart(function(MACHINE) { - MACHINE.a = oldArgcount; finalizeClosureCall(MACHINE, v); }); }, @@ -1897,13 +1891,11 @@ 2, function(MACHINE) { var view = checkMockView(MACHINE, 'view-append-child', 0); - var oldArgcount = MACHINE.a; var x = MACHINE.e[MACHINE.e.length - 2]; PAUSE(function(restart) { coerseToDomNode(x, function(dom) { restart(function(MACHINE) { - MACHINE.a = oldArgcount; var updatedView = view.appendChild(dom); finalizeClosureCall(MACHINE, updatedView); }); @@ -1927,13 +1919,11 @@ 2, function(MACHINE) { var view = checkMockView(MACHINE, 'view-insert-right', 0); - var oldArgcount = MACHINE.a; var x = MACHINE.e[MACHINE.e.length - 2]; PAUSE(function(restart) { coerseToDomNode(x, function(dom) { restart(function(MACHINE) { - MACHINE.a = oldArgcount; var updatedView = view.insertRight(dom); finalizeClosureCall(MACHINE, updatedView); }); @@ -1959,13 +1949,11 @@ 2, function(MACHINE) { var view = checkMockView(MACHINE, 'view-insert-left', 0); - var oldArgcount = MACHINE.a; var x = MACHINE.e[MACHINE.e.length - 2]; PAUSE(function(restart) { coerseToDomNode(x, function(dom) { restart(function(MACHINE) { - MACHINE.a = oldArgcount; var updatedView = view.insertLeft(dom); finalizeClosureCall(MACHINE, updatedView); }); diff --git a/world/kernel.js b/world/kernel.js index 9c5234f..3110ae7 100644 --- a/world/kernel.js +++ b/world/kernel.js @@ -24,9 +24,6 @@ var finalizeClosureCall = plt.baselib.functions.finalizeClosureCall; ////////////////////////////////////////////////////////////////////// var bigBang = function(MACHINE, initW, handlers) { - - var oldArgcount = MACHINE.a; - var outerToplevelNode = $('').css('padding', '0px').get(0); MACHINE.params.currentOutputPort.writeDomNode(MACHINE, outerToplevelNode); var toplevelNode = $('').css('padding', '0px').appendTo(outerToplevelNode).get(0); @@ -65,9 +62,7 @@ var bigBang = function(MACHINE, initW, handlers) { function(finalWorldValue) { // state.removeBreakRequestedListener(onBreak); - restart(function(MACHINE) { - MACHINE.a = oldArgcount; finalizeClosureCall( MACHINE, finalWorldValue);