equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
70 |
70 |
71 public: |
71 public: |
72 // Initializes the buffer to be empty, but with the given "word_sz". |
72 // Initializes the buffer to be empty, but with the given "word_sz". |
73 // Must get initialized with "set_buf" for an allocation to succeed. |
73 // Must get initialized with "set_buf" for an allocation to succeed. |
74 PLAB(size_t word_sz); |
74 PLAB(size_t word_sz); |
75 virtual ~PLAB() {} |
|
76 |
75 |
77 static size_t size_required_for_allocation(size_t word_size) { return word_size + AlignmentReserve; } |
76 static size_t size_required_for_allocation(size_t word_size) { return word_size + AlignmentReserve; } |
78 |
77 |
79 // Minimum PLAB size. |
78 // Minimum PLAB size. |
80 static size_t min_size(); |
79 static size_t min_size(); |
118 bool contains(void* addr) { |
117 bool contains(void* addr) { |
119 return (void*)_bottom <= addr && addr < (void*)_hard_end; |
118 return (void*)_bottom <= addr && addr < (void*)_hard_end; |
120 } |
119 } |
121 |
120 |
122 // Sets the space of the buffer to be [buf, space+word_sz()). |
121 // Sets the space of the buffer to be [buf, space+word_sz()). |
123 virtual void set_buf(HeapWord* buf, size_t new_word_sz) { |
122 void set_buf(HeapWord* buf, size_t new_word_sz) { |
124 assert(new_word_sz > AlignmentReserve, "Too small"); |
123 assert(new_word_sz > AlignmentReserve, "Too small"); |
125 _word_sz = new_word_sz; |
124 _word_sz = new_word_sz; |
126 |
125 |
127 _bottom = buf; |
126 _bottom = buf; |
128 _top = _bottom; |
127 _top = _bottom; |
134 } |
133 } |
135 |
134 |
136 // Flush allocation statistics into the given PLABStats supporting ergonomic |
135 // Flush allocation statistics into the given PLABStats supporting ergonomic |
137 // sizing of PLAB's and retire the current buffer. To be called at the end of |
136 // sizing of PLAB's and retire the current buffer. To be called at the end of |
138 // GC. |
137 // GC. |
139 virtual void flush_and_retire_stats(PLABStats* stats); |
138 void flush_and_retire_stats(PLABStats* stats); |
140 |
139 |
141 // Fills in the unallocated portion of the buffer with a garbage object and updates |
140 // Fills in the unallocated portion of the buffer with a garbage object and updates |
142 // statistics. To be called during GC. |
141 // statistics. To be called during GC. |
143 virtual void retire(); |
142 void retire(); |
144 }; |
143 }; |
145 |
144 |
146 // PLAB book-keeping. |
145 // PLAB book-keeping. |
147 class PLABStats : public CHeapObj<mtGC> { |
146 class PLABStats : public CHeapObj<mtGC> { |
148 protected: |
147 protected: |