Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp @ 5965:cc74fa5a91a9
7103665: HeapWord*ParallelScavengeHeap::failed_mem_allocate(unsigned long,bool)+0x97
Summary: Make sure that MutableNUMASpace::ensure_parsability() only calls CollectedHeap::fill_with_object() with valid sizes and make sure CollectedHeap::filler_array_max_size() returns a value that can be converted to an int without overflow
Reviewed-by: azeemj, jmasa, iveresov
author | brutisso |
---|---|
date | Fri, 23 Mar 2012 15:28:24 +0100 |
parents | 20bfb6d15a94 |
children | b632e80fc9dc |
comparison
equal
deleted
inserted
replaced
5964:21595f05bc93 | 5965:cc74fa5a91a9 |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. | 3 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * | 5 * |
6 * This code is free software; you can redistribute it and/or modify it | 6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as | 7 * under the terms of the GNU General Public License version 2 only, as |
8 * published by the Free Software Foundation. | 8 * published by the Free Software Foundation. |
89 for (int i = 0; i < lgrp_spaces()->length(); i++) { | 89 for (int i = 0; i < lgrp_spaces()->length(); i++) { |
90 LGRPSpace *ls = lgrp_spaces()->at(i); | 90 LGRPSpace *ls = lgrp_spaces()->at(i); |
91 MutableSpace *s = ls->space(); | 91 MutableSpace *s = ls->space(); |
92 if (s->top() < top()) { // For all spaces preceding the one containing top() | 92 if (s->top() < top()) { // For all spaces preceding the one containing top() |
93 if (s->free_in_words() > 0) { | 93 if (s->free_in_words() > 0) { |
94 size_t area_touched_words = pointer_delta(s->end(), s->top()); | 94 intptr_t cur_top = (intptr_t)s->top(); |
95 CollectedHeap::fill_with_object(s->top(), area_touched_words); | 95 size_t words_left_to_fill = pointer_delta(s->end(), s->top());; |
96 while (words_left_to_fill > 0) { | |
97 size_t words_to_fill = MIN2(words_left_to_fill, CollectedHeap::filler_array_max_size()); | |
98 assert(words_to_fill >= CollectedHeap::min_fill_size(), | |
99 err_msg("Remaining size ("SIZE_FORMAT ") is too small to fill (based on " SIZE_FORMAT " and " SIZE_FORMAT ")", | |
100 words_to_fill, words_left_to_fill, CollectedHeap::filler_array_max_size())); | |
101 CollectedHeap::fill_with_object((HeapWord*)cur_top, words_to_fill); | |
102 if (!os::numa_has_static_binding()) { | |
103 size_t touched_words = words_to_fill; | |
96 #ifndef ASSERT | 104 #ifndef ASSERT |
97 if (!ZapUnusedHeapArea) { | 105 if (!ZapUnusedHeapArea) { |
98 area_touched_words = MIN2((size_t)align_object_size(typeArrayOopDesc::header_size(T_INT)), | 106 touched_words = MIN2((size_t)align_object_size(typeArrayOopDesc::header_size(T_INT)), |
99 area_touched_words); | 107 touched_words); |
100 } | 108 } |
101 #endif | 109 #endif |
102 if (!os::numa_has_static_binding()) { | 110 MemRegion invalid; |
103 MemRegion invalid; | 111 HeapWord *crossing_start = (HeapWord*)round_to(cur_top, os::vm_page_size()); |
104 HeapWord *crossing_start = (HeapWord*)round_to((intptr_t)s->top(), os::vm_page_size()); | 112 HeapWord *crossing_end = (HeapWord*)round_to(cur_top + touched_words, os::vm_page_size()); |
105 HeapWord *crossing_end = (HeapWord*)round_to((intptr_t)(s->top() + area_touched_words), | 113 if (crossing_start != crossing_end) { |
106 os::vm_page_size()); | 114 // If object header crossed a small page boundary we mark the area |
107 if (crossing_start != crossing_end) { | 115 // as invalid rounding it to a page_size(). |
108 // If object header crossed a small page boundary we mark the area | 116 HeapWord *start = MAX2((HeapWord*)round_down(cur_top, page_size()), s->bottom()); |
109 // as invalid rounding it to a page_size(). | 117 HeapWord *end = MIN2((HeapWord*)round_to(cur_top + touched_words, page_size()), s->end()); |
110 HeapWord *start = MAX2((HeapWord*)round_down((intptr_t)s->top(), page_size()), s->bottom()); | 118 invalid = MemRegion(start, end); |
111 HeapWord *end = MIN2((HeapWord*)round_to((intptr_t)(s->top() + area_touched_words), page_size()), | 119 } |
112 s->end()); | 120 |
113 invalid = MemRegion(start, end); | 121 ls->add_invalid_region(invalid); |
114 } | 122 } |
115 | 123 cur_top = cur_top + (words_to_fill * HeapWordSize); |
116 ls->add_invalid_region(invalid); | 124 words_left_to_fill -= words_to_fill; |
117 } | 125 } |
118 } | 126 } |
119 } else { | 127 } else { |
120 if (!os::numa_has_static_binding()) { | 128 if (!os::numa_has_static_binding()) { |
121 #ifdef ASSERT | 129 #ifdef ASSERT |