23 */ |
23 */ |
24 |
24 |
25 # include "incls/_precompiled.incl" |
25 # include "incls/_precompiled.incl" |
26 # include "incls/_mutableSpace.cpp.incl" |
26 # include "incls/_mutableSpace.cpp.incl" |
27 |
27 |
28 void MutableSpace::initialize(MemRegion mr, bool clear_space) { |
28 MutableSpace::MutableSpace(): ImmutableSpace(), _top(NULL) { |
|
29 _mangler = new MutableSpaceMangler(this); |
|
30 } |
|
31 |
|
32 MutableSpace::~MutableSpace() { |
|
33 delete _mangler; |
|
34 } |
|
35 |
|
36 void MutableSpace::initialize(MemRegion mr, |
|
37 bool clear_space, |
|
38 bool mangle_space) { |
29 HeapWord* bottom = mr.start(); |
39 HeapWord* bottom = mr.start(); |
30 HeapWord* end = mr.end(); |
40 HeapWord* end = mr.end(); |
31 |
41 |
32 assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), |
42 assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), |
33 "invalid space boundaries"); |
43 "invalid space boundaries"); |
34 set_bottom(bottom); |
44 set_bottom(bottom); |
35 set_end(end); |
45 set_end(end); |
36 |
46 |
37 if (clear_space) clear(); |
47 if (clear_space) { |
|
48 clear(mangle_space); |
|
49 } |
38 } |
50 } |
39 |
51 |
40 void MutableSpace::clear() { |
52 void MutableSpace::clear(bool mangle_space) { |
41 set_top(bottom()); |
53 set_top(bottom()); |
42 if (ZapUnusedHeapArea) mangle_unused_area(); |
54 if (ZapUnusedHeapArea && mangle_space) { |
|
55 mangle_unused_area(); |
|
56 } |
43 } |
57 } |
|
58 |
|
59 #ifndef PRODUCT |
|
60 void MutableSpace::check_mangled_unused_area(HeapWord* limit) { |
|
61 mangler()->check_mangled_unused_area(limit); |
|
62 } |
|
63 |
|
64 void MutableSpace::check_mangled_unused_area_complete() { |
|
65 mangler()->check_mangled_unused_area_complete(); |
|
66 } |
|
67 |
|
68 // Mangle only the unused space that has not previously |
|
69 // been mangled and that has not been allocated since being |
|
70 // mangled. |
|
71 void MutableSpace::mangle_unused_area() { |
|
72 mangler()->mangle_unused_area(); |
|
73 } |
|
74 |
|
75 void MutableSpace::mangle_unused_area_complete() { |
|
76 mangler()->mangle_unused_area_complete(); |
|
77 } |
|
78 |
|
79 void MutableSpace::mangle_region(MemRegion mr) { |
|
80 SpaceMangler::mangle_region(mr); |
|
81 } |
|
82 |
|
83 void MutableSpace::set_top_for_allocations(HeapWord* v) { |
|
84 mangler()->set_top_for_allocations(v); |
|
85 } |
|
86 |
|
87 void MutableSpace::set_top_for_allocations() { |
|
88 mangler()->set_top_for_allocations(top()); |
|
89 } |
|
90 #endif |
44 |
91 |
45 // This version requires locking. */ |
92 // This version requires locking. */ |
46 HeapWord* MutableSpace::allocate(size_t size) { |
93 HeapWord* MutableSpace::allocate(size_t size) { |
47 assert(Heap_lock->owned_by_self() || |
94 assert(Heap_lock->owned_by_self() || |
48 (SafepointSynchronize::is_at_safepoint() && |
95 (SafepointSynchronize::is_at_safepoint() && |