57 // Mangle between top and the high water mark. Safeguard
58 // against the space changing since top_for_allocations was
59 // set.
60 HeapWord* mangled_end = MIN2(top_for_allocations(), end());
61 if (top() < mangled_end) {
62 MemRegion mangle_mr(top(), mangled_end);
63 SpaceMangler::mangle_region(mangle_mr);
64 // Light weight check of mangling.
65 check_mangled_unused_area(end());
66 }
67 // Complete check of unused area which is functional when
68 // DEBUG_MANGLING is defined.
69 check_mangled_unused_area_complete();
70 }
71
72 // A complete mangle is expected in the
73 // exceptional case where top_for_allocations is not
74 // properly tracking the high water mark for mangling.
75 // This can be the case when to-space is being used for
76 // scratch space during a mark-sweep-compact. See
77 // contribute_scratch() and PSMarkSweep::allocate_stacks().
78 void SpaceMangler::mangle_unused_area_complete() {
79 assert(ZapUnusedHeapArea, "Mangling should not be in use");
80 MemRegion mangle_mr(top(), end());
81 SpaceMangler::mangle_region(mangle_mr);
82 }
83
84 // Simply mangle the MemRegion mr.
85 void SpaceMangler::mangle_region(MemRegion mr) {
86 assert(ZapUnusedHeapArea, "Mangling should not be in use");
87 #ifdef ASSERT
88 Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord);
89 #endif
90 }
91
92 // Check that top, top_for_allocations and the last
93 // word of the space are mangled. In a tight memory
94 // situation even this light weight mangling could
95 // cause paging by touching the end of the space.
96 void SpaceMangler::check_mangled_unused_area(HeapWord* limit) {
97 if (CheckZapUnusedHeapArea) {
|
57 // Mangle between top and the high water mark. Safeguard
58 // against the space changing since top_for_allocations was
59 // set.
60 HeapWord* mangled_end = MIN2(top_for_allocations(), end());
61 if (top() < mangled_end) {
62 MemRegion mangle_mr(top(), mangled_end);
63 SpaceMangler::mangle_region(mangle_mr);
64 // Light weight check of mangling.
65 check_mangled_unused_area(end());
66 }
67 // Complete check of unused area which is functional when
68 // DEBUG_MANGLING is defined.
69 check_mangled_unused_area_complete();
70 }
71
72 // A complete mangle is expected in the
73 // exceptional case where top_for_allocations is not
74 // properly tracking the high water mark for mangling.
75 // This can be the case when to-space is being used for
76 // scratch space during a mark-sweep-compact. See
77 // contribute_scratch().
78 void SpaceMangler::mangle_unused_area_complete() {
79 assert(ZapUnusedHeapArea, "Mangling should not be in use");
80 MemRegion mangle_mr(top(), end());
81 SpaceMangler::mangle_region(mangle_mr);
82 }
83
84 // Simply mangle the MemRegion mr.
85 void SpaceMangler::mangle_region(MemRegion mr) {
86 assert(ZapUnusedHeapArea, "Mangling should not be in use");
87 #ifdef ASSERT
88 Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord);
89 #endif
90 }
91
92 // Check that top, top_for_allocations and the last
93 // word of the space are mangled. In a tight memory
94 // situation even this light weight mangling could
95 // cause paging by touching the end of the space.
96 void SpaceMangler::check_mangled_unused_area(HeapWord* limit) {
97 if (CheckZapUnusedHeapArea) {
|