aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-02 11:23:05 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-02 11:23:05 -0800
commit52acac245a7599b7b4eba793c2384adaab39a1ff (patch)
tree54bb50303bb0175ab7964d8e027043091bd6b86a
parent8950ba2d235173749bc97da1f635e2a2d7a6bc32 (diff)
do not set label when leaving a multiple with one post-entry, and properly optimize the case of not setting label with new BRNOL branch signature
-rw-r--r--src/analyzer.js9
-rw-r--r--src/jsifier.js3
2 files changed, 11 insertions, 1 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 8c07951e..9783f447 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -1182,9 +1182,15 @@ function analyzer(data) {
actualEntryLabels.forEach(function(actualEntryLabel) {
if (dcheck('relooping')) dprint(' creating sub-block in multiple for ' + actualEntryLabel.ident + ' : ' + getLabelIds(actualEntryLabel.blockChildren) + ' ::: ' + actualEntryLabel.blockChildren.length);
+ var pattern = 'BREAK|' + blockId;
+ if (keys(postEntryLabels).length == 1) {
+ // We are breaking out of a multiple and have one entry after it, so we don't need to set __label__
+ pattern = 'BRNOL|' + blockId;
+ }
keys(postEntryLabels).forEach(function(post) {
- replaceLabelLabels(actualEntryLabel.blockChildren, set(post), 'BREAK|' + blockId);
+ replaceLabelLabels(actualEntryLabel.blockChildren, set(post), pattern);
});
+
// Create child block
actualEntryLabel.block = makeBlock(actualEntryLabel.blockChildren, [actualEntryLabel.blockChildren[0].ident], labelsDict);
});
@@ -1273,6 +1279,7 @@ function analyzer(data) {
replaceLabelLabels(block.labels, set('BJSET|*|' + block.willGetTo), 'BNOPP');
replaceLabelLabels(block.labels, set('BCONT|*|' + block.willGetTo), 'BNOPP');
replaceLabelLabels(block.labels, set('BREAK|*|' + block.willGetTo), 'BNOPP');
+ replaceLabelLabels(block.labels, set('BRNOL|*|' + block.willGetTo), 'BNOPP');
}
}
diff --git a/src/jsifier.js b/src/jsifier.js
index b06b4334..1f4ab7f8 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -760,6 +760,9 @@ function JSify(data, functionsOnly, givenFunctions) {
var labelSetting = oldLabel ? '__label__ = ' + getLabelId(oldLabel) + ';' +
(SHOW_LABELS ? ' /* to: ' + cleanLabel(oldLabel) + ' */' : '') : ''; // TODO: optimize away the setting
if (label[1] == 'R') {
+ if (label[2] == 'N') { // BRNOL: break, no label setting
+ labelSetting = '';
+ }
return pre + labelSetting + 'break ' + trueLabel + ';';
} else if (label[1] == 'C') { // CONT
return pre + labelSetting + 'continue ' + trueLabel + ';';