comparison src/share/vm/memory/heap.hpp @ 10114:a7fb14888912

8006952: Slow VM due to excessive code cache freelist iteration Summary: Remove continous free block requirement Reviewed-by: kvn
author neliasso
date Thu, 11 Apr 2013 13:57:44 +0200
parents b9a9ed0f8eeb
children de6a9e811145
comparison
equal deleted inserted replaced
10113:4b2eebe03f93 10114:a7fb14888912
89 int _log2_segment_size; 89 int _log2_segment_size;
90 90
91 size_t _next_segment; 91 size_t _next_segment;
92 92
93 FreeBlock* _freelist; 93 FreeBlock* _freelist;
94 size_t _free_segments; // No. of segments in freelist 94 size_t _freelist_segments; // No. of segments in freelist
95 95
96 // Helper functions 96 // Helper functions
97 size_t number_of_segments(size_t size) const { return (size + _segment_size - 1) >> _log2_segment_size; } 97 size_t size_to_segments(size_t size) const { return (size + _segment_size - 1) >> _log2_segment_size; }
98 size_t size(size_t number_of_segments) const { return number_of_segments << _log2_segment_size; } 98 size_t segments_to_size(size_t number_of_segments) const { return number_of_segments << _log2_segment_size; }
99 99
100 size_t segment_for(void* p) const { return ((char*)p - _memory.low()) >> _log2_segment_size; } 100 size_t segment_for(void* p) const { return ((char*)p - _memory.low()) >> _log2_segment_size; }
101 HeapBlock* block_at(size_t i) const { return (HeapBlock*)(_memory.low() + (i << _log2_segment_size)); } 101 HeapBlock* block_at(size_t i) const { return (HeapBlock*)(_memory.low() + (i << _log2_segment_size)); }
102 102
103 void mark_segmap_as_free(size_t beg, size_t end); 103 void mark_segmap_as_free(size_t beg, size_t end);
108 void insert_after(FreeBlock* a, FreeBlock* b); 108 void insert_after(FreeBlock* a, FreeBlock* b);
109 void merge_right (FreeBlock* a); 109 void merge_right (FreeBlock* a);
110 110
111 // Toplevel freelist management 111 // Toplevel freelist management
112 void add_to_freelist(HeapBlock *b); 112 void add_to_freelist(HeapBlock *b);
113 FreeBlock* search_freelist(size_t length); 113 FreeBlock* search_freelist(size_t length, bool is_critical);
114 114
115 // Iteration helpers 115 // Iteration helpers
116 void* next_free(HeapBlock* b) const; 116 void* next_free(HeapBlock* b) const;
117 HeapBlock* first_block() const; 117 HeapBlock* first_block() const;
118 HeapBlock* next_block(HeapBlock* b) const; 118 HeapBlock* next_block(HeapBlock* b) const;
130 bool expand_by(size_t size); // expands commited memory by size 130 bool expand_by(size_t size); // expands commited memory by size
131 void shrink_by(size_t size); // shrinks commited memory by size 131 void shrink_by(size_t size); // shrinks commited memory by size
132 void clear(); // clears all heap contents 132 void clear(); // clears all heap contents
133 133
134 // Memory allocation 134 // Memory allocation
135 void* allocate (size_t size); // allocates a block of size or returns NULL 135 void* allocate (size_t size, bool is_critical); // allocates a block of size or returns NULL
136 void deallocate(void* p); // deallocates a block 136 void deallocate(void* p); // deallocates a block
137 137
138 // Attributes 138 // Attributes
139 void* begin() const { return _memory.low (); } 139 char* low_boundary() const { return _memory.low_boundary (); }
140 void* end() const { return _memory.high(); } 140 char* high() const { return _memory.high(); }
141 bool contains(void* p) const { return begin() <= p && p < end(); } 141 char* high_boundary() const { return _memory.high_boundary(); }
142 void* find_start(void* p) const; // returns the block containing p or NULL
143 size_t alignment_unit() const; // alignment of any block
144 size_t alignment_offset() const; // offset of first byte of any block, within the enclosing alignment unit
145 static size_t header_size(); // returns the header size for each heap block
146 142
147 // Returns reserved area high and low addresses 143 bool contains(const void* p) const { return low_boundary() <= p && p < high(); }
148 char *low_boundary() const { return _memory.low_boundary (); } 144 void* find_start(void* p) const; // returns the block containing p or NULL
149 char *high() const { return _memory.high(); } 145 size_t alignment_unit() const; // alignment of any block
150 char *high_boundary() const { return _memory.high_boundary(); } 146 size_t alignment_offset() const; // offset of first byte of any block, within the enclosing alignment unit
147 static size_t header_size(); // returns the header size for each heap block
151 148
152 // Iteration 149 // Iteration
153 150
154 // returns the first block or NULL 151 // returns the first block or NULL
155 void* first() const { return next_free(first_block()); } 152 void* first() const { return next_free(first_block()); }
159 // Statistics 156 // Statistics
160 size_t capacity() const; 157 size_t capacity() const;
161 size_t max_capacity() const; 158 size_t max_capacity() const;
162 size_t allocated_capacity() const; 159 size_t allocated_capacity() const;
163 size_t unallocated_capacity() const { return max_capacity() - allocated_capacity(); } 160 size_t unallocated_capacity() const { return max_capacity() - allocated_capacity(); }
164 size_t largest_free_block() const;
165 161
162 private:
163 size_t heap_unallocated_capacity() const;
164
165 public:
166 // Debugging 166 // Debugging
167 void verify(); 167 void verify();
168 void print() PRODUCT_RETURN; 168 void print() PRODUCT_RETURN;
169 }; 169 };
170 170