summaryrefslogtreecommitdiff
path: root/src/jit/objectalloc.h
diff options
context:
space:
mode:
authorEgor Chesakov <t-egche@microsoft.com>2016-07-21 15:37:41 -0700
committerEgor Chesakov <t-egche@microsoft.com>2016-08-08 17:58:25 -0700
commit3c30aa1642ac52844aa3078fd6bc79a06f5c586a (patch)
tree5a13beb22fce080b9172ee097670e4122eaab755 /src/jit/objectalloc.h
parent17ced7fea35cb89ce6fe6c0a614c9fe15171bdea (diff)
downloadcoreclr-3c30aa1642ac52844aa3078fd6bc79a06f5c586a.tar.gz
coreclr-3c30aa1642ac52844aa3078fd6bc79a06f5c586a.tar.bz2
coreclr-3c30aa1642ac52844aa3078fd6bc79a06f5c586a.zip
Work towards objects stack allocation: moved allocation part of newobj-lowering into separate phase
1. Introduced `GT_ALLOCOBJ` node to mark places where object allocation happens 2. In `importer.cpp` changed lowering of allocation part of newobj instruction from an allocation helper call to a `GT_ALLOCOBJ` node creation 3. Created new phase `ObjectAllocator` (`PHASE_ALLOCATE_OBJECTS`) and put it right after dominator computing (we will need the information for escape analysis) 4. Current implementation of ObjectAllocator walks over all basic blocks having flag `BBF_HAS_NEWOBJ` set and replaces `GT_ALLOCOBJ` with an allocation helper call
Diffstat (limited to 'src/jit/objectalloc.h')
-rw-r--r--src/jit/objectalloc.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/jit/objectalloc.h b/src/jit/objectalloc.h
new file mode 100644
index 0000000000..a9707f326d
--- /dev/null
+++ b/src/jit/objectalloc.h
@@ -0,0 +1,86 @@
+// 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