summaryrefslogtreecommitdiff
path: root/js/src/jit/BaselineCompiler.cpp
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2022-05-20 15:38:43 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2022-05-21 01:02:22 +0800
commitbbe40dab58fa3e6ee395974da641581e08958de8 (patch)
tree78cdd79841cd99e569a964d6dcab2edd7b665a26 /js/src/jit/BaselineCompiler.cpp
parent5e500dc2b4371f7ae10483bfc786cf2ad0161939 (diff)
downloaduxp-bbe40dab58fa3e6ee395974da641581e08958de8.tar.gz
Issue #1894 - Part 4: Implement IonMonkey support for nullish coalescing
Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1566141
Diffstat (limited to 'js/src/jit/BaselineCompiler.cpp')
-rw-r--r--js/src/jit/BaselineCompiler.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/js/src/jit/BaselineCompiler.cpp b/js/src/jit/BaselineCompiler.cpp
index fd85ec00ed..53254718c0 100644
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -1253,6 +1253,25 @@ BaselineCompiler::emit_JSOP_IFNE()
}
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)
{
bool knownBoolean = frame.peek(-1)->isKnownBoolean();