@@ -67,29 +67,29 @@ static void EmitOptionalChainWrapper(ParseNodeUni *pnodeOptChain, ByteCodeGenera
67
67
emitChainContent(innerNode);
68
68
funcInfo->ReleaseLoc(innerNode);
69
69
70
- if (innerNode->isUsed)
70
+ Js::ByteCodeLabel doneLabel = Js::Constants::NoRegister;
71
+ if (pnodeOptChain->isUsed)
71
72
{
72
- Assert(Js::Constants::NoRegister != innerNode->location);
73
-
74
- // Acquire slot for the result value
75
- Js::RegSlot resultSlot = funcInfo->AcquireLoc(pnodeOptChain);
76
- // Copy chain result
77
- byteCodeGenerator->Writer()->Reg2(Js::OpCode::Ld_A, resultSlot, innerNode->location);
73
+ Assert(innerNode->isUsed);
78
74
79
75
// Skip short-circuiting logic
80
- Js::ByteCodeLabel doneLabel = byteCodeGenerator->Writer()->DefineLabel();
76
+ doneLabel = byteCodeGenerator->Writer()->DefineLabel();
81
77
byteCodeGenerator->Writer()->Br(doneLabel);
78
+ }
79
+
80
+ byteCodeGenerator->Writer()->MarkLabel(skipLabel);
81
+
82
+ if (pnodeOptChain->isUsed)
83
+ {
84
+ // Acquire slot for the result value
85
+ Js::RegSlot resultSlot = funcInfo->AcquireLoc(pnodeOptChain);
86
+ Assert(Js::Constants::NoRegister != resultSlot);
87
+ Assert(resultSlot == innerNode->location);
82
88
83
89
// Set `undefined` on short-circuiting
84
- byteCodeGenerator->Writer()->MarkLabel(skipLabel);
85
90
byteCodeGenerator->Writer()->Reg2(Js::OpCode::Ld_A_ReuseLoc, resultSlot, funcInfo->undefinedConstantRegister);
86
-
87
91
byteCodeGenerator->Writer()->MarkLabel(doneLabel);
88
92
}
89
- else
90
- {
91
- byteCodeGenerator->Writer()->MarkLabel(skipLabel);
92
- }
93
93
funcInfo->currentOptionalChainSkipLabel = previousSkipLabel;
94
94
}
95
95
0 commit comments