VirtualBox

Ignore:
Timestamp:
Nov 6, 2023 1:38:17 PM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Remove code for unused platforms from nsprpub, bugref:10545

Location:
trunk/src/libs/xpcom18a4/nsprpub/lib/ds
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.c

    r58734 r101869  
    5353static PLArena *arena_freelist;
    5454
    55 #ifdef PL_ARENAMETER
    56 static PLArenaStats *arena_stats_list;
    57 
    58 #define COUNT(pool,what)  (pool)->stats.what++
    59 #else
    60 #define COUNT(pool,what)  /* nothing */
    61 #endif
    62 
     55#define COUNT(pool,what)
    6356#define PL_ARENA_DEFAULT_ALIGN  sizeof(double)
    6457
     
    108101    PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
    109102{
    110 #if defined(XP_MAC)
    111 #pragma unused (name)
    112 #endif
    113 
    114103    if (align == 0)
    115104        align = PL_ARENA_DEFAULT_ALIGN;
     
    122111        (PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);
    123112    pool->current = &pool->first;
    124     pool->arenasize = size;                                 
    125 #ifdef PL_ARENAMETER
    126     memset(&pool->stats, 0, sizeof pool->stats);
    127     pool->stats.name = strdup(name);
    128     pool->stats.next = arena_stats_list;
    129     arena_stats_list = &pool->stats;
    130 #endif
     113    pool->arenasize = size;
    131114}
    132115
     
    322305{
    323306    FreeArenaList(pool, &pool->first, PR_TRUE);
    324 #ifdef PL_ARENAMETER
    325     {
    326         PLArenaStats *stats, **statsp;
    327 
    328         if (pool->stats.name)
    329             PR_DELETE(pool->stats.name);
    330         for (statsp = &arena_stats_list; (stats = *statsp) != 0;
    331              statsp = &stats->next) {
    332             if (stats == &pool->stats) {
    333                 *statsp = stats->next;
    334                 return;
    335             }
    336         }
    337     }
    338 #endif
    339307}
    340308
    341309PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool *ap)
    342310{
    343 #if XP_MAC
    344 #pragma unused (ap)
    345 #if 0
    346     PRArena *curr = &(ap->first);
    347     while (curr) {
    348         reallocSmaller(curr, curr->avail - (uprword_t)curr);
    349         curr->limit = curr->avail;
    350         curr = curr->next;
    351     }
    352 #endif
    353 #endif
    354311}
    355312
     
    370327}
    371328
    372 #ifdef PL_ARENAMETER
    373 PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb)
    374 {
    375     pool->stats.nallocs++;
    376     pool->stats.nbytes += nb;
    377     if (nb > pool->stats.maxalloc)
    378         pool->stats.maxalloc = nb;
    379     pool->stats.variance += nb * nb;
    380 }
    381 
    382 PR_IMPLEMENT(void) PL_ArenaCountInplaceGrowth(
    383     PLArenaPool *pool, PRUint32 size, PRUint32 incr)
    384 {
    385     pool->stats.ninplace++;
    386 }
    387 
    388 PR_IMPLEMENT(void) PL_ArenaCountGrowth(
    389     PLArenaPool *pool, PRUint32 size, PRUint32 incr)
    390 {
    391     pool->stats.ngrows++;
    392     pool->stats.nbytes += incr;
    393     pool->stats.variance -= size * size;
    394     size += incr;
    395     if (size > pool->stats.maxalloc)
    396         pool->stats.maxalloc = size;
    397     pool->stats.variance += size * size;
    398 }
    399 
    400 PR_IMPLEMENT(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark)
    401 {
    402     pool->stats.nreleases++;
    403 }
    404 
    405 PR_IMPLEMENT(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark)
    406 {
    407     pool->stats.nfastrels++;
    408 }
    409 
    410 #include <math.h>
    411 #include <stdio.h>
    412 
    413 PR_IMPLEMENT(void) PL_DumpArenaStats(FILE *fp)
    414 {
    415     PLArenaStats *stats;
    416     double mean, variance;
    417 
    418     for (stats = arena_stats_list; stats; stats = stats->next) {
    419         if (stats->nallocs != 0) {
    420             mean = (double)stats->nbytes / stats->nallocs;
    421             variance = fabs(stats->variance / stats->nallocs - mean * mean);
    422         } else {
    423             mean = variance = 0;
    424         }
    425 
    426         fprintf(fp, "\n%s allocation statistics:\n", stats->name);
    427         fprintf(fp, "              number of arenas: %u\n", stats->narenas);
    428         fprintf(fp, "         number of allocations: %u\n", stats->nallocs);
    429         fprintf(fp, " number of free arena reclaims: %u\n", stats->nreclaims);
    430         fprintf(fp, "        number of malloc calls: %u\n", stats->nmallocs);
    431         fprintf(fp, "       number of deallocations: %u\n", stats->ndeallocs);
    432         fprintf(fp, "  number of allocation growths: %u\n", stats->ngrows);
    433         fprintf(fp, "    number of in-place growths: %u\n", stats->ninplace);
    434         fprintf(fp, "number of released allocations: %u\n", stats->nreleases);
    435         fprintf(fp, "       number of fast releases: %u\n", stats->nfastrels);
    436         fprintf(fp, "         total bytes allocated: %u\n", stats->nbytes);
    437         fprintf(fp, "          mean allocation size: %g\n", mean);
    438         fprintf(fp, "            standard deviation: %g\n", sqrt(variance));
    439         fprintf(fp, "       maximum allocation size: %u\n", stats->maxalloc);
    440     }
    441 }
    442 #endif /* PL_ARENAMETER */
  • trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.h

    r58734 r101869  
    6060};
    6161
    62 #ifdef PL_ARENAMETER
    63 typedef struct PLArenaStats PLArenaStats;
    64 
    65 struct PLArenaStats {
    66     PLArenaStats  *next;        /* next in arenaStats list */
    67     char          *name;        /* name for debugging */
    68     PRUint32      narenas;      /* number of arenas in pool */
    69     PRUint32      nallocs;      /* number of PL_ARENA_ALLOCATE() calls */
    70     PRUint32      nreclaims;    /* number of reclaims from freeArenas */
    71     PRUint32      nmallocs;     /* number of malloc() calls */
    72     PRUint32      ndeallocs;    /* number of lifetime deallocations */
    73     PRUint32      ngrows;       /* number of PL_ARENA_GROW() calls */
    74     PRUint32      ninplace;     /* number of in-place growths */
    75     PRUint32      nreleases;    /* number of PL_ARENA_RELEASE() calls */
    76     PRUint32      nfastrels;    /* number of "fast path" releases */
    77     PRUint32      nbytes;       /* total bytes allocated */
    78     PRUint32      maxalloc;     /* maximum allocation size in bytes */
    79     PRFloat64     variance;     /* size variance accumulator */
    80 };
    81 #endif
    82 
    8362struct PLArenaPool {
    8463    PLArena     first;          /* first arena in pool list */
     
    8665    PRUint32    arenasize;      /* net exact size of a new arena */
    8766    PRUword     mask;           /* alignment mask (power-of-2 - 1) */
    88 #ifdef PL_ARENAMETER
    89     PLArenaStats stats;
    90 #endif
    9167};
    9268
     
    171147    PR_END_MACRO
    172148
    173 #ifdef PL_ARENAMETER
    174 #define PL_COUNT_ARENA(pool,op) ((pool)->stats.narenas op)
    175 #else
    176149#define PL_COUNT_ARENA(pool,op)
    177 #endif
    178150
    179151#define PL_ARENA_DESTROY(pool, a, pnext) \
     
    187159    PR_END_MACRO
    188160
    189 #ifdef PL_ARENAMETER
    190 
    191 #include <stdio.h>
    192 
    193 PR_EXTERN(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb);
    194 
    195 PR_EXTERN(void) PL_ArenaCountInplaceGrowth(
    196     PLArenaPool *pool, PRUint32 size, PRUint32 incr);
    197 
    198 PR_EXTERN(void) PL_ArenaCountGrowth(
    199     PLArenaPool *pool, PRUint32 size, PRUint32 incr);
    200 
    201 PR_EXTERN(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark);
    202 
    203 PR_EXTERN(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark);
    204 
    205 PR_EXTERN(void) PL_DumpArenaStats(FILE *fp);
    206 
    207 #else  /* !PL_ARENAMETER */
    208 
    209161#define PL_ArenaCountAllocation(ap, nb)                 /* nothing */
    210162#define PL_ArenaCountInplaceGrowth(ap, size, incr)      /* nothing */
     
    213165#define PL_ArenaCountRetract(ap, mark)                  /* nothing */
    214166
    215 #endif /* !PL_ARENAMETER */
    216 
    217167PR_END_EXTERN_C
    218168
  • trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarenas.h

    r11551 r101869  
    5656
    5757/*
    58 ** Allocate an arena pool as specified by the parameters.
    59 **
    60 ** This is equivelant to allocating the space yourself and then
    61 ** calling PL_InitArenaPool().
    62 **
    63 ** This function may fail (and return a NULL) for a variety of
    64 ** reasons. The reason for a particular failure can be discovered
    65 ** by calling PR_GetError().
    66 */
    67 #if 0  /* Not implemented */
    68 PR_EXTERN(PLArenaPool*) PL_AllocArenaPool(
    69     const char *name, PRUint32 size, PRUint32 align);
    70 #endif
    71 
    72 /*
    73 ** Destroy an arena pool previously allocated by PL_AllocArenaPool().
    74 **
    75 ** This function may fail if the arena is not empty and the caller
    76 ** wishes to check for empty upon descruction.
    77 */
    78 #if 0  /* Not implemented */
    79 PR_EXTERN(PRStatus) PL_DestroyArenaPool(PLArenaPool *pool, PRBool checkEmpty);
    80 #endif
    81 
    82 
    83 /*
    8458** Initialize an arena pool with the given name for debugging and metering,
    8559** with a minimum size per arena of size bytes.
  • trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plhash.c

    r1 r101869  
    6666DefaultAllocTable(void *pool, PRSize size)
    6767{
    68 #if defined(XP_MAC)
    69 #pragma unused (pool)
    70 #endif
    71 
    7268    return PR_MALLOC(size);
    7369}
     
    7672DefaultFreeTable(void *pool, void *item)
    7773{
    78 #if defined(XP_MAC)
    79 #pragma unused (pool)
    80 #endif
    81 
    8274    PR_Free(item);
    8375}
     
    8678DefaultAllocEntry(void *pool, const void *key)
    8779{
    88 #if defined(XP_MAC)
    89 #pragma unused (pool,key)
    90 #endif
    91 
    9280    return PR_NEW(PLHashEntry);
    9381}
     
    9684DefaultFreeEntry(void *pool, PLHashEntry *he, PRUintn flag)
    9785{
    98 #if defined(XP_MAC)
    99 #pragma unused (pool)
    100 #endif
    101 
    10286    if (flag == HT_FREE_ENTRY)
    10387        PR_Free(he);
     
    133117    ht->shift = PL_HASH_BITS - n;
    134118    n = 1 << n;
    135 #if defined(WIN16)
    136     if (n > 16000) {
    137         (*allocOps->freeTable)(allocPriv, ht);
    138         return 0;
    139     }
    140 #endif  /* WIN16 */
     119
    141120    nb = n * sizeof(PLHashEntry *);
    142121    ht->buckets = (PLHashEntry**)((*allocOps->allocTable)(allocPriv, nb));
     
    191170    PLHashNumber h;
    192171
    193 #ifdef HASHMETER
    194     ht->nlookups++;
    195 #endif
    196172    h = keyHash * GOLDEN_RATIO;
    197173    h >>= ht->shift;
     
    208184        }
    209185        hep = &he->next;
    210 #ifdef HASHMETER
    211         ht->nsteps++;
    212 #endif
    213186    }
    214187    return hep;
     
    225198    PLHashNumber h;
    226199
    227 #ifdef HASHMETER
    228     ht->nlookups++;
    229 #endif
    230200    h = keyHash * GOLDEN_RATIO;
    231201    h >>= ht->shift;
     
    236206        }
    237207        hep = &he->next;
    238 #ifdef HASHMETER
    239         ht->nsteps++;
    240 #endif
    241208    }
    242209    return hep;
     
    255222    if (ht->nentries >= OVERLOADED(n)) {
    256223        oldbuckets = ht->buckets;
    257 #if defined(WIN16)
    258         if (2 * n > 16000)
    259             return 0;
    260 #endif  /* WIN16 */
     224
    261225        nb = 2 * n * sizeof(PLHashEntry *);
    262226        ht->buckets = (PLHashEntry**)
     
    267231        }
    268232        memset(ht->buckets, 0, nb);
    269 #ifdef HASHMETER
    270         ht->ngrows++;
    271 #endif
    272233        ht->shift--;
    273234
     
    345306        }
    346307        memset(ht->buckets, 0, nb);
    347 #ifdef HASHMETER
    348         ht->nshrinks++;
    349 #endif
    350308        ht->shift++;
    351309
     
    455413}
    456414
    457 #ifdef HASHMETER
    458 #include <math.h>
    459 #include <stdio.h>
    460 
    461 PR_IMPLEMENT(void)
    462 PL_HashTableDumpMeter(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
    463 {
    464     double mean, variance;
    465     PRUint32 nchains, nbuckets;
    466     PRUint32 i, n, maxChain, maxChainLen;
    467     PLHashEntry *he;
    468 
    469     variance = 0;
    470     nchains = 0;
    471     maxChainLen = 0;
    472     nbuckets = NBUCKETS(ht);
    473     for (i = 0; i < nbuckets; i++) {
    474         he = ht->buckets[i];
    475         if (!he)
    476             continue;
    477         nchains++;
    478         for (n = 0; he; he = he->next)
    479             n++;
    480         variance += n * n;
    481         if (n > maxChainLen) {
    482             maxChainLen = n;
    483             maxChain = i;
    484         }
    485     }
    486     mean = (double)ht->nentries / nchains;
    487     variance = fabs(variance / nchains - mean * mean);
    488 
    489     fprintf(fp, "\nHash table statistics:\n");
    490     fprintf(fp, "     number of lookups: %u\n", ht->nlookups);
    491     fprintf(fp, "     number of entries: %u\n", ht->nentries);
    492     fprintf(fp, "       number of grows: %u\n", ht->ngrows);
    493     fprintf(fp, "     number of shrinks: %u\n", ht->nshrinks);
    494     fprintf(fp, "   mean steps per hash: %g\n", (double)ht->nsteps
    495                                                 / ht->nlookups);
    496     fprintf(fp, "mean hash chain length: %g\n", mean);
    497     fprintf(fp, "    standard deviation: %g\n", sqrt(variance));
    498     fprintf(fp, " max hash chain length: %u\n", maxChainLen);
    499     fprintf(fp, "        max hash chain: [%u]\n", maxChain);
    500 
    501     for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)
    502         if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT)
    503             break;
    504 }
    505 #endif /* HASHMETER */
    506 
    507415PR_IMPLEMENT(int)
    508416PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
     
    511419
    512420    count = PL_HashTableEnumerateEntries(ht, dump, fp);
    513 #ifdef HASHMETER
    514     PL_HashTableDumpMeter(ht, dump, fp);
    515 #endif
    516421    return count;
    517422}
  • trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plhash.h

    r11551 r101869  
    7070typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);
    7171typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
    72 
    73 #if defined(XP_OS2_VACPP) && defined(VACPP_FLIP) /* for nsSpaceManager.cpp */
    74 PR_END_EXTERN_C                                  /* and nsHTMLDocument.cpp */
    75 #endif
    7672typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
    77 
    78 #if defined(XP_OS2_VACPP) && defined(VACPP_FLIP)
    79 PR_BEGIN_EXTERN_C
    80 #endif
    8173
    8274/* Flag bits in PLHashEnumerator's return value */
     
    112104    const PLHashAllocOps *allocOps;     /* allocation operations */
    113105    void                *allocPriv;     /* allocation private data */
    114 #ifdef HASHMETER
    115     PRUint32              nlookups;       /* total number of lookups */
    116     PRUint32              nsteps;         /* number of hash chains traversed */
    117     PRUint32              ngrows;         /* number of table expansions */
    118     PRUint32              nshrinks;       /* number of table contractions */
    119 #endif
    120106};
    121107
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette