diff options
Diffstat (limited to 'src/jit/objectalloc.h')
-rw-r--r-- | src/jit/objectalloc.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/jit/objectalloc.h b/src/jit/objectalloc.h new file mode 100644 index 0000000000..bea6744024 --- /dev/null +++ b/src/jit/objectalloc.h @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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 ObjectAllocator XX +XX XX +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +*/ + +/*****************************************************************************/ +#ifndef OBJECTALLOC_H +#define OBJECTALLOC_H +/*****************************************************************************/ + +//=============================================================================== +#include "phase.h" + +class ObjectAllocator final : public Phase +{ + //=============================================================================== + // Data members + bool m_IsObjectStackAllocationEnabled; + bool m_AnalysisDone; + //=============================================================================== + // Methods +public: + ObjectAllocator(Compiler* comp); + bool IsObjectStackAllocationEnabled() const; + void EnableObjectStackAllocation(); + +protected: + virtual void DoPhase() override; + +private: + bool CanAllocateLclVarOnStack(unsigned int lclNum) const; + void DoAnalysis(); + void MorphAllocObjNodes(); + GenTreePtr MorphAllocObjNodeIntoHelperCall(GenTreeAllocObj* allocObj); + GenTreePtr MorphAllocObjNodeIntoStackAlloc(GenTreeAllocObj* allocObj, BasicBlock* block, GenTreeStmt* stmt); +#ifdef DEBUG + static Compiler::fgWalkResult AssertWhenAllocObjFoundVisitor(GenTreePtr* pTree, Compiler::fgWalkData* data); +#endif // DEBUG +}; + +//=============================================================================== + +inline ObjectAllocator::ObjectAllocator(Compiler* comp) + : Phase(comp, "Allocate Objects", PHASE_ALLOCATE_OBJECTS) + , m_IsObjectStackAllocationEnabled(false) + , m_AnalysisDone(false) +{ +} + +inline bool ObjectAllocator::IsObjectStackAllocationEnabled() const +{ + return m_IsObjectStackAllocationEnabled; +} + +inline void ObjectAllocator::EnableObjectStackAllocation() +{ + m_IsObjectStackAllocationEnabled = true; +} + +//------------------------------------------------------------------------ +// CanAllocateLclVarOnStack: Returns true iff local variable can not +// potentially escape from the method and +// can be allocated on the stack. +inline bool ObjectAllocator::CanAllocateLclVarOnStack(unsigned int lclNum) const +{ + assert(m_AnalysisDone); + // TODO-ObjectStackAllocation + NYI("CanAllocateLclVarOnStack"); + return false; +} + +//=============================================================================== + +#endif // OBJECTALLOC_H |