From 53926d7fbf4232cdef0449b5b515404085fea3f1 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 27 May 2022 16:21:50 -0500 Subject: [JS:Engine] Implement support for nullish coalescing in the JS parser - UXP Parts 1, 2, 4, 5, and 7 based on Bug 1566141 - UXP Part 3 partially based on Bugs 1566141 and 1593415 - UXP Part 6 partly based on Bugs 1566141 and 1599163 with a different approach by modifying the `Boolish` function directly to act differently if we're checking for nullish values. --- js/src/jit/CodeGenerator.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/src/jit/CodeGenerator.cpp') diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index ec3d35ff0..66e8e25dd 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -11517,6 +11517,24 @@ CodeGenerator::visitIsObjectAndBranch(LIsObjectAndBranch* ins) testObjectEmitBranch(Assembler::Equal, value, ins->ifTrue(), ins->ifFalse()); } +void +CodeGenerator::visitIsNullOrUndefined(LIsNullOrUndefined* ins) +{ + Register output = ToRegister(ins->output()); + ValueOperand value = ToValue(ins, LIsNullOrUndefined::Input); + + Label isNotNull, done; + masm.branchTestNull(Assembler::NotEqual, value, &isNotNull); + + masm.move32(Imm32(1), output); + masm.jump(&done); + + masm.bind(&isNotNull); + masm.testUndefinedSet(Assembler::Equal, value, output); + + masm.bind(&done); +} + void CodeGenerator::loadOutermostJSScript(Register reg) { -- cgit v1.2.3