Issue #1894 - Part 4: Implement IonMonkey support for nullish coalescing

Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1566141
This commit is contained in:
FranklinDM 2022-05-20 15:38:43 +08:00 committed by roytam1
commit 5812721809
12 changed files with 123 additions and 16 deletions

View file

@ -1252,6 +1252,25 @@ BaselineCompiler::emit_JSOP_IFNE()
return emitTest(true);
}
bool
BaselineCompiler::emit_JSOP_COALESCE() {
// COALESCE leaves the original value on the stack.
frame.syncStack(0);
masm.loadValue(frame.addressOfStackValue(frame.peek(-1)), R0);
Label undefinedOrNull;
masm.branchTestUndefined(Assembler::Equal, R0, &undefinedOrNull);
masm.branchTestNull(Assembler::Equal, R0, &undefinedOrNull);
jsbytecode* target = pc + GET_JUMP_OFFSET(pc);
masm.jump(labelOf(target));
masm.bind(&undefinedOrNull);
return true;
}
bool
BaselineCompiler::emitAndOr(bool branchIfTrue)
{