示例#1
0
MozJSImplScope::~MozJSImplScope() {
    for (auto&& x : _funcs) {
        x.reset();
    }

    unregisterOperation();
}
示例#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;
}
示例#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;
}
示例#4
0
void MozJSImplScope::reset() {
    unregisterOperation();
    _pendingKill.store(false);
    _pendingGC.store(false);
    advanceGeneration();
}