summaryrefslogtreecommitdiff
path: root/src/jit/ssarenamestate.cpp
diff options
context:
space:
mode:
authorMike Danes <onemihaid@hotmail.com>2017-11-13 22:36:50 +0200
committerMike Danes <onemihaid@hotmail.com>2018-07-19 07:29:44 +0300
commit72a1d0ee7c9f5989edc9f449df24b5b87a5844ce (patch)
treed0ee59011a0f538a9a129289c7285fadc4d51fd0 /src/jit/ssarenamestate.cpp
parent624f72d55a92e49aef3c3cd6e69150fa3b085fac (diff)
downloadcoreclr-72a1d0ee7c9f5989edc9f449df24b5b87a5844ce.tar.gz
coreclr-72a1d0ee7c9f5989edc9f449df24b5b87a5844ce.tar.bz2
coreclr-72a1d0ee7c9f5989edc9f449df24b5b87a5844ce.zip
Eliminate duplicate SSA number bookkeeping
During SSA construction SsaRenameState keeps a definition count for each variable in an array. But each variable has a lvPerSsaData array that does almost the same thing, count the definitions. "Almost" because lvPerSsaData is a JitExpandArray that tracks only the array size and not the number of elements actually stored in the array. Replace JitExpandArray with purposely designed "array" that is in charge with allocating new SSA numbers and handles their intricacies - RESERVED_SSA_NUM, UNINIT_SSA_NUM and FIRST_SSA_NUM. This also allows the removal of the allocator from the array. Allocating new SSA numbers happens only during SSA construction and it's reasonable to pass the allocator to AllocSsaNum rather than increasing the size of PerSsaArray and LclVarDsc.
Diffstat (limited to 'src/jit/ssarenamestate.cpp')
-rw-r--r--src/jit/ssarenamestate.cpp57
1 files changed, 1 insertions, 56 deletions
diff --git a/src/jit/ssarenamestate.cpp b/src/jit/ssarenamestate.cpp
index 9ec0770199..71dda0d269 100644
--- a/src/jit/ssarenamestate.cpp
+++ b/src/jit/ssarenamestate.cpp
@@ -2,23 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-// ==++==
-//
-
-//
-
-//
-// ==--==
-
-/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-XX XX
-XX SSA XX
-XX XX
-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-*/
-
#include "jitpch.h"
#include "ssaconfig.h"
#include "ssarenamestate.h"
@@ -29,11 +12,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* @params alloc The allocator class used to allocate jitstd data.
*/
SsaRenameState::SsaRenameState(CompAllocator alloc, unsigned lvaCount, bool byrefStatesMatchGcHeapStates)
- : counts(nullptr)
- , stacks(nullptr)
+ : stacks(nullptr)
, definedLocs(alloc)
, memoryStack(alloc)
- , memoryCount(0)
, lvaCount(lvaCount)
, m_alloc(alloc)
, byrefStatesMatchGcHeapStates(byrefStatesMatchGcHeapStates)
@@ -41,23 +22,6 @@ SsaRenameState::SsaRenameState(CompAllocator alloc, unsigned lvaCount, bool byre
}
/**
- * Allocates memory to hold SSA variable def counts,
- * if not allocated already.
- *
- */
-void SsaRenameState::EnsureCounts()
-{
- if (counts == nullptr)
- {
- counts = m_alloc.allocate<unsigned>(lvaCount);
- for (unsigned i = 0; i < lvaCount; ++i)
- {
- counts[i] = SsaConfig::FIRST_SSA_NUM;
- }
- }
-}
-
-/**
* Allocates memory for holding pointers to lcl's stacks,
* if not allocated already.
*
@@ -75,25 +39,6 @@ void SsaRenameState::EnsureStacks()
}
/**
- * Returns a SSA count number for a local variable and does a post increment.
- *
- * If there is no counter for the local yet, initializes it with the default value
- * else, returns the count with a post increment, so the next def gets a new count.
- *
- * @params lclNum The local variable def for which a count has to be returned.
- * @return the variable name for the current definition.
- *
- */
-unsigned SsaRenameState::CountForDef(unsigned lclNum)
-{
- EnsureCounts();
- unsigned count = counts[lclNum];
- counts[lclNum]++;
- DBG_SSA_JITDUMP("Incrementing counter = %d by 1 for V%02u.\n", count, lclNum);
- return count;
-}
-
-/**
* Returns a SSA count number for a local variable from top of the stack.
*
* @params lclNum The local variable def for which a count has to be returned.