annotate src/share/vm/runtime/interfaceSupport.cpp @ 20527:8cb56c8cb30d

Merge
author jiangli
date Mon, 15 Sep 2014 16:39:00 -0400
parents ce8f6bb717c9
children 4e4ebe50c8e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 2426
diff changeset
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/shared/markSweep.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_interface/collectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/genCollectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/init.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/interfaceSupport.hpp"
20197
ce8f6bb717c9 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 17937
diff changeset
33 #include "runtime/orderAccess.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/threadLocalStorage.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "runtime/vframe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "utilities/preserveException.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
37
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 2426
diff changeset
38 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Implementation of InterfaceSupport
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 long InterfaceSupport::_number_of_calls = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 long InterfaceSupport::_scavenge_alot_counter = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 long InterfaceSupport::_fullgc_alot_counter = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 long InterfaceSupport::_fullgc_alot_invocation = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 Histogram* RuntimeHistogram;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 RuntimeHistogramElement::RuntimeHistogramElement(const char* elementName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 static volatile jint RuntimeHistogram_lock = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _name = elementName;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 uintx count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 while (Atomic::cmpxchg(1, &RuntimeHistogram_lock, 0) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 while (OrderAccess::load_acquire(&RuntimeHistogram_lock) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 count +=1;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if ( (WarnOnStalledSpinLock > 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
60 && (count % WarnOnStalledSpinLock == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 warning("RuntimeHistogram_lock seems to be stalled");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 if (RuntimeHistogram == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 RuntimeHistogram = new Histogram("VM Runtime Call Counts",200);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 RuntimeHistogram->add_element(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 Atomic::dec(&RuntimeHistogram_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void InterfaceSupport::trace(const char* result_type, const char* header) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 tty->print_cr("%6d %s", _number_of_calls, header);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 void InterfaceSupport::gc_alot() {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 Thread *thread = Thread::current();
806
821269eca479 6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents: 0
diff changeset
80 if (!thread->is_Java_thread()) return; // Avoid concurrent calls
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Check for new, not quite initialized thread. A thread in new mode cannot initiate a GC.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 JavaThread *current_thread = (JavaThread *)thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (current_thread->active_handles() == NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
84
806
821269eca479 6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents: 0
diff changeset
85 // Short-circuit any possible re-entrant gc-a-lot attempt
821269eca479 6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents: 0
diff changeset
86 if (thread->skip_gcalot()) return;
821269eca479 6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents: 0
diff changeset
87
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if (is_init_completed()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (++_fullgc_alot_invocation < FullGCALotStart) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Use this line if you want to block at a specific point,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // e.g. one number_of_calls/scavenge/gc before you got into problems
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (FullGCALot) _fullgc_alot_counter--;
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Check if we should force a full gc
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (_fullgc_alot_counter == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Release dummy so objects are forced to move
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (!Universe::release_fullgc_alot_dummy()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 warning("FullGCALot: Unable to release more dummies at bottom of heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 HandleMark hm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 Universe::heap()->collect(GCCause::_full_gc_alot);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 unsigned int invocations = Universe::heap()->total_full_collections();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Compute new interval
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (FullGCALotInterval > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _fullgc_alot_counter = 1+(long)((double)FullGCALotInterval*os::random()/(max_jint+1.0));
a61af66fc99e Initial load
duke
parents:
diff changeset
110 if (PrintGCDetails && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 tty->print_cr("Full gc no: %u\tInterval: %d", invocations,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _fullgc_alot_counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 _fullgc_alot_counter = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Print progress message
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (invocations % 100 == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 if (PrintGCDetails && Verbose) tty->print_cr("Full gc no: %u", invocations);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (ScavengeALot) _scavenge_alot_counter--;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Check if we should force a scavenge
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if (_scavenge_alot_counter == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 HandleMark hm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 Universe::heap()->collect(GCCause::_scavenge_alot);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 unsigned int invocations = Universe::heap()->total_collections() - Universe::heap()->total_full_collections();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Compute new interval
a61af66fc99e Initial load
duke
parents:
diff changeset
129 if (ScavengeALotInterval > 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _scavenge_alot_counter = 1+(long)((double)ScavengeALotInterval*os::random()/(max_jint+1.0));
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (PrintGCDetails && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 tty->print_cr("Scavenge no: %u\tInterval: %d", invocations,
a61af66fc99e Initial load
duke
parents:
diff changeset
133 _scavenge_alot_counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _scavenge_alot_counter = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Print progress message
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (invocations % 1000 == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (PrintGCDetails && Verbose) tty->print_cr("Scavenge no: %u", invocations);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 vframe* vframe_array[50];
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int walk_stack_counter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void InterfaceSupport::walk_stack_from(vframe* start_vf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // walk
a61af66fc99e Initial load
duke
parents:
diff changeset
153 int i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 for (vframe* f = start_vf; f; f = f->sender() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if (i < 50) vframe_array[i++] = f;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void InterfaceSupport::walk_stack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 walk_stack_counter++;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (!thread->has_last_Java_frame()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 ResourceMark rm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 RegisterMap reg_map(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 walk_stack_from(thread->last_java_vframe(&reg_map));
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 # ifdef ENABLE_ZAP_DEAD_LOCALS
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 static int zap_traversals = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 void InterfaceSupport::zap_dead_locals_old() {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (zap_traversals == -1) // edit constant for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
177 warning("I am here");
a61af66fc99e Initial load
duke
parents:
diff changeset
178 int zap_frame_count = 0; // count frames to help debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
179 for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 sfs.current()->zap_dead_locals(thread, sfs.register_map());
a61af66fc99e Initial load
duke
parents:
diff changeset
181 ++zap_frame_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 ++zap_traversals;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 # endif
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 int deoptimizeAllCounter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 int zombieAllCounter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 void InterfaceSupport::zombieAll() {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 if (is_init_completed() && zombieAllCounter > ZombieALotInterval) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 zombieAllCounter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 VM_ZombieAll op;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 VMThread::execute(&op);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 zombieAllCounter++;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
203 void InterfaceSupport::unlinkSymbols() {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
204 VM_UnlinkSymbols op;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
205 VMThread::execute(&op);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
206 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
207
0
a61af66fc99e Initial load
duke
parents:
diff changeset
208 void InterfaceSupport::deoptimizeAll() {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (is_init_completed() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (DeoptimizeALot && deoptimizeAllCounter > DeoptimizeALotInterval) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 deoptimizeAllCounter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 VM_DeoptimizeAll op;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 VMThread::execute(&op);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 } else if (DeoptimizeRandom && (deoptimizeAllCounter & 0x1f) == (os::random() & 0x1f)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 VM_DeoptimizeAll op;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 VMThread::execute(&op);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 deoptimizeAllCounter++;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 void InterfaceSupport::stress_derived_pointers() {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
225 JavaThread *thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (!is_init_completed()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 ResourceMark rm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
228 bool found = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 for (StackFrameStream sfs(thread); !sfs.is_done() && !found; sfs.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 CodeBlob* cb = sfs.current()->cb();
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if (cb != NULL && cb->oop_maps() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Find oopmap for current method
a61af66fc99e Initial load
duke
parents:
diff changeset
233 OopMap* map = cb->oop_map_for_return_address(sfs.current()->pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
234 assert(map != NULL, "no oopmap found for pc");
a61af66fc99e Initial load
duke
parents:
diff changeset
235 found = map->has_derived_pointer();
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (found) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // $$$ Not sure what to do here.
a61af66fc99e Initial load
duke
parents:
diff changeset
240 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
241 Scavenge::invoke(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 */
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 void InterfaceSupport::verify_stack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
250 ResourceMark rm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // disabled because it throws warnings that oop maps should only be accessed
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // in VM thread or during debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if (!thread->has_pending_exception()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // verification does not work if there are pending exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
256 StackFrameStream sfs(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 CodeBlob* cb = sfs.current()->cb();
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // In case of exceptions we might not have a runtime_stub on
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // top of stack, hence, all callee-saved registers are not going
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // to be setup correctly, hence, we cannot do stack verify
a61af66fc99e Initial load
duke
parents:
diff changeset
261 if (cb != NULL && !(cb->is_runtime_stub() || cb->is_uncommon_trap_stub())) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 for (; !sfs.is_done(); sfs.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 sfs.current()->verify(sfs.register_map());
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 void InterfaceSupport::verify_last_frame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 JavaThread* thread = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
272 ResourceMark rm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 RegisterMap reg_map(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 frame fr = thread->last_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 fr.verify(&reg_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 void InterfaceSupport_init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
284 if (ScavengeALot || FullGCALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 srand(ScavengeALotInterval * FullGCALotInterval);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }