src/share/vm/memory/defNewGeneration.inline.hpp

Mon, 29 Apr 2013 16:13:57 -0400

author
hseigel
date
Mon, 29 Apr 2013 16:13:57 -0400
changeset 4987
f258c5828eb8
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

8011773: Some tests on Interned String crashed JVM with OOM
Summary: Instead of terminating the VM, throw OutOfMemoryError exceptions.
Reviewed-by: coleenp, dholmes

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP
stefank@2314 27
stefank@2314 28 #include "memory/cardTableRS.hpp"
stefank@2314 29 #include "memory/defNewGeneration.hpp"
stefank@2314 30 #include "memory/space.hpp"
stefank@2314 31
coleenp@548 32 // Methods of protected closure types
coleenp@548 33
coleenp@548 34 template <class T>
coleenp@548 35 inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {
coleenp@548 36 #ifdef ASSERT
coleenp@548 37 {
coleenp@548 38 // We never expect to see a null reference being processed
coleenp@548 39 // as a weak reference.
coleenp@548 40 assert (!oopDesc::is_null(*p), "expected non-null ref");
coleenp@548 41 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
coleenp@548 42 assert (obj->is_oop(), "expected an oop while scanning weak refs");
coleenp@548 43 }
coleenp@548 44 #endif // ASSERT
coleenp@548 45
coleenp@548 46 _cl->do_oop_nv(p);
coleenp@548 47
coleenp@548 48 // Card marking is trickier for weak refs.
coleenp@548 49 // This oop is a 'next' field which was filled in while we
coleenp@548 50 // were discovering weak references. While we might not need
coleenp@548 51 // to take a special action to keep this reference alive, we
coleenp@548 52 // will need to dirty a card as the field was modified.
coleenp@548 53 //
coleenp@548 54 // Alternatively, we could create a method which iterates through
coleenp@548 55 // each generation, allowing them in turn to examine the modified
coleenp@548 56 // field.
coleenp@548 57 //
coleenp@548 58 // We could check that p is also in an older generation, but
coleenp@548 59 // dirty cards in the youngest gen are never scanned, so the
coleenp@548 60 // extra check probably isn't worthwhile.
coleenp@548 61 if (Universe::heap()->is_in_reserved(p)) {
coleenp@548 62 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
coleenp@548 63 _rs->inline_write_ref_field_gc(p, obj);
coleenp@548 64 }
duke@435 65 }
duke@435 66
coleenp@548 67 template <class T>
coleenp@548 68 inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {
coleenp@548 69 #ifdef ASSERT
coleenp@548 70 {
coleenp@548 71 // We never expect to see a null reference being processed
coleenp@548 72 // as a weak reference.
coleenp@548 73 assert (!oopDesc::is_null(*p), "expected non-null ref");
coleenp@548 74 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
coleenp@548 75 assert (obj->is_oop(), "expected an oop while scanning weak refs");
duke@435 76 }
coleenp@548 77 #endif // ASSERT
duke@435 78
coleenp@548 79 _cl->do_oop_nv(p);
coleenp@548 80
coleenp@548 81 // Optimized for Defnew generation if it's the youngest generation:
coleenp@548 82 // we set a younger_gen card if we have an older->youngest
coleenp@548 83 // generation pointer.
coleenp@548 84 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
coleenp@548 85 if (((HeapWord*)obj < _boundary) && Universe::heap()->is_in_reserved(p)) {
coleenp@548 86 _rs->inline_write_ref_field_gc(p, obj);
duke@435 87 }
duke@435 88 }
stefank@2314 89
stefank@2314 90 #endif // SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP

mercurial