src/share/vm/code/scopeDesc.cpp

Tue, 15 Sep 2009 21:53:47 -0700

author
jrose
date
Tue, 15 Sep 2009 21:53:47 -0700
changeset 1424
148e5441d916
parent 1366
72088be4b386
child 1688
f70b0d9ab095
permissions
-rw-r--r--

6863023: need non-perm oops in code cache for JSR 292
Summary: Make a special root-list for those few nmethods which might contain non-perm oops.
Reviewed-by: twisti, kvn, never, jmasa, ysr

duke@435 1 /*
cfang@1366 2 * Copyright 1997-2009 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_scopeDesc.cpp.incl"
duke@435 27
duke@435 28
cfang@1366 29 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute) {
duke@435 30 _code = code;
duke@435 31 _decode_offset = decode_offset;
duke@435 32 _objects = decode_object_values(obj_decode_offset);
cfang@1366 33 _reexecute = reexecute;
duke@435 34 decode_body();
duke@435 35 }
duke@435 36
cfang@1366 37 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute) {
duke@435 38 _code = code;
duke@435 39 _decode_offset = decode_offset;
duke@435 40 _objects = decode_object_values(DebugInformationRecorder::serialized_null);
cfang@1366 41 _reexecute = reexecute;
duke@435 42 decode_body();
duke@435 43 }
duke@435 44
duke@435 45
duke@435 46 ScopeDesc::ScopeDesc(const ScopeDesc* parent) {
duke@435 47 _code = parent->_code;
duke@435 48 _decode_offset = parent->_sender_decode_offset;
duke@435 49 _objects = parent->_objects;
cfang@1366 50 _reexecute = false; //reexecute only applies to the first scope
duke@435 51 decode_body();
duke@435 52 }
duke@435 53
duke@435 54
duke@435 55 void ScopeDesc::decode_body() {
duke@435 56 if (decode_offset() == DebugInformationRecorder::serialized_null) {
duke@435 57 // This is a sentinel record, which is only relevant to
duke@435 58 // approximate queries. Decode a reasonable frame.
duke@435 59 _sender_decode_offset = DebugInformationRecorder::serialized_null;
duke@435 60 _method = methodHandle(_code->method());
duke@435 61 _bci = InvocationEntryBci;
duke@435 62 _locals_decode_offset = DebugInformationRecorder::serialized_null;
duke@435 63 _expressions_decode_offset = DebugInformationRecorder::serialized_null;
duke@435 64 _monitors_decode_offset = DebugInformationRecorder::serialized_null;
duke@435 65 } else {
duke@435 66 // decode header
duke@435 67 DebugInfoReadStream* stream = stream_at(decode_offset());
duke@435 68
duke@435 69 _sender_decode_offset = stream->read_int();
duke@435 70 _method = methodHandle((methodOop) stream->read_oop());
cfang@1366 71 _bci = stream->read_bci();
cfang@1335 72
duke@435 73 // decode offsets for body and sender
duke@435 74 _locals_decode_offset = stream->read_int();
duke@435 75 _expressions_decode_offset = stream->read_int();
duke@435 76 _monitors_decode_offset = stream->read_int();
duke@435 77 }
duke@435 78 }
duke@435 79
duke@435 80
duke@435 81 GrowableArray<ScopeValue*>* ScopeDesc::decode_scope_values(int decode_offset) {
duke@435 82 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL;
duke@435 83 DebugInfoReadStream* stream = stream_at(decode_offset);
duke@435 84 int length = stream->read_int();
duke@435 85 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*> (length);
duke@435 86 for (int index = 0; index < length; index++) {
duke@435 87 result->push(ScopeValue::read_from(stream));
duke@435 88 }
duke@435 89 return result;
duke@435 90 }
duke@435 91
duke@435 92 GrowableArray<ScopeValue*>* ScopeDesc::decode_object_values(int decode_offset) {
duke@435 93 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL;
duke@435 94 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*>();
duke@435 95 DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result);
duke@435 96 int length = stream->read_int();
duke@435 97 for (int index = 0; index < length; index++) {
kvn@479 98 // Objects values are pushed to 'result' array during read so that
kvn@479 99 // object's fields could reference it (OBJECT_ID_CODE).
kvn@479 100 (void)ScopeValue::read_from(stream);
duke@435 101 }
duke@435 102 assert(result->length() == length, "inconsistent debug information");
duke@435 103 return result;
duke@435 104 }
duke@435 105
duke@435 106
duke@435 107 GrowableArray<MonitorValue*>* ScopeDesc::decode_monitor_values(int decode_offset) {
duke@435 108 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL;
duke@435 109 DebugInfoReadStream* stream = stream_at(decode_offset);
duke@435 110 int length = stream->read_int();
duke@435 111 GrowableArray<MonitorValue*>* result = new GrowableArray<MonitorValue*> (length);
duke@435 112 for (int index = 0; index < length; index++) {
duke@435 113 result->push(new MonitorValue(stream));
duke@435 114 }
duke@435 115 return result;
duke@435 116 }
duke@435 117
duke@435 118 DebugInfoReadStream* ScopeDesc::stream_at(int decode_offset) const {
duke@435 119 return new DebugInfoReadStream(_code, decode_offset, _objects);
duke@435 120 }
duke@435 121
duke@435 122 GrowableArray<ScopeValue*>* ScopeDesc::locals() {
duke@435 123 return decode_scope_values(_locals_decode_offset);
duke@435 124 }
duke@435 125
duke@435 126 GrowableArray<ScopeValue*>* ScopeDesc::expressions() {
duke@435 127 return decode_scope_values(_expressions_decode_offset);
duke@435 128 }
duke@435 129
duke@435 130 GrowableArray<MonitorValue*>* ScopeDesc::monitors() {
duke@435 131 return decode_monitor_values(_monitors_decode_offset);
duke@435 132 }
duke@435 133
duke@435 134 GrowableArray<ScopeValue*>* ScopeDesc::objects() {
duke@435 135 return _objects;
duke@435 136 }
duke@435 137
duke@435 138 bool ScopeDesc::is_top() const {
duke@435 139 return _sender_decode_offset == DebugInformationRecorder::serialized_null;
duke@435 140 }
duke@435 141
duke@435 142 ScopeDesc* ScopeDesc::sender() const {
duke@435 143 if (is_top()) return NULL;
duke@435 144 return new ScopeDesc(this);
duke@435 145 }
duke@435 146
duke@435 147
duke@435 148 #ifndef PRODUCT
duke@435 149
duke@435 150 void ScopeDesc::print_value_on(outputStream* st) const {
duke@435 151 tty->print(" ");
duke@435 152 method()()->print_short_name(st);
duke@435 153 int lineno = method()->line_number_from_bci(bci());
duke@435 154 if (lineno != -1) {
duke@435 155 st->print_cr("@%d (line %d)", bci(), lineno);
duke@435 156 } else {
duke@435 157 st->print_cr("@%d", bci());
duke@435 158 }
duke@435 159 }
duke@435 160
duke@435 161 void ScopeDesc::print_on(outputStream* st) const {
duke@435 162 print_on(st, NULL);
duke@435 163 }
duke@435 164
duke@435 165 void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const {
duke@435 166 // header
duke@435 167 if (pd != NULL) {
duke@435 168 tty->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", pd->real_pc(_code), pd->pc_offset());
duke@435 169 }
duke@435 170
duke@435 171 print_value_on(st);
duke@435 172 // decode offsets
duke@435 173 if (WizardMode) {
duke@435 174 st->print("ScopeDesc[%d]@" PTR_FORMAT " ", _decode_offset, _code->instructions_begin());
duke@435 175 st->print_cr(" offset: %d", _decode_offset);
duke@435 176 st->print_cr(" bci: %d", bci());
cfang@1335 177 st->print_cr(" reexecute: %s", should_reexecute() ? "true" : "false");
duke@435 178 st->print_cr(" locals: %d", _locals_decode_offset);
duke@435 179 st->print_cr(" stack: %d", _expressions_decode_offset);
duke@435 180 st->print_cr(" monitor: %d", _monitors_decode_offset);
duke@435 181 st->print_cr(" sender: %d", _sender_decode_offset);
duke@435 182 }
duke@435 183 // locals
duke@435 184 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->locals();
duke@435 185 if (l != NULL) {
duke@435 186 tty->print_cr(" Locals");
duke@435 187 for (int index = 0; index < l->length(); index++) {
duke@435 188 st->print(" - l%d: ", index);
duke@435 189 l->at(index)->print_on(st);
duke@435 190 st->cr();
duke@435 191 }
duke@435 192 }
duke@435 193 }
duke@435 194 // expressions
duke@435 195 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->expressions();
duke@435 196 if (l != NULL) {
duke@435 197 st->print_cr(" Expression stack");
duke@435 198 for (int index = 0; index < l->length(); index++) {
duke@435 199 st->print(" - @%d: ", index);
duke@435 200 l->at(index)->print_on(st);
duke@435 201 st->cr();
duke@435 202 }
duke@435 203 }
duke@435 204 }
duke@435 205 // monitors
duke@435 206 { GrowableArray<MonitorValue*>* l = ((ScopeDesc*) this)->monitors();
duke@435 207 if (l != NULL) {
duke@435 208 st->print_cr(" Monitor stack");
duke@435 209 for (int index = 0; index < l->length(); index++) {
duke@435 210 st->print(" - @%d: ", index);
duke@435 211 l->at(index)->print_on(st);
duke@435 212 st->cr();
duke@435 213 }
duke@435 214 }
duke@435 215 }
duke@435 216
duke@435 217 #ifdef COMPILER2
duke@435 218 if (DoEscapeAnalysis && is_top() && _objects != NULL) {
duke@435 219 tty->print_cr("Objects");
duke@435 220 for (int i = 0; i < _objects->length(); i++) {
duke@435 221 ObjectValue* sv = (ObjectValue*) _objects->at(i);
duke@435 222 tty->print(" - %d: ", sv->id());
duke@435 223 sv->print_fields_on(tty);
duke@435 224 tty->cr();
duke@435 225 }
duke@435 226 }
duke@435 227 #endif // COMPILER2
duke@435 228 }
duke@435 229
duke@435 230 #endif
duke@435 231
duke@435 232 void ScopeDesc::verify() {
duke@435 233 ResourceMark rm;
duke@435 234 guarantee(method()->is_method(), "type check");
duke@435 235
duke@435 236 // check if we have any illegal elements on the expression stack
duke@435 237 { GrowableArray<ScopeValue*>* l = expressions();
duke@435 238 if (l != NULL) {
duke@435 239 for (int index = 0; index < l->length(); index++) {
duke@435 240 //guarantee(!l->at(index)->is_illegal(), "expression element cannot be illegal");
duke@435 241 }
duke@435 242 }
duke@435 243 }
duke@435 244 }

mercurial