Bug 1597943 part 1 - Remove some now-unused source notes. r=arai

Removes:

* SRC_IF
* SRC_IF_ELSE
* SRC_COND
* SRC_CONTINUE
* SRC_BREAK
* SRC_BREAK2LABEL
* SRC_SWITCHBREAK
* SRC_NEXTCASE

IonBuilder no longer needs those source notes since bug 1595476.

Differential Revision: https://phabricator.services.mozilla.com/D54087

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-11-21 12:59:19 +00:00
Родитель 2f6d8cf062
Коммит 0798d11d6c
9 изменённых файлов: 22 добавлений и 92 удалений

Просмотреть файл

@ -85,9 +85,6 @@ bool LoopControl::emitSpecialBreakForDone(BytecodeEmitter* bce) {
MOZ_ASSERT(bce->bytecodeSection().stackDepth() == stackDepth_);
MOZ_ASSERT(bce->innermostNestableControl == this);
if (!bce->newSrcNote(SRC_BREAK)) {
return false;
}
if (!bce->emitJump(JSOP_GOTO, &breaks)) {
return false;
}

Просмотреть файл

@ -861,8 +861,8 @@ bool NonLocalExitControl::prepareForNonLocalJump(NestableControl* target) {
} // anonymous namespace
bool BytecodeEmitter::emitGoto(NestableControl* target, JumpList* jumplist,
SrcNoteType noteType) {
NonLocalExitControl nle(this, noteType == SRC_CONTINUE
GotoKind kind) {
NonLocalExitControl nle(this, kind == GotoKind::Continue
? NonLocalExitControl::Continue
: NonLocalExitControl::Break);
@ -870,12 +870,6 @@ bool BytecodeEmitter::emitGoto(NestableControl* target, JumpList* jumplist,
return false;
}
if (noteType != SRC_NULL) {
if (!newSrcNote(noteType)) {
return false;
}
}
return emitJump(JSOP_GOTO, jumplist);
}
@ -5867,24 +5861,20 @@ bool BytecodeEmitter::emitWhile(BinaryNode* whileNode) {
bool BytecodeEmitter::emitBreak(PropertyName* label) {
BreakableControl* target;
SrcNoteType noteType;
if (label) {
// Any statement with the matching label may be the break target.
auto hasSameLabel = [label](LabelControl* labelControl) {
return labelControl->label() == label;
};
target = findInnermostNestableControl<LabelControl>(hasSameLabel);
noteType = SRC_BREAK2LABEL;
} else {
auto isNotLabel = [](BreakableControl* control) {
return !control->is<LabelControl>();
};
target = findInnermostNestableControl<BreakableControl>(isNotLabel);
noteType =
(target->kind() == StatementKind::Switch) ? SRC_SWITCHBREAK : SRC_BREAK;
}
return emitGoto(target, &target->breaks, noteType);
return emitGoto(target, &target->breaks, GotoKind::Break);
}
bool BytecodeEmitter::emitContinue(PropertyName* label) {
@ -5902,7 +5892,7 @@ bool BytecodeEmitter::emitContinue(PropertyName* label) {
} else {
target = findInnermostNestableControl<LoopControl>();
}
return emitGoto(target, &target->continues, SRC_CONTINUE);
return emitGoto(target, &target->continues, GotoKind::Continue);
}
bool BytecodeEmitter::emitGetFunctionThis(NameNode* thisName) {

Просмотреть файл

@ -451,8 +451,9 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
mozilla::Maybe<uint32_t> getOffsetForLoop(ParseNode* nextpn);
enum class GotoKind { Break, Continue };
MOZ_MUST_USE bool emitGoto(NestableControl* target, JumpList* jumplist,
SrcNoteType noteType = SRC_NULL);
GotoKind kind);
MOZ_MUST_USE bool emitIndex32(JSOp op, uint32_t index);
MOZ_MUST_USE bool emitIndexOp(JSOp op, uint32_t index);

Просмотреть файл

@ -7,7 +7,6 @@
#include "frontend/IfEmitter.h"
#include "frontend/BytecodeEmitter.h"
#include "frontend/SourceNotes.h"
#include "vm/Opcodes.h"
using namespace js;
@ -24,29 +23,20 @@ IfEmitter::IfEmitter(BytecodeEmitter* bce, Kind kind)
IfEmitter::IfEmitter(BytecodeEmitter* bce)
: IfEmitter(bce, Kind::MayContainLexicalAccessInBranch) {}
bool BranchEmitterBase::emitThenInternal(SrcNoteType type) {
bool BranchEmitterBase::emitThenInternal() {
// The end of TDZCheckCache for cond for else-if.
if (kind_ == Kind::MayContainLexicalAccessInBranch) {
tdzCache_.reset();
}
// Emit an annotated branch-if-false around the then part.
if (!bce_->newSrcNote(type)) {
return false;
}
// Emit a branch-if-false around the then part.
if (!bce_->emitJump(JSOP_IFEQ, &jumpAroundThen_)) {
return false;
}
// To restore stack depth in else part, save depth of the then part.
#ifdef DEBUG
// If DEBUG, this is also necessary to calculate |pushed_|.
// To restore stack depth in else part (if present), save depth of the then
// part.
thenDepth_ = bce_->bytecodeSection().stackDepth();
#else
if (type == SRC_COND || type == SRC_IF_ELSE) {
thenDepth_ = bce_->bytecodeSection().stackDepth();
}
#endif
// Enclose then-branch with TDZCheckCache.
if (kind_ == Kind::MayContainLexicalAccessInBranch) {
@ -149,7 +139,7 @@ bool IfEmitter::emitThen() {
MOZ_ASSERT_IF(state_ == State::ElseIf, tdzCache_.isSome());
MOZ_ASSERT_IF(state_ != State::ElseIf, tdzCache_.isNothing());
if (!emitThenInternal(SRC_IF)) {
if (!emitThenInternal()) {
return false;
}
@ -164,7 +154,7 @@ bool IfEmitter::emitThenElse() {
MOZ_ASSERT_IF(state_ == State::ElseIf, tdzCache_.isSome());
MOZ_ASSERT_IF(state_ != State::ElseIf, tdzCache_.isNothing());
if (!emitThenInternal(SRC_IF_ELSE)) {
if (!emitThenInternal()) {
return false;
}
@ -246,7 +236,7 @@ bool CondEmitter::emitCond() {
bool CondEmitter::emitThenElse() {
MOZ_ASSERT(state_ == State::Cond);
if (!emitThenInternal(SRC_COND)) {
if (!emitThenInternal()) {
return false;
}

Просмотреть файл

@ -69,7 +69,7 @@ class MOZ_STACK_CLASS BranchEmitterBase {
protected:
BranchEmitterBase(BytecodeEmitter* bce, Kind kind);
MOZ_MUST_USE bool emitThenInternal(SrcNoteType type);
MOZ_MUST_USE bool emitThenInternal();
void calculateOrCheckPushed();
MOZ_MUST_USE bool emitElseInternal();
MOZ_MUST_USE bool emitEndInternal();

Просмотреть файл

@ -121,16 +121,6 @@ class SrcNote {
Count
};
};
// SRC_NEXTCASE: Source note for JSOP_CASE in a JSOP_CONDSWITCH.
class NextCase {
public:
enum Fields {
// Offset of the next JSOP_CASE from this JSOP_CASE. This field is
// 0 if this is the last JSOP_CASE.
NextCaseOffset,
Count
};
};
// SRC_TRY: Source note for JSOP_TRY.
class Try {
public:
@ -165,21 +155,13 @@ class SrcNote {
// clang-format off
#define FOR_EACH_SRC_NOTE_TYPE(M) \
M(SRC_NULL, "null", 0) /* Terminates a note vector. */ \
M(SRC_IF, "if", 0) /* JSOP_IFEQ bytecode is from an if-then. */ \
M(SRC_IF_ELSE, "if-else", 0) /* JSOP_IFEQ bytecode is from an if-then-else. */ \
M(SRC_COND, "cond", 0) /* JSOP_IFEQ is from conditional ?: operator. */ \
M(SRC_FOR, "for", SrcNote::For::Count) \
M(SRC_WHILE, "while", SrcNote::While::Count) \
M(SRC_DO_WHILE, "do-while", SrcNote::DoWhile::Count) \
M(SRC_FOR_IN, "for-in", SrcNote::ForIn::Count) \
M(SRC_FOR_OF, "for-of", SrcNote::ForOf::Count) \
M(SRC_CONTINUE, "continue", 0) /* JSOP_GOTO is a continue. */ \
M(SRC_BREAK, "break", 0) /* JSOP_GOTO is a break. */ \
M(SRC_BREAK2LABEL, "break2label", 0) /* JSOP_GOTO for 'break label'. */ \
M(SRC_SWITCHBREAK, "switchbreak", 0) /* JSOP_GOTO is a break in a switch. */ \
M(SRC_TABLESWITCH, "tableswitch", SrcNote::TableSwitch::Count) \
M(SRC_CONDSWITCH, "condswitch", SrcNote::CondSwitch::Count) \
M(SRC_NEXTCASE, "nextcase", SrcNote::NextCase::Count) \
M(SRC_ASSIGNOP, "assignop", 0) /* += or another assign-op follows. */ \
M(SRC_CLASS_SPAN, "class", 2) /* The starting and ending offsets for the class, used \
for toString correctness for default ctors. */ \
@ -190,6 +172,14 @@ class SrcNote {
M(SRC_SETLINE, "setline", SrcNote::SetLine::Count) \
M(SRC_BREAKPOINT, "breakpoint", 0) /* Bytecode is a recommended breakpoint. */ \
M(SRC_STEP_SEP, "step-sep", 0) /* Bytecode is the first in a new steppable area. */ \
M(SRC_UNUSED16, "unused", 0) \
M(SRC_UNUSED17, "unused", 0) \
M(SRC_UNUSED18, "unused", 0) \
M(SRC_UNUSED19, "unused", 0) \
M(SRC_UNUSED20, "unused", 0) \
M(SRC_UNUSED21, "unused", 0) \
M(SRC_UNUSED22, "unused", 0) \
M(SRC_UNUSED23, "unused", 0) \
M(SRC_XDELTA, "xdelta", 0) /* 24-31 are for extended delta notes. */
// clang-format on

Просмотреть файл

@ -226,20 +226,6 @@ bool SwitchEmitter::emitCaseOrDefaultJump(uint32_t caseIndex, bool isDefault) {
return true;
}
if (caseIndex > 0) {
// Link the last JSOP_CASE's SRC_NEXTCASE to current JSOP_CASE for the
// benefit of IonBuilder.
if (!bce_->setSrcNoteOffset(
caseNoteIndex_, SrcNote::NextCase::NextCaseOffset,
bce_->bytecodeSection().offset() - lastCaseOffset_)) {
return false;
}
}
if (!bce_->newSrcNote2(SRC_NEXTCASE, 0, &caseNoteIndex_)) {
return false;
}
JumpList caseJump;
if (!bce_->emitJump(JSOP_CASE, &caseJump)) {
return false;
@ -249,15 +235,9 @@ bool SwitchEmitter::emitCaseOrDefaultJump(uint32_t caseIndex, bool isDefault) {
if (caseIndex == 0) {
// Switch note's second offset is to first JSOP_CASE.
unsigned noteCount = bce_->bytecodeSection().notes().length();
if (!bce_->setSrcNoteOffset(noteIndex_, 1, lastCaseOffset_ - top_)) {
return false;
}
unsigned noteCountDelta =
bce_->bytecodeSection().notes().length() - noteCount;
if (noteCountDelta != 0) {
caseNoteIndex_ += noteCountDelta;
}
}
return true;

Просмотреть файл

@ -302,9 +302,6 @@ class MOZ_STACK_CLASS SwitchEmitter {
// The source note index for SRC_CONDSWITCH.
unsigned noteIndex_ = 0;
// Source note index of the previous SRC_NEXTCASE.
unsigned caseNoteIndex_ = 0;
// The number of cases in the switch statement, excluding the default case.
uint32_t caseCount_ = 0;

Просмотреть файл

@ -3046,13 +3046,6 @@ static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
switch (type) {
case SRC_NULL:
case SRC_IF:
case SRC_IF_ELSE:
case SRC_COND:
case SRC_CONTINUE:
case SRC_BREAK:
case SRC_BREAK2LABEL:
case SRC_SWITCHBREAK:
case SRC_ASSIGNOP:
case SRC_BREAKPOINT:
case SRC_STEP_SEP:
@ -3116,14 +3109,6 @@ static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
}
break;
case SRC_NEXTCASE:
if (!sp->jsprintf(" next case offset %u",
unsigned(GetSrcNoteOffset(
sn, SrcNote::NextCase::NextCaseOffset)))) {
return false;
}
break;
case SRC_TABLESWITCH: {
mozilla::DebugOnly<JSOp> op = JSOp(script->code()[offset]);
MOZ_ASSERT(op == JSOP_TABLESWITCH);