/* static */ bool
RematerializedFrame::RematerializeInlineFrames(JSContext *cx, uint8_t *top,
                                               InlineFrameIterator &iter,
                                               MaybeReadFallback &fallback,
                                               Vector<RematerializedFrame *> &frames)
{
    if (!frames.resize(iter.frameCount()))
        return false;

    while (true) {
        size_t frameNo = iter.frameNo();
        RematerializedFrame *frame = RematerializedFrame::New(cx, top, iter, fallback);
        if (!frame)
            return false;
        if (frame->scopeChain()) {
            if (!EnsureHasScopeObjects(cx, frame))
                return false;
        }

        frames[frameNo] = frame;

        if (!iter.more())
            break;
        ++iter;
    }

    return true;
}
/* static */ bool
RematerializedFrame::RematerializeInlineFrames(JSContext* cx, uint8_t* top,
                                               InlineFrameIterator& iter,
                                               MaybeReadFallback& fallback,
                                               GCVector<RematerializedFrame*>& frames)
{
    Rooted<GCVector<RematerializedFrame*>> tempFrames(cx, GCVector<RematerializedFrame*>(cx));
    if (!tempFrames.resize(iter.frameCount()))
        return false;

    while (true) {
        size_t frameNo = iter.frameNo();
        tempFrames[frameNo].set(RematerializedFrame::New(cx, top, iter, fallback));
        if (!tempFrames[frameNo])
            return false;
        if (tempFrames[frameNo]->environmentChain()) {
            if (!EnsureHasEnvironmentObjects(cx, tempFrames[frameNo].get()))
                return false;
        }

        if (!iter.more())
            break;
        ++iter;
    }

    frames = Move(tempFrames.get());
    return true;
}