| 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
|---|---|
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_HEAP_SPACES_H_ |
| 6 | #define RUNTIME_VM_HEAP_SPACES_H_ |
| 7 | |
| 8 | #include "platform/atomic.h" |
| 9 | #include "platform/globals.h" |
| 10 | |
| 11 | // This file contains utilities shared by old and new space. |
| 12 | // TODO(koda): Create Space base class with Space::CurrentUsage(). |
| 13 | |
| 14 | namespace dart { |
| 15 | |
| 16 | // Usage statistics for a space/generation at a particular moment in time. |
| 17 | class SpaceUsage { |
| 18 | public: |
| 19 | SpaceUsage() : capacity_in_words(0), used_in_words(0), external_in_words(0) {} |
| 20 | RelaxedAtomic<intptr_t> capacity_in_words; |
| 21 | RelaxedAtomic<intptr_t> used_in_words; |
| 22 | RelaxedAtomic<intptr_t> external_in_words; |
| 23 | |
| 24 | intptr_t CombinedCapacityInWords() const { |
| 25 | return capacity_in_words + external_in_words; |
| 26 | } |
| 27 | intptr_t CombinedUsedInWords() const { |
| 28 | return used_in_words + external_in_words; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | } // namespace dart |
| 33 | |
| 34 | #endif // RUNTIME_VM_HEAP_SPACES_H_ |
| 35 |