summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2022-04-30 17:34:11 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2022-05-04 14:57:18 +0800
commit6d480d82a5e5d223786851865170983a47684930 (patch)
tree5093f20e0c4054764e3dd5c3937332439519a37e
parentfa72aef363d3e8b825024d389f3f3bf52ee38c07 (diff)
downloaduxp-6d480d82a5e5d223786851865170983a47684930.tar.gz
Issue #1658 - Part 6: Break and return no control flow for jumps emitted by optional chains under IonBuilder
IIUC, we want to process the GOTO in the case of optional chains, and we do not satisfy the requirements mentioned in the comment of snoopControlFlow's caller. Optional chains are not loops, we (probably) don't have a loop in the instruction following the GOTO, and in the GOTO destination, we're either returning an undefined/null value or the actual value.
-rw-r--r--js/src/frontend/BytecodeEmitter.cpp8
-rw-r--r--js/src/frontend/SourceNotes.h2
-rw-r--r--js/src/jit/IonBuilder.cpp6
3 files changed, 15 insertions, 1 deletions
diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
index 0c6b1c9263..b5a96f32d9 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -12172,6 +12172,10 @@ OptionalEmitter::emitJumpShortCircuit() {
return false;
}
+ if (!bce_->newSrcNote(SRC_OPTCHAIN)) {
+ return false;
+ }
+
if (!bce_->emitJump(JSOP_GOTO, &jumpShortCircuit_)) {
// [stack] UNDEFINED-OR-NULL
return false;
@@ -12218,6 +12222,10 @@ OptionalEmitter::emitJumpShortCircuitForCall() {
return false;
}
+ if (!bce_->newSrcNote(SRC_OPTCHAIN)) {
+ return false;
+ }
+
if (!bce_->emitJump(JSOP_GOTO, &jumpShortCircuit_)) {
// [stack] UNDEFINED-OR-NULL
return false;
diff --git a/js/src/frontend/SourceNotes.h b/js/src/frontend/SourceNotes.h
index 3d2a1bc1f7..3951f55649 100644
--- a/js/src/frontend/SourceNotes.h
+++ b/js/src/frontend/SourceNotes.h
@@ -49,6 +49,7 @@ namespace js {
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_OPTCHAIN, "optchain", 0) /* JSOP_GOTO for optional chains. */ \
M(SRC_TABLESWITCH, "tableswitch", 1) /* JSOP_TABLESWITCH; offset points to end of switch. */ \
M(SRC_CONDSWITCH, "condswitch", 2) /* JSOP_CONDSWITCH; 1st offset points to end of switch, \
2nd points to first JSOP_CASE. */ \
@@ -63,7 +64,6 @@ namespace js {
M(SRC_COLSPAN, "colspan", 1) /* Number of columns this opcode spans. */ \
M(SRC_NEWLINE, "newline", 0) /* Bytecode follows a source newline. */ \
M(SRC_SETLINE, "setline", 1) /* A file-absolute source line number note. */ \
- M(SRC_UNUSED21, "unused21", 0) /* Unused. */ \
M(SRC_UNUSED22, "unused22", 0) /* Unused. */ \
M(SRC_UNUSED23, "unused23", 0) /* Unused. */ \
M(SRC_XDELTA, "xdelta", 0) /* 24-31 are for extended delta notes. */
diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp
index dae86fd92a..dbecec2a7e 100644
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -1649,6 +1649,12 @@ IonBuilder::snoopControlFlow(JSOp op)
// while (cond) { }
return whileOrForInLoop(sn);
+ case SRC_OPTCHAIN:
+ // XXX Instead of aborting early, breaking at this point works.
+ // However, I'm not sure if we still need to further process
+ // optional chains under IonBuilder.
+ break;
+
default:
// Hard assert for now - make an error later.
MOZ_CRASH("unknown goto case");