static void
getString(CacheAndIndex* cacheAndIndex)
{
    for (int i = 0; i < NUM_ITERATIONS; i++) {
        auto str = STRINGS[cacheAndIndex->index % NUM_STRINGS];

        auto dupe = js::DuplicateString(str);
        MOZ_RELEASE_ASSERT(dupe);

        auto deduped = cacheAndIndex->cache->getOrCreate(mozilla::Move(dupe), js_strlen(str));
        MOZ_RELEASE_ASSERT(deduped.isSome());
        MOZ_RELEASE_ASSERT(js_strcmp(str, deduped->chars()) == 0);

        {
            auto cloned = deduped->clone();
            // We should be de-duplicating and giving back the same string.
            MOZ_RELEASE_ASSERT(deduped->chars() == cloned.chars());
        }
    }

    js_delete(cacheAndIndex);
}
void
setBitAndCheck(CounterAndBit* counterAndBit)
{
    while (true) {
        {
            // Set our bit. Repeatedly setting it is idempotent.
            auto guard = counterAndBit->counter.lock();
            printDiagnosticMessage(guard);
            guard |= (uint64_t(1) << counterAndBit->bit);
        }

        {
            // Check to see if we have observed all the other threads setting
            // their bit as well.
            auto guard = counterAndBit->counter.lock();
            printDiagnosticMessage(guard);
            if (guard == UINT64_MAX) {
                js_delete(counterAndBit);
                return;
            }
        }
    }
}
void PR_DestroyCondVar(PRCondVar* cvar) {
    js_delete(cvar);
}
void PR_DestroyLock(PRLock* lock) {
    js_delete(lock);
}
void
PR_DestroyCondVar(PRCondVar *cvar)
{
    pthread_cond_destroy(&cvar->cond());
    js_delete(cvar);
}
void
PR_DestroyLock(PRLock *lock)
{
    pthread_mutex_destroy(&lock->mutex());
    js_delete(lock);
}
Exemple #7
0
PerfMeasurement::~PerfMeasurement() { js_delete(static_cast<Impl*>(impl)); }