当前位置: 首页>>代码示例>>C++>>正文


C++ JSRuntime::clearUsedByExclusiveThread方法代码示例

本文整理汇总了C++中JSRuntime::clearUsedByExclusiveThread方法的典型用法代码示例。如果您正苦于以下问题:C++ JSRuntime::clearUsedByExclusiveThread方法的具体用法?C++ JSRuntime::clearUsedByExclusiveThread怎么用?C++ JSRuntime::clearUsedByExclusiveThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSRuntime的用法示例。


在下文中一共展示了JSRuntime::clearUsedByExclusiveThread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lock

void
WorkerThreadState::finishParseTaskForScript(JSScript *script)
{
    JSRuntime *rt = script->compartment()->runtimeFromMainThread();
    ParseTask *parseTask = NULL;

    {
        AutoLockWorkerThreadState lock(*rt->workerThreadState);
        for (size_t i = 0; i < parseFinishedList.length(); i++) {
            if (parseFinishedList[i]->script == script) {
                parseTask = parseFinishedList[i];
                parseFinishedList[i] = parseFinishedList.back();
                parseFinishedList.popBack();
                break;
            }
        }
    }
    JS_ASSERT(parseTask);

    // Mark the zone as no longer in use by an ExclusiveContext, and available
    // to be collected by the GC.
    rt->clearUsedByExclusiveThread(parseTask->zone);

    if (!script) {
        // Parsing failed and there is nothing to finish, but there still may
        // be lingering ParseTask instances holding roots which need to be
        // cleaned up. The ParseTask which we picked might not be the right
        // one but this is ok as finish calls will be 1:1 with calls that
        // create a ParseTask.
        js_delete(parseTask);
        return;
    }

    // Point the prototypes of any objects in the script's compartment to refer
    // to the corresponding prototype in the new compartment. This will briefly
    // create cross compartment pointers, which will be fixed by the
    // MergeCompartments call below.
    for (gc::CellIter iter(parseTask->zone, gc::FINALIZE_TYPE_OBJECT); !iter.done(); iter.next()) {
        types::TypeObject *object = iter.get<types::TypeObject>();
        JSObject *proto = object->proto;
        if (!proto)
            continue;

        JSProtoKey key = js_IdentifyClassPrototype(proto);
        if (key == JSProto_Null)
            continue;

        JSObject *newProto = GetClassPrototypePure(&parseTask->scopeChain->global(), key);
        JS_ASSERT(newProto);

        object->proto = newProto;
    }

    // Move the parsed script and all its contents into the desired compartment.
    gc::MergeCompartments(parseTask->script->compartment(), parseTask->scopeChain->compartment());

    js_delete(parseTask);
}
开发者ID:,项目名称:,代码行数:58,代码来源:


注:本文中的JSRuntime::clearUsedByExclusiveThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。