Пример #1
0
void ThreadTimers::sharedTimerFiredInternal()
{
    ASSERT(isMainThread() || (!isWebThread() && !isUIThread()));
    // Do a re-entrancy check.
    if (m_firingTimers)
        return;
    m_firingTimers = true;
    m_pendingSharedTimerFireTime = 0;

    double fireTime = monotonicallyIncreasingTime();
    double timeToQuit = fireTime + maxDurationOfFiringTimers;

    while (!m_timerHeap.isEmpty() && m_timerHeap.first()->m_nextFireTime <= fireTime) {
        TimerBase* timer = m_timerHeap.first();
        timer->m_nextFireTime = 0;
        timer->m_unalignedNextFireTime = 0;
        timer->heapDeleteMin();

        double interval = timer->repeatInterval();
        timer->setNextFireTime(interval ? fireTime + interval : 0);

        // Once the timer has been fired, it may be deleted, so do nothing else with it after this point.
        timer->fired();

        // Catch the case where the timer asked timers to fire in a nested event loop, or we are over time limit.
        if (!m_firingTimers || timeToQuit < monotonicallyIncreasingTime())
            break;
    }

    m_firingTimers = false;

    updateSharedTimer();
}
Пример #2
0
void FloatingPointEnvironment::saveMainThreadEnvironment()
{
    RELEASE_ASSERT(!m_isInitialized);
    RELEASE_ASSERT(isUIThread());
    fegetenv(&m_mainThreadEnvironment);
    m_isInitialized = true;
}
Пример #3
0
ThreadTimers::ThreadTimers()
    : m_sharedTimer(0)
    , m_firingTimers(false)
    , m_pendingSharedTimerFireTime(0)
{
    if (isUIThread())
        setSharedTimer(&MainThreadSharedTimer::singleton());
}
Пример #4
0
void FloatingPointEnvironment::enableDenormalSupport()
{
    RELEASE_ASSERT(isUIThread());
#if defined _ARM_ARCH_7
    fenv_t env; 
    fegetenv(&env); 
    env.__fpscr &= ~0x01000000U;
    fesetenv(&env); 
#endif
    // Supporting denormal mode is already the default on x86, x86_64, and ARM64.
}
Пример #5
0
void AtomicString::init()
{
    static bool initialized;
    if (!initialized) {
        // Initialization is not thread safe, so this function must be called from the main thread first.
        ASSERT(isUIThread());

        // Use placement new to initialize the globals.
        new (NotNull, (void*)&nullAtom) AtomicString;
        new (NotNull, (void*)&emptyAtom) AtomicString("");
        new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&xmlAtom) AtomicString("xml", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns", AtomicString::ConstructFromLiteral);

        initialized = true;
    }
}
Пример #6
0
void AtomicStringTable::create(WTFThreadData& data)
{
#if USE(WEB_THREAD)
    // On iOS, one AtomicStringTable is shared between the main UI thread and the WebThread.
    static AtomicStringTable* sharedStringTable = new AtomicStringTable;

    bool currentThreadIsWebThread = isWebThread();
    if (currentThreadIsWebThread || isUIThread())
        data.m_atomicStringTable = sharedStringTable;
    else
        data.m_atomicStringTable = new AtomicStringTable;

    // We do the following so that its destruction happens only
    // once - on the main UI thread.
    if (!currentThreadIsWebThread)
        data.m_atomicStringTableDestructor = AtomicStringTable::destroy;
#else
    data.m_atomicStringTable = new AtomicStringTable;
    data.m_atomicStringTableDestructor = AtomicStringTable::destroy;
#endif // USE(WEB_THREAD)
}
Пример #7
0
void AtomicString::init()
{
#if !PLATFORM(WKC)
    static bool initialized;
#else
    WKC_DEFINE_STATIC_BOOL(initialized, false);
#endif
    if (!initialized) {
        // Initialization is not thread safe, so this function must be called from the main thread first.
        ASSERT(isUIThread());

        // Use placement new to initialize the globals.
        new (NotNull, (void*)&nullAtom) AtomicString;
        new (NotNull, (void*)&emptyAtom) AtomicString("");
        new (NotNull, (void*)&textAtom) AtomicString("#text", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&commentAtom) AtomicString("#comment", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&xmlAtom) AtomicString("xml", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns", AtomicString::ConstructFromLiteral);
        new (NotNull, (void*)&xlinkAtom) AtomicString("xlink", AtomicString::ConstructFromLiteral);

        initialized = true;
    }
}
Пример #8
0
void FloatingPointEnvironment::propagateMainThreadEnvironment()
{
    RELEASE_ASSERT(m_isInitialized);
    RELEASE_ASSERT(!isUIThread());
    fesetenv(&m_mainThreadEnvironment);
}