jit::RematerializedFrame * jit::JitActivation::getRematerializedFrame(JSContext *cx, const JitFrameIterator &iter, size_t inlineDepth) { // Only allow rematerializing from the same thread. MOZ_ASSERT(cx->perThreadData == cx_->perThreadData); MOZ_ASSERT(iter.activation() == this); MOZ_ASSERT(iter.isIonScripted()); if (!rematerializedFrames_) { rematerializedFrames_ = cx->new_<RematerializedFrameTable>(cx); if (!rematerializedFrames_ || !rematerializedFrames_->init()) { rematerializedFrames_ = nullptr; return nullptr; } } uint8_t *top = iter.fp(); RematerializedFrameTable::AddPtr p = rematerializedFrames_->lookupForAdd(top); if (!p) { RematerializedFrameVector empty(cx); if (!rematerializedFrames_->add(p, top, Move(empty))) return nullptr; // The unit of rematerialization is an uninlined frame and its inlined // frames. Since inlined frames do not exist outside of snapshots, it // is impossible to synchronize their rematerialized copies to // preserve identity. Therefore, we always rematerialize an uninlined // frame and all its inlined frames at once. InlineFrameIterator inlineIter(cx, &iter); if (!RematerializedFrame::RematerializeInlineFrames(cx, top, inlineIter, p->value())) return nullptr; } return p->value()[inlineDepth]; }
jit::RematerializedFrame * jit::JitActivation::getRematerializedFrame(ThreadSafeContext *cx, JitFrameIterator &iter, size_t inlineDepth) { // Only allow rematerializing from the same thread. MOZ_ASSERT(cx->perThreadData == cx_->perThreadData); MOZ_ASSERT(iter.activation() == this); MOZ_ASSERT(iter.isIonJS()); if (!rematerializedFrames_) { rematerializedFrames_ = cx->new_<RematerializedFrameTable>(cx); if (!rematerializedFrames_ || !rematerializedFrames_->init()) { rematerializedFrames_ = nullptr; return nullptr; } } // The unit of rematerialization is an uninlined frame and its inlined // frames. Since inlined frames do not exist outside of snapshots, it is // impossible to synchronize their rematerialized copies to preserve // identity. Therefore, we always rematerialize an uninlined frame and all // its inlined frames at once. uint8_t *top = iter.fp(); RematerializedFrameTable::AddPtr p = rematerializedFrames_->lookupForAdd(top); if (!p) { RematerializedFrameVector empty(cx); if (!rematerializedFrames_->add(p, top, Move(empty))) return nullptr; InlineFrameIterator inlineIter(cx, &iter); if (!p->value().resize(inlineIter.frameCount())) return nullptr; while (true) { size_t frameNo = inlineIter.frameNo(); p->value()[frameNo] = RematerializedFrame::New(cx, top, inlineIter); if (!p->value()[frameNo]) return nullptr; if (!inlineIter.more()) break; ++inlineIter; } } return p->value()[inlineDepth]; }