@@ -3901,7 +3901,7 @@ Lowerer::GenerateProfiledNewScArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteI
39013901 }
39023902 GenerateArrayInfoIsNativeIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
39033903 Assert(Js::JavascriptNativeIntArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex());
3904- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed);
3904+ headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed);
39053905 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
39063906
39073907 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -3919,7 +3919,7 @@ Lowerer::GenerateProfiledNewScArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteI
39193919 }
39203920 GenerateArrayInfoIsNativeFloatAndNotIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
39213921 Assert(Js::JavascriptNativeFloatArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex());
3922- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed);
3922+ headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed);
39233923 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
39243924
39253925 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -3942,7 +3942,7 @@ Lowerer::GenerateProfiledNewScArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteI
39423942 return;
39433943 }
39443944 uint const offsetStart = sizeof(Js::SparseArraySegmentBase);
3945- headOpnd = GenerateArrayAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed);
3945+ headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed);
39463946 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
39473947 for (; i < size; i++)
39483948 {
@@ -3997,7 +3997,22 @@ IR::JnHelperMethod GetArrayAllocMemHelper<Js::JavascriptNativeFloatArray>()
39973997
39983998template <typename ArrayType>
39993999IR::RegOpnd *
4000- Lowerer::GenerateArrayAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed, bool isArrayObjCtor /* = false */)
4000+ Lowerer::GenerateArrayLiteralsAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed)
4001+ {
4002+ return GenerateArrayAllocHelper<ArrayType>(instr, psize, arrayInfo, pIsHeadSegmentZeroed, false /* isArrayObjCtor */, false /* isNoArgs */);
4003+ }
4004+
4005+ template <typename ArrayType>
4006+ IR::RegOpnd *
4007+ Lowerer::GenerateArrayObjectsAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed, bool isNoArgs)
4008+ {
4009+ return GenerateArrayAllocHelper<ArrayType>(instr, psize, arrayInfo, pIsHeadSegmentZeroed, true /* isArrayObjCtor */, isNoArgs);
4010+ }
4011+
4012+
4013+ template <typename ArrayType>
4014+ IR::RegOpnd *
4015+ Lowerer::GenerateArrayAllocHelper(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed, bool isArrayObjCtor, bool isNoArgs)
40014016{
40024017 Func * func = this->m_func;
40034018 IR::RegOpnd * dstOpnd = instr->GetDst()->AsRegOpnd();
@@ -4016,7 +4031,8 @@ Lowerer::GenerateArrayAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteI
40164031 {
40174032 if (isArrayObjCtor)
40184033 {
4019- arrayAllocSize = Js::JavascriptArray::DetermineAllocationSizeForArrayObjects<ArrayType, 0>(count, nullptr, &alignedHeadSegmentSize);
4034+ uint32 allocCount = isNoArgs ? Js::SparseArraySegmentBase::SMALL_CHUNK_SIZE : count;
4035+ arrayAllocSize = Js::JavascriptArray::DetermineAllocationSizeForArrayObjects<ArrayType, 0>(allocCount, nullptr, &alignedHeadSegmentSize);
40204036 }
40214037 else
40224038 {
@@ -4205,7 +4221,7 @@ Lowerer::GenerateArrayAlloc(IR::Instr *instr, IR::Opnd * arrayLenOpnd, Js::Array
42054221
42064222
42074223void
4208- Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteInfo * arrayInfo, intptr_t arrayInfoAddr, intptr_t weakFuncRef, uint32 length, IR::LabelInstr* labelDone)
4224+ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteInfo * arrayInfo, intptr_t arrayInfoAddr, intptr_t weakFuncRef, uint32 length, IR::LabelInstr* labelDone, bool isNoArgs )
42094225{
42104226 if (PHASE_OFF(Js::ArrayCtorFastPathPhase, m_func))
42114227 {
@@ -4223,7 +4239,7 @@ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
42234239 {
42244240 GenerateArrayInfoIsNativeIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
42254241 Assert(Js::JavascriptNativeIntArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex());
4226- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed, true );
4242+ headOpnd = GenerateArrayObjectsAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed, isNoArgs );
42274243
42284244 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex(), IR::IntConstOpnd::New(profileId, TyUint16, func, true), instr, isZeroed);
42294245 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -4237,7 +4253,7 @@ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
42374253 {
42384254 GenerateArrayInfoIsNativeFloatAndNotIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
42394255 Assert(Js::JavascriptNativeFloatArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex());
4240- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed, true );
4256+ headOpnd = GenerateArrayObjectsAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed, isNoArgs );
42414257
42424258 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex(), IR::IntConstOpnd::New(profileId, TyUint16, func, true), instr, isZeroed);
42434259 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -4256,7 +4272,7 @@ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
42564272 else
42574273 {
42584274 uint const offsetStart = sizeof(Js::SparseArraySegmentBase);
4259- headOpnd = GenerateArrayAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed, true );
4275+ headOpnd = GenerateArrayObjectsAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed, isNoArgs );
42604276 for (uint i = 0; i < size; i++)
42614277 {
42624278 GenerateMemInit(
@@ -4407,7 +4423,7 @@ Lowerer::GenerateProfiledNewScIntArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
44074423 bool isHeadSegmentZeroed;
44084424 IR::RegOpnd * dstOpnd = instr->GetDst()->AsRegOpnd();
44094425 Assert(Js::JavascriptNativeIntArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex());
4410- IR::RegOpnd * headOpnd = GenerateArrayAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
4426+ IR::RegOpnd * headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
44114427 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
44124428
44134429 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicMisc, m_func), instr, isHeadSegmentZeroed);
@@ -4479,7 +4495,7 @@ Lowerer::GenerateProfiledNewScFloatArrayFastPath(IR::Instr *instr, Js::ArrayCall
44794495 bool isHeadSegmentZeroed;
44804496 IR::RegOpnd * dstOpnd = instr->GetDst()->AsRegOpnd();
44814497 Assert(Js::JavascriptNativeFloatArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex());
4482- IR::RegOpnd * headOpnd = GenerateArrayAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
4498+ IR::RegOpnd * headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
44834499 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
44844500
44854501 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isHeadSegmentZeroed);
@@ -5478,7 +5494,7 @@ Lowerer::LowerNewScObjArray(IR::Instr *newObjInstr)
54785494 int32 length = linkSym->GetIntConstValue();
54795495 if (length >= 0 && length <= upperBoundValue)
54805496 {
5481- GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, (uint32)length, labelDone);
5497+ GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, (uint32)length, labelDone, false );
54825498 }
54835499 else
54845500 {
@@ -5596,7 +5612,7 @@ Lowerer::LowerNewScObjArrayNoArg(IR::Instr *newObjInstr)
55965612 }
55975613
55985614 IR::LabelInstr *labelDone = IR::LabelInstr::New(Js::OpCode::Label, func);
5599- GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, 0, labelDone);
5615+ GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, 0, labelDone, true );
56005616 newObjInstr->InsertAfter(labelDone);
56015617
56025618 m_lowererMD.LoadHelperArgument(newObjInstr, IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, func));
0 commit comments