Wed, 10 Oct 2012 14:35:58 -0400
7189254: Change makefiles for more flexibility to override defaults
Summary: Change makefiles so that targets and parameters can be overridden by alternate makefiles.
Reviewed-by: dholmes, coleenp
zgu@3900 | 1 | /* |
zgu@3900 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
zgu@3900 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
zgu@3900 | 4 | * |
zgu@3900 | 5 | * This code is free software; you can redistribute it and/or modify it |
zgu@3900 | 6 | * under the terms of the GNU General Public License version 2 only, as |
zgu@3900 | 7 | * published by the Free Software Foundation. |
zgu@3900 | 8 | * |
zgu@3900 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
zgu@3900 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
zgu@3900 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
zgu@3900 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
zgu@3900 | 13 | * accompanied this code). |
zgu@3900 | 14 | * |
zgu@3900 | 15 | * You should have received a copy of the GNU General Public License version |
zgu@3900 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
zgu@3900 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
zgu@3900 | 18 | * |
zgu@3900 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
zgu@3900 | 20 | * or visit www.oracle.com if you need additional information or have any |
zgu@3900 | 21 | * questions. |
zgu@3900 | 22 | * |
zgu@3900 | 23 | */ |
zgu@3900 | 24 | |
zgu@3900 | 25 | #include "precompiled.hpp" |
zgu@3900 | 26 | |
zgu@3900 | 27 | #include "runtime/atomic.hpp" |
zgu@3900 | 28 | #include "services/memBaseline.hpp" |
zgu@3900 | 29 | #include "services/memRecorder.hpp" |
zgu@3900 | 30 | #include "services/memPtr.hpp" |
zgu@3900 | 31 | #include "services/memTracker.hpp" |
zgu@3900 | 32 | |
zgu@3900 | 33 | MemPointer* SequencedRecordIterator::next_record() { |
zgu@3900 | 34 | MemPointer* itr_cur = _itr.current(); |
zgu@3900 | 35 | if (itr_cur == NULL) return NULL; |
zgu@3900 | 36 | MemPointer* itr_next = _itr.next(); |
zgu@3900 | 37 | |
zgu@3900 | 38 | while (itr_next != NULL && |
zgu@3900 | 39 | same_kind((MemPointerRecord*)itr_cur, (MemPointerRecord*)itr_next)) { |
zgu@3900 | 40 | itr_cur = itr_next; |
zgu@3900 | 41 | itr_next = _itr.next(); |
zgu@3900 | 42 | } |
zgu@3900 | 43 | |
zgu@3900 | 44 | return itr_cur; |
zgu@3900 | 45 | } |
zgu@3900 | 46 | |
zgu@3900 | 47 | |
zgu@3935 | 48 | volatile jint MemRecorder::_instance_count = 0; |
zgu@3900 | 49 | |
zgu@3900 | 50 | MemRecorder::MemRecorder() { |
zgu@3900 | 51 | assert(MemTracker::is_on(), "Native memory tracking is off"); |
zgu@3935 | 52 | Atomic::inc(&_instance_count); |
zgu@3900 | 53 | debug_only(set_generation();) |
zgu@3900 | 54 | |
zgu@3900 | 55 | if (MemTracker::track_callsite()) { |
zgu@3900 | 56 | _pointer_records = new (std::nothrow)FixedSizeMemPointerArray<SeqMemPointerRecordEx, |
zgu@3900 | 57 | DEFAULT_RECORDER_PTR_ARRAY_SIZE>(); |
zgu@3900 | 58 | } else { |
zgu@3900 | 59 | _pointer_records = new (std::nothrow)FixedSizeMemPointerArray<SeqMemPointerRecord, |
zgu@3900 | 60 | DEFAULT_RECORDER_PTR_ARRAY_SIZE>(); |
zgu@3900 | 61 | } |
zgu@3900 | 62 | _next = NULL; |
zgu@3900 | 63 | |
zgu@3900 | 64 | |
zgu@3900 | 65 | if (_pointer_records != NULL) { |
zgu@3900 | 66 | // recode itself |
zgu@3900 | 67 | record((address)this, (MemPointerRecord::malloc_tag()|mtNMT|otNMTRecorder), |
zgu@3900 | 68 | sizeof(MemRecorder), CALLER_PC); |
zgu@3900 | 69 | record((address)_pointer_records, (MemPointerRecord::malloc_tag()|mtNMT|otNMTRecorder), |
zgu@3900 | 70 | _pointer_records->instance_size(),CURRENT_PC); |
zgu@3900 | 71 | } |
zgu@3900 | 72 | } |
zgu@3900 | 73 | |
zgu@3900 | 74 | MemRecorder::~MemRecorder() { |
zgu@3900 | 75 | if (_pointer_records != NULL) { |
zgu@3900 | 76 | if (MemTracker::is_on()) { |
zgu@3900 | 77 | MemTracker::record_free((address)_pointer_records, mtNMT); |
zgu@3900 | 78 | MemTracker::record_free((address)this, mtNMT); |
zgu@3900 | 79 | } |
zgu@3900 | 80 | delete _pointer_records; |
zgu@3900 | 81 | } |
zgu@3900 | 82 | if (_next != NULL) { |
zgu@3900 | 83 | delete _next; |
zgu@3900 | 84 | } |
zgu@3900 | 85 | |
zgu@3900 | 86 | Atomic::dec(&_instance_count); |
zgu@3900 | 87 | } |
zgu@3900 | 88 | |
zgu@3900 | 89 | // Sorting order: |
zgu@3900 | 90 | // 1. memory block address |
zgu@3900 | 91 | // 2. mem pointer record tags |
zgu@3900 | 92 | // 3. sequence number |
zgu@3900 | 93 | int MemRecorder::sort_record_fn(const void* e1, const void* e2) { |
zgu@3900 | 94 | const MemPointerRecord* p1 = (const MemPointerRecord*)e1; |
zgu@3900 | 95 | const MemPointerRecord* p2 = (const MemPointerRecord*)e2; |
zgu@3900 | 96 | int delta = UNSIGNED_COMPARE(p1->addr(), p2->addr()); |
zgu@3900 | 97 | if (delta == 0) { |
zgu@3900 | 98 | int df = UNSIGNED_COMPARE((p1->flags() & MemPointerRecord::tag_masks), |
zgu@3900 | 99 | (p2->flags() & MemPointerRecord::tag_masks)); |
zgu@3900 | 100 | if (df == 0) { |
zgu@3900 | 101 | assert(p1->seq() != p2->seq(), "dup seq"); |
zgu@3900 | 102 | return p1->seq() - p2->seq(); |
zgu@3900 | 103 | } else { |
zgu@3900 | 104 | return df; |
zgu@3900 | 105 | } |
zgu@3900 | 106 | } else { |
zgu@3900 | 107 | return delta; |
zgu@3900 | 108 | } |
zgu@3900 | 109 | } |
zgu@3900 | 110 | |
zgu@3900 | 111 | bool MemRecorder::record(address p, MEMFLAGS flags, size_t size, address pc) { |
zgu@3900 | 112 | #ifdef ASSERT |
zgu@3900 | 113 | if (MemPointerRecord::is_virtual_memory_record(flags)) { |
zgu@3900 | 114 | assert((flags & MemPointerRecord::tag_masks) != 0, "bad virtual memory record"); |
zgu@3900 | 115 | } else { |
zgu@3900 | 116 | assert((flags & MemPointerRecord::tag_masks) == MemPointerRecord::malloc_tag() || |
zgu@3900 | 117 | (flags & MemPointerRecord::tag_masks) == MemPointerRecord::free_tag() || |
zgu@3900 | 118 | IS_ARENA_OBJ(flags), |
zgu@3900 | 119 | "bad malloc record"); |
zgu@3900 | 120 | } |
zgu@3900 | 121 | // a recorder should only hold records within the same generation |
zgu@3900 | 122 | unsigned long cur_generation = SequenceGenerator::current_generation(); |
zgu@3900 | 123 | assert(cur_generation == _generation, |
zgu@3900 | 124 | "this thread did not enter sync point"); |
zgu@3900 | 125 | #endif |
zgu@3900 | 126 | |
zgu@3900 | 127 | if (MemTracker::track_callsite()) { |
zgu@3900 | 128 | SeqMemPointerRecordEx ap(p, flags, size, pc); |
zgu@3900 | 129 | debug_only(check_dup_seq(ap.seq());) |
zgu@3900 | 130 | return _pointer_records->append(&ap); |
zgu@3900 | 131 | } else { |
zgu@3900 | 132 | SeqMemPointerRecord ap(p, flags, size); |
zgu@3900 | 133 | debug_only(check_dup_seq(ap.seq());) |
zgu@3900 | 134 | return _pointer_records->append(&ap); |
zgu@3900 | 135 | } |
zgu@3900 | 136 | } |
zgu@3900 | 137 | |
zgu@3900 | 138 | // iterator for alloc pointers |
zgu@3900 | 139 | SequencedRecordIterator MemRecorder::pointer_itr() { |
zgu@3900 | 140 | assert(_pointer_records != NULL, "just check"); |
zgu@3900 | 141 | _pointer_records->sort((FN_SORT)sort_record_fn); |
zgu@3900 | 142 | return SequencedRecordIterator(_pointer_records); |
zgu@3900 | 143 | } |
zgu@3900 | 144 | |
zgu@3900 | 145 | |
zgu@3900 | 146 | #ifdef ASSERT |
zgu@3900 | 147 | void MemRecorder::set_generation() { |
zgu@3900 | 148 | _generation = SequenceGenerator::current_generation(); |
zgu@3900 | 149 | } |
zgu@3900 | 150 | |
zgu@3900 | 151 | void MemRecorder::check_dup_seq(jint seq) const { |
zgu@3900 | 152 | MemPointerArrayIteratorImpl itr(_pointer_records); |
zgu@3900 | 153 | MemPointerRecord* rc = (MemPointerRecord*)itr.current(); |
zgu@3900 | 154 | while (rc != NULL) { |
zgu@3900 | 155 | assert(rc->seq() != seq, "dup seq"); |
zgu@3900 | 156 | rc = (MemPointerRecord*)itr.next(); |
zgu@3900 | 157 | } |
zgu@3900 | 158 | } |
zgu@3900 | 159 | |
zgu@3900 | 160 | #endif |