Skip to content

Commit a402cca

Browse files
committed
remove fixup method for those types which not necessary to do fixing up
dump meaningful information for simple type(like int, Var) allocation which is helpful for debugging.
1 parent f3a453d commit a402cca

12 files changed

+56
-115
lines changed

lib/Backend/BailOut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2793,7 +2793,7 @@ void LazyBailOutRecord::Dump(Js::FunctionBody* functionBody)
27932793

27942794
void GlobalBailOutRecordDataTable::Finalize(NativeCodeData::Allocator *allocator, JitArenaAllocator *tempAlloc)
27952795
{
2796-
GlobalBailOutRecordDataRow *newRows = NativeCodeDataNewArrayZ(allocator, GlobalBailOutRecordDataRow, length);
2796+
GlobalBailOutRecordDataRow *newRows = NativeCodeDataNewArrayZNoFixup(allocator, GlobalBailOutRecordDataRow, length);
27972797
memcpy(newRows, globalBailOutRecordDataRows, sizeof(GlobalBailOutRecordDataRow) * length);
27982798
JitAdeleteArray(tempAlloc, length, globalBailOutRecordDataRows);
27992799
globalBailOutRecordDataRows = newRows;

lib/Backend/BailOut.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,6 @@ class BailOutInfo
161161
}
162162
};
163163

164-
struct BVFixedWrapper
165-
{
166-
BVFixed bv;
167-
void Fixup(NativeCodeData::DataChunk* chunkList) {}
168-
};
169-
170164
class BailOutRecord
171165
{
172166
public:
@@ -284,7 +278,6 @@ class BailOutRecord
284278
{
285279
Js::RegSlot regSlot;
286280
uint initFldCount;
287-
void Fixup(NativeCodeData::DataChunk* chunkList) {}
288281
};
289282

290283
struct ArgOutOffsetInfo
@@ -459,8 +452,6 @@ struct GlobalBailOutRecordDataRow
459452
unsigned isSimd128U4 : 1;
460453
unsigned isSimd128U8 : 1;
461454
unsigned isSimd128U16 : 1;
462-
463-
void Fixup(NativeCodeData::DataChunk* chunkList) {}
464455
};
465456

466457
struct GlobalBailOutRecordDataTable

lib/Backend/Encoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ Encoder::Encode()
463463

464464
// The extra room for sizeof(Js::TypePropertyGuardEntry) allocated by HeapNewPlus will be used for the terminating invalid propertyId.
465465
// Review (jedmiad): Skip zeroing? This is heap allocated so there shouldn't be any false recycler references.
466-
Js::TypeGuardTransferEntry* typeGuardTransferRecord = NativeCodeDataNewPlusZ(typeGuardTransferSize, m_func->GetNativeCodeDataAllocator(), Js::TypeGuardTransferEntry);
466+
Js::TypeGuardTransferEntry* typeGuardTransferRecord = NativeCodeDataNewPlusZNoFixup(typeGuardTransferSize, m_func->GetNativeCodeDataAllocator(), Js::TypeGuardTransferEntry);
467467

468468
Func* func = this->m_func;
469469

lib/Backend/Func.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ Func::GetOrCreateSingleTypeGuard(intptr_t typeAddr)
12221222
if (!this->singleTypeGuards->TryGetValue(typeAddr, &guard))
12231223
{
12241224
// Property guards are allocated by NativeCodeData::Allocator so that their lifetime extends as long as the EntryPointInfo is alive.
1225-
guard = NativeCodeDataNew(GetNativeCodeDataAllocator(), Js::JitTypePropertyGuard, typeAddr, this->indexedPropertyGuardCount++);
1225+
guard = NativeCodeDataNewNoFixup(GetNativeCodeDataAllocator(), Js::JitTypePropertyGuard, typeAddr, this->indexedPropertyGuardCount++);
12261226
this->singleTypeGuards->Add(typeAddr, guard);
12271227
}
12281228
else

lib/Backend/InlineeFrameInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ struct InlineeFrameRecord
100100
static InlineeFrameRecord* New(NativeCodeData::Allocator* alloc, uint argCount, uint constantCount, intptr_t functionBodyAddr, InlineeFrameInfo* frameInfo)
101101
{
102102
InlineeFrameRecord* record = NativeCodeDataNewZ(alloc, InlineeFrameRecord, argCount, (Js::FunctionBody*)functionBodyAddr, frameInfo);
103-
record->argOffsets = NativeCodeDataNewArray(alloc, int, argCount);
104-
record->constants = NativeCodeDataNewArray(alloc, Js::Var, constantCount);
103+
record->argOffsets = (int*)NativeCodeDataNewArrayNoFixup(alloc, IntType<DataDesc_InlineeFrameRecord_ArgOffsets>, argCount);
104+
record->constants = (Js::Var*)NativeCodeDataNewArrayNoFixup(alloc, VarType<DataDesc_InlineeFrameRecord_Constants>, constantCount);
105105
DebugOnly(record->constantCount = constantCount);
106106
return record;
107107
}

lib/Backend/LinearScan.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,11 +1676,11 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
16761676
{
16771677
Assert(startCallCount != 0);
16781678
uint argOutSlot = 0;
1679-
uint * startCallOutParamCounts = NativeCodeDataNewArray(allocator, uint, startCallCount);
1679+
uint * startCallOutParamCounts = (uint*)NativeCodeDataNewArrayNoFixup(allocator, UIntType<DataDesc_ArgOutOffsetInfo_StartCallOutParamCounts>, startCallCount);
16801680
#ifdef _M_IX86
16811681
uint * startCallArgRestoreAdjustCounts = NativeCodeDataNewArray(allocator, uint, startCallCount);
16821682
#endif
1683-
NativeCodeData::AllocatorT<BVFixedWrapper>* allocatorT = (NativeCodeData::AllocatorT<BVFixedWrapper>*)allocator;
1683+
NativeCodeData::AllocatorNoFixup<BVFixed>* allocatorT = (NativeCodeData::AllocatorNoFixup<BVFixed>*)allocator;
16841684
BVFixed * argOutFloat64Syms = BVFixed::New(bailOutInfo->totalOutParamCount, allocatorT);
16851685
BVFixed * argOutLosslessInt32Syms = BVFixed::New(bailOutInfo->totalOutParamCount, allocatorT);
16861686
// SIMD_JS
@@ -1695,7 +1695,7 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
16951695
BVFixed * argOutSimd128B8Syms = BVFixed::New(bailOutInfo->totalOutParamCount, allocatorT);
16961696
BVFixed * argOutSimd128B16Syms = BVFixed::New(bailOutInfo->totalOutParamCount, allocatorT);
16971697

1698-
int* outParamOffsets = bailOutInfo->outParamOffsets = NativeCodeDataNewArrayZ(allocator, int, bailOutInfo->totalOutParamCount);
1698+
int* outParamOffsets = bailOutInfo->outParamOffsets = (int*)NativeCodeDataNewArrayZNoFixup(allocator, IntType<DataDesc_BailoutInfo_CotalOutParamCount>, bailOutInfo->totalOutParamCount);
16991699
#ifdef _M_IX86
17001700
int currentStackOffset = 0;
17011701
bailOutInfo->outParamFrameAdjustArgSlot = JitAnew(this->func->m_alloc, BVSparse<JitArenaAllocator>, this->func->m_alloc);
@@ -2183,7 +2183,7 @@ LinearScan::FillStackLiteralBailOutRecord(IR::Instr * instr, BailOutInfo * bailO
21832183
if (stackLiteralBailOutRecordCount)
21842184
{
21852185
funcBailOutData[i].bailOutRecord->stackLiteralBailOutRecord =
2186-
NativeCodeDataNewArray(allocator, BailOutRecord::StackLiteralBailOutRecord, stackLiteralBailOutRecordCount);
2186+
NativeCodeDataNewArrayNoFixup(allocator, BailOutRecord::StackLiteralBailOutRecord, stackLiteralBailOutRecordCount);
21872187
// reset the count so we can track how much we have filled below
21882188
funcBailOutData[i].bailOutRecord->stackLiteralBailOutRecordCount = 0;
21892189
}

lib/Backend/Lower.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7164,7 +7164,8 @@ Lowerer::CreateEquivalentTypeGuardAndLinkToGuardedProperties(JITType* type, IR::
71647164
NEXT_BITSET_IN_SPARSEBV;
71657165

71667166
cache->record.propertyCount = propIdCount;
7167-
cache->record.properties = NativeCodeDataNewArray(this->m_func->GetNativeCodeDataAllocator(), Js::EquivalentPropertyEntry, propIdCount);
7167+
// Js::EquivalentPropertyEntry does not contain pointer, no need to fixup
7168+
cache->record.properties = NativeCodeDataNewArrayNoFixup(this->m_func->GetNativeCodeDataAllocator(), Js::EquivalentPropertyEntry, propIdCount);
71687169

71697170
memcpy(cache->record.properties, properties, propIdCount * sizeof(Js::EquivalentPropertyEntry));
71707171

lib/Backend/LowerMDShared.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6260,7 +6260,7 @@ LowererMD::EmitLoadFloatCommon(IR::Opnd *dst, IR::Opnd *src, IR::Instr *insertIn
62606260
Assert(regOpnd->m_sym->m_isSingleDef);
62616261
Js::Var value = regOpnd->m_sym->GetFloatConstValueAsVar_PostGlobOpt();
62626262
#if FLOATVAR
6263-
double *pDouble = NativeCodeDataNew(this->m_func->GetNativeCodeDataAllocator(), double);
6263+
double *pDouble = (double*)NativeCodeDataNewNoFixup(this->m_func->GetNativeCodeDataAllocator(), DoubleType<DataDesc_LowererMD_EmitLoadFloatCommon_Double>);
62646264
AnalysisAssert(pDouble);
62656265
*pDouble = Js::JavascriptNumber::GetValue(value);
62666266
IR::MemRefOpnd *memRef = IR::MemRefOpnd::New((BYTE*)pDouble, TyFloat64, this->m_func, IR::AddrOpndKindDynamicDoubleRef);
@@ -7052,12 +7052,12 @@ LowererMD::LoadFloatValue(IR::Opnd * opndDst, double value, IR::Instr * instrIns
70527052
bool isFloat64 = opndDst->IsFloat64();
70537053
if (isFloat64)
70547054
{
7055-
pValue = NativeCodeDataNew(instrInsert->m_func->GetNativeCodeDataAllocator(), double, value);
7055+
pValue = NativeCodeDataNewNoFixup(instrInsert->m_func->GetNativeCodeDataAllocator(), DoubleType<DataDesc_LowererMD_LoadFloatValue_Double>, value);
70567056
}
70577057
else
70587058
{
70597059
Assert(opndDst->IsFloat32());
7060-
pValue = NativeCodeDataNew(instrInsert->m_func->GetNativeCodeDataAllocator(), float, (float)value);
7060+
pValue = (float*)NativeCodeDataNewNoFixup(instrInsert->m_func->GetNativeCodeDataAllocator(), FloatType<DataDesc_LowererMD_LoadFloatValue_Float>, (float)value);
70617061
}
70627062

70637063
if (!instrInsert->m_func->IsOOPJIT())

lib/Backend/LowerMDSharedSimd128.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ IR::Instr* LowererMD::Simd128LoadConst(IR::Instr* instr)
373373
AsmJsSIMDValue value = instr->GetSrc1()->AsSimd128ConstOpnd()->m_value;
374374

375375
// MOVUPS dst, [const]
376-
AsmJsSIMDValue *pValue = NativeCodeDataNew(instr->m_func->GetNativeCodeDataAllocator(), AsmJsSIMDValue);
376+
AsmJsSIMDValue *pValue = NativeCodeDataNewNoFixup(instr->m_func->GetNativeCodeDataAllocator(), AsmJsSIMDValue);
377377
pValue->SetValue(value);
378378
IR::Opnd * opnd = IR::MemRefOpnd::New((void *)pValue, instr->GetDst()->GetType(), instr->m_func);
379379
instr->ReplaceSrc1(opnd);

lib/Backend/NativeCodeData.h

Lines changed: 41 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#define NativeCodeDataNewArrayZ(alloc, T, count) AllocatorNewArrayZ(NativeCodeData::AllocatorT<NativeCodeData::Array<T>>, alloc, T, count)
1111
#define NativeCodeDataNewPlusZ(size, alloc, T, ...) AllocatorNewPlusZ(NativeCodeData::AllocatorT<T>, alloc, size, T, __VA_ARGS__)
1212

13-
1413
#define NativeCodeDataNewNoFixup(alloc, T, ...) AllocatorNew(NativeCodeData::AllocatorNoFixup<T>, alloc, T, __VA_ARGS__)
1514
#define NativeCodeDataNewZNoFixup(alloc, T, ...) AllocatorNewZ(NativeCodeData::AllocatorNoFixup<T>, alloc, T, __VA_ARGS__)
1615
#define NativeCodeDataNewArrayNoFixup(alloc, T, count) AllocatorNewArray(NativeCodeData::AllocatorNoFixup<NativeCodeData::Array<T>>, alloc, T, count)
1716
#define NativeCodeDataNewArrayZNoFixup(alloc, T, count) AllocatorNewArrayZ(NativeCodeData::AllocatorNoFixup<NativeCodeData::Array<T>>, alloc, T, count)
17+
#define NativeCodeDataNewPlusZNoFixup(size, alloc, T, ...) AllocatorNewPlusZ(NativeCodeData::AllocatorNoFixup<T>, alloc, size, T, __VA_ARGS__)
1818

1919
#define FixupNativeDataPointer(field, chunkList) NativeCodeData::AddFixupEntry(this->field, &this->field, this, chunkList)
2020

@@ -193,91 +193,58 @@ class NativeCodeData
193193
~NativeCodeData();
194194
};
195195

196-
#if DBG
197-
template<> void NativeCodeData::AllocatorT<double>::Fixup(void* pThis, NativeCodeData::DataChunk* chunkList){}
198-
template<> void NativeCodeData::AllocatorT<float>::Fixup(void* pThis, NativeCodeData::DataChunk* chunkList){}
199-
template<> void NativeCodeData::AllocatorT<AsmJsSIMDValue>::Fixup(void* pThis, NativeCodeData::DataChunk* chunkList){}
200-
template<> void NativeCodeData::AllocatorT<int>::Fixup(void* pThis, NativeCodeData::DataChunk* chunkList) {}
201-
template<> void NativeCodeData::AllocatorT<uint>::Fixup(void* pThis, NativeCodeData::DataChunk* chunkList) {}
202-
#else
203-
template<>
204-
char*
205-
NativeCodeData::AllocatorT<double>::Alloc(size_t requestedBytes)
206-
{
207-
return __super::Alloc(requestedBytes);
208-
}
209-
template<>
210-
char*
211-
NativeCodeData::AllocatorT<double>::AllocZero(size_t requestedBytes)
212-
{
213-
return __super::AllocZero(requestedBytes);
214-
}
215-
template<>
216-
char*
217-
NativeCodeData::AllocatorT<float>::Alloc(size_t requestedBytes)
218-
{
219-
return __super::Alloc(requestedBytes);
220-
}
221-
template<>
222-
char*
223-
NativeCodeData::AllocatorT<float>::AllocZero(size_t requestedBytes)
224-
{
225-
return __super::AllocZero(requestedBytes);
226-
}
227-
template<>
228-
char*
229-
NativeCodeData::AllocatorT<AsmJsSIMDValue>::Alloc(size_t requestedBytes)
230-
{
231-
return __super::Alloc(requestedBytes);
232-
}
233-
template<>
234-
char*
235-
NativeCodeData::AllocatorT<AsmJsSIMDValue>::AllocZero(size_t requestedBytes)
236-
{
237-
return __super::AllocZero(requestedBytes);
238-
}
196+
char DataDesc_None[] = "";
197+
char DataDesc_InlineeFrameRecord_ArgOffsets[] = "";
198+
char DataDesc_InlineeFrameRecord_Constants[] = "";
199+
char DataDesc_BailoutInfo_CotalOutParamCount[] = "";
200+
char DataDesc_ArgOutOffsetInfo_StartCallOutParamCounts[] = "";
201+
char DataDesc_LowererMD_LoadFloatValue_Float[] = "";
202+
char DataDesc_LowererMD_LoadFloatValue_Double[] = "";
203+
char DataDesc_LowererMD_EmitLoadFloatCommon_Double[] = "";
204+
205+
template<char const *desc = DataDesc_None>
206+
struct IntType
207+
{
208+
int data;
209+
};
239210

240-
template<>
241-
char*
242-
NativeCodeData::AllocatorT<int>::Alloc(size_t requestedBytes)
211+
template<char const *desc = DataDesc_None>
212+
struct UIntType
243213
{
244-
return __super::Alloc(requestedBytes);
245-
}
246-
template<>
247-
char*
248-
NativeCodeData::AllocatorT<int>::AllocZero(size_t requestedBytes)
249-
{
250-
return __super::AllocZero(requestedBytes);
251-
}
214+
uint data;
215+
};
252216

253-
template<>
254-
char*
255-
NativeCodeData::AllocatorT<uint>::Alloc(size_t requestedBytes)
217+
template<char const *desc = DataDesc_None>
218+
struct FloatType
256219
{
257-
return __super::Alloc(requestedBytes);
258-
}
259-
template<>
260-
char*
261-
NativeCodeData::AllocatorT<uint>::AllocZero(size_t requestedBytes)
262-
{
263-
return __super::AllocZero(requestedBytes);
264-
}
265-
#endif
220+
FloatType(float val) :data(val) {}
221+
float data;
222+
};
266223

267-
template<> void NativeCodeData::Array<int>::Fixup(NativeCodeData::DataChunk* chunkList)
224+
template<char const *desc = DataDesc_None>
225+
struct DoubleType
268226
{
269-
}
227+
DoubleType() {}
228+
DoubleType(double val) :data(val) {}
229+
double data;
230+
};
270231

271-
template<> void NativeCodeData::Array<unsigned int>::Fixup(NativeCodeData::DataChunk* chunkList)
232+
template<char const *desc = DataDesc_None>
233+
struct VarType
272234
{
273-
}
274-
275-
template<> void NativeCodeData::Array<Js::Var>::Fixup(NativeCodeData::DataChunk* chunkList)
235+
Js::Var data;
236+
void Fixup(NativeCodeData::DataChunk* chunkList)
237+
{
238+
AssertMsg(false, "Please specialize Fixup method for this Var type or use no-fixup allocator");
239+
}
240+
};
241+
template<>
242+
void VarType<DataDesc_InlineeFrameRecord_Constants>::Fixup(NativeCodeData::DataChunk* chunkList)
276243
{
244+
AssertMsg(false, "InlineeFrameRecord::constants contains Var from main process, should not fixup");
277245
}
278246

279247
struct GlobalBailOutRecordDataTable;
280-
281248
template<> void NativeCodeData::Array<GlobalBailOutRecordDataTable *>::Fixup(NativeCodeData::DataChunk* chunkList)
282249
{
283250
NativeCodeData::AddFixupEntryForPointerArray(this, chunkList);

lib/Runtime/Base/FunctionBody.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ namespace Js
8787
void SetValue(intptr_t value) { Assert(value != 0); this->value = value; }
8888
intptr_t const* GetAddressOfValue() { return &this->value; }
8989
void Invalidate() { this->value = 0; }
90-
void Fixup(NativeCodeData::DataChunk* chunkList)
91-
{
92-
}
9390
};
9491

9592
class PropertyGuardValidator
@@ -109,10 +106,6 @@ namespace Js
109106
Js::PropertyGuard(value), index(index) {}
110107

111108
int GetIndex() const { return this->index; }
112-
void Fixup(NativeCodeData::DataChunk* chunkList)
113-
{
114-
__super::Fixup(chunkList);
115-
}
116109
};
117110

118111
class JitTypePropertyGuard : public Js::JitIndexedPropertyGuard
@@ -123,10 +116,6 @@ namespace Js
123116

124117
intptr_t GetTypeAddr() const { return this->GetValue(); }
125118

126-
void Fixup(NativeCodeData::DataChunk* chunkList)
127-
{
128-
__super::Fixup(chunkList);
129-
}
130119
};
131120

132121
struct TypeGuardTransferEntry
@@ -135,12 +124,6 @@ namespace Js
135124
JitIndexedPropertyGuard* guards[0];
136125

137126
TypeGuardTransferEntry(): propertyId(Js::Constants::NoProperty) {}
138-
139-
void Fixup(NativeCodeData::DataChunk* chunkList)
140-
{
141-
// OOP JIT does not use this data structure to transfer the Guards
142-
Assert(false);
143-
}
144127
};
145128

146129
class FakePropertyGuardWeakReference: public RecyclerWeakReference<Js::PropertyGuard>

lib/Runtime/Types/TypeHandler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ namespace Js
3939
Js::PropertyIndex slotIndex;
4040
bool isAuxSlot;
4141
bool mustBeWritable;
42-
void Fixup(NativeCodeData::DataChunk* chunkList) {}
4342
};
4443

4544
struct TypeEquivalenceRecord

0 commit comments

Comments
 (0)