Skip to content

Commit 39dce94

Browse files
author
Jianchun Xu
committed
JIT: (xplat) address CR issues
also merge to latest.
1 parent 33d0943 commit 39dce94

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
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
{

lib/Runtime/Language/Arguments.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@
2727

2828
inline Js::Var* _get_va(void* addrOfReturnAddress, int n)
2929
{
30+
// All args are right after ReturnAddress by custom calling convention
3031
Js::Var* pArgs = reinterpret_cast<Js::Var*>(addrOfReturnAddress) + 1;
3132
return pArgs + n;
3233
}
3334

3435
inline int _count_args(Js::CallInfo callInfo)
3536
{
36-
return 2; // for typical JsMethod with 2 known args "function, callInfo"
37+
// This is to support typical runtime "ARGUMENTS(args, callInfo)" usage.
38+
// Only "callInfo" listed, but we have 2 known args "function, callInfo".
39+
return 2;
3740
}
3841
template <class T1>
3942
inline int _count_args(const T1&, Js::CallInfo callInfo)

0 commit comments

Comments
 (0)