@@ -3930,7 +3930,7 @@ Lowerer::GenerateProfiledNewScArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteI
39303930 }
39313931 GenerateArrayInfoIsNativeIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
39323932 Assert(Js::JavascriptNativeIntArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex());
3933- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed);
3933+ headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed);
39343934 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
39353935
39363936 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -3948,7 +3948,7 @@ Lowerer::GenerateProfiledNewScArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteI
39483948 }
39493949 GenerateArrayInfoIsNativeFloatAndNotIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
39503950 Assert(Js::JavascriptNativeFloatArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex());
3951- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed);
3951+ headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed);
39523952 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
39533953
39543954 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -3971,7 +3971,7 @@ Lowerer::GenerateProfiledNewScArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteI
39713971 return;
39723972 }
39733973 uint const offsetStart = sizeof(Js::SparseArraySegmentBase);
3974- headOpnd = GenerateArrayAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed);
3974+ headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed);
39753975 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
39763976 for (; i < size; i++)
39773977 {
@@ -4026,7 +4026,22 @@ IR::JnHelperMethod GetArrayAllocMemHelper<Js::JavascriptNativeFloatArray>()
40264026
40274027template <typename ArrayType>
40284028IR::RegOpnd *
4029- Lowerer::GenerateArrayAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed, bool isArrayObjCtor /* = false */)
4029+ Lowerer::GenerateArrayLiteralsAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed)
4030+ {
4031+ return GenerateArrayAllocHelper<ArrayType>(instr, psize, arrayInfo, pIsHeadSegmentZeroed, false /* isArrayObjCtor */, false /* isNoArgs */);
4032+ }
4033+
4034+ template <typename ArrayType>
4035+ IR::RegOpnd *
4036+ Lowerer::GenerateArrayObjectsAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed, bool isNoArgs)
4037+ {
4038+ return GenerateArrayAllocHelper<ArrayType>(instr, psize, arrayInfo, pIsHeadSegmentZeroed, true /* isArrayObjCtor */, isNoArgs);
4039+ }
4040+
4041+
4042+ template <typename ArrayType>
4043+ IR::RegOpnd *
4044+ Lowerer::GenerateArrayAllocHelper(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteInfo * arrayInfo, bool * pIsHeadSegmentZeroed, bool isArrayObjCtor, bool isNoArgs)
40304045{
40314046 Func * func = this->m_func;
40324047 IR::RegOpnd * dstOpnd = instr->GetDst()->AsRegOpnd();
@@ -4045,7 +4060,8 @@ Lowerer::GenerateArrayAlloc(IR::Instr *instr, uint32 * psize, Js::ArrayCallSiteI
40454060 {
40464061 if (isArrayObjCtor)
40474062 {
4048- arrayAllocSize = Js::JavascriptArray::DetermineAllocationSizeForArrayObjects<ArrayType, 0>(count, nullptr, &alignedHeadSegmentSize);
4063+ uint32 allocCount = isNoArgs ? Js::SparseArraySegmentBase::SMALL_CHUNK_SIZE : count;
4064+ arrayAllocSize = Js::JavascriptArray::DetermineAllocationSizeForArrayObjects<ArrayType, 0>(allocCount, nullptr, &alignedHeadSegmentSize);
40494065 }
40504066 else
40514067 {
@@ -4234,7 +4250,7 @@ Lowerer::GenerateArrayAlloc(IR::Instr *instr, IR::Opnd * arrayLenOpnd, Js::Array
42344250
42354251
42364252void
4237- Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteInfo * arrayInfo, intptr_t arrayInfoAddr, intptr_t weakFuncRef, uint32 length, IR::LabelInstr* labelDone)
4253+ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSiteInfo * arrayInfo, intptr_t arrayInfoAddr, intptr_t weakFuncRef, uint32 length, IR::LabelInstr* labelDone, bool isNoArgs )
42384254{
42394255 if (PHASE_OFF(Js::ArrayCtorFastPathPhase, m_func))
42404256 {
@@ -4252,7 +4268,7 @@ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
42524268 {
42534269 GenerateArrayInfoIsNativeIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
42544270 Assert(Js::JavascriptNativeIntArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex());
4255- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed, true );
4271+ headOpnd = GenerateArrayObjectsAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isZeroed, isNoArgs );
42564272
42574273 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex(), IR::IntConstOpnd::New(profileId, TyUint16, func, true), instr, isZeroed);
42584274 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -4266,7 +4282,7 @@ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
42664282 {
42674283 GenerateArrayInfoIsNativeFloatAndNotIntArrayTest(instr, arrayInfo, arrayInfoAddr, helperLabel);
42684284 Assert(Js::JavascriptNativeFloatArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex());
4269- headOpnd = GenerateArrayAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed, true );
4285+ headOpnd = GenerateArrayObjectsAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isZeroed, isNoArgs );
42704286
42714287 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex(), IR::IntConstOpnd::New(profileId, TyUint16, func, true), instr, isZeroed);
42724288 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isZeroed);
@@ -4285,7 +4301,7 @@ Lowerer::GenerateProfiledNewScObjArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
42854301 else
42864302 {
42874303 uint const offsetStart = sizeof(Js::SparseArraySegmentBase);
4288- headOpnd = GenerateArrayAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed, true );
4304+ headOpnd = GenerateArrayObjectsAlloc <Js::JavascriptArray>(instr, &size, arrayInfo, &isZeroed, isNoArgs );
42894305 for (uint i = 0; i < size; i++)
42904306 {
42914307 GenerateMemInit(
@@ -4436,7 +4452,7 @@ Lowerer::GenerateProfiledNewScIntArrayFastPath(IR::Instr *instr, Js::ArrayCallSi
44364452 bool isHeadSegmentZeroed;
44374453 IR::RegOpnd * dstOpnd = instr->GetDst()->AsRegOpnd();
44384454 Assert(Js::JavascriptNativeIntArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeIntArray::GetOffsetOfArrayCallSiteIndex());
4439- IR::RegOpnd * headOpnd = GenerateArrayAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
4455+ IR::RegOpnd * headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeIntArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
44404456 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
44414457
44424458 GenerateMemInit(dstOpnd, Js::JavascriptNativeIntArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicMisc, m_func), instr, isHeadSegmentZeroed);
@@ -4508,7 +4524,7 @@ Lowerer::GenerateProfiledNewScFloatArrayFastPath(IR::Instr *instr, Js::ArrayCall
45084524 bool isHeadSegmentZeroed;
45094525 IR::RegOpnd * dstOpnd = instr->GetDst()->AsRegOpnd();
45104526 Assert(Js::JavascriptNativeFloatArray::GetOffsetOfArrayFlags() + sizeof(uint16) == Js::JavascriptNativeFloatArray::GetOffsetOfArrayCallSiteIndex());
4511- IR::RegOpnd * headOpnd = GenerateArrayAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
4527+ IR::RegOpnd * headOpnd = GenerateArrayLiteralsAlloc <Js::JavascriptNativeFloatArray>(instr, &size, arrayInfo, &isHeadSegmentZeroed);
45124528 const IR::AutoReuseOpnd autoReuseHeadOpnd(headOpnd, func);
45134529
45144530 GenerateMemInit(dstOpnd, Js::JavascriptNativeFloatArray::GetOffsetOfWeakFuncRef(), IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, m_func), instr, isHeadSegmentZeroed);
@@ -5507,7 +5523,7 @@ Lowerer::LowerNewScObjArray(IR::Instr *newObjInstr)
55075523 int32 length = linkSym->GetIntConstValue();
55085524 if (length >= 0 && length <= upperBoundValue)
55095525 {
5510- GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, (uint32)length, labelDone);
5526+ GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, (uint32)length, labelDone, false );
55115527 }
55125528 else
55135529 {
@@ -5625,7 +5641,7 @@ Lowerer::LowerNewScObjArrayNoArg(IR::Instr *newObjInstr)
56255641 }
56265642
56275643 IR::LabelInstr *labelDone = IR::LabelInstr::New(Js::OpCode::Label, func);
5628- GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, 0, labelDone);
5644+ GenerateProfiledNewScObjArrayFastPath(newObjInstr, arrayInfo, arrayInfoAddr, weakFuncRef, 0, labelDone, true );
56295645 newObjInstr->InsertAfter(labelDone);
56305646
56315647 m_lowererMD.LoadHelperArgument(newObjInstr, IR::AddrOpnd::New(weakFuncRef, IR::AddrOpndKindDynamicFunctionBodyWeakRef, func));
0 commit comments