Changes in external/tcl/tclExecute.c [d7d2da3:adeddd8] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/tcl/tclExecute.c
rd7d2da3 radeddd8 51 51 52 52 /* 53 * Variable that controls whether execution tracing is enabled and, if so,54 * what level of tracing is desired:55 * 0: no execution tracing56 * 1: trace invocations of Tcl procs only57 * 2: trace invocations of all (not compiled away) commands58 * 3: display each instruction executed59 * This variable is linked to the Tcl variable "tcl_traceExec".60 */61 62 int tclTraceExec = 0;63 64 /*65 53 * The following global variable is use to signal matherr that Tcl 66 54 * is responsible for the arithmetic, so errors can be handled in a … … 102 90 }; 103 91 104 /*105 * Mapping from Tcl result codes to strings; used for error and debugging106 * messages.107 */108 109 #ifdef TCL_COMPILE_DEBUG110 static char *resultStrings[] = {111 "TCL_OK", "TCL_ERROR", "TCL_RETURN", "TCL_BREAK", "TCL_CONTINUE"112 };113 #endif /* TCL_COMPILE_DEBUG */114 115 /*116 * The following are statistics-related variables that record information117 * about the bytecode compiler and interpreter's operation. This includes118 * an array that records for each instruction how often it is executed.119 */120 121 #ifdef TCL_COMPILE_STATS122 static long numExecutions = 0;123 static int instructionCount[256];124 #endif /* TCL_COMPILE_STATS */125 126 92 /* 127 93 * Macros for testing floating-point values for certain special cases. Test … … 187 153 #define POP_OBJECT() \ 188 154 (stackPtr[stackTop--].o) 189 190 /*191 * Macros used to trace instruction execution. The macros TRACE,192 * TRACE_WITH_OBJ, and O2S are only used inside TclExecuteByteCode.193 * O2S is only used in TRACE* calls to get a string from an object.194 *195 * NOTE THAT CLIENTS OF O2S ARE LIKELY TO FAIL IF THE OBJECT'S196 * STRING REP CONTAINS NULLS.197 */198 199 #ifdef TCL_COMPILE_DEBUG200 201 #define O2S(objPtr) \202 Tcl_GetStringFromObj((objPtr), &length)203 204 #ifdef TCL_COMPILE_STATS205 #define TRACE(a) \206 if (traceInstructions) { \207 fprintf(stdout, "%d: %d,%ld (%u) ", iPtr->numLevels, \208 stackTop, (tclObjsAlloced - tclObjsFreed), \209 (unsigned int)(pc - codePtr->codeStart)); \210 printf a; \211 fflush(stdout); \212 }213 #define TRACE_WITH_OBJ(a, objPtr) \214 if (traceInstructions) { \215 fprintf(stdout, "%d: %d,%ld (%u) ", iPtr->numLevels, \216 stackTop, (tclObjsAlloced - tclObjsFreed), \217 (unsigned int)(pc - codePtr->codeStart)); \218 printf a; \219 bytes = Tcl_GetStringFromObj((objPtr), &length); \220 TclPrintSource(stdout, bytes, TclMin(length, 30)); \221 fprintf(stdout, "\n"); \222 fflush(stdout); \223 }224 #else /* not TCL_COMPILE_STATS */225 #define TRACE(a) \226 if (traceInstructions) { \227 fprintf(stdout, "%d: %d (%u) ", iPtr->numLevels, stackTop, \228 (unsigned int)(pc - codePtr->codeStart)); \229 printf a; \230 fflush(stdout); \231 }232 #define TRACE_WITH_OBJ(a, objPtr) \233 if (traceInstructions) { \234 fprintf(stdout, "%d: %d (%u) ", iPtr->numLevels, stackTop, \235 (unsigned int)(pc - codePtr->codeStart)); \236 printf a; \237 bytes = Tcl_GetStringFromObj((objPtr), &length); \238 TclPrintSource(stdout, bytes, TclMin(length, 30)); \239 fprintf(stdout, "\n"); \240 fflush(stdout); \241 }242 #endif /* TCL_COMPILE_STATS */243 244 #else /* not TCL_COMPILE_DEBUG */245 246 #define TRACE(a)247 #define TRACE_WITH_OBJ(a, objPtr)248 #define O2S(objPtr)249 250 #endif /* TCL_COMPILE_DEBUG */251 155 252 156 /* … … 274 178 static int ExprUnaryFunc _ANSI_ARGS_((Tcl_Interp *interp, 275 179 ExecEnv *eePtr, ClientData clientData)); 276 #ifdef TCL_COMPILE_STATS277 static int EvalStatsCmd _ANSI_ARGS_((ClientData clientData,278 Tcl_Interp *interp, int argc, char **argv));279 #endif /* TCL_COMPILE_STATS */280 180 static void FreeCmdNameInternalRep _ANSI_ARGS_(( 281 181 Tcl_Obj *objPtr)); … … 293 193 static int SetCmdNameFromAny _ANSI_ARGS_((Tcl_Interp *interp, 294 194 Tcl_Obj *objPtr)); 295 #ifdef TCL_COMPILE_DEBUG296 static char * StringForResultCode _ANSI_ARGS_((int result));297 #endif /* TCL_COMPILE_DEBUG */298 195 static void UpdateStringOfCmdName _ANSI_ARGS_((Tcl_Obj *objPtr)); 299 #ifdef TCL_COMPILE_DEBUG300 static void ValidatePcAndStackTop _ANSI_ARGS_((301 ByteCode *codePtr, unsigned char *pc,302 int stackTop, int stackLowerBound,303 int stackUpperBound));304 #endif /* TCL_COMPILE_DEBUG */305 196 306 197 /* … … 368 259 * 369 260 * Side effects: 370 * This procedure initializes the array of instruction names. If 371 * compiling with the TCL_COMPILE_STATS flag, it initializes the 372 * array that counts the executions of each instruction and it 373 * creates the "evalstats" command. It also registers the command name 374 * Tcl_ObjType. It also establishes the link between the Tcl 375 * "tcl_traceExec" and C "tclTraceExec" variables. 261 * This procedure initializes the array of instruction names. 376 262 * 377 263 *---------------------------------------------------------------------- … … 391 277 for (i = 0; instructionTable[i].name != NULL; i++) { 392 278 opName[i] = instructionTable[i].name; 393 }394 395 #ifdef TCL_COMPILE_STATS396 (VOID *) memset(instructionCount, 0, sizeof(instructionCount));397 (VOID *) memset(tclByteCodeCount, 0, sizeof(tclByteCodeCount));398 (VOID *) memset(tclSourceCount, 0, sizeof(tclSourceCount));399 400 Tcl_CreateCommand(interp, "evalstats", EvalStatsCmd,401 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);402 #endif /* TCL_COMPILE_STATS */403 404 if (Tcl_LinkVar(interp, "tcl_traceExec", (char *) &tclTraceExec,405 TCL_LINK_INT) != TCL_OK) {406 panic("InitByteCodeExecution: can't create link for tcl_traceExec variable");407 279 } 408 280 } … … 598 470 * process break, continue, and errors. */ 599 471 int result = TCL_OK; /* Return code returned after execution. */ 600 int traceInstructions = (tclTraceExec == 3);601 472 Tcl_Obj *valuePtr, *value2Ptr, *namePtr, *objPtr; 602 473 char *bytes; 603 474 int length; 604 475 long i; 605 Tcl_DString command; /* Used for debugging. If tclTraceExec >= 2606 * holds a string representing the last607 * command invoked. */608 476 609 477 /* … … 620 488 621 489 /* 622 * THIS PROC FAILS IF AN OBJECT'S STRING REP HAS A NULL BYTE.623 */624 625 if (tclTraceExec >= 2) {626 PrintByteCodeInfo(codePtr);627 #ifdef TCL_COMPILE_STATS628 fprintf(stdout, " Starting stack top=%d, system objects=%ld\n",629 eePtr->stackTop, (tclObjsAlloced - tclObjsFreed));630 #else631 fprintf(stdout, " Starting stack top=%d\n", eePtr->stackTop);632 #endif /* TCL_COMPILE_STATS */633 fflush(stdout);634 }635 636 #ifdef TCL_COMPILE_STATS637 numExecutions++;638 #endif /* TCL_COMPILE_STATS */639 640 /*641 490 * Make sure the catch stack is large enough to hold the maximum number 642 491 * of catch commands that could ever be executing at the same time. This … … 659 508 660 509 /* 661 * Initialize the buffer that holds a string containing the name and662 * arguments for the last invoked command.663 */664 665 Tcl_DStringInit(&command);666 667 /*668 510 * Loop executing instructions until a "done" instruction, a TCL_RETURN, 669 511 * or some error. … … 671 513 672 514 for (;;) { 673 #ifdef TCL_COMPILE_DEBUG674 ValidatePcAndStackTop(codePtr, pc, stackTop, initStackTop,675 eePtr->stackEnd);676 #else /* not TCL_COMPILE_DEBUG */677 if (traceInstructions) {678 #ifdef TCL_COMPILE_STATS679 fprintf(stdout, "%d: %d,%ld ", iPtr->numLevels, stackTop,680 (tclObjsAlloced - tclObjsFreed));681 #else /* TCL_COMPILE_STATS */682 fprintf(stdout, "%d: %d ", iPtr->numLevels, stackTop);683 #endif /* TCL_COMPILE_STATS */684 TclPrintInstruction(codePtr, pc);685 fflush(stdout);686 }687 #endif /* TCL_COMPILE_DEBUG */688 689 515 opCode = *pc; 690 #ifdef TCL_COMPILE_STATS691 instructionCount[opCode]++;692 #endif /* TCL_COMPILE_STATS */693 516 694 517 switch (opCode) { … … 710 533 panic("TclExecuteByteCode execution failure: end stack top != start stack top"); 711 534 } 712 TRACE_WITH_OBJ(("done => return code=%d, result is ", result),713 iPtr->objResultPtr);714 535 goto done; 715 536 … … 717 538 valuePtr = objArrayPtr[TclGetUInt1AtPtr(pc+1)]; 718 539 PUSH_OBJECT(valuePtr); 719 TRACE_WITH_OBJ(("push1 %u => ", TclGetUInt1AtPtr(pc+1)),720 valuePtr);721 540 ADJUST_PC(2); 722 541 … … 724 543 valuePtr = objArrayPtr[TclGetUInt4AtPtr(pc+1)]; 725 544 PUSH_OBJECT(valuePtr); 726 TRACE_WITH_OBJ(("push4 %u => ", TclGetUInt4AtPtr(pc+1)),727 valuePtr);728 545 ADJUST_PC(5); 729 546 730 547 case INST_POP: 731 548 valuePtr = POP_OBJECT(); 732 TRACE_WITH_OBJ(("pop => discarding "), valuePtr);733 549 TclDecrRefCount(valuePtr); /* finished with pop'ed object. */ 734 550 ADJUST_PC(1); … … 737 553 valuePtr = stackPtr[stackTop].o; 738 554 PUSH_OBJECT(Tcl_DuplicateObj(valuePtr)); 739 TRACE_WITH_OBJ(("dup => "), valuePtr);740 555 ADJUST_PC(1); 741 556 … … 790 605 791 606 PUSH_OBJECT(concatObjPtr); 792 TRACE_WITH_OBJ(("concat %u => ", opnd), concatObjPtr);793 607 ADJUST_PC(2); 794 608 } … … 815 629 * Init. to avoid compiler warning. */ 816 630 Tcl_Command cmd; 817 #ifdef TCL_COMPILE_DEBUG818 int isUnknownCmd = 0;819 char cmdNameBuf[30];820 #endif /* TCL_COMPILE_DEBUG */821 631 822 632 /* … … 867 677 "invalid command name \"", cmdName, "\"", 868 678 (char *) NULL); 869 TRACE(("%s %u => unknown proc not found: ",870 opName[opCode], objc));871 679 result = TCL_ERROR; 872 680 goto checkForCatch; 873 681 } 874 682 cmdPtr = (Command *) cmd; 875 #ifdef TCL_COMPILE_DEBUG876 isUnknownCmd = 1;877 #endif /*TCL_COMPILE_DEBUG*/878 683 stackTop++; /* need room for new inserted objv[0] */ 879 684 for (i = objc; i >= 0; i--) { … … 918 723 Tcl_ResetResult(interp); 919 724 920 if (tclTraceExec >= 2) {921 char buffer[50];922 923 sprintf(buffer, "%d: (%u) invoking ", iPtr->numLevels,924 (unsigned int)(pc - codePtr->codeStart));925 Tcl_DStringAppend(&command, buffer, -1);926 927 #ifdef TCL_COMPILE_DEBUG928 if (traceInstructions) { /* tclTraceExec == 3 */929 strncpy(cmdNameBuf, cmdName, 20);930 TRACE(("%s %u => call ", opName[opCode],931 (isUnknownCmd? objc-1 : objc)));932 } else {933 fprintf(stdout, "%s", buffer);934 }935 #else /* TCL_COMPILE_DEBUG */936 fprintf(stdout, "%s", buffer);937 #endif /*TCL_COMPILE_DEBUG*/938 939 for (i = 0; i < objc; i++) {940 bytes = TclGetStringFromObj(objv[i], &length);941 TclPrintSource(stdout, bytes, TclMin(length, 15));942 fprintf(stdout, " ");943 944 sprintf(buffer, "\"%.*s\" ", TclMin(length, 15), bytes);945 Tcl_DStringAppend(&command, buffer, -1);946 }947 fprintf(stdout, "\n");948 fflush(stdout);949 950 Tcl_DStringFree(&command);951 }952 953 725 iPtr->cmdCount++; 954 726 DECACHE_STACK_INFO(); … … 996 768 */ 997 769 PUSH_OBJECT(Tcl_GetObjResult(interp)); 998 TRACE_WITH_OBJ(("%s %u => ...after \"%.20s\", result=",999 opName[opCode], objc, cmdNameBuf),1000 Tcl_GetObjResult(interp));1001 770 ADJUST_PC(pcAdjustment); 1002 771 … … 1015 784 /*catchOnly*/ 0, codePtr); 1016 785 if (rangePtr == NULL) { 1017 TRACE(("%s %u => ... after \"%.20s\", no encl. loop or catch, returning %s\n",1018 opName[opCode], objc, cmdNameBuf,1019 StringForResultCode(result)));1020 786 goto abnormalReturn; /* no catch exists to check */ 1021 787 } … … 1025 791 newPcOffset = rangePtr->breakOffset; 1026 792 } else if (rangePtr->continueOffset == -1) { 1027 TRACE(("%s %u => ... after \"%.20s\", %s, loop w/o continue, checking for catch\n",1028 opName[opCode], objc, cmdNameBuf,1029 StringForResultCode(result)));1030 793 goto checkForCatch; 1031 794 } else { 1032 795 newPcOffset = rangePtr->continueOffset; 1033 796 } 1034 TRACE(("%s %u => ... after \"%.20s\", %s, range at %d, new pc %d\n",1035 opName[opCode], objc, cmdNameBuf,1036 StringForResultCode(result),1037 rangePtr->codeOffset, newPcOffset));1038 797 break; 1039 798 case CATCH_EXCEPTION_RANGE: 1040 TRACE(("%s %u => ... after \"%.20s\", %s...\n",1041 opName[opCode], objc, cmdNameBuf,1042 StringForResultCode(result)));1043 799 goto processCatch; /* it will use rangePtr */ 1044 800 default: … … 1054 810 * enclosing catch exception range, if any. 1055 811 */ 1056 TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", TCL_ERROR ",1057 opName[opCode], objc, cmdNameBuf),1058 Tcl_GetObjResult(interp));1059 812 goto checkForCatch; 1060 813 … … 1065 818 * for an enclosing catch exception range, if any. 1066 819 */ 1067 TRACE(("%s %u => ... after \"%.20s\", TCL_RETURN\n",1068 opName[opCode], objc, cmdNameBuf));1069 820 goto checkForCatch; 1070 821 1071 822 default: 1072 TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", OTHER RETURN CODE %d ",1073 opName[opCode], objc, cmdNameBuf, result),1074 Tcl_GetObjResult(interp));1075 823 goto checkForCatch; 1076 824 } /* end of switch on result from invoke instruction */ … … 1088 836 1089 837 PUSH_OBJECT(Tcl_GetObjResult(interp)); 1090 TRACE_WITH_OBJ(("evalStk \"%.30s\" => ", O2S(objPtr)),1091 Tcl_GetObjResult(interp));1092 838 TclDecrRefCount(objPtr); 1093 839 ADJUST_PC(1); … … 1109 855 codePtr); 1110 856 if (rangePtr == NULL) { 1111 TRACE(("evalStk \"%.30s\" => no encl. loop or catch, returning %s\n",1112 O2S(objPtr), StringForResultCode(result)));1113 857 Tcl_DecrRefCount(objPtr); 1114 858 goto abnormalReturn; /* no catch exists to check */ … … 1119 863 newPcOffset = rangePtr->breakOffset; 1120 864 } else if (rangePtr->continueOffset == -1) { 1121 TRACE(("evalStk \"%.30s\" => %s, loop w/o continue, checking for catch\n",1122 O2S(objPtr), StringForResultCode(result)));1123 865 Tcl_DecrRefCount(objPtr); 1124 866 goto checkForCatch; … … 1127 869 } 1128 870 result = TCL_OK; 1129 TRACE_WITH_OBJ(("evalStk \"%.30s\" => %s, range at %d, new pc %d ",1130 O2S(objPtr), StringForResultCode(result),1131 rangePtr->codeOffset, newPcOffset), valuePtr);1132 871 break; 1133 872 case CATCH_EXCEPTION_RANGE: 1134 TRACE_WITH_OBJ(("evalStk \"%.30s\" => %s ",1135 O2S(objPtr), StringForResultCode(result)),1136 valuePtr);1137 873 Tcl_DecrRefCount(objPtr); 1138 874 goto processCatch; /* it will use rangePtr */ … … 1144 880 continue; /* restart outer instruction loop at pc */ 1145 881 } else { /* eval returned TCL_ERROR, TCL_RETURN, unknown code */ 1146 TRACE_WITH_OBJ(("evalStk \"%.30s\" => ERROR: ", O2S(objPtr)),1147 Tcl_GetObjResult(interp));1148 882 Tcl_DecrRefCount(objPtr); 1149 883 goto checkForCatch; … … 1157 891 CACHE_STACK_INFO(); 1158 892 if (result != TCL_OK) { 1159 TRACE_WITH_OBJ(("exprStk \"%.30s\" => ERROR: ",1160 O2S(objPtr)), Tcl_GetObjResult(interp));1161 893 Tcl_DecrRefCount(objPtr); 1162 894 goto checkForCatch; 1163 895 } 1164 896 stackPtr[++stackTop].o = valuePtr; /* already has right refct */ 1165 TRACE_WITH_OBJ(("exprStk \"%.30s\" => ", O2S(objPtr)), valuePtr);1166 897 TclDecrRefCount(objPtr); 1167 898 ADJUST_PC(1); … … 1182 913 CACHE_STACK_INFO(); 1183 914 if (valuePtr == NULL) { 1184 TRACE_WITH_OBJ(("%s %u => ERROR: ", opName[opCode], opnd),1185 Tcl_GetObjResult(interp));1186 915 result = TCL_ERROR; 1187 916 goto checkForCatch; 1188 917 } 1189 918 PUSH_OBJECT(valuePtr); 1190 TRACE_WITH_OBJ(("%s %u => ", opName[opCode], opnd), valuePtr);1191 919 ADJUST_PC(pcAdjustment); 1192 920 … … 1198 926 CACHE_STACK_INFO(); 1199 927 if (valuePtr == NULL) { 1200 TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ERROR: ",1201 O2S(namePtr)), Tcl_GetObjResult(interp));1202 928 Tcl_DecrRefCount(namePtr); 1203 929 result = TCL_ERROR; … … 1205 931 } 1206 932 PUSH_OBJECT(valuePtr); 1207 TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ",1208 O2S(namePtr)), valuePtr);1209 933 TclDecrRefCount(namePtr); 1210 934 ADJUST_PC(1); … … 1228 952 CACHE_STACK_INFO(); 1229 953 if (valuePtr == NULL) { 1230 TRACE_WITH_OBJ(("%s %u \"%.30s\" => ERROR: ",1231 opName[opCode], opnd, O2S(elemPtr)),1232 Tcl_GetObjResult(interp));1233 954 Tcl_DecrRefCount(elemPtr); 1234 955 result = TCL_ERROR; … … 1236 957 } 1237 958 PUSH_OBJECT(valuePtr); 1238 TRACE_WITH_OBJ(("%s %u \"%.30s\" => ",1239 opName[opCode], opnd, O2S(elemPtr)), valuePtr);1240 959 TclDecrRefCount(elemPtr); 1241 960 } … … 1252 971 CACHE_STACK_INFO(); 1253 972 if (valuePtr == NULL) { 1254 TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ERROR: ",1255 O2S(namePtr), O2S(elemPtr)),1256 Tcl_GetObjResult(interp));1257 973 Tcl_DecrRefCount(namePtr); 1258 974 Tcl_DecrRefCount(elemPtr); … … 1261 977 } 1262 978 PUSH_OBJECT(valuePtr); 1263 TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ",1264 O2S(namePtr), O2S(elemPtr)), valuePtr);1265 979 TclDecrRefCount(namePtr); 1266 980 TclDecrRefCount(elemPtr); … … 1275 989 CACHE_STACK_INFO(); 1276 990 if (valuePtr == NULL) { 1277 TRACE_WITH_OBJ(("loadStk \"%.30s\" => ERROR: ",1278 O2S(namePtr)), Tcl_GetObjResult(interp));1279 991 Tcl_DecrRefCount(namePtr); 1280 992 result = TCL_ERROR; … … 1282 994 } 1283 995 PUSH_OBJECT(valuePtr); 1284 TRACE_WITH_OBJ(("loadStk \"%.30s\" => ", O2S(namePtr)),1285 valuePtr);1286 996 TclDecrRefCount(namePtr); 1287 997 ADJUST_PC(1); … … 1303 1013 CACHE_STACK_INFO(); 1304 1014 if (value2Ptr == NULL) { 1305 TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ERROR: ",1306 opName[opCode], opnd, O2S(valuePtr)),1307 Tcl_GetObjResult(interp));1308 1015 Tcl_DecrRefCount(valuePtr); 1309 1016 result = TCL_ERROR; … … 1311 1018 } 1312 1019 PUSH_OBJECT(value2Ptr); 1313 TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ",1314 opName[opCode], opnd, O2S(valuePtr)), value2Ptr);1315 1020 TclDecrRefCount(valuePtr); 1316 1021 ADJUST_PC(pcAdjustment); … … 1324 1029 CACHE_STACK_INFO(); 1325 1030 if (value2Ptr == NULL) { 1326 TRACE_WITH_OBJ(1327 ("storeScalarStk \"%.30s\" <- \"%.30s\" => ERROR: ",1328 O2S(namePtr), O2S(valuePtr)),1329 Tcl_GetObjResult(interp));1330 1031 Tcl_DecrRefCount(namePtr); 1331 1032 Tcl_DecrRefCount(valuePtr); … … 1334 1035 } 1335 1036 PUSH_OBJECT(value2Ptr); 1336 TRACE_WITH_OBJ(1337 ("storeScalarStk \"%.30s\" <- \"%.30s\" => ",1338 O2S(namePtr),1339 O2S(valuePtr)),1340 value2Ptr);1341 1037 TclDecrRefCount(namePtr); 1342 1038 TclDecrRefCount(valuePtr); … … 1363 1059 CACHE_STACK_INFO(); 1364 1060 if (value2Ptr == NULL) { 1365 TRACE_WITH_OBJ(1366 ("%s %u \"%.30s\" <- \"%.30s\" => ERROR: ",1367 opName[opCode], opnd, O2S(elemPtr),1368 O2S(valuePtr)), Tcl_GetObjResult(interp));1369 1061 Tcl_DecrRefCount(elemPtr); 1370 1062 Tcl_DecrRefCount(valuePtr); … … 1373 1065 } 1374 1066 PUSH_OBJECT(value2Ptr); 1375 TRACE_WITH_OBJ(("%s %u \"%.30s\" <- \"%.30s\" => ",1376 opName[opCode], opnd, O2S(elemPtr), O2S(valuePtr)),1377 value2Ptr);1378 1067 TclDecrRefCount(elemPtr); 1379 1068 TclDecrRefCount(valuePtr); … … 1393 1082 CACHE_STACK_INFO(); 1394 1083 if (value2Ptr == NULL) { 1395 TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ERROR: ",1396 O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),1397 Tcl_GetObjResult(interp));1398 1084 Tcl_DecrRefCount(namePtr); 1399 1085 Tcl_DecrRefCount(elemPtr); … … 1403 1089 } 1404 1090 PUSH_OBJECT(value2Ptr); 1405 TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ",1406 O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),1407 value2Ptr);1408 1091 TclDecrRefCount(namePtr); 1409 1092 TclDecrRefCount(elemPtr); … … 1420 1103 CACHE_STACK_INFO(); 1421 1104 if (value2Ptr == NULL) { 1422 TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ERROR: ",1423 O2S(namePtr), O2S(valuePtr)),1424 Tcl_GetObjResult(interp));1425 1105 Tcl_DecrRefCount(namePtr); 1426 1106 Tcl_DecrRefCount(valuePtr); … … 1429 1109 } 1430 1110 PUSH_OBJECT(value2Ptr); 1431 TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ",1432 O2S(namePtr), O2S(valuePtr)), value2Ptr);1433 1111 TclDecrRefCount(namePtr); 1434 1112 TclDecrRefCount(valuePtr); … … 1441 1119 result = tclIntType.setFromAnyProc(interp, valuePtr); 1442 1120 if (result != TCL_OK) { 1443 TRACE_WITH_OBJ(("incrScalar1 %u (by %s) => ERROR converting increment amount to int: ",1444 opnd, O2S(valuePtr)), Tcl_GetObjResult(interp));1445 1121 Tcl_DecrRefCount(valuePtr); 1446 1122 goto checkForCatch; … … 1452 1128 CACHE_STACK_INFO(); 1453 1129 if (value2Ptr == NULL) { 1454 TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ERROR: ",1455 opnd, i), Tcl_GetObjResult(interp));1456 1130 Tcl_DecrRefCount(valuePtr); 1457 1131 result = TCL_ERROR; … … 1459 1133 } 1460 1134 PUSH_OBJECT(value2Ptr); 1461 TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ", opnd, i),1462 value2Ptr);1463 1135 TclDecrRefCount(valuePtr); 1464 1136 ADJUST_PC(2); … … 1471 1143 result = tclIntType.setFromAnyProc(interp, valuePtr); 1472 1144 if (result != TCL_OK) { 1473 TRACE_WITH_OBJ(("%s \"%.30s\" (by %s) => ERROR converting increment amount to int: ",1474 opName[opCode], O2S(namePtr), O2S(valuePtr)),1475 Tcl_GetObjResult(interp));1476 1145 Tcl_DecrRefCount(namePtr); 1477 1146 Tcl_DecrRefCount(valuePtr); … … 1485 1154 CACHE_STACK_INFO(); 1486 1155 if (value2Ptr == NULL) { 1487 TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ERROR: ",1488 opName[opCode], O2S(namePtr), i),1489 Tcl_GetObjResult(interp));1490 1156 Tcl_DecrRefCount(namePtr); 1491 1157 Tcl_DecrRefCount(valuePtr); … … 1494 1160 } 1495 1161 PUSH_OBJECT(value2Ptr); 1496 TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ",1497 opName[opCode], O2S(namePtr), i), value2Ptr);1498 1162 Tcl_DecrRefCount(namePtr); 1499 1163 Tcl_DecrRefCount(valuePtr); … … 1510 1174 result = tclIntType.setFromAnyProc(interp, valuePtr); 1511 1175 if (result != TCL_OK) { 1512 TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %s) => ERROR converting increment amount to int: ",1513 opnd, O2S(elemPtr), O2S(valuePtr)),1514 Tcl_GetObjResult(interp));1515 1176 Tcl_DecrRefCount(elemPtr); 1516 1177 Tcl_DecrRefCount(valuePtr); … … 1524 1185 CACHE_STACK_INFO(); 1525 1186 if (value2Ptr == NULL) { 1526 TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ERROR: ",1527 opnd, O2S(elemPtr), i),1528 Tcl_GetObjResult(interp));1529 1187 Tcl_DecrRefCount(elemPtr); 1530 1188 Tcl_DecrRefCount(valuePtr); … … 1533 1191 } 1534 1192 PUSH_OBJECT(value2Ptr); 1535 TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ",1536 opnd, O2S(elemPtr), i), value2Ptr);1537 1193 Tcl_DecrRefCount(elemPtr); 1538 1194 Tcl_DecrRefCount(valuePtr); … … 1550 1206 result = tclIntType.setFromAnyProc(interp, valuePtr); 1551 1207 if (result != TCL_OK) { 1552 TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %s) => ERROR converting increment amount to int: ",1553 O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),1554 Tcl_GetObjResult(interp));1555 1208 Tcl_DecrRefCount(namePtr); 1556 1209 Tcl_DecrRefCount(elemPtr); … … 1565 1218 CACHE_STACK_INFO(); 1566 1219 if (value2Ptr == NULL) { 1567 TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ERROR: ",1568 O2S(namePtr), O2S(elemPtr), i),1569 Tcl_GetObjResult(interp));1570 1220 Tcl_DecrRefCount(namePtr); 1571 1221 Tcl_DecrRefCount(elemPtr); … … 1575 1225 } 1576 1226 PUSH_OBJECT(value2Ptr); 1577 TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ",1578 O2S(namePtr), O2S(elemPtr), i), value2Ptr);1579 1227 Tcl_DecrRefCount(namePtr); 1580 1228 Tcl_DecrRefCount(elemPtr); … … 1590 1238 CACHE_STACK_INFO(); 1591 1239 if (value2Ptr == NULL) { 1592 TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ERROR: ",1593 opnd, i), Tcl_GetObjResult(interp));1594 1240 result = TCL_ERROR; 1595 1241 goto checkForCatch; 1596 1242 } 1597 1243 PUSH_OBJECT(value2Ptr); 1598 TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ", opnd, i),1599 value2Ptr);1600 1244 ADJUST_PC(3); 1601 1245 … … 1609 1253 CACHE_STACK_INFO(); 1610 1254 if (value2Ptr == NULL) { 1611 TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ERROR: ",1612 opName[opCode], O2S(namePtr), i),1613 Tcl_GetObjResult(interp));1614 1255 result = TCL_ERROR; 1615 1256 Tcl_DecrRefCount(namePtr); … … 1617 1258 } 1618 1259 PUSH_OBJECT(value2Ptr); 1619 TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ",1620 opName[opCode], O2S(namePtr), i), value2Ptr);1621 1260 TclDecrRefCount(namePtr); 1622 1261 ADJUST_PC(2); … … 1634 1273 CACHE_STACK_INFO(); 1635 1274 if (value2Ptr == NULL) { 1636 TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ERROR: ",1637 opnd, O2S(elemPtr), i),1638 Tcl_GetObjResult(interp));1639 1275 Tcl_DecrRefCount(elemPtr); 1640 1276 result = TCL_ERROR; … … 1642 1278 } 1643 1279 PUSH_OBJECT(value2Ptr); 1644 TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ",1645 opnd, O2S(elemPtr), i), value2Ptr);1646 1280 Tcl_DecrRefCount(elemPtr); 1647 1281 } … … 1660 1294 CACHE_STACK_INFO(); 1661 1295 if (value2Ptr == NULL) { 1662 TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ERROR: ",1663 O2S(namePtr), O2S(elemPtr), i),1664 Tcl_GetObjResult(interp));1665 1296 Tcl_DecrRefCount(namePtr); 1666 1297 Tcl_DecrRefCount(elemPtr); … … 1669 1300 } 1670 1301 PUSH_OBJECT(value2Ptr); 1671 TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ",1672 O2S(namePtr), O2S(elemPtr), i), value2Ptr);1673 1302 Tcl_DecrRefCount(namePtr); 1674 1303 Tcl_DecrRefCount(elemPtr); … … 1678 1307 case INST_JUMP1: 1679 1308 opnd = TclGetInt1AtPtr(pc+1); 1680 TRACE(("jump1 %d => new pc %u\n", opnd,1681 (unsigned int)(pc + opnd - codePtr->codeStart)));1682 1309 ADJUST_PC(opnd); 1683 1310 1684 1311 case INST_JUMP4: 1685 1312 opnd = TclGetInt4AtPtr(pc+1); 1686 TRACE(("jump4 %d => new pc %u\n", opnd,1687 (unsigned int)(pc + opnd - codePtr->codeStart)));1688 1313 ADJUST_PC(opnd); 1689 1314 … … 1709 1334 result = Tcl_GetBooleanFromObj(interp, valuePtr, &b); 1710 1335 if (result != TCL_OK) { 1711 TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],1712 opnd), Tcl_GetObjResult(interp));1713 1336 Tcl_DecrRefCount(valuePtr); 1714 1337 goto checkForCatch; … … 1716 1339 } 1717 1340 if (b) { 1718 TRACE(("%s %d => %.20s true, new pc %u\n",1719 opName[opCode], opnd, O2S(valuePtr),1720 (unsigned int)(pc+opnd - codePtr->codeStart)));1721 1341 TclDecrRefCount(valuePtr); 1722 1342 ADJUST_PC(opnd); 1723 1343 } else { 1724 TRACE(("%s %d => %.20s false\n", opName[opCode], opnd,1725 O2S(valuePtr)));1726 1344 TclDecrRefCount(valuePtr); 1727 1345 ADJUST_PC(pcAdjustment); … … 1750 1368 result = Tcl_GetBooleanFromObj(interp, valuePtr, &b); 1751 1369 if (result != TCL_OK) { 1752 TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],1753 opnd), Tcl_GetObjResult(interp));1754 1370 Tcl_DecrRefCount(valuePtr); 1755 1371 goto checkForCatch; … … 1757 1373 } 1758 1374 if (b) { 1759 TRACE(("%s %d => %.20s true\n", opName[opCode], opnd,1760 O2S(valuePtr)));1761 1375 TclDecrRefCount(valuePtr); 1762 1376 ADJUST_PC(pcAdjustment); 1763 1377 } else { 1764 TRACE(("%s %d => %.20s false, new pc %u\n",1765 opName[opCode], opnd, O2S(valuePtr),1766 (unsigned int)(pc + opnd - codePtr->codeStart)));1767 1378 TclDecrRefCount(valuePtr); 1768 1379 ADJUST_PC(opnd); … … 1804 1415 } 1805 1416 if (result != TCL_OK) { 1806 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",1807 opName[opCode], O2S(valuePtr),1808 (t1Ptr? t1Ptr->name : "null")));1809 1417 IllegalExprOperandType(interp, opCode, valuePtr); 1810 1418 Tcl_DecrRefCount(valuePtr); … … 1830 1438 } 1831 1439 if (result != TCL_OK) { 1832 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",1833 opName[opCode], O2S(value2Ptr),1834 (t2Ptr? t2Ptr->name : "null")));1835 1440 IllegalExprOperandType(interp, opCode, value2Ptr); 1836 1441 Tcl_DecrRefCount(valuePtr); … … 1851 1456 if (Tcl_IsShared(valuePtr)) { 1852 1457 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 1853 TRACE(("%s %.20s %.20s => %d\n", opName[opCode],1854 O2S(valuePtr), O2S(value2Ptr), iResult));1855 1458 TclDecrRefCount(valuePtr); 1856 1459 } else { /* reuse the valuePtr object */ 1857 TRACE(("%s %.20s %.20s => %d\n",1858 opName[opCode], /* NB: stack top is off by 1 */1859 O2S(valuePtr), O2S(value2Ptr), iResult));1860 1460 Tcl_SetLongObj(valuePtr, iResult); 1861 1461 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2013 1613 if (Tcl_IsShared(valuePtr)) { 2014 1614 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 2015 TRACE(("%s %.20s %.20s => %ld\n", opName[opCode],2016 O2S(valuePtr), O2S(value2Ptr), iResult));2017 1615 TclDecrRefCount(valuePtr); 2018 1616 } else { /* reuse the valuePtr object */ 2019 TRACE(("%s %.20s %.20s => %ld\n",2020 opName[opCode], /* NB: stack top is off by 1 */2021 O2S(valuePtr), O2S(value2Ptr), iResult));2022 1617 Tcl_SetLongObj(valuePtr, iResult); 2023 1618 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2049 1644 valuePtr, &i); 2050 1645 if (result != TCL_OK) { 2051 TRACE(("%s %.20s %.20s => ILLEGAL 1st TYPE %s\n",2052 opName[opCode], O2S(valuePtr), O2S(value2Ptr),2053 (valuePtr->typePtr?2054 valuePtr->typePtr->name : "null")));2055 1646 IllegalExprOperandType(interp, opCode, valuePtr); 2056 1647 Tcl_DecrRefCount(valuePtr); … … 2065 1656 value2Ptr, &i2); 2066 1657 if (result != TCL_OK) { 2067 TRACE(("%s %.20s %.20s => ILLEGAL 2nd TYPE %s\n",2068 opName[opCode], O2S(valuePtr), O2S(value2Ptr),2069 (value2Ptr->typePtr?2070 value2Ptr->typePtr->name : "null")));2071 1658 IllegalExprOperandType(interp, opCode, value2Ptr); 2072 1659 Tcl_DecrRefCount(valuePtr); … … 2085 1672 */ 2086 1673 if (i2 == 0) { 2087 TRACE(("mod %ld %ld => DIVIDE BY ZERO\n", i, i2));2088 1674 Tcl_DecrRefCount(valuePtr); 2089 1675 Tcl_DecrRefCount(value2Ptr); … … 2137 1723 if (Tcl_IsShared(valuePtr)) { 2138 1724 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 2139 TRACE(("%s %ld %ld => %ld\n", opName[opCode], i, i2,2140 iResult));2141 1725 TclDecrRefCount(valuePtr); 2142 1726 } else { /* reuse the valuePtr object */ 2143 TRACE(("%s %ld %ld => %ld\n", opName[opCode], i, i2,2144 iResult)); /* NB: stack top is off by 1 */2145 1727 Tcl_SetLongObj(valuePtr, iResult); 2146 1728 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2186 1768 } 2187 1769 if (result != TCL_OK) { 2188 TRACE(("%s %.20s %.20s => ILLEGAL 1st TYPE %s\n",2189 opName[opCode], s, O2S(value2Ptr),2190 (valuePtr->typePtr?2191 valuePtr->typePtr->name : "null")));2192 1770 IllegalExprOperandType(interp, opCode, valuePtr); 2193 1771 Tcl_DecrRefCount(valuePtr); … … 2212 1790 } 2213 1791 if (result != TCL_OK) { 2214 TRACE(("%s %.20s %.20s => ILLEGAL 2nd TYPE %s\n",2215 opName[opCode], O2S(valuePtr), s,2216 (value2Ptr->typePtr?2217 value2Ptr->typePtr->name : "null")));2218 1792 IllegalExprOperandType(interp, opCode, value2Ptr); 2219 1793 Tcl_DecrRefCount(valuePtr); … … 2246 1820 case INST_DIV: 2247 1821 if (d2 == 0.0) { 2248 TRACE(("div %.6g %.6g => DIVIDE BY ZERO\n",2249 d1, d2));2250 1822 Tcl_DecrRefCount(valuePtr); 2251 1823 Tcl_DecrRefCount(value2Ptr); … … 2261 1833 2262 1834 if (IS_NAN(dResult) || IS_INF(dResult)) { 2263 TRACE(("%s %.20s %.20s => IEEE FLOATING PT ERROR\n",2264 opName[opCode], O2S(valuePtr), O2S(value2Ptr)));2265 1835 TclExprFloatError(interp, dResult); 2266 1836 result = TCL_ERROR; … … 2291 1861 */ 2292 1862 if (i2 == 0) { 2293 TRACE(("div %ld %ld => DIVIDE BY ZERO\n",2294 i, i2));2295 1863 Tcl_DecrRefCount(valuePtr); 2296 1864 Tcl_DecrRefCount(value2Ptr); … … 2318 1886 if (doDouble) { 2319 1887 PUSH_OBJECT(Tcl_NewDoubleObj(dResult)); 2320 TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],2321 d1, d2, dResult));2322 1888 } else { 2323 1889 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 2324 TRACE(("%s %ld %ld => %ld\n", opName[opCode],2325 i, i2, iResult));2326 1890 } 2327 1891 TclDecrRefCount(valuePtr); 2328 1892 } else { /* reuse the valuePtr object */ 2329 1893 if (doDouble) { /* NB: stack top is off by 1 */ 2330 TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],2331 d1, d2, dResult));2332 1894 Tcl_SetDoubleObj(valuePtr, dResult); 2333 1895 } else { 2334 TRACE(("%s %ld %ld => %ld\n", opName[opCode],2335 i, i2, iResult));2336 1896 Tcl_SetLongObj(valuePtr, iResult); 2337 1897 } … … 2363 1923 } 2364 1924 if (result != TCL_OK) { 2365 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",2366 opName[opCode], s,2367 (tPtr? tPtr->name : "null")));2368 1925 IllegalExprOperandType(interp, opCode, valuePtr); 2369 1926 goto checkForCatch; 2370 1927 } 2371 1928 } 2372 TRACE_WITH_OBJ(("uplus %s => ", O2S(valuePtr)), valuePtr);2373 1929 } 2374 1930 ADJUST_PC(1); … … 2399 1955 } 2400 1956 if (result != TCL_OK) { 2401 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s\n",2402 opName[opCode], s,2403 (tPtr? tPtr->name : "null")));2404 1957 IllegalExprOperandType(interp, opCode, valuePtr); 2405 1958 Tcl_DecrRefCount(valuePtr); … … 2417 1970 objPtr = Tcl_NewLongObj( 2418 1971 (opCode == INST_UMINUS)? -i : !i); 2419 TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),2420 objPtr); /* NB: stack top is off by 1 */2421 1972 } else { 2422 1973 d = valuePtr->internalRep.doubleValue; … … 2430 1981 objPtr = Tcl_NewLongObj((d==0.0)? 1 : 0); 2431 1982 } 2432 TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),2433 objPtr); /* NB: stack top is off by 1 */2434 1983 } 2435 1984 PUSH_OBJECT(objPtr); … … 2443 1992 Tcl_SetLongObj(valuePtr, 2444 1993 (opCode == INST_UMINUS)? -i : !i); 2445 TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),2446 valuePtr); /* NB: stack top is off by 1 */2447 1994 } else { 2448 1995 d = valuePtr->internalRep.doubleValue; … … 2456 2003 Tcl_SetLongObj(valuePtr, (d==0.0)? 1 : 0); 2457 2004 } 2458 TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),2459 valuePtr); /* NB: stack top is off by 1 */2460 2005 } 2461 2006 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2481 2026 valuePtr, &i); 2482 2027 if (result != TCL_OK) { /* try to convert to double */ 2483 TRACE(("bitnot \"%.20s\" => ILLEGAL TYPE %s\n",2484 O2S(valuePtr), (tPtr? tPtr->name : "null")));2485 2028 IllegalExprOperandType(interp, opCode, valuePtr); 2486 2029 Tcl_DecrRefCount(valuePtr); … … 2492 2035 if (Tcl_IsShared(valuePtr)) { 2493 2036 PUSH_OBJECT(Tcl_NewLongObj(~i)); 2494 TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));2495 2037 TclDecrRefCount(valuePtr); 2496 2038 } else { … … 2500 2042 Tcl_SetLongObj(valuePtr, ~i); 2501 2043 ++stackTop; /* valuePtr now on stk top has right r.c. */ 2502 TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));2503 2044 } 2504 2045 } … … 2515 2056 2516 2057 if ((opnd < 0) || (opnd > LAST_BUILTIN_FUNC)) { 2517 TRACE(("UNRECOGNIZED BUILTIN FUNC CODE %d\n", opnd));2518 2058 panic("TclExecuteByteCode: unrecognized builtin function code %d", opnd); 2519 2059 } … … 2528 2068 goto checkForCatch; 2529 2069 } 2530 TRACE_WITH_OBJ(("callBuiltinFunc1 %d => ", opnd),2531 stackPtr[stackTop].o);2532 2070 } 2533 2071 ADJUST_PC(2); … … 2555 2093 goto checkForCatch; 2556 2094 } 2557 TRACE_WITH_OBJ(("callFunc1 %d => ", objc),2558 stackPtr[stackTop].o);2559 2095 ADJUST_PC(2); 2560 2096 } … … 2627 2163 d = valuePtr->internalRep.doubleValue; 2628 2164 if (IS_NAN(d) || IS_INF(d)) { 2629 TRACE(("tryCvtToNumeric \"%.20s\" => IEEE FLOATING PT ERROR\n",2630 O2S(valuePtr)));2631 2165 TclExprFloatError(interp, d); 2632 2166 result = TCL_ERROR; … … 2636 2170 shared = shared; /* lint, shared not used. */ 2637 2171 converted = converted; /* lint, converted not used. */ 2638 TRACE(("tryCvtToNumeric \"%.20s\" => numeric, %s, %s\n",2639 O2S(valuePtr),2640 (converted? "converted" : "not converted"),2641 (shared? "shared" : "not shared")));2642 } else {2643 TRACE(("tryCvtToNumeric \"%.20s\" => not numeric\n",2644 O2S(valuePtr)));2645 2172 } 2646 2173 } … … 2660 2187 codePtr); 2661 2188 if (rangePtr == NULL) { 2662 TRACE(("break => no encl. loop or catch, returning TCL_BREAK\n"));2663 2189 result = TCL_BREAK; 2664 2190 goto abnormalReturn; /* no catch exists to check */ … … 2667 2193 case LOOP_EXCEPTION_RANGE: 2668 2194 result = TCL_OK; 2669 TRACE(("break => range at %d, new pc %d\n",2670 rangePtr->codeOffset, rangePtr->breakOffset));2671 2195 break; 2672 2196 case CATCH_EXCEPTION_RANGE: 2673 2197 result = TCL_BREAK; 2674 TRACE(("break => ...\n"));2675 2198 goto processCatch; /* it will use rangePtr */ 2676 2199 default: … … 2693 2216 codePtr); 2694 2217 if (rangePtr == NULL) { 2695 TRACE(("continue => no encl. loop or catch, returning TCL_CONTINUE\n"));2696 2218 result = TCL_CONTINUE; 2697 2219 goto abnormalReturn; … … 2700 2222 case LOOP_EXCEPTION_RANGE: 2701 2223 if (rangePtr->continueOffset == -1) { 2702 TRACE(("continue => loop w/o continue, checking for catch\n"));2703 2224 goto checkForCatch; 2704 2225 } else { 2705 2226 result = TCL_OK; 2706 TRACE(("continue => range at %d, new pc %d\n",2707 rangePtr->codeOffset, rangePtr->continueOffset));2708 2227 } 2709 2228 break; 2710 2229 case CATCH_EXCEPTION_RANGE: 2711 2230 result = TCL_CONTINUE; 2712 TRACE(("continue => ...\n"));2713 2231 goto processCatch; /* it will use rangePtr */ 2714 2232 default: … … 2744 2262 TclSetVarScalar(iterVarPtr); 2745 2263 TclClearVarUndefined(iterVarPtr); 2746 TRACE(("foreach_start4 %u => loop iter count temp %d\n",2747 opnd, iterTmpIndex));2748 2264 } 2749 2265 ADJUST_PC(5); … … 2794 2310 result = Tcl_ListObjLength(interp, listPtr, &listLen); 2795 2311 if (result != TCL_OK) { 2796 TRACE_WITH_OBJ(("foreach_step4 %u => ERROR converting list %ld, \"%s\": ",2797 opnd, i, O2S(listPtr)),2798 Tcl_GetObjResult(interp));2799 2312 goto checkForCatch; 2800 2313 } … … 2840 2353 CACHE_STACK_INFO(); 2841 2354 if (value2Ptr == NULL) { 2842 TRACE_WITH_OBJ(("foreach_step4 %u => ERROR init. index temp %d: ",2843 opnd, varIndex),2844 Tcl_GetObjResult(interp));2845 2355 if (setEmptyStr) { 2846 2356 Tcl_DecrRefCount(elemPtr); /* unneeded */ … … 2862 2372 2863 2373 PUSH_OBJECT(Tcl_NewLongObj(continueLoop)); 2864 TRACE(("foreach_step4 %u => %d lists, iter %d, %s loop\n",2865 opnd, numLists, iterNum,2866 (continueLoop? "continue" : "exit")));2867 2374 } 2868 2375 ADJUST_PC(5); … … 2875 2382 */ 2876 2383 catchStackPtr[++catchTop] = stackTop; 2877 TRACE(("beginCatch4 %u => catchTop=%d, stackTop=%d\n",2878 TclGetUInt4AtPtr(pc+1), catchTop, stackTop));2879 2384 ADJUST_PC(5); 2880 2385 … … 2882 2387 catchTop--; 2883 2388 result = TCL_OK; 2884 TRACE(("endCatch => catchTop=%d\n", catchTop));2885 2389 ADJUST_PC(1); 2886 2390 2887 2391 case INST_PUSH_RESULT: 2888 2392 PUSH_OBJECT(Tcl_GetObjResult(interp)); 2889 TRACE_WITH_OBJ(("pushResult => "), Tcl_GetObjResult(interp));2890 2393 ADJUST_PC(1); 2891 2394 2892 2395 case INST_PUSH_RETURN_CODE: 2893 2396 PUSH_OBJECT(Tcl_NewLongObj(result)); 2894 TRACE(("pushReturnCode => %u\n", result));2895 2397 ADJUST_PC(1); 2896 2398 2897 2399 default: 2898 TRACE(("UNRECOGNIZED INSTRUCTION %u\n", opCode));2899 2400 panic("TclExecuteByteCode: unrecognized opCode %u", opCode); 2900 2401 } /* end of switch on opCode */ … … 2926 2427 rangePtr = TclGetExceptionRangeForPc(pc, /*catchOnly*/ 1, codePtr); 2927 2428 if (rangePtr == NULL) { 2928 TRACE((" ... no enclosing catch, returning %s\n",2929 StringForResultCode(result)));2930 2429 goto abnormalReturn; 2931 2430 } … … 2945 2444 TclDecrRefCount(valuePtr); 2946 2445 } 2947 TRACE((" ... found catch at %d, catchTop=%d, unwound to %d, new pc %u\n",2948 rangePtr->codeOffset, catchTop, catchStackPtr[catchTop],2949 (unsigned int)(rangePtr->catchOffset)));2950 2446 pc = (codePtr->codeStart + rangePtr->catchOffset); 2951 2447 continue; /* restart the execution loop at pc */ … … 2975 2471 #undef STATIC_CATCH_STACK_SIZE 2976 2472 } 2977 2978 2979 /*2980 *----------------------------------------------------------------------2981 *2982 * PrintByteCodeInfo --2983 *2984 * This procedure prints a summary about a bytecode object to stdout.2985 * It is called by TclExecuteByteCode when starting to execute the2986 * bytecode object if tclTraceExec has the value 2 or more.2987 *2988 * Results:2989 * None.2990 *2991 * Side effects:2992 * None.2993 *2994 *----------------------------------------------------------------------2995 */2996 2997 static void2998 PrintByteCodeInfo(codePtr)2999 register ByteCode *codePtr; /* The bytecode whose summary is printed3000 * to stdout. */3001 {3002 Proc *procPtr = codePtr->procPtr;3003 int numCmds = codePtr->numCommands;3004 int numObjs = codePtr->numObjects;3005 int objBytes, i;3006 3007 objBytes = (numObjs * sizeof(Tcl_Obj));3008 for (i = 0; i < numObjs; i++) {3009 Tcl_Obj *litObjPtr = codePtr->objArrayPtr[i];3010 if (litObjPtr->bytes != NULL) {3011 objBytes += litObjPtr->length;3012 }3013 }3014 3015 fprintf(stdout, "\nExecuting ByteCode 0x%x, ref ct %u, epoch %u, interp 0x%x(epoch %u)\n",3016 (unsigned int) codePtr, codePtr->refCount,3017 codePtr->compileEpoch, (unsigned int) codePtr->iPtr,3018 codePtr->iPtr->compileEpoch);3019 3020 fprintf(stdout, " Source: ");3021 TclPrintSource(stdout, codePtr->source, 70);3022 3023 fprintf(stdout, "\n Cmds %d, chars %d, inst %u, objs %u, aux %d, stk depth %u, code/src %.2fn",3024 numCmds, codePtr->numSrcChars, codePtr->numCodeBytes, numObjs,3025 codePtr->numAuxDataItems, codePtr->maxStackDepth,3026 (codePtr->numSrcChars?3027 ((float)codePtr->totalSize)/((float)codePtr->numSrcChars) : 0.0));3028 3029 fprintf(stdout, " Code %zu = %u(header)+%d(inst)+%d(objs)+%u(exc)+%u(aux)+%d(cmd map)\n",3030 codePtr->totalSize, sizeof(ByteCode), codePtr->numCodeBytes,3031 objBytes, (codePtr->numExcRanges * sizeof(ExceptionRange)),3032 (codePtr->numAuxDataItems * sizeof(AuxData)),3033 codePtr->numCmdLocBytes);3034 3035 if (procPtr != NULL) {3036 fprintf(stdout,3037 " Proc 0x%x, ref ct %d, args %d, compiled locals %d\n",3038 (unsigned int) procPtr, procPtr->refCount,3039 procPtr->numArgs, procPtr->numCompiledLocals);3040 }3041 }3042 3043 3044 /*3045 *----------------------------------------------------------------------3046 *3047 * ValidatePcAndStackTop --3048 *3049 * This procedure is called by TclExecuteByteCode when debugging to3050 * verify that the program counter and stack top are valid during3051 * execution.3052 *3053 * Results:3054 * None.3055 *3056 * Side effects:3057 * Prints a message to stderr and panics if either the pc or stack3058 * top are invalid.3059 *3060 *----------------------------------------------------------------------3061 */3062 3063 #ifdef TCL_COMPILE_DEBUG3064 static void3065 ValidatePcAndStackTop(codePtr, pc, stackTop, stackLowerBound, stackUpperBound)3066 register ByteCode *codePtr; /* The bytecode whose summary is printed3067 * to stdout. */3068 unsigned char *pc; /* Points to first byte of a bytecode3069 * instruction. The program counter. */3070 int stackTop; /* Current stack top. Must be between3071 * stackLowerBound and stackUpperBound3072 * (inclusive). */3073 int stackLowerBound; /* Smallest legal value for stackTop. */3074 int stackUpperBound; /* Greatest legal value for stackTop. */3075 {3076 unsigned int relativePc = (unsigned int) (pc - codePtr->codeStart);3077 unsigned int codeStart = (unsigned int) codePtr->codeStart;3078 unsigned int codeEnd = (unsigned int)3079 (codePtr->codeStart + codePtr->numCodeBytes);3080 unsigned char opCode = *pc;3081 3082 if (((unsigned int) pc < codeStart) || ((unsigned int) pc > codeEnd)) {3083 fprintf(stderr, "\nBad instruction pc 0x%x in TclExecuteByteCode\n",3084 (unsigned int) pc);3085 panic("TclExecuteByteCode execution failure: bad pc");3086 }3087 if ((unsigned int) opCode > LAST_INST_OPCODE) {3088 fprintf(stderr, "\nBad opcode %d at pc %u in TclExecuteByteCode\n",3089 (unsigned int) opCode, relativePc);3090 panic("TclExecuteByteCode execution failure: bad opcode");3091 }3092 if ((stackTop < stackLowerBound) || (stackTop > stackUpperBound)) {3093 int numChars;3094 char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars);3095 char *ellipsis = "";3096 3097 fprintf(stderr, "\nBad stack top %d at pc %u in TclExecuteByteCode",3098 stackTop, relativePc);3099 if (cmd != NULL) {3100 if (numChars > 100) {3101 numChars = 100;3102 ellipsis = "...";3103 }3104 fprintf(stderr, "\n executing %.*s%s\n", numChars, cmd,3105 ellipsis);3106 } else {3107 fprintf(stderr, "\n");3108 }3109 panic("TclExecuteByteCode execution failure: bad stack top");3110 }3111 }3112 #endif /* TCL_COMPILE_DEBUG */3113 2473 3114 2474 … … 4271 3631 4272 3632 4273 #ifdef TCL_COMPILE_STATS4274 /*4275 *----------------------------------------------------------------------4276 *4277 * TclLog2 --4278 *4279 * Procedure used while collecting compilation statistics to determine4280 * the log base 2 of an integer.4281 *4282 * Results:4283 * Returns the log base 2 of the operand. If the argument is less4284 * than or equal to zero, a zero is returned.4285 *4286 * Side effects:4287 * None.4288 *4289 *----------------------------------------------------------------------4290 */4291 4292 int4293 TclLog2(value)4294 register int value; /* The integer for which to compute the4295 * log base 2. */4296 {4297 register int n = value;4298 register int result = 0;4299 4300 while (n > 1) {4301 n = n >> 1;4302 result++;4303 }4304 return result;4305 }4306 4307 4308 /*4309 *----------------------------------------------------------------------4310 *4311 * EvalStatsCmd --4312 *4313 * Implements the "evalstats" command that prints instruction execution4314 * counts to stdout.4315 *4316 * Results:4317 * Standard Tcl results.4318 *4319 * Side effects:4320 * None.4321 *4322 *----------------------------------------------------------------------4323 */4324 4325 static int4326 EvalStatsCmd(unused, interp, argc, argv)4327 ClientData unused; /* Unused. */4328 Tcl_Interp *interp; /* The current interpreter. */4329 int argc; /* The number of arguments. */4330 char **argv; /* The argument strings. */4331 {4332 register double total = 0.0;4333 register int i;4334 int maxSizeDecade = 0;4335 double totalHeaderBytes = (tclNumCompilations * sizeof(ByteCode));4336 4337 for (i = 0; i < 256; i++) {4338 if (instructionCount[i] != 0) {4339 total += instructionCount[i];4340 }4341 }4342 4343 for (i = 31; i >= 0; i--) {4344 if ((tclSourceCount[i] > 0) && (tclByteCodeCount[i] > 0)) {4345 maxSizeDecade = i;4346 break;4347 }4348 }4349 4350 fprintf(stdout, "\nNumber of compilations %ld\n",4351 tclNumCompilations);4352 fprintf(stdout, "Number of executions %ld\n",4353 numExecutions);4354 fprintf(stdout, "Average executions/compilation %.0f\n",4355 ((float) numExecutions/tclNumCompilations));4356 4357 fprintf(stdout, "\nInstructions executed %.0f\n",4358 total);4359 fprintf(stdout, "Average instructions/compile %.0f\n",4360 total/tclNumCompilations);4361 fprintf(stdout, "Average instructions/execution %.0f\n",4362 total/numExecutions);4363 4364 fprintf(stdout, "\nTotal source bytes %.6g\n",4365 tclTotalSourceBytes);4366 fprintf(stdout, "Total code bytes %.6g\n",4367 tclTotalCodeBytes);4368 fprintf(stdout, "Average code/compilation %.0f\n",4369 tclTotalCodeBytes/tclNumCompilations);4370 fprintf(stdout, "Average code/source %.2f\n",4371 tclTotalCodeBytes/tclTotalSourceBytes);4372 fprintf(stdout, "Current source bytes %.6g\n",4373 tclCurrentSourceBytes);4374 fprintf(stdout, "Current code bytes %.6g\n",4375 tclCurrentCodeBytes);4376 fprintf(stdout, "Current code/source %.2f\n",4377 tclCurrentCodeBytes/tclCurrentSourceBytes);4378 4379 fprintf(stdout, "\nTotal objects allocated %ld\n",4380 tclObjsAlloced);4381 fprintf(stdout, "Total objects freed %ld\n",4382 tclObjsFreed);4383 fprintf(stdout, "Current objects: %ld\n",4384 (tclObjsAlloced - tclObjsFreed));4385 4386 fprintf(stdout, "\nBreakdown of code byte requirements:\n");4387 fprintf(stdout, " Total bytes Pct of Avg per\n");4388 fprintf(stdout, " all code compile\n");4389 fprintf(stdout, "Total code %12.6g 100%% %8.2f\n",4390 tclTotalCodeBytes, tclTotalCodeBytes/tclNumCompilations);4391 fprintf(stdout, "Header %12.6g %8.2f%% %8.2f\n",4392 totalHeaderBytes,4393 ((totalHeaderBytes * 100.0) / tclTotalCodeBytes),4394 totalHeaderBytes/tclNumCompilations);4395 fprintf(stdout, "Instructions %12.6g %8.2f%% %8.2f\n",4396 tclTotalInstBytes,4397 ((tclTotalInstBytes * 100.0) / tclTotalCodeBytes),4398 tclTotalInstBytes/tclNumCompilations);4399 fprintf(stdout, "Objects %12.6g %8.2f%% %8.2f\n",4400 tclTotalObjBytes,4401 ((tclTotalObjBytes * 100.0) / tclTotalCodeBytes),4402 tclTotalObjBytes/tclNumCompilations);4403 fprintf(stdout, "Exception table %12.6g %8.2f%% %8.2f\n",4404 tclTotalExceptBytes,4405 ((tclTotalExceptBytes * 100.0) / tclTotalCodeBytes),4406 tclTotalExceptBytes/tclNumCompilations);4407 fprintf(stdout, "Auxiliary data %12.6g %8.2f%% %8.2f\n",4408 tclTotalAuxBytes,4409 ((tclTotalAuxBytes * 100.0) / tclTotalCodeBytes),4410 tclTotalAuxBytes/tclNumCompilations);4411 fprintf(stdout, "Command map %12.6g %8.2f%% %8.2f\n",4412 tclTotalCmdMapBytes,4413 ((tclTotalCmdMapBytes * 100.0) / tclTotalCodeBytes),4414 tclTotalCmdMapBytes/tclNumCompilations);4415 4416 fprintf(stdout, "\nSource and ByteCode size distributions:\n");4417 fprintf(stdout, " binary decade source code\n");4418 for (i = 0; i <= maxSizeDecade; i++) {4419 int decadeLow, decadeHigh;4420 4421 if (i == 0) {4422 decadeLow = 0;4423 } else {4424 decadeLow = 1 << i;4425 }4426 decadeHigh = (1 << (i+1)) - 1;4427 fprintf(stdout, " %6d -%6d %6d %6d\n",4428 decadeLow, decadeHigh,4429 tclSourceCount[i], tclByteCodeCount[i]);4430 }4431 4432 fprintf(stdout, "\nInstruction counts:\n");4433 for (i = 0; i < 256; i++) {4434 if (instructionCount[i]) {4435 fprintf(stdout, "%20s %8d %6.2f%%\n",4436 opName[i], instructionCount[i],4437 (instructionCount[i] * 100.0)/total);4438 }4439 }4440 4441 #ifdef TCL_MEM_DEBUG4442 fprintf(stdout, "\nHeap Statistics:\n");4443 TclDumpMemoryInfo(stdout);4444 #endif /* TCL_MEM_DEBUG */4445 4446 return TCL_OK;4447 }4448 #endif /* TCL_COMPILE_STATS */4449 4450 4451 3633 /* 4452 3634 *---------------------------------------------------------------------- … … 4758 3940 panic("UpdateStringOfCmdName should never be invoked"); 4759 3941 } 4760 4761 4762 #ifdef TCL_COMPILE_DEBUG4763 /*4764 *----------------------------------------------------------------------4765 *4766 * StringForResultCode --4767 *4768 * Procedure that returns a human-readable string representing a4769 * Tcl result code such as TCL_ERROR.4770 *4771 * Results:4772 * If the result code is one of the standard Tcl return codes, the4773 * result is a string representing that code such as "TCL_ERROR".4774 * Otherwise, the result string is that code formatted as a4775 * sequence of decimal digit characters. Note that the resulting4776 * string must not be modified by the caller.4777 *4778 * Side effects:4779 * None.4780 *4781 *----------------------------------------------------------------------4782 */4783 4784 static char *4785 StringForResultCode(result)4786 int result; /* The Tcl result code for which to4787 * generate a string. */4788 {4789 static char buf[20];4790 4791 if ((result >= TCL_OK) && (result <= TCL_CONTINUE)) {4792 return resultStrings[result];4793 }4794 TclFormatInt(buf, result);4795 return buf;4796 }4797 #endif /* TCL_COMPILE_DEBUG */
Note:
See TracChangeset
for help on using the changeset viewer.