Itcl - the [incr Tcl] extension

Check-in [befa6a2d70]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:amend to [734b2ff2e3]: fix release, ckfree -> ItclCkfree (without in-between temp automation in tcl-core)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sebres-memopt-perf-branch
Files: files | file ages | folders
SHA3-256: befa6a2d709f319ea4ef6bb90b0afbb37602ef42c6515ae09848756a74b99b3c
User & Date: sebres 2019-02-07 23:39:10
Context
2019-02-08
18:50
merge trunk (all tests now available in dev-environment) check-in: bb070ae8b6 user: sebres tags: sebres-memopt-perf-branch
2019-02-07
23:39
amend to [734b2ff2e3]: fix release, ckfree -> ItclCkfree (without in-between temp automation in tcl-core) check-in: befa6a2d70 user: sebres tags: sebres-memopt-perf-branch
21:37
fixes huge performance regression (introduced in [c7e729d15408ed4e]), replace internal mechanism of preservation facilities (Itcl_PreserveData/Itcl_ReleaseData) from Tcl_Preserve (which is basically inappropriate here) to own memory facilities without this major overhead. check-in: 734b2ff2e3 user: sebres tags: sebres-memopt-perf-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/itclClass.c.

1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
....
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
....
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
....
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
    Tcl_DecrRefCount(iclsPtr->namePtr);
    Tcl_DecrRefCount(iclsPtr->fullNamePtr);

    if (iclsPtr->resolvePtr != NULL) {
        ckfree((char *)iclsPtr->resolvePtr->clientData);
        ckfree((char *)iclsPtr->resolvePtr);
    }
    ckfree((char*)iclsPtr);
}

 
/*
 * ------------------------------------------------------------------------
 *  Itcl_IsClassNamespace()
 *
................................................................................
    Tcl_DecrRefCount(ivPtr->fullNamePtr);
    if (ivPtr->init) {
        Tcl_DecrRefCount(ivPtr->init);
    }
    if (ivPtr->arrayInitPtr) {
        Tcl_DecrRefCount(ivPtr->arrayInitPtr);
    }
    ckfree((char*)ivPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  ItclDeleteOption()
 *
 *  Destroys a option definition created by Itcl_CreateOption(),
................................................................................
    if (ioptPtr->validateMethodPtr != NULL) {
        Tcl_DecrRefCount(ioptPtr->validateMethodPtr);
    }
    if (ioptPtr->validateMethodVarPtr != NULL) {
        Tcl_DecrRefCount(ioptPtr->validateMethodVarPtr);
    }
    Itcl_ReleaseData(ioptPtr->idoPtr);
    ckfree((char*)ioptPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  ItclDeleteFunction()
 *
 *  fre data associated with a function
................................................................................
    }
    FOREACH_HASH_VALUE(objPtr, &idoPtr->exceptions) {
	if (objPtr != NULL) {
            Tcl_DecrRefCount(objPtr);
        }
    }
    Tcl_DeleteHashTable(&idoPtr->exceptions);
    ckfree((char *)idoPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  ItclDeleteDelegatedFunction()
 *
 *  free data associated with a delegated function






|







 







|







 







|







 







|







1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
....
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
....
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
....
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
    Tcl_DecrRefCount(iclsPtr->namePtr);
    Tcl_DecrRefCount(iclsPtr->fullNamePtr);

    if (iclsPtr->resolvePtr != NULL) {
        ckfree((char *)iclsPtr->resolvePtr->clientData);
        ckfree((char *)iclsPtr->resolvePtr);
    }
    ItclCkfree(iclsPtr);
}

 
/*
 * ------------------------------------------------------------------------
 *  Itcl_IsClassNamespace()
 *
................................................................................
    Tcl_DecrRefCount(ivPtr->fullNamePtr);
    if (ivPtr->init) {
        Tcl_DecrRefCount(ivPtr->init);
    }
    if (ivPtr->arrayInitPtr) {
        Tcl_DecrRefCount(ivPtr->arrayInitPtr);
    }
    ItclCkfree(ivPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  ItclDeleteOption()
 *
 *  Destroys a option definition created by Itcl_CreateOption(),
................................................................................
    if (ioptPtr->validateMethodPtr != NULL) {
        Tcl_DecrRefCount(ioptPtr->validateMethodPtr);
    }
    if (ioptPtr->validateMethodVarPtr != NULL) {
        Tcl_DecrRefCount(ioptPtr->validateMethodVarPtr);
    }
    Itcl_ReleaseData(ioptPtr->idoPtr);
    ItclCkfree(ioptPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  ItclDeleteFunction()
 *
 *  fre data associated with a function
................................................................................
    }
    FOREACH_HASH_VALUE(objPtr, &idoPtr->exceptions) {
	if (objPtr != NULL) {
            Tcl_DecrRefCount(objPtr);
        }
    }
    Tcl_DeleteHashTable(&idoPtr->exceptions);
    ItclCkfree(idoPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  ItclDeleteDelegatedFunction()
 *
 *  free data associated with a delegated function

Changes to generic/itclInt.h.

657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
typedef struct ItclPresMemoryPrefix {
    Tcl_FreeProc *freeProc;	/* free function called by last Itcl_ReleaseData */
    int refCount;		/* refernce (resp preserving) counter */
} ItclPresMemoryPrefix;

#ifndef ITCL_PRESERVE_DEBUG
MODULE_SCOPE void *	ItclCkalloc(size_t size, Tcl_FreeProc *freeProc);
MODULE_SCOPE void	ItclFree(void *ptr);
#else
#   define ItclCkalloc	ckalloc
#   define ItclFree	ckfree
#endif
/*
 * The macro below is used to modify a "char" value (e.g. by casting
 * it to an unsigned character) so that it can be used safely with
 * macros such as isspace.
 */







|


|







657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
typedef struct ItclPresMemoryPrefix {
    Tcl_FreeProc *freeProc;	/* free function called by last Itcl_ReleaseData */
    int refCount;		/* refernce (resp preserving) counter */
} ItclPresMemoryPrefix;

#ifndef ITCL_PRESERVE_DEBUG
MODULE_SCOPE void *	ItclCkalloc(size_t size, Tcl_FreeProc *freeProc);
MODULE_SCOPE void	ItclCkfree(void *ptr);
#else
#   define ItclCkalloc	ckalloc
#   define ItclCkfree	ckfree
#endif
/*
 * The macro below is used to modify a "char" value (e.g. by casting
 * it to an unsigned character) so that it can be used safely with
 * macros such as isspace.
 */

Changes to generic/itclParse.c.

2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
    }
    Tcl_DeleteHashTable(&infoPtr->objects);

    Itcl_DeleteStack(&infoPtr->clsStack);
/* FIXME !!!
 free class_meta_type and object_meta_type
*/
    ckfree((char*)infoPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  Itcl_ClassFilterCmd()
 *
 *






|







2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
    }
    Tcl_DeleteHashTable(&infoPtr->objects);

    Itcl_DeleteStack(&infoPtr->clsStack);
/* FIXME !!!
 free class_meta_type and object_meta_type
*/
    ItclCkfree(infoPtr);
}
 
/*
 * ------------------------------------------------------------------------
 *  Itcl_ClassFilterCmd()
 *
 *

Changes to generic/itclUtil.c.

823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
 *	Release memory blocks (release preserved block).
 *
 * Results:
 *	None.
 *
 * ------------------------------------------------------------------------
 */
void ItclFree(void *ptr) {
    if (ptr == NULL) {
	return;
    }
    /* Itcl memory block to ckalloc block */
    ItclPresMemoryPrefix *blk = ((ItclPresMemoryPrefix *)ptr)-1;

    assert(blk->refCount <= 0); /* it should be not preserved */






|







823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
 *	Release memory blocks (release preserved block).
 *
 * Results:
 *	None.
 *
 * ------------------------------------------------------------------------
 */
void ItclCkfree(void *ptr) {
    if (ptr == NULL) {
	return;
    }
    /* Itcl memory block to ckalloc block */
    ItclPresMemoryPrefix *blk = ((ItclPresMemoryPrefix *)ptr)-1;

    assert(blk->refCount <= 0); /* it should be not preserved */