summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2019-05-16 18:17:52 (GMT)
committersebres <sebres@users.sourceforge.net>2019-05-16 18:17:52 (GMT)
commit2865a8da13749af3807ff9ea42c079f8c6c73133 (patch)
tree87c5f3b9c83fe3c86a41b6bf2886c74ecdbe3ffe
parentccc592df50d217757d74cb343d046a92d76860c1 (diff)
downloadtcl-2865a8da13749af3807ff9ea42c079f8c6c73133.zip
tcl-2865a8da13749af3807ff9ea42c079f8c6c73133.tar.gz
tcl-2865a8da13749af3807ff9ea42c079f8c6c73133.tar.bz2
small amend to [ac566e9df84daeab] with rollback of done/continue optimization
-rw-r--r--generic/tclCmdMZ.c7
-rw-r--r--tests/cmdMZ.test6
2 files changed, 13 insertions, 0 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 6be5087..d2485ef 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4009,6 +4009,7 @@ Tcl_TimeRateObjCmd(
TMRT_EV_DIRECT, TMRT_OVERHEAD, TMRT_CALIBRATE, TMRT_LAST
};
ByteCode *codePtr = NULL;
+ int codeOptimized = 0;
for (i = 1; i < objc - 1; i++) {
int index;
@@ -4200,6 +4201,7 @@ Tcl_TimeRateObjCmd(
*/
if (codePtr->codeStart[codePtr->numCodeBytes-1] == INST_DONE) {
codePtr->codeStart[codePtr->numCodeBytes-1] = INST_CONTINUE;
+ codeOptimized = 1;
}
}
@@ -4487,6 +4489,11 @@ Tcl_TimeRateObjCmd(
done:
if (codePtr != NULL) {
+ if ( codeOptimized
+ && codePtr->codeStart[codePtr->numCodeBytes-1] == INST_CONTINUE
+ ) {
+ codePtr->codeStart[codePtr->numCodeBytes-1] = INST_DONE;
+ }
TclReleaseByteCode(codePtr);
}
return result;
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test
index 09fff07..db72a44 100644
--- a/tests/cmdMZ.test
+++ b/tests/cmdMZ.test
@@ -433,6 +433,12 @@ test cmdMZ-6.10 {Tcl_TimeRateObjCmd: huge overhead cause 0us result} {
[expr {[lindex $m1 4] == 1000000}] \
[expr {[lindex $m1 6] <= 0.001}]
} {1 1 1 1}
+test cmdMZ-6.11 {Tcl_TimeRateObjCmd: done/continue optimization rollback} {
+ set m1 {set m2 ok}
+ if 1 $m1
+ timerate $m1 1000 10
+ if 1 $m1; # if rollback is missing throws an error: invoked "continue" outside of a loop
+} ok
# The tests for Tcl_WhileObjCmd are in while.test