From 208d3bc095fdd08edae1515322e61c85561a572a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 27 May 2024 11:04:53 +0000 Subject: Eliminate TclPrintByteCodeObj()'s 'interp' argument, which is not used. --- generic/tclAssembly.c | 7 +---- generic/tclCompile.c | 34 ++++++++------------- generic/tclCompile.h | 5 ++-- generic/tclDisassemble.c | 78 +++++++++++++++++++++++++----------------------- generic/tclExecute.c | 29 ++++++++---------- 5 files changed, 68 insertions(+), 85 deletions(-) diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index 61eb319..e596a87 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -923,12 +923,7 @@ CompileAssembleObj( * Report on what the assembler did. */ -#ifdef TCL_COMPILE_DEBUG - if (tclTraceCompile >= 2) { - TclPrintByteCodeObj(interp, objPtr); - fflush(stdout); - } -#endif /* TCL_COMPILE_DEBUG */ + TclDebugPrintByteCodeObj(objPtr); return codePtr; } diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 3e77231..1adb4d7 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -415,17 +415,17 @@ InstructionDesc const tclInstructionTable[] = { * stktop; op1 is 1 for errors on problems, 0 otherwise */ {"dictExpand", 1, -1, 0, {OPERAND_NONE}}, - /* Probe into a dict and extract it (or a subdict of it) into - * variables with matched names. Produces list of keys bound as - * result. Part of [dict with]. + /* Probe into a dict and extract it (or a subdict of it) into + * variables with matched names. Produces list of keys bound as + * result. Part of [dict with]. * Stack: ... dict path => ... keyList */ {"dictRecombineStk", 1, -3, 0, {OPERAND_NONE}}, - /* Map variable contents back into a dictionary in a variable. Part of - * [dict with]. + /* Map variable contents back into a dictionary in a variable. Part of + * [dict with]. * Stack: ... dictVarName path keyList => ... */ {"dictRecombineImm", 5, -2, 1, {OPERAND_LVT4}}, - /* Map variable contents back into a dictionary in the local variable - * indicated by the LVT index. Part of [dict with]. + /* Map variable contents back into a dictionary in the local variable + * indicated by the LVT index. Part of [dict with]. * Stack: ... path keyList => ... */ {"dictExists", 5, INT_MIN, 1, {OPERAND_UINT4}}, /* The top op4 words (min 1) are a key path into the dictionary just @@ -655,7 +655,7 @@ InstructionDesc const tclInstructionTable[] = { * Stack: ... varName list => ... listVarContents */ {"clockRead", 2, +1, 1, {OPERAND_UINT1}}, - /* Read clock out to the stack. Operand is which clock to read + /* Read clock out to the stack. Operand is which clock to read * 0=clicks, 1=microseconds, 2=milliseconds, 3=seconds. * Stack: ... => ... time */ @@ -896,12 +896,7 @@ TclSetByteCodeFromAny( if (result == TCL_OK) { (void) TclInitByteCodeObj(objPtr, &tclByteCodeType, &compEnv); -#ifdef TCL_COMPILE_DEBUG - if (tclTraceCompile >= 2) { - TclPrintByteCodeObj(interp, objPtr); - fflush(stdout); - } -#endif /* TCL_COMPILE_DEBUG */ + TclDebugPrintByteCodeObj(objPtr); } TclFreeCompileEnv(&compEnv); @@ -1361,12 +1356,7 @@ CompileSubstObj( codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr; codePtr->localCachePtr->refCount++; } -#ifdef TCL_COMPILE_DEBUG - if (tclTraceCompile >= 2) { - TclPrintByteCodeObj(interp, objPtr); - fflush(stdout); - } -#endif /* TCL_COMPILE_DEBUG */ + TclDebugPrintByteCodeObj(objPtr); } return codePtr; } @@ -2489,7 +2479,7 @@ TclCompileTokens( if (numCL >= maxNumCL) { maxNumCL *= 2; clPosition = (int *)ckrealloc(clPosition, - maxNumCL * sizeof(int)); + maxNumCL * sizeof(int)); } clPosition[numCL] = clPos; numCL ++; @@ -2799,7 +2789,7 @@ PreventCycle( * * NOTE: [Bugs 3392070, 3389764] We make a copy based completely * on the string value, and do not call Tcl_DuplicateObj() so we - * can be sure we do not have any lingering cycles hiding in + * can be sure we do not have any lingering cycles hiding in * the internalrep. */ int numBytes; diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 16bc972..d577b6a 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -1175,8 +1175,9 @@ MODULE_SCOPE Tcl_Size TclLocalScalarFromToken(Tcl_Token *tokenPtr, CompileEnv *envPtr); MODULE_SCOPE void TclOptimizeBytecode(void *envPtr); #ifdef TCL_COMPILE_DEBUG -MODULE_SCOPE void TclPrintByteCodeObj(Tcl_Interp *interp, - Tcl_Obj *objPtr); +MODULE_SCOPE void TclDebugPrintByteCodeObj(Tcl_Obj *objPtr); +#else +#define TclDebugPrintByteCodeObj(objPtr) (void)(objPtr) #endif MODULE_SCOPE int TclPrintInstruction(ByteCode *codePtr, const unsigned char *pc); diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c index 304fa30..b6cd9b5 100644 --- a/generic/tclDisassemble.c +++ b/generic/tclDisassemble.c @@ -114,7 +114,7 @@ GetLocationInformation( /* *---------------------------------------------------------------------- * - * TclPrintByteCodeObj -- + * TclDebugPrintByteCodeObj -- * * This procedure prints ("disassembles") the instructions of a bytecode * object to stdout. @@ -129,14 +129,16 @@ GetLocationInformation( */ void -TclPrintByteCodeObj( - TCL_UNUSED(Tcl_Interp *), /* Stuck with this in internal stubs */ +TclDebugPrintByteCodeObj( Tcl_Obj *objPtr) /* The bytecode object to disassemble. */ { - Tcl_Obj *bufPtr = DisassembleByteCodeObj(objPtr); + if (tclTraceCompile >= 2) { + Tcl_Obj *bufPtr = DisassembleByteCodeObj(objPtr); - fprintf(stdout, "\n%s", TclGetString(bufPtr)); - Tcl_DecrRefCount(bufPtr); + fprintf(stdout, "\n%s", TclGetString(bufPtr)); + Tcl_DecrRefCount(bufPtr); + fflush(stdout); + } } /* @@ -703,8 +705,8 @@ TclGetInnerContext( case INST_TRY_CVT_TO_NUMERIC: case INST_EXPAND_STKTOP: case INST_EXPR_STK: - objc = 1; - break; + objc = 1; + break; case INST_LIST_IN: case INST_LIST_NOT_IN: /* Basic list containment operators. */ @@ -731,22 +733,22 @@ TclGetInnerContext( case INST_SUB: case INST_DIV: case INST_MULT: - objc = 2; - break; + objc = 2; + break; case INST_RETURN_STK: - /* early pop. TODO: dig out opt dict too :/ */ - objc = 1; - break; + /* early pop. TODO: dig out opt dict too :/ */ + objc = 1; + break; case INST_SYNTAX: case INST_RETURN_IMM: - objc = 2; - break; + objc = 2; + break; case INST_INVOKE_STK4: objc = TclGetUInt4AtPtr(pc+1); - break; + break; case INST_INVOKE_STK1: objc = TclGetUInt1AtPtr(pc+1); @@ -755,37 +757,37 @@ TclGetInnerContext( result = iPtr->innerContext; if (Tcl_IsShared(result)) { - Tcl_DecrRefCount(result); - iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL); - Tcl_IncrRefCount(result); + Tcl_DecrRefCount(result); + iPtr->innerContext = result = Tcl_NewListObj(objc + 1, NULL); + Tcl_IncrRefCount(result); } else { - Tcl_Size len; + Tcl_Size len; - /* - * Reset while keeping the list internalrep as much as possible. - */ + /* + * Reset while keeping the list internalrep as much as possible. + */ TclListObjLength(interp, result, &len); - Tcl_ListObjReplace(interp, result, 0, len, 0, NULL); + Tcl_ListObjReplace(interp, result, 0, len, 0, NULL); } Tcl_ListObjAppendElement(NULL, result, TclNewInstNameObj(*pc)); for (; objc>0 ; objc--) { - Tcl_Obj *objPtr; + Tcl_Obj *objPtr; - objPtr = tosPtr[1 - objc]; - if (!objPtr) { - Tcl_Panic("InnerContext: bad tos -- appending null object"); - } - if ((objPtr->refCount<=0) + objPtr = tosPtr[1 - objc]; + if (!objPtr) { + Tcl_Panic("InnerContext: bad tos -- appending null object"); + } + if ((objPtr->refCount<=0) #ifdef TCL_MEM_DEBUG - || (objPtr->refCount==0x61616161) + || (objPtr->refCount==0x61616161) #endif - ) { - Tcl_Panic("InnerContext: bad tos -- appending freed object %p", - objPtr); - } - Tcl_ListObjAppendElement(NULL, result, objPtr); + ) { + Tcl_Panic("InnerContext: bad tos -- appending freed object %p", + objPtr); + } + Tcl_ListObjAppendElement(NULL, result, objPtr); } return result; @@ -836,7 +838,7 @@ UpdateStringOfInstName( if (inst > LAST_INST_OPCODE) { dst = Tcl_InitStringRep(objPtr, NULL, TCL_INTEGER_SPACE + 5); TclOOM(dst, TCL_INTEGER_SPACE + 5); - snprintf(dst, TCL_INTEGER_SPACE + 5, "inst_%" TCL_Z_MODIFIER "u", inst); + snprintf(dst, TCL_INTEGER_SPACE + 5, "inst_%" TCL_Z_MODIFIER "u", inst); (void) Tcl_InitStringRep(objPtr, NULL, strlen(dst)); } else { const char *s = tclInstructionTable[inst].name; @@ -1229,7 +1231,7 @@ DisassembleByteCodeAsDicts( TclDictPut(NULL, description, "commands", commands); TclDictPut(NULL, description, "script", Tcl_NewStringObj(codePtr->source, codePtr->numSrcBytes)); - TclDictPut(NULL, description, "namespace", + TclDictPut(NULL, description, "namespace", Tcl_NewStringObj(codePtr->nsPtr->fullName, -1)); TclDictPut(NULL, description, "stackdepth", Tcl_NewWideIntObj(codePtr->maxStackDepth)); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 380a0a3..cdecc08 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1520,12 +1520,7 @@ CompileExprObj( codePtr->localCachePtr = iPtr->varFramePtr->localCachePtr; codePtr->localCachePtr->refCount++; } -#ifdef TCL_COMPILE_DEBUG - if (tclTraceCompile == 2) { - TclPrintByteCodeObj(interp, objPtr); - fflush(stdout); - } -#endif /* TCL_COMPILE_DEBUG */ + TclDebugPrintByteCodeObj(objPtr); } return codePtr; } @@ -2082,8 +2077,8 @@ TEBCresume( Tcl_Obj **tosPtr; /* Cached pointer to top of evaluation * stack. */ const unsigned char *pc = (const unsigned char *)data[1]; - /* The current program counter. */ - unsigned char inst; /* The currently running instruction */ + /* The current program counter. */ + unsigned char inst; /* The currently running instruction */ /* * Transfer variables - needed only between opcodes, but not while @@ -2092,7 +2087,7 @@ TEBCresume( int cleanup = PTR2INT(data[2]); Tcl_Obj *objResultPtr; - int checkInterp = 0; /* Indicates when a check of interp readyness + int checkInterp = 0; /* Indicates when a check of interp readyness * is necessary. Set by CACHE_STACK_INFO() */ /* @@ -2146,7 +2141,7 @@ TEBCresume( goto cleanup0; } else { - /* resume from invocation */ + /* resume from invocation */ CACHE_STACK_INFO(); NRE_ASSERT(iPtr->cmdFramePtr == bcFramePtr); @@ -2446,7 +2441,7 @@ TEBCresume( } else { fprintf(stdout, "%" TCL_SIZE_MODIFIER "d: (%" TCL_T_MODIFIER "d) yielding value \"%.30s\"\n", iPtr->numLevels, (pc - codePtr->codeStart), - Tcl_GetString(OBJ_AT_TOS)); + TclGetString(OBJ_AT_TOS)); } fflush(stdout); } @@ -6687,7 +6682,7 @@ TEBCresume( numVars = varListPtr->numVars; listVarPtr = LOCAL(listTmpIndex); - /* Do not use TclListObjCopy here - shimmers arithseries to list */ + /* Do not use TclListObjCopy here - shimmers arithseries to list */ listPtr = Tcl_DuplicateObj(listVarPtr->value.objPtr); TclListObjGetElements(interp, listPtr, &listLen, &elements); @@ -9440,21 +9435,21 @@ TclGetSourceFromFrame( Tcl_Obj *const objv[]) { if (cfPtr == NULL) { - return Tcl_NewListObj(objc, objv); + return Tcl_NewListObj(objc, objv); } if (cfPtr->cmdObj == NULL) { - if (cfPtr->cmd == NULL) { + if (cfPtr->cmd == NULL) { ByteCode *codePtr = (ByteCode *) cfPtr->data.tebc.codePtr; - cfPtr->cmd = GetSrcInfoForPc((unsigned char *) + cfPtr->cmd = GetSrcInfoForPc((unsigned char *) cfPtr->data.tebc.pc, codePtr, &cfPtr->len, NULL, NULL); - } + } if (cfPtr->cmd) { cfPtr->cmdObj = Tcl_NewStringObj(cfPtr->cmd, cfPtr->len); } else { cfPtr->cmdObj = Tcl_NewListObj(objc, objv); } - Tcl_IncrRefCount(cfPtr->cmdObj); + Tcl_IncrRefCount(cfPtr->cmdObj); } return cfPtr->cmdObj; } -- cgit v0.12