Bug 1865597 - Add error checking when initializing parallel marking and disable on...
[gecko.git] / js / src / frontend / LabelEmitter.cpp
blob8b9b6233e6784facf98e780bfe464f3e3a105506
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "frontend/LabelEmitter.h"
9 #include "mozilla/Assertions.h" // MOZ_ASSERT
11 #include "frontend/BytecodeEmitter.h" // BytecodeEmitter
13 using namespace js;
14 using namespace js::frontend;
16 void LabelEmitter::emitLabel(TaggedParserAtomIndex name) {
17 MOZ_ASSERT(state_ == State::Start);
19 controlInfo_.emplace(bce_, name, bce_->bytecodeSection().offset());
21 #ifdef DEBUG
22 state_ = State::Label;
23 #endif
26 bool LabelEmitter::emitEnd() {
27 MOZ_ASSERT(state_ == State::Label);
29 // Patch the break/continue to this label.
30 if (!controlInfo_->patchBreaks(bce_)) {
31 return false;
34 controlInfo_.reset();
36 #ifdef DEBUG
37 state_ = State::End;
38 #endif
39 return true;