diff options
author | FranklinDM <mrmineshafter17@gmail.com> | 2022-05-20 15:38:43 +0800 |
---|---|---|
committer | FranklinDM <mrmineshafter17@gmail.com> | 2022-05-21 01:02:22 +0800 |
commit | bbe40dab58fa3e6ee395974da641581e08958de8 (patch) | |
tree | 78cdd79841cd99e569a964d6dcab2edd7b665a26 /js/src/jit/BaselineCompiler.cpp | |
parent | 5e500dc2b4371f7ae10483bfc786cf2ad0161939 (diff) | |
download | uxp-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.cpp | 19 |
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(); |