Skip to content

Commit 783e64d

Browse files
author
Jianchun Xu
committed
JIT: (xplat) address CR issues
also merge to latest.
1 parent 271e410 commit 783e64d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/Backend/GlobOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4878,7 +4878,7 @@ GlobOpt::OptInstr(IR::Instr *&instr, bool* isInstrRemoved)
48784878
}
48794879

48804880
// Change LdFld on arrays, strings, and 'arguments' to LdLen when we're accessing the .length field
4881-
if (instr->GetSrc1() && instr->GetSrc1()->IsSymOpnd() && instr->m_opcode == Js::OpCode::ProfiledLdFld || instr->m_opcode == Js::OpCode::LdFld || instr->m_opcode == Js::OpCode::ScopedLdFld)
4881+
if ((instr->GetSrc1() && instr->GetSrc1()->IsSymOpnd() && instr->m_opcode == Js::OpCode::ProfiledLdFld) || instr->m_opcode == Js::OpCode::LdFld || instr->m_opcode == Js::OpCode::ScopedLdFld)
48824882
{
48834883
IR::Opnd * opnd = instr->GetSrc1();
48844884
Sym *sym = opnd->AsSymOpnd()->m_sym;

lib/Backend/amd64/LowererMDArch.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,29 +926,36 @@ LowererMDArch::LowerCall(IR::Instr * callInstr, uint32 argCount)
926926
#define _V_ARG_INDEX(index) _vindex[(index) - 1]
927927
#endif
928928

929+
// xplat NOTE: Lower often loads "known args" with LoadHelperArgument() and
930+
// variadic JS runtime args with LowerCallArgs(). So the full args length is
931+
// this->helperCallArgsCount + argCount
932+
// "argCount > 0" indicates we have variadic JS runtime args and needs to
933+
// manually home registers on xplat.
934+
const bool shouldHomeParams = argCount > 0;
935+
929936
while (argsLeft > 0)
930937
{
931938
IR::Opnd * helperSrc = this->helperCallArgs[this->helperCallArgsCount - argsLeft];
932939
uint16 index = _V_ARG_INDEX(argsLeft);
933940
StackSym * helperSym = m_func->m_symTable->GetArgSlotSym(index);
934941
helperSym->m_type = ExtendHelperArg(helperSrc->GetType());
935942
Lowerer::InsertMove(
936-
this->GetArgSlotOpnd(index, helperSym, /*isHelper*/true),
943+
this->GetArgSlotOpnd(index, helperSym, /*isHelper*/!shouldHomeParams),
937944
helperSrc,
938945
callInstr);
939946
--argsLeft;
940947
}
941948

942949
#ifndef _WIN32
943950
// Manually home args
944-
if (argCount > 0)
951+
if (shouldHomeParams)
945952
{
946953
static const RegNum s_argRegs[IntArgRegsCount] = {
947954
#define REG_INT_ARG(Index, Name) Reg ## Name,
948955
#include "RegList.h"
949956
};
950957

951-
const int callArgCount = static_cast<int>(argCount) + this->helperCallArgsCount;
958+
const int callArgCount = this->helperCallArgsCount + static_cast<int>(argCount);
952959
const int argRegs = min(callArgCount, static_cast<int>(IntArgRegsCount));
953960
for (int i = argRegs - 1; i >= 0; i--)
954961
{

0 commit comments

Comments
 (0)