1 //===- subzero/src/IceMemory.cpp - Memory management definitions -*- C++ -*-==// 2 // 3 // The Subzero Code Generator 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// \brief Implements memory management related routines for subzero. 12 ///// 13 //===----------------------------------------------------------------------===// 14 15 #include "IceMemory.h" 16 17 #include "IceCfg.h" 18 #include "IceLiveness.h" 19 #include "IceTLS.h" 20 21 #include <cassert> 22 #include <utility> 23 24 namespace Ice { 25 ICE_TLS_DEFINE_FIELD(ArenaAllocator *, CfgAllocatorTraits, CfgAllocator); 26 current()27CfgAllocatorTraits::allocator_type CfgAllocatorTraits::current() { 28 return ICE_TLS_GET_FIELD(CfgAllocator); 29 } 30 set_current(const manager_type * Manager)31void CfgAllocatorTraits::set_current(const manager_type *Manager) { 32 ArenaAllocator *Allocator = 33 Manager == nullptr ? nullptr : Manager->Allocator.get(); 34 set_current(Allocator); 35 } 36 set_current(ArenaAllocator * Allocator)37void CfgAllocatorTraits::set_current(ArenaAllocator *Allocator) { 38 ICE_TLS_SET_FIELD(CfgAllocator, Allocator); 39 } 40 set_current(std::nullptr_t)41void CfgAllocatorTraits::set_current(std::nullptr_t) { 42 ICE_TLS_SET_FIELD(CfgAllocator, nullptr); 43 } 44 45 ICE_TLS_DEFINE_FIELD(ArenaAllocator *, LivenessAllocatorTraits, 46 LivenessAllocator); 47 current()48LivenessAllocatorTraits::allocator_type LivenessAllocatorTraits::current() { 49 return ICE_TLS_GET_FIELD(LivenessAllocator); 50 } 51 set_current(const manager_type * Manager)52void LivenessAllocatorTraits::set_current(const manager_type *Manager) { 53 ArenaAllocator *Allocator = 54 Manager == nullptr ? nullptr : Manager->getAllocator(); 55 ICE_TLS_SET_FIELD(LivenessAllocator, Allocator); 56 } 57 } // end of namespace Ice 58