Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / objectalloc.h
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.
4
5 /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7 XX                                                                           XX
8 XX                         ObjectAllocator                                   XX
9 XX                                                                           XX
10 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
11 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
12 */
13
14 /*****************************************************************************/
15 #ifndef OBJECTALLOC_H
16 #define OBJECTALLOC_H
17 /*****************************************************************************/
18
19 //===============================================================================
20 #include "phase.h"
21
22 class ObjectAllocator final : public Phase
23 {
24     //===============================================================================
25     // Data members
26     bool m_IsObjectStackAllocationEnabled;
27     bool m_AnalysisDone;
28     //===============================================================================
29     // Methods
30 public:
31     ObjectAllocator(Compiler* comp);
32     bool IsObjectStackAllocationEnabled() const;
33     void EnableObjectStackAllocation();
34
35 protected:
36     virtual void DoPhase() override;
37
38 private:
39     bool CanAllocateLclVarOnStack(unsigned int lclNum) const;
40     void     DoAnalysis();
41     void     MorphAllocObjNodes();
42     GenTree* MorphAllocObjNodeIntoHelperCall(GenTreeAllocObj* allocObj);
43     GenTree* MorphAllocObjNodeIntoStackAlloc(GenTreeAllocObj* allocObj, BasicBlock* block, GenTreeStmt* stmt);
44 #ifdef DEBUG
45     static Compiler::fgWalkResult AssertWhenAllocObjFoundVisitor(GenTree** pTree, Compiler::fgWalkData* data);
46 #endif // DEBUG
47 };
48
49 //===============================================================================
50
51 inline ObjectAllocator::ObjectAllocator(Compiler* comp)
52     : Phase(comp, "Allocate Objects", PHASE_ALLOCATE_OBJECTS)
53     , m_IsObjectStackAllocationEnabled(false)
54     , m_AnalysisDone(false)
55 {
56 }
57
58 inline bool ObjectAllocator::IsObjectStackAllocationEnabled() const
59 {
60     return m_IsObjectStackAllocationEnabled;
61 }
62
63 inline void ObjectAllocator::EnableObjectStackAllocation()
64 {
65     m_IsObjectStackAllocationEnabled = true;
66 }
67
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
73 {
74     assert(m_AnalysisDone);
75     // TODO-ObjectStackAllocation
76     NYI("CanAllocateLclVarOnStack");
77     return false;
78 }
79
80 //===============================================================================
81
82 #endif // OBJECTALLOC_H