src/share/vm/code/scopeDesc.cpp

Wed, 08 Apr 2009 00:12:59 -0700

author
jrose
date
Wed, 08 Apr 2009 00:12:59 -0700
changeset 1144
1d037ecd7960
parent 631
d1605aabd0a1
child 1335
9987d9d5eb0e
permissions
-rw-r--r--

6827505: sizing logic for vtable and itable stubs needs self-check
Summary: Asserts and comments to help maintain the correct sizing of certain stubs
Reviewed-by: kvn

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

mercurial