1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
10 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
11 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
14 /*****************************************************************************/
17 /*****************************************************************************/
19 //===============================================================================
22 class ObjectAllocator final : public Phase
24 //===============================================================================
26 bool m_IsObjectStackAllocationEnabled;
28 //===============================================================================
31 ObjectAllocator(Compiler* comp);
32 bool IsObjectStackAllocationEnabled() const;
33 void EnableObjectStackAllocation();
36 virtual void DoPhase() override;
39 bool CanAllocateLclVarOnStack(unsigned int lclNum) const;
41 void MorphAllocObjNodes();
42 GenTree* MorphAllocObjNodeIntoHelperCall(GenTreeAllocObj* allocObj);
43 GenTree* MorphAllocObjNodeIntoStackAlloc(GenTreeAllocObj* allocObj, BasicBlock* block, GenTreeStmt* stmt);
45 static Compiler::fgWalkResult AssertWhenAllocObjFoundVisitor(GenTree** pTree, Compiler::fgWalkData* data);
49 //===============================================================================
51 inline ObjectAllocator::ObjectAllocator(Compiler* comp)
52 : Phase(comp, "Allocate Objects", PHASE_ALLOCATE_OBJECTS)
53 , m_IsObjectStackAllocationEnabled(false)
54 , m_AnalysisDone(false)
58 inline bool ObjectAllocator::IsObjectStackAllocationEnabled() const
60 return m_IsObjectStackAllocationEnabled;
63 inline void ObjectAllocator::EnableObjectStackAllocation()
65 m_IsObjectStackAllocationEnabled = true;
68 //------------------------------------------------------------------------
69 // CanAllocateLclVarOnStack: Returns true iff local variable can not
70 // potentially escape from the method and
71 // can be allocated on the stack.
72 inline bool ObjectAllocator::CanAllocateLclVarOnStack(unsigned int lclNum) const
74 assert(m_AnalysisDone);
75 // TODO-ObjectStackAllocation
76 NYI("CanAllocateLclVarOnStack");
80 //===============================================================================
82 #endif // OBJECTALLOC_H