24 |
24 |
25 #ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
25 #ifndef SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
26 #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
26 #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
27 |
27 |
28 #ifndef SERIALGC |
28 #ifndef SERIALGC |
|
29 #include "gc_implementation/g1/g1MonitoringSupport.hpp" |
29 #include "services/memoryPool.hpp" |
30 #include "services/memoryPool.hpp" |
30 #include "services/memoryUsage.hpp" |
31 #include "services/memoryUsage.hpp" |
31 #endif |
32 #endif |
32 |
|
33 class G1CollectedHeap; |
|
34 |
33 |
35 // This file contains the three classes that represent the memory |
34 // This file contains the three classes that represent the memory |
36 // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and |
35 // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and |
37 // G1OldGenPool. In G1, unlike our other GCs, we do not have a |
36 // G1OldGenPool. In G1, unlike our other GCs, we do not have a |
38 // physical space for each of those spaces. Instead, we allocate |
37 // physical space for each of those spaces. Instead, we allocate |
48 // |
47 // |
49 // See comments in g1MonitoringSupport.hpp for additional details |
48 // See comments in g1MonitoringSupport.hpp for additional details |
50 // on this model. |
49 // on this model. |
51 // |
50 // |
52 |
51 |
53 |
|
54 // This class is shared by the three G1 memory pool classes |
52 // This class is shared by the three G1 memory pool classes |
55 // (G1EdenPool, G1SurvivorPool, G1OldGenPool). Given that the way we |
53 // (G1EdenPool, G1SurvivorPool, G1OldGenPool). |
56 // calculate used / committed bytes for these three pools is related |
|
57 // (see comment above), we put the calculations in this class so that |
|
58 // we can easily share them among the subclasses. |
|
59 class G1MemoryPoolSuper : public CollectedMemoryPool { |
54 class G1MemoryPoolSuper : public CollectedMemoryPool { |
60 protected: |
55 protected: |
61 G1CollectedHeap* _g1h; |
56 const static size_t _undefined_max = (size_t) -1; |
|
57 G1MonitoringSupport* _g1mm; |
62 |
58 |
63 // Would only be called from subclasses. |
59 // Would only be called from subclasses. |
64 G1MemoryPoolSuper(G1CollectedHeap* g1h, |
60 G1MemoryPoolSuper(G1CollectedHeap* g1h, |
65 const char* name, |
61 const char* name, |
66 size_t init_size, |
62 size_t init_size, |
|
63 size_t max_size, |
67 bool support_usage_threshold); |
64 bool support_usage_threshold); |
68 |
|
69 // The reason why all the code is in static methods is so that it |
|
70 // can be safely called from the constructors of the subclasses. |
|
71 |
|
72 static size_t undefined_max() { |
|
73 return (size_t) -1; |
|
74 } |
|
75 |
|
76 static size_t eden_space_committed(G1CollectedHeap* g1h); |
|
77 static size_t eden_space_used(G1CollectedHeap* g1h); |
|
78 |
|
79 static size_t survivor_space_committed(G1CollectedHeap* g1h); |
|
80 static size_t survivor_space_used(G1CollectedHeap* g1h); |
|
81 |
|
82 static size_t old_space_committed(G1CollectedHeap* g1h); |
|
83 static size_t old_space_used(G1CollectedHeap* g1h); |
|
84 }; |
65 }; |
85 |
66 |
86 // Memory pool that represents the G1 eden. |
67 // Memory pool that represents the G1 eden. |
87 class G1EdenPool : public G1MemoryPoolSuper { |
68 class G1EdenPool : public G1MemoryPoolSuper { |
88 public: |
69 public: |
89 G1EdenPool(G1CollectedHeap* g1h); |
70 G1EdenPool(G1CollectedHeap* g1h); |
90 |
71 |
91 size_t used_in_bytes() { |
72 size_t used_in_bytes() { |
92 return eden_space_used(_g1h); |
73 return _g1mm->eden_space_used(); |
93 } |
74 } |
94 size_t max_size() const { |
75 size_t max_size() const { |
95 return undefined_max(); |
76 return _undefined_max; |
96 } |
77 } |
97 MemoryUsage get_memory_usage(); |
78 MemoryUsage get_memory_usage(); |
98 }; |
79 }; |
99 |
80 |
100 // Memory pool that represents the G1 survivor. |
81 // Memory pool that represents the G1 survivor. |
101 class G1SurvivorPool : public G1MemoryPoolSuper { |
82 class G1SurvivorPool : public G1MemoryPoolSuper { |
102 public: |
83 public: |
103 G1SurvivorPool(G1CollectedHeap* g1h); |
84 G1SurvivorPool(G1CollectedHeap* g1h); |
104 |
85 |
105 size_t used_in_bytes() { |
86 size_t used_in_bytes() { |
106 return survivor_space_used(_g1h); |
87 return _g1mm->survivor_space_used(); |
107 } |
88 } |
108 size_t max_size() const { |
89 size_t max_size() const { |
109 return undefined_max(); |
90 return _undefined_max; |
110 } |
91 } |
111 MemoryUsage get_memory_usage(); |
92 MemoryUsage get_memory_usage(); |
112 }; |
93 }; |
113 |
94 |
114 // Memory pool that represents the G1 old gen. |
95 // Memory pool that represents the G1 old gen. |
115 class G1OldGenPool : public G1MemoryPoolSuper { |
96 class G1OldGenPool : public G1MemoryPoolSuper { |
116 public: |
97 public: |
117 G1OldGenPool(G1CollectedHeap* g1h); |
98 G1OldGenPool(G1CollectedHeap* g1h); |
118 |
99 |
119 size_t used_in_bytes() { |
100 size_t used_in_bytes() { |
120 return old_space_used(_g1h); |
101 return _g1mm->old_space_used(); |
121 } |
102 } |
122 size_t max_size() const { |
103 size_t max_size() const { |
123 return undefined_max(); |
104 return _undefined_max; |
124 } |
105 } |
125 MemoryUsage get_memory_usage(); |
106 MemoryUsage get_memory_usage(); |
126 }; |
107 }; |
127 |
108 |
128 #endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |
109 #endif // SHARE_VM_SERVICES_G1MEMORYPOOL_HPP |