Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ ValueNumStore::Chunk::Chunk(CompAllocator alloc, ValueNum* pNextBaseVN, var_type
, m_baseVN(*pNextBaseVN)
, m_typ(typ)
, m_attribs(attribs)
, m_funcAppElemSize(0)
{
// Allocate "m_defs" here, according to the typ/attribs pair.
switch (attribs)
Expand Down Expand Up @@ -1747,20 +1748,25 @@ ValueNumStore::Chunk::Chunk(CompAllocator alloc, ValueNum* pNextBaseVN, var_type
break;

case CEA_Func0:
m_defs = new (alloc) VNFunc[ChunkSize];
m_defs = new (alloc) VNFunc[ChunkSize];
m_funcAppElemSize = sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 0;
break;

case CEA_Func1:
m_defs = alloc.allocate<char>((sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 1) * ChunkSize);
m_funcAppElemSize = sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 1;
m_defs = alloc.allocate<char>(m_funcAppElemSize * ChunkSize);
break;
case CEA_Func2:
m_defs = alloc.allocate<char>((sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 2) * ChunkSize);
m_funcAppElemSize = sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 2;
m_defs = alloc.allocate<char>(m_funcAppElemSize * ChunkSize);
break;
case CEA_Func3:
m_defs = alloc.allocate<char>((sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 3) * ChunkSize);
m_funcAppElemSize = sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 3;
m_defs = alloc.allocate<char>(m_funcAppElemSize * ChunkSize);
break;
case CEA_Func4:
m_defs = alloc.allocate<char>((sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 4) * ChunkSize);
m_funcAppElemSize = sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * 4;
m_defs = alloc.allocate<char>(m_funcAppElemSize * ChunkSize);
break;
default:
unreached();
Expand Down
9 changes: 6 additions & 3 deletions src/coreclr/jit/valuenum.h
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,10 @@ class ValueNumStore
var_types m_typ;
ChunkExtraAttribs m_attribs;

// Precomputed element size for func-app chunks (sizeof(VNFunc) + sizeof(ValueNum) * arity).
// Zero for non-func chunks.
unsigned m_funcAppElemSize;

// Initialize a chunk, starting at "*baseVN", for the given "typ", and "attribs", using "alloc" for allocations.
// (Increments "*baseVN" by ChunkSize.)
Chunk(CompAllocator alloc, ValueNum* baseVN, var_types typ, ChunkExtraAttribs attribs);
Expand All @@ -1556,9 +1560,8 @@ class ValueNumStore
{
assert((m_attribs >= CEA_Func0) && (m_attribs <= CEA_Func4));
assert(numArgs == (unsigned)(m_attribs - CEA_Func0));
static_assert(sizeof(VNDefFuncAppFlexible) == sizeof(VNFunc));
return reinterpret_cast<VNDefFuncAppFlexible*>(
(char*)m_defs + offsetWithinChunk * (sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * numArgs));
assert(m_funcAppElemSize == sizeof(VNDefFuncAppFlexible) + sizeof(ValueNum) * numArgs);
return reinterpret_cast<VNDefFuncAppFlexible*>((char*)m_defs + offsetWithinChunk * m_funcAppElemSize);
}

template <int N>
Expand Down
Loading