Commit 3ef732aa authored by Jan de Mooij's avatar Jan de Mooij
Browse files

Bug 1598548 part 11 - Remove source note offset for loop backjump. r=arai,tcampbell

For now we still need the source note itself to determine the
stackPhiCount in IonBuilder. Hopefully we can fix that later.

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

--HG--
extra : moz-landing-system : lando
parent 0ac3a6e8
......@@ -140,11 +140,6 @@ class LoopControl : public BreakableControl {
BytecodeOffset breakTargetOffset() const { return breakTarget_.offset; }
BytecodeOffset continueTargetOffset() const { return continueTarget_.offset; }
// The offset of the backward jump at the loop end from the JSOP_LOOPHEAD.
BytecodeOffsetDiff loopEndOffsetFromLoopHead() const {
return loopEndOffset_ - head_.offset;
}
MOZ_MUST_USE bool emitContinueTarget(BytecodeEmitter* bce);
// Emit a jump to break target from the top level of the loop.
......
......@@ -5178,11 +5178,7 @@ bool BytecodeEmitter::emitAsyncIterator() {
bool BytecodeEmitter::emitSpread(bool allowSelfHosted) {
LoopControl loopInfo(this, StatementKind::Spread);
// Jump down to the loop condition to minimize overhead assuming at least
// one iteration, as the other loop forms do. Annotate so IonMonkey can
// find the loop-closing jump.
unsigned noteIndex;
if (!newSrcNote(SRC_FOR_OF, &noteIndex)) {
if (!newSrcNote(SRC_FOR_OF)) {
return false;
}
......@@ -5243,12 +5239,6 @@ bool BytecodeEmitter::emitSpread(bool allowSelfHosted) {
// manually.
bytecodeSection().setStackDepth(bytecodeSection().stackDepth() + 1);
// Let Ion know where the closing jump of this loop is.
if (!setSrcNoteOffset(noteIndex, SrcNote::Loop::BackJumpOffset,
loopInfo.loopEndOffsetFromLoopHead())) {
return false;
}
// No continues should occur in spreads.
MOZ_ASSERT(!loopInfo.continues.offset.valid());
......
......@@ -67,7 +67,7 @@ bool CForEmitter::emitCond(const Maybe<uint32_t>& condPos) {
}
}
if (!bce_->newSrcNote(SRC_FOR, &noteIndex_)) {
if (!bce_->newSrcNote(SRC_FOR)) {
return false;
}
......@@ -175,14 +175,6 @@ bool CForEmitter::emitEnd(const Maybe<uint32_t>& forPos) {
return false;
}
// The note offset helps us find the loop-closing jump.
if (!bce_->setSrcNoteOffset(noteIndex_, SrcNote::Loop::BackJumpOffset,
loopInfo_->loopEndOffsetFromLoopHead()))
{
return false;
}
if (!bce_->addTryNote(JSTRY_LOOP, bce_->bytecodeSection().stackDepth(),
loopInfo_->headOffset(),
loopInfo_->breakTargetOffset())) {
......
......@@ -79,9 +79,6 @@ class MOZ_STACK_CLASS CForEmitter {
private:
BytecodeEmitter* bce_;
// The source note index for SRC_FOR.
unsigned noteIndex_ = 0;
// Whether the c-style for loop has `cond` and `update`.
Cond cond_ = Cond::Missing;
Update update_ = Update::Missing;
......
......@@ -34,8 +34,7 @@ bool DoWhileEmitter::emitBody(const Maybe<uint32_t>& doPos,
return false;
}
// Emit an annotated nop so IonBuilder can recognize the 'do' loop.
if (!bce_->newSrcNote(SRC_DO_WHILE, &noteIndex_)) {
if (!bce_->newSrcNote(SRC_DO_WHILE)) {
return false;
}
......@@ -77,12 +76,6 @@ bool DoWhileEmitter::emitEnd() {
return false;
}
// Update the annotation with the back edge position, for IonBuilder.
if (!bce_->setSrcNoteOffset(noteIndex_, SrcNote::Loop::BackJumpOffset,
loopInfo_->loopEndOffsetFromLoopHead())) {
return false;
}
if (!loopInfo_->patchBreaksAndContinues(bce_)) {
return false;
}
......
......@@ -34,9 +34,6 @@ struct BytecodeEmitter;
class MOZ_STACK_CLASS DoWhileEmitter {
BytecodeEmitter* bce_;
// The source note index for SRC_DO_WHILE.
unsigned noteIndex_ = 0;
mozilla::Maybe<LoopControl> loopInfo_;
#ifdef DEBUG
......
......@@ -43,8 +43,7 @@ bool ForInEmitter::emitInitialize() {
loopInfo_.emplace(bce_, StatementKind::ForInLoop);
// Annotate so IonMonkey can find the loop-closing jump.
if (!bce_->newSrcNote(SRC_FOR_IN, &noteIndex_)) {
if (!bce_->newSrcNote(SRC_FOR_IN)) {
return false;
}
......@@ -144,12 +143,6 @@ bool ForInEmitter::emitEnd(const Maybe<uint32_t>& forPos) {
return false;
}
// Set the srcnote offset so we can find the closing jump.
if (!bce_->setSrcNoteOffset(noteIndex_, SrcNote::Loop::BackJumpOffset,
loopInfo_->loopEndOffsetFromLoopHead())) {
return false;
}
// When we leave the loop body and jump to this point, the iteration value is
// still on the stack. Account for that by updating the stack depth manually.
int32_t stackDepth = bce_->bytecodeSection().stackDepth() + 1;
......
......@@ -39,9 +39,6 @@ class EmitterScope;
class MOZ_STACK_CLASS ForInEmitter {
BytecodeEmitter* bce_;
// The source note index for SRC_FOR_IN.
unsigned noteIndex_ = 0;
#ifdef DEBUG
// The stack depth before emitting initialize code inside loop.
int32_t loopDepth_ = 0;
......
......@@ -70,8 +70,7 @@ bool ForOfEmitter::emitInitialize(const Maybe<uint32_t>& forPos) {
loopInfo_.emplace(bce_, iterDepth, allowSelfHostedIter_, iterKind_);
// Annotate so IonMonkey can find the loop-closing jump.
if (!bce_->newSrcNote(SRC_FOR_OF, &noteIndex_)) {
if (!bce_->newSrcNote(SRC_FOR_OF)) {
return false;
}
......@@ -241,12 +240,6 @@ bool ForOfEmitter::emitEnd(const Maybe<uint32_t>& iteratedPos) {
MOZ_ASSERT(bce_->bytecodeSection().stackDepth() == loopDepth_);
// Let Ion know where the closing jump of this loop is.
if (!bce_->setSrcNoteOffset(noteIndex_, SrcNote::Loop::BackJumpOffset,
loopInfo_->loopEndOffsetFromLoopHead())) {
return false;
}
if (!loopInfo_->patchBreaksAndContinues(bce_)) {
return false;
}
......
......@@ -41,9 +41,6 @@ class EmitterScope;
class MOZ_STACK_CLASS ForOfEmitter {
BytecodeEmitter* bce_;
// The source note index for SRC_FOR_OF.
unsigned noteIndex_ = 0;
#ifdef DEBUG
// The stack depth before emitting IteratorNext code inside loop.
int32_t loopDepth_ = 0;
......
......@@ -38,17 +38,6 @@ namespace js {
class SrcNote {
public:
// SRC_FOR, SRC_DO_WHILE, SRC_WHILE, SRC_FOR_IN, SRC_FOR_OF: Source note for
// JSOP_LOOPHEAD at the top of a loop.
class Loop {
public:
enum Fields {
// The offset of JSOP_GOTO/JSOP_IFEQ/JSOP_IFNE at the end of the loop from
// JSOP_LOOPHEAD.
BackJumpOffset,
Count,
};
};
// SRC_TRY: Source note for JSOP_TRY.
class Try {
public:
......@@ -83,11 +72,11 @@ class SrcNote {
// clang-format off
#define FOR_EACH_SRC_NOTE_TYPE(M) \
M(SRC_NULL, "null", 0) /* Terminates a note vector. */ \
M(SRC_FOR, "for", SrcNote::Loop::Count) \
M(SRC_WHILE, "while", SrcNote::Loop::Count) \
M(SRC_DO_WHILE, "do-while", SrcNote::Loop::Count) \
M(SRC_FOR_IN, "for-in", SrcNote::Loop::Count) \
M(SRC_FOR_OF, "for-of", SrcNote::Loop::Count) \
M(SRC_FOR, "for", 0) /* JSOP_LOOPHEAD is for C-style for-loop. */ \
M(SRC_WHILE, "while", 0) /* JSOP_LOOPHEAD is for while loop. */ \
M(SRC_DO_WHILE, "do-while", 0) /* JSOP_LOOPHEAD is for do-while loop. */ \
M(SRC_FOR_IN, "for-in", 0) /* JSOP_LOOPHEAD is for for-in loop. */ \
M(SRC_FOR_OF, "for-of", 0) /* JSOP_LOOPHEAD is for for-of loop. */ \
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. */ \
......
......@@ -42,7 +42,7 @@ bool WhileEmitter::emitCond(const Maybe<uint32_t>& whilePos,
loopInfo_.emplace(bce_, StatementKind::WhileLoop);
if (!bce_->newSrcNote(SRC_WHILE, &noteIndex_)) {
if (!bce_->newSrcNote(SRC_WHILE)) {
return false;
}
......@@ -90,11 +90,6 @@ bool WhileEmitter::emitEnd() {
return false;
}
if (!bce_->setSrcNoteOffset(noteIndex_, SrcNote::Loop::BackJumpOffset,
loopInfo_->loopEndOffsetFromLoopHead())) {
return false;
}
if (!loopInfo_->patchBreaksAndContinues(bce_)) {
return false;
}
......
......@@ -37,9 +37,6 @@ struct BytecodeEmitter;
class MOZ_STACK_CLASS WhileEmitter {
BytecodeEmitter* bce_;
// The source note index for SRC_WHILE.
unsigned noteIndex_ = 0;
mozilla::Maybe<LoopControl> loopInfo_;
// Cache for the loop body, which is enclosed by the cache in `loopInfo_`,
......
......@@ -3030,6 +3030,11 @@ static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
case SRC_BREAKPOINT:
case SRC_STEP_SEP:
case SRC_XDELTA:
case SRC_FOR:
case SRC_DO_WHILE:
case SRC_WHILE:
case SRC_FOR_IN:
case SRC_FOR_OF:
break;
case SRC_COLSPAN:
......@@ -3051,19 +3056,6 @@ static MOZ_MUST_USE bool SrcNotes(JSContext* cx, HandleScript script,
++lineno;
break;
case SRC_FOR:
case SRC_DO_WHILE:
case SRC_WHILE:
case SRC_FOR_IN:
case SRC_FOR_OF: {
unsigned backJumpOffset =
GetSrcNoteOffset(sn, SrcNote::Loop::BackJumpOffset);
if (!sp->jsprintf(" backjump %u", backJumpOffset)) {
return false;
}
break;
}
case SRC_TRY:
MOZ_ASSERT(JSOp(script->code()[offset]) == JSOP_TRY);
if (!sp->jsprintf(" offset to jump %u",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment