Cache inputs - accelerate recursive reporters

and warped / turbo recursive commands by up to 40%
pull/3/merge
Jens Mönig 2015-02-28 05:44:59 -08:00
rodzic 85388f1939
commit ee88f7ad39
4 zmienionych plików z 42 dodań i 7 usunięć

Wyświetl plik

@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2015-February-23'; modules.blocks = '2015-February-28';
var SyntaxElementMorph; var SyntaxElementMorph;
@ -340,6 +340,7 @@ SyntaxElementMorph.prototype.setScale = function (num) {
}; };
SyntaxElementMorph.prototype.setScale(1); SyntaxElementMorph.prototype.setScale(1);
SyntaxElementMorph.prototype.isCachingInputs = true;
// SyntaxElementMorph instance creation: // SyntaxElementMorph instance creation:
@ -356,6 +357,7 @@ SyntaxElementMorph.prototype.init = function () {
SyntaxElementMorph.uber.init.call(this); SyntaxElementMorph.uber.init.call(this);
this.defaults = []; this.defaults = [];
this.cachedInputs = null;
}; };
// SyntaxElementMorph accessing: // SyntaxElementMorph accessing:
@ -375,10 +377,12 @@ SyntaxElementMorph.prototype.parts = function () {
SyntaxElementMorph.prototype.inputs = function () { SyntaxElementMorph.prototype.inputs = function () {
// answer my arguments and nested reporters // answer my arguments and nested reporters
return this.parts().filter(function (part) { if (isNil(this.cachedInputs) || !this.isCachingInputs) {
return part instanceof SyntaxElementMorph; this.cachedInputs = this.parts().filter(function (part) {
}); return part instanceof SyntaxElementMorph;
});
}
return this.cachedInputs;
}; };
SyntaxElementMorph.prototype.allInputs = function () { SyntaxElementMorph.prototype.allInputs = function () {
@ -494,6 +498,7 @@ SyntaxElementMorph.prototype.replaceInput = function (oldArg, newArg) {
replacement.drawNew(); replacement.drawNew();
this.fixLayout(); this.fixLayout();
} }
this.cachedInputs = null;
this.endLayout(); this.endLayout();
}; };
@ -529,6 +534,7 @@ SyntaxElementMorph.prototype.silentReplaceInput = function (oldArg, newArg) {
replacement.drawNew(); replacement.drawNew();
this.fixLayout(); this.fixLayout();
} }
this.cachedInputs = null;
}; };
SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) { SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) {
@ -571,6 +577,7 @@ SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) {
} else if (deflt instanceof RingMorph) { } else if (deflt instanceof RingMorph) {
deflt.fixBlockColor(); deflt.fixBlockColor();
} }
this.cachedInputs = null;
}; };
SyntaxElementMorph.prototype.isLocked = function () { SyntaxElementMorph.prototype.isLocked = function () {
@ -1942,6 +1949,7 @@ BlockMorph.prototype.init = function () {
BlockMorph.uber.init.call(this); BlockMorph.uber.init.call(this);
this.color = new Color(0, 17, 173); this.color = new Color(0, 17, 173);
this.cashedInputs = null;
}; };
BlockMorph.prototype.receiver = function () { BlockMorph.prototype.receiver = function () {
@ -2047,6 +2055,7 @@ BlockMorph.prototype.setSpec = function (spec) {
}); });
this.blockSpec = spec; this.blockSpec = spec;
this.fixLayout(); this.fixLayout();
this.cachedInputs = null;
}; };
BlockMorph.prototype.buildSpec = function () { BlockMorph.prototype.buildSpec = function () {
@ -2439,6 +2448,7 @@ BlockMorph.prototype.restoreInputs = function (oldInputs) {
} }
i += 1; i += 1;
}); });
this.cachedInputs = null;
}; };
BlockMorph.prototype.showHelp = function () { BlockMorph.prototype.showHelp = function () {
@ -3034,6 +3044,7 @@ BlockMorph.prototype.fullCopy = function () {
//block.comment = null; //block.comment = null;
}); });
ans.cachedInputs = null;
return ans; return ans;
}; };
@ -9186,6 +9197,10 @@ MultiArgMorph.prototype = new ArgMorph();
MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.prototype.constructor = MultiArgMorph;
MultiArgMorph.uber = ArgMorph.prototype; MultiArgMorph.uber = ArgMorph.prototype;
// MultiArgMorph preferences settings
MultiArgMorph.prototype.isCachingInputs = false;
// MultiArgMorph instance creation: // MultiArgMorph instance creation:
function MultiArgMorph( function MultiArgMorph(
@ -9616,6 +9631,10 @@ ArgLabelMorph.prototype = new ArgMorph();
ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.prototype.constructor = ArgLabelMorph;
ArgLabelMorph.uber = ArgMorph.prototype; ArgLabelMorph.uber = ArgMorph.prototype;
// ArgLabelMorph preferences settings
ArgLabelMorph.prototype.isCachingInputs = false;
// MultiArgMorph instance creation: // MultiArgMorph instance creation:
function ArgLabelMorph(argMorph, labelTxt) { function ArgLabelMorph(argMorph, labelTxt) {

13
gui.js
Wyświetl plik

@ -69,7 +69,7 @@ SpeechBubbleMorph*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.gui = '2015-February-23'; modules.gui = '2015-February-28';
// Declarations // Declarations
@ -2266,6 +2266,17 @@ IDE_Morph.prototype.settingsMenu = function () {
'uncheck to run scripts\nat normal speed', 'uncheck to run scripts\nat normal speed',
'check to prioritize\nscript execution' 'check to prioritize\nscript execution'
); );
addPreference(
'Cache Inputs',
function () {
SyntaxElementMorph.prototype.isCachingInputs =
!SyntaxElementMorph.prototype.isCachingInputs;
},
SyntaxElementMorph.prototype.isCachingInputs,
'uncheck to stop caching\ninputs (for debugging the evaluator)',
'check to cache inputs\nboosts recursion',
true
);
addPreference( addPreference(
'Rasterize SVGs', 'Rasterize SVGs',
function () { function () {

Wyświetl plik

@ -2451,3 +2451,7 @@ ______
150224 150224
------ ------
* Store: fixed #725 * Store: fixed #725
150228
------
* Blocks, Store, GUI: Cache inputs, accelerates evaluating recursive reporters and warped / turbo recursive commands by up to 40%

Wyświetl plik

@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.store = '2015-February-24'; modules.store = '2015-February-28';
// XML_Serializer /////////////////////////////////////////////////////// // XML_Serializer ///////////////////////////////////////////////////////
@ -1027,6 +1027,7 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter) {
this.loadInput(child, inputs[i], block); this.loadInput(child, inputs[i], block);
} }
}, this); }, this);
block.cachedInputs = null;
return block; return block;
}; };