Esempio n. 1
0
MozJSImplScope::~MozJSImplScope() {
    for (auto&& x : _funcs) {
        x.reset();
    }

    unregisterOperation();
}
Esempio n. 2
0
bool MozJSImplScope::_interruptCallback(JSContext* cx) {
    auto scope = getScope(cx);

    if (scope->_pendingGC.load()) {
        scope->_pendingGC.store(false);
        JS_GC(scope->_runtime);
    } else {
        JS_MaybeGC(cx);
    }

    bool kill = scope->isKillPending();

    if (kill) {
        scope->_engine->getDeadlineMonitor().stopDeadline(scope);
        scope->unregisterOperation();
    }

    return !kill;
}
Esempio n. 3
0
bool MozJSImplScope::_interruptCallback(JSContext* cx) {
    auto scope = getScope(cx);

    JS_SetInterruptCallback(scope->_runtime, nullptr);
    auto guard = MakeGuard([&]() { JS_SetInterruptCallback(scope->_runtime, _interruptCallback); });

    if (scope->_pendingGC.load()) {
        scope->_pendingGC.store(false);
        JS_GC(scope->_runtime);
    } else {
        JS_MaybeGC(cx);
    }

    bool kill = scope->isKillPending();

    if (kill) {
        scope->_engine->getDeadlineMonitor().stopDeadline(scope);
        scope->unregisterOperation();

        scope->_status = Status(ErrorCodes::JSInterpreterFailure, "Interrupted by the host");
    }

    return !kill;
}
Esempio n. 4
0
void MozJSImplScope::reset() {
    unregisterOperation();
    _pendingKill.store(false);
    _pendingGC.store(false);
    advanceGeneration();
}