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


C++ HandleArrayObject::lastProperty方法代码示例

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


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

示例1: shape

bool
js::ForOfPIC::Chain::tryOptimizeArray(JSContext *cx, HandleArrayObject array, bool *optimized)
{
    MOZ_ASSERT(optimized);

    *optimized = false;

    if (!initialized_) {
        // If PIC is not initialized, initialize it.
        if (!initialize(cx))
            return false;

    } else if (!disabled_ && !isArrayStateStillSane()) {
        // Otherwise, if array state is no longer sane, reinitialize.
        reset(cx);

        if (!initialize(cx))
            return false;
    }
    MOZ_ASSERT(initialized_);

    // If PIC is disabled, don't bother trying to optimize.
    if (disabled_)
        return true;

    // By the time we get here, we should have a sane array state to work with.
    MOZ_ASSERT(isArrayStateStillSane());

    // Check if stub already exists.
    ForOfPIC::Stub *stub = isArrayOptimized(&array->as<ArrayObject>());
    if (stub) {
        *optimized = true;
        return true;
    }

    // If the number of stubs is about to exceed the limit, throw away entire
    // existing cache before adding new stubs.  We shouldn't really have heavy
    // churn on these.
    if (numStubs() >= MAX_STUBS)
        eraseChain();

    // Ensure array's prototype is the actual Array.prototype
    if (!isOptimizableArray(array))
        return true;

    // Ensure array doesn't define '@@iterator' directly.
    if (array->lookup(cx, cx->names().std_iterator))
        return true;

    // Good to optimize now, create stub to add.
    RootedShape shape(cx, array->lastProperty());
    stub = cx->new_<Stub>(shape);
    if (!stub)
        return false;

    // Add the stub.
    addStub(stub);

    *optimized = true;
    return true;
}
开发者ID:alex-tifrea,项目名称:gecko-dev,代码行数:61,代码来源:PIC.cpp


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