77 void initialize_statistics();
78
79 void set_start(HeapWord* start) { _start = start; }
80 void set_end(HeapWord* end) { _end = end; }
81 void set_actual_end(HeapWord* actual_end) { _actual_end = actual_end; }
82 void set_slow_path_end(HeapWord* slow_path_end) { _slow_path_end = slow_path_end; }
83 void set_top(HeapWord* top) { _top = top; }
84 void set_pf_top(HeapWord* pf_top) { _pf_top = pf_top; }
85 void set_desired_size(size_t desired_size) { _desired_size = desired_size; }
86 void set_refill_waste_limit(size_t waste) { _refill_waste_limit = waste; }
87 void set_bytes_until_sample(size_t bytes) { _bytes_until_sample = bytes; }
88
89 size_t initial_refill_waste_limit() { return desired_size() / TLABRefillWasteFraction; }
90
91 static int target_refills() { return _target_refills; }
92 size_t initial_desired_size();
93
94 size_t remaining() { return end() == NULL ? 0 : pointer_delta(hard_end(), top()); }
95
96 // Obtain the actual end of the TLAB.
97 HeapWord* hard_end();
98 void set_sample_end();
99
100 // Make parsable and release it.
101 void reset();
102
103 // Resize based on amount of allocation, etc.
104 void resize();
105
106 void invariants() const { assert(top() >= start() && top() <= end(), "invalid tlab"); }
107
108 void initialize(HeapWord* start, HeapWord* top, HeapWord* end);
109
110 void print_stats(const char* tag);
111
112 Thread* myThread();
113
114 // statistics
115
116 int number_of_refills() const { return _number_of_refills; }
117 int fast_refill_waste() const { return _fast_refill_waste; }
118 int slow_refill_waste() const { return _slow_refill_waste; }
119 int gc_waste() const { return _gc_waste; }
120 int slow_allocations() const { return _slow_allocations; }
121
122 static GlobalTLABStats* _global_stats;
123 static GlobalTLABStats* global_stats() { return _global_stats; }
124
125 public:
126 ThreadLocalAllocBuffer() : _allocation_fraction(TLABAllocationWeight), _allocated_before_last_gc(0) {
127 // do nothing. tlabs must be inited by initialize() calls
128 }
129
130 static size_t min_size() { return align_object_size(MinTLABSize / HeapWordSize) + alignment_reserve(); }
131 static size_t max_size() { assert(_max_size != 0, "max_size not set up"); return _max_size; }
132 static size_t max_size_in_bytes() { return max_size() * BytesPerWord; }
133 static void set_max_size(size_t max_size) { _max_size = max_size; }
134
135 HeapWord* start() const { return _start; }
136 HeapWord* end() const { return _end; }
137 HeapWord* top() const { return _top; }
138 HeapWord* pf_top() const { return _pf_top; }
139 size_t desired_size() const { return _desired_size; }
140 size_t used() const { return pointer_delta(top(), start()); }
141 size_t used_bytes() const { return pointer_delta(top(), start(), 1); }
142 size_t free() const { return pointer_delta(end(), top()); }
143 // Don't discard tlab if remaining space is larger than this.
144 size_t refill_waste_limit() const { return _refill_waste_limit; }
145
146 // Allocate size HeapWords. The memory is NOT initialized to zero.
147 inline HeapWord* allocate(size_t size);
148
149 // Reserve space at the end of TLAB
150 static size_t end_reserve() {
151 int reserve_size = typeArrayOopDesc::header_size(T_INT);
152 return MAX2(reserve_size, _reserve_for_allocation_prefetch);
153 }
154 static size_t alignment_reserve() { return align_object_size(end_reserve()); }
|
77 void initialize_statistics();
78
79 void set_start(HeapWord* start) { _start = start; }
80 void set_end(HeapWord* end) { _end = end; }
81 void set_actual_end(HeapWord* actual_end) { _actual_end = actual_end; }
82 void set_slow_path_end(HeapWord* slow_path_end) { _slow_path_end = slow_path_end; }
83 void set_top(HeapWord* top) { _top = top; }
84 void set_pf_top(HeapWord* pf_top) { _pf_top = pf_top; }
85 void set_desired_size(size_t desired_size) { _desired_size = desired_size; }
86 void set_refill_waste_limit(size_t waste) { _refill_waste_limit = waste; }
87 void set_bytes_until_sample(size_t bytes) { _bytes_until_sample = bytes; }
88
89 size_t initial_refill_waste_limit() { return desired_size() / TLABRefillWasteFraction; }
90
91 static int target_refills() { return _target_refills; }
92 size_t initial_desired_size();
93
94 size_t remaining() { return end() == NULL ? 0 : pointer_delta(hard_end(), top()); }
95
96 // Obtain the actual end of the TLAB.
97 void set_sample_end();
98
99 // Make parsable and release it.
100 void reset();
101
102 // Resize based on amount of allocation, etc.
103 void resize();
104
105 void invariants() const { assert(top() >= start() && top() <= end(), "invalid tlab"); }
106
107 void initialize(HeapWord* start, HeapWord* top, HeapWord* end);
108
109 void print_stats(const char* tag);
110
111 Thread* myThread();
112
113 // statistics
114
115 int number_of_refills() const { return _number_of_refills; }
116 int fast_refill_waste() const { return _fast_refill_waste; }
117 int slow_refill_waste() const { return _slow_refill_waste; }
118 int gc_waste() const { return _gc_waste; }
119 int slow_allocations() const { return _slow_allocations; }
120
121 static GlobalTLABStats* _global_stats;
122 static GlobalTLABStats* global_stats() { return _global_stats; }
123
124 public:
125 ThreadLocalAllocBuffer() : _allocation_fraction(TLABAllocationWeight), _allocated_before_last_gc(0) {
126 // do nothing. tlabs must be inited by initialize() calls
127 }
128
129 static size_t min_size() { return align_object_size(MinTLABSize / HeapWordSize) + alignment_reserve(); }
130 static size_t max_size() { assert(_max_size != 0, "max_size not set up"); return _max_size; }
131 static size_t max_size_in_bytes() { return max_size() * BytesPerWord; }
132 static void set_max_size(size_t max_size) { _max_size = max_size; }
133
134 HeapWord* hard_end();
135 HeapWord* start() const { return _start; }
136 HeapWord* end() const { return _end; }
137 HeapWord* top() const { return _top; }
138 HeapWord* pf_top() const { return _pf_top; }
139 size_t desired_size() const { return _desired_size; }
140 size_t used() const { return pointer_delta(top(), start()); }
141 size_t used_bytes() const { return pointer_delta(top(), start(), 1); }
142 size_t free() const { return pointer_delta(end(), top()); }
143 // Don't discard tlab if remaining space is larger than this.
144 size_t refill_waste_limit() const { return _refill_waste_limit; }
145
146 // Allocate size HeapWords. The memory is NOT initialized to zero.
147 inline HeapWord* allocate(size_t size);
148
149 // Reserve space at the end of TLAB
150 static size_t end_reserve() {
151 int reserve_size = typeArrayOopDesc::header_size(T_INT);
152 return MAX2(reserve_size, _reserve_for_allocation_prefetch);
153 }
154 static size_t alignment_reserve() { return align_object_size(end_reserve()); }
|