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


C++ JSCompartment::barrierTracer方法代码示例

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


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

示例1: childRoot

Shape *
PropertyTree::getChild(JSContext *cx, Shape *parent_, uint32_t nfixed, const StackShape &child)
{
    Shape *shape = NULL;

    JS_ASSERT(parent_);

    /*
     * The property tree has extremely low fan-out below its root in
     * popular embeddings with real-world workloads. Patterns such as
     * defining closures that capture a constructor's environment as
     * getters or setters on the new object that is passed in as
     * |this| can significantly increase fan-out below the property
     * tree root -- see bug 335700 for details.
     */
    KidsPointer *kidp = &parent_->kids;
    if (kidp->isShape()) {
        Shape *kid = kidp->toShape();
        if (kid->matches(child))
            shape = kid;
    } else if (kidp->isHash()) {
        shape = *kidp->toHash()->lookup(child);
    } else {
        /* If kidp->isNull(), we always insert. */
    }

#ifdef JSGC_INCREMENTAL
    if (shape) {
        JSCompartment *comp = shape->compartment();
        if (comp->needsBarrier()) {
            /*
             * We need a read barrier for the shape tree, since these are weak
             * pointers.
             */
            Shape *tmp = shape;
            MarkShapeUnbarriered(comp->barrierTracer(), &tmp, "read barrier");
            JS_ASSERT(tmp == shape);
        } else if (comp->isGCSweeping() && !shape->isMarked() &&
                   !shape->arenaHeader()->allocatedDuringIncremental)
        {
            /*
             * The shape we've found is unreachable and due to be finalized, so
             * remove our weak reference to it and don't use it.
             */
            JS_ASSERT(parent_->isMarked());
            parent_->removeChild(shape);
            shape = NULL;
        }
    }
#endif

    if (shape)
        return shape;

    StackShape::AutoRooter childRoot(cx, &child);
    RootedShape parent(cx, parent_);

    shape = newShape(cx);
    if (!shape)
        return NULL;

    new (shape) Shape(child, nfixed);

    if (!insertChild(cx, parent, shape))
        return NULL;

    return shape;
}
开发者ID:Lynart,项目名称:mozilla-central,代码行数:68,代码来源:jspropertytree.cpp


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