Mercurial > hg > truffle
comparison src/share/vm/memory/space.cpp @ 356:1ee8caae33af
Merge
author | tonyp |
---|---|
date | Thu, 21 Aug 2008 23:36:31 -0400 |
parents | 60fb9c4db4e6 850fdf70db2b |
children | 122d10c82f3f |
comparison
equal
deleted
inserted
replaced
355:0edda524b58c | 356:1ee8caae33af |
---|---|
1 /* | 1 /* |
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1997-2008 Sun Microsystems, Inc. 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. |
237 CardTableModRefBS::PrecisionStyle precision, | 237 CardTableModRefBS::PrecisionStyle precision, |
238 HeapWord* boundary) { | 238 HeapWord* boundary) { |
239 return new ContiguousSpaceDCTOC(this, cl, precision, boundary); | 239 return new ContiguousSpaceDCTOC(this, cl, precision, boundary); |
240 } | 240 } |
241 | 241 |
242 void Space::set_bounds(MemRegion mr) { | 242 void Space::initialize(MemRegion mr, |
243 bool clear_space, | |
244 bool mangle_space) { | |
243 HeapWord* bottom = mr.start(); | 245 HeapWord* bottom = mr.start(); |
244 HeapWord* end = mr.end(); | 246 HeapWord* end = mr.end(); |
245 assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), | 247 assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), |
246 "invalid space boundaries"); | 248 "invalid space boundaries"); |
247 set_bottom(bottom); | 249 set_bottom(bottom); |
248 set_end(end); | 250 set_end(end); |
249 } | 251 if (clear_space) clear(mangle_space); |
250 | 252 } |
251 void Space::initialize(MemRegion mr, bool clear_space) { | 253 |
252 set_bounds(mr); | 254 void Space::clear(bool mangle_space) { |
253 if (clear_space) clear(); | 255 if (ZapUnusedHeapArea && mangle_space) { |
254 } | 256 mangle_unused_area(); |
255 | 257 } |
256 void Space::clear() { | 258 } |
257 if (ZapUnusedHeapArea) mangle_unused_area(); | 259 |
258 } | 260 ContiguousSpace::ContiguousSpace(): CompactibleSpace(), _top(NULL), |
259 | 261 _concurrent_iteration_safe_limit(NULL) { |
260 void CompactibleSpace::initialize(MemRegion mr, bool clear_space) { | 262 _mangler = new GenSpaceMangler(this); |
261 Space::initialize(mr, false); // We'll do the clearing if there's | 263 } |
262 // clearing to be done. | 264 |
263 _compaction_top = bottom(); | 265 ContiguousSpace::~ContiguousSpace() { |
264 _next_compaction_space = NULL; | 266 delete _mangler; |
265 if (clear_space) clear(); | 267 } |
266 } | 268 |
267 | 269 void ContiguousSpace::initialize(MemRegion mr, |
268 void CompactibleSpace::clear() { | 270 bool clear_space, |
269 _compaction_top = bottom(); | 271 bool mangle_space) |
270 Space::clear(); | 272 { |
271 } | 273 CompactibleSpace::initialize(mr, clear_space, mangle_space); |
272 | 274 set_concurrent_iteration_safe_limit(top()); |
273 void ContiguousSpace::initialize(MemRegion mr, bool clear_space) { | 275 } |
274 CompactibleSpace::initialize(mr, false); // We'll do the clearing if there's | 276 |
275 // clearing to be done. | 277 void ContiguousSpace::clear(bool mangle_space) { |
276 set_top(bottom()); | 278 set_top(bottom()); |
277 set_saved_mark(); | 279 set_saved_mark(); |
278 if (clear_space) clear(); | 280 CompactibleSpace::clear(mangle_space); |
279 set_concurrent_iteration_safe_limit(top()); | |
280 } | |
281 | |
282 void ContiguousSpace::clear() { | |
283 set_top(bottom()); | |
284 set_saved_mark(); | |
285 CompactibleSpace::clear(); | |
286 } | 281 } |
287 | 282 |
288 bool Space::is_in(const void* p) const { | 283 bool Space::is_in(const void* p) const { |
289 HeapWord* b = block_start_const(p); | 284 HeapWord* b = block_start_const(p); |
290 return b != NULL && block_is_obj(b); | 285 return b != NULL && block_is_obj(b); |
296 | 291 |
297 bool ContiguousSpace::is_free_block(const HeapWord* p) const { | 292 bool ContiguousSpace::is_free_block(const HeapWord* p) const { |
298 return p >= _top; | 293 return p >= _top; |
299 } | 294 } |
300 | 295 |
301 void OffsetTableContigSpace::initialize(MemRegion mr, bool clear_space) { | 296 void OffsetTableContigSpace::clear(bool mangle_space) { |
302 // false ==> we'll do the clearing if there's clearing to be done. | 297 ContiguousSpace::clear(mangle_space); |
303 ContiguousSpace::initialize(mr, false); | |
304 _offsets.zero_bottom_entry(); | |
305 _offsets.initialize_threshold(); | |
306 if (clear_space) clear(); | |
307 } | |
308 | |
309 void OffsetTableContigSpace::clear() { | |
310 ContiguousSpace::clear(); | |
311 _offsets.zero_bottom_entry(); | |
312 _offsets.initialize_threshold(); | 298 _offsets.initialize_threshold(); |
313 } | 299 } |
314 | 300 |
315 void OffsetTableContigSpace::set_bottom(HeapWord* new_bottom) { | 301 void OffsetTableContigSpace::set_bottom(HeapWord* new_bottom) { |
316 Space::set_bottom(new_bottom); | 302 Space::set_bottom(new_bottom); |
322 // until after the underlying offest table has been enlarged. | 308 // until after the underlying offest table has been enlarged. |
323 _offsets.resize(pointer_delta(new_end, bottom())); | 309 _offsets.resize(pointer_delta(new_end, bottom())); |
324 Space::set_end(new_end); | 310 Space::set_end(new_end); |
325 } | 311 } |
326 | 312 |
313 #ifndef PRODUCT | |
314 | |
315 void ContiguousSpace::set_top_for_allocations(HeapWord* v) { | |
316 mangler()->set_top_for_allocations(v); | |
317 } | |
318 void ContiguousSpace::set_top_for_allocations() { | |
319 mangler()->set_top_for_allocations(top()); | |
320 } | |
321 void ContiguousSpace::check_mangled_unused_area(HeapWord* limit) { | |
322 mangler()->check_mangled_unused_area(limit); | |
323 } | |
324 | |
325 void ContiguousSpace::check_mangled_unused_area_complete() { | |
326 mangler()->check_mangled_unused_area_complete(); | |
327 } | |
328 | |
329 // Mangled only the unused space that has not previously | |
330 // been mangled and that has not been allocated since being | |
331 // mangled. | |
327 void ContiguousSpace::mangle_unused_area() { | 332 void ContiguousSpace::mangle_unused_area() { |
328 // to-space is used for storing marks during mark-sweep | 333 mangler()->mangle_unused_area(); |
329 mangle_region(MemRegion(top(), end())); | 334 } |
330 } | 335 void ContiguousSpace::mangle_unused_area_complete() { |
331 | 336 mangler()->mangle_unused_area_complete(); |
337 } | |
332 void ContiguousSpace::mangle_region(MemRegion mr) { | 338 void ContiguousSpace::mangle_region(MemRegion mr) { |
333 debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord)); | 339 // Although this method uses SpaceMangler::mangle_region() which |
340 // is not specific to a space, the when the ContiguousSpace version | |
341 // is called, it is always with regard to a space and this | |
342 // bounds checking is appropriate. | |
343 MemRegion space_mr(bottom(), end()); | |
344 assert(space_mr.contains(mr), "Mangling outside space"); | |
345 SpaceMangler::mangle_region(mr); | |
346 } | |
347 #endif // NOT_PRODUCT | |
348 | |
349 void CompactibleSpace::initialize(MemRegion mr, | |
350 bool clear_space, | |
351 bool mangle_space) { | |
352 Space::initialize(mr, clear_space, mangle_space); | |
353 set_compaction_top(bottom()); | |
354 _next_compaction_space = NULL; | |
355 } | |
356 | |
357 void CompactibleSpace::clear(bool mangle_space) { | |
358 Space::clear(mangle_space); | |
359 _compaction_top = bottom(); | |
334 } | 360 } |
335 | 361 |
336 HeapWord* CompactibleSpace::forward(oop q, size_t size, | 362 HeapWord* CompactibleSpace::forward(oop q, size_t size, |
337 CompactPoint* cp, HeapWord* compact_top) { | 363 CompactPoint* cp, HeapWord* compact_top) { |
338 // q is alive | 364 // q is alive |
848 obj->set_klass_gap(0); | 874 obj->set_klass_gap(0); |
849 obj->set_klass(SystemDictionary::object_klass()); | 875 obj->set_klass(SystemDictionary::object_klass()); |
850 } | 876 } |
851 } | 877 } |
852 | 878 |
853 void EdenSpace::clear() { | 879 void EdenSpace::clear(bool mangle_space) { |
854 ContiguousSpace::clear(); | 880 ContiguousSpace::clear(mangle_space); |
855 set_soft_end(end()); | 881 set_soft_end(end()); |
856 } | 882 } |
857 | 883 |
858 // Requires locking. | 884 // Requires locking. |
859 HeapWord* EdenSpace::allocate(size_t size) { | 885 HeapWord* EdenSpace::allocate(size_t size) { |
906 MemRegion mr) : | 932 MemRegion mr) : |
907 _offsets(sharedOffsetArray, mr), | 933 _offsets(sharedOffsetArray, mr), |
908 _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true) | 934 _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true) |
909 { | 935 { |
910 _offsets.set_contig_space(this); | 936 _offsets.set_contig_space(this); |
911 initialize(mr, true); | 937 initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle); |
912 } | 938 } |
913 | 939 |
914 | 940 |
915 class VerifyOldOopClosure : public OopClosure { | 941 class VerifyOldOopClosure : public OopClosure { |
916 public: | 942 public: |