John Porto | e82b560 | 2016-02-24 15:58:55 -0800 | [diff] [blame] | 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" |
John Porto | 7bb9cab | 2016-04-01 05:43:09 -0700 | [diff] [blame] | 18 | #include "IceLiveness.h" |
John Porto | e82b560 | 2016-02-24 15:58:55 -0800 | [diff] [blame] | 19 | #include "IceTLS.h" |
| 20 | |
| 21 | #include <cassert> |
| 22 | #include <utility> |
| 23 | |
| 24 | namespace Ice { |
| 25 | ICE_TLS_DEFINE_FIELD(ArenaAllocator *, CfgAllocatorTraits, CfgAllocator); |
| 26 | |
| 27 | CfgAllocatorTraits::allocator_type CfgAllocatorTraits::current() { |
| 28 | return ICE_TLS_GET_FIELD(CfgAllocator); |
| 29 | } |
| 30 | |
| 31 | void CfgAllocatorTraits::set_current(const manager_type *Manager) { |
| 32 | ArenaAllocator *Allocator = |
| 33 | Manager == nullptr ? nullptr : Manager->Allocator.get(); |
Nicolas Capens | a9a92a5 | 2016-09-06 12:59:58 -0400 | [diff] [blame] | 34 | set_current(Allocator); |
| 35 | } |
| 36 | |
| 37 | void CfgAllocatorTraits::set_current(ArenaAllocator *Allocator) { |
John Porto | e82b560 | 2016-02-24 15:58:55 -0800 | [diff] [blame] | 38 | ICE_TLS_SET_FIELD(CfgAllocator, Allocator); |
| 39 | } |
| 40 | |
Jim Stichnoth | 5d5b662 | 2016-09-09 09:29:08 -0700 | [diff] [blame] | 41 | void CfgAllocatorTraits::set_current(std::nullptr_t) { |
Nicolas Capens | a9a92a5 | 2016-09-06 12:59:58 -0400 | [diff] [blame] | 42 | ICE_TLS_SET_FIELD(CfgAllocator, nullptr); |
| 43 | } |
| 44 | |
John Porto | 7bb9cab | 2016-04-01 05:43:09 -0700 | [diff] [blame] | 45 | ICE_TLS_DEFINE_FIELD(ArenaAllocator *, LivenessAllocatorTraits, |
| 46 | LivenessAllocator); |
| 47 | |
| 48 | LivenessAllocatorTraits::allocator_type LivenessAllocatorTraits::current() { |
| 49 | return ICE_TLS_GET_FIELD(LivenessAllocator); |
| 50 | } |
| 51 | |
| 52 | void LivenessAllocatorTraits::set_current(const manager_type *Manager) { |
| 53 | ArenaAllocator *Allocator = |
| 54 | Manager == nullptr ? nullptr : Manager->getAllocator(); |
| 55 | ICE_TLS_SET_FIELD(LivenessAllocator, Allocator); |
| 56 | } |
John Porto | e82b560 | 2016-02-24 15:58:55 -0800 | [diff] [blame] | 57 | } // end of namespace Ice |