src/share/vm/gc_implementation/g1/vm_operations_g1.hpp

Thu, 07 Apr 2011 09:53:20 -0700

author
johnc
date
Thu, 07 Apr 2011 09:53:20 -0700
changeset 2781
e1162778c1c8
parent 2532
c798c277ddd1
child 3218
db89aa49298f
permissions
-rw-r--r--

7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
Summary: A referent object that is only weakly reachable at the start of concurrent marking but is re-attached to the strongly reachable object graph during marking may not be marked as live. This can cause the reference object to be processed prematurely and leave dangling pointers to the referent object. Implement a read barrier for the java.lang.ref.Reference::referent field by intrinsifying the Reference.get() method, and intercepting accesses though JNI, reflection, and Unsafe, so that when a non-null referent object is read it is also logged in an SATB buffer.
Reviewed-by: kvn, iveresov, never, tonyp, dholmes

ysr@777 1 /*
brutisso@2532 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 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.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_VM_OPERATIONS_G1_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_VM_OPERATIONS_G1_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/shared/vmGCOperations.hpp"
stefank@2314 29
ysr@777 30 // VM_operations for the G1 collector.
ysr@777 31 // VM_GC_Operation:
ysr@777 32 // - VM_CGC_Operation
ysr@777 33 // - VM_G1CollectFull
tonyp@2315 34 // - VM_G1OperationWithAllocRequest
tonyp@2315 35 // - VM_G1CollectForAllocation
tonyp@2315 36 // - VM_G1IncCollectionPause
tonyp@2315 37
tonyp@2315 38 class VM_G1OperationWithAllocRequest: public VM_GC_Operation {
tonyp@2315 39 protected:
tonyp@2315 40 size_t _word_size;
tonyp@2315 41 HeapWord* _result;
tonyp@2315 42 bool _pause_succeeded;
tonyp@2315 43
tonyp@2315 44 public:
tonyp@2315 45 VM_G1OperationWithAllocRequest(unsigned int gc_count_before,
tonyp@2315 46 size_t word_size)
brutisso@2532 47 : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure),
tonyp@2315 48 _word_size(word_size), _result(NULL), _pause_succeeded(false) { }
tonyp@2315 49 HeapWord* result() { return _result; }
tonyp@2315 50 bool pause_succeeded() { return _pause_succeeded; }
tonyp@2315 51 };
ysr@777 52
ysr@777 53 class VM_G1CollectFull: public VM_GC_Operation {
tonyp@2315 54 public:
tonyp@2011 55 VM_G1CollectFull(unsigned int gc_count_before,
tonyp@2011 56 unsigned int full_gc_count_before,
tonyp@2011 57 GCCause::Cause cause)
brutisso@2532 58 : VM_GC_Operation(gc_count_before, cause, full_gc_count_before) { }
ysr@777 59 virtual VMOp_Type type() const { return VMOp_G1CollectFull; }
ysr@777 60 virtual void doit();
ysr@777 61 virtual const char* name() const {
ysr@777 62 return "full garbage-first collection";
ysr@777 63 }
ysr@777 64 };
ysr@777 65
tonyp@2315 66 class VM_G1CollectForAllocation: public VM_G1OperationWithAllocRequest {
tonyp@2315 67 public:
tonyp@2315 68 VM_G1CollectForAllocation(unsigned int gc_count_before,
tonyp@2315 69 size_t word_size);
ysr@777 70 virtual VMOp_Type type() const { return VMOp_G1CollectForAllocation; }
ysr@777 71 virtual void doit();
ysr@777 72 virtual const char* name() const {
ysr@777 73 return "garbage-first collection to satisfy allocation";
ysr@777 74 }
ysr@777 75 };
ysr@777 76
tonyp@2315 77 class VM_G1IncCollectionPause: public VM_G1OperationWithAllocRequest {
tonyp@2011 78 private:
tonyp@2315 79 bool _should_initiate_conc_mark;
tonyp@2315 80 double _target_pause_time_ms;
tonyp@2011 81 unsigned int _full_collections_completed_before;
tonyp@2011 82 public:
tonyp@2011 83 VM_G1IncCollectionPause(unsigned int gc_count_before,
tonyp@2315 84 size_t word_size,
tonyp@2011 85 bool should_initiate_conc_mark,
tonyp@2011 86 double target_pause_time_ms,
tonyp@2315 87 GCCause::Cause gc_cause);
ysr@777 88 virtual VMOp_Type type() const { return VMOp_G1IncCollectionPause; }
ysr@777 89 virtual void doit();
tonyp@2011 90 virtual void doit_epilogue();
ysr@777 91 virtual const char* name() const {
ysr@777 92 return "garbage-first incremental collection pause";
ysr@777 93 }
ysr@777 94 };
ysr@777 95
ysr@777 96 // Concurrent GC stop-the-world operations such as initial and final mark;
ysr@777 97 // consider sharing these with CMS's counterparts.
ysr@777 98 class VM_CGC_Operation: public VM_Operation {
ysr@777 99 VoidClosure* _cl;
ysr@777 100 const char* _printGCMessage;
tonyp@2315 101 public:
tonyp@2315 102 VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg)
tonyp@2315 103 : _cl(cl), _printGCMessage(printGCMsg) { }
ysr@777 104 virtual VMOp_Type type() const { return VMOp_CGC_Operation; }
ysr@777 105 virtual void doit();
ysr@777 106 virtual bool doit_prologue();
ysr@777 107 virtual void doit_epilogue();
ysr@777 108 virtual const char* name() const {
ysr@777 109 return "concurrent gc";
ysr@777 110 }
ysr@777 111 };
stefank@2314 112
stefank@2314 113 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_VM_OPERATIONS_G1_HPP

mercurial