src/share/vm/code/debugInfo.cpp

Mon, 28 Feb 2011 06:07:12 -0800

author
twisti
date
Mon, 28 Feb 2011 06:07:12 -0800
changeset 2603
1b4e6a5d98e0
parent 2314
f95d63e2154a
child 4037
da91efe96a93
permissions
-rw-r--r--

7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
Reviewed-by: never, bdelsart

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 *
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.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "code/debugInfo.hpp"
stefank@2314 27 #include "code/debugInfoRec.hpp"
stefank@2314 28 #include "code/nmethod.hpp"
stefank@2314 29 #include "runtime/handles.inline.hpp"
duke@435 30
duke@435 31 // Comstructors
duke@435 32
duke@435 33 DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size)
duke@435 34 : CompressedWriteStream(initial_size) {
duke@435 35 _recorder = recorder;
duke@435 36 }
duke@435 37
duke@435 38 // Serializing oops
duke@435 39
duke@435 40 void DebugInfoWriteStream::write_handle(jobject h) {
duke@435 41 write_int(recorder()->oop_recorder()->find_index(h));
duke@435 42 }
duke@435 43
duke@435 44 ScopeValue* DebugInfoReadStream::read_object_value() {
duke@435 45 int id = read_int();
duke@435 46 #ifdef ASSERT
duke@435 47 assert(_obj_pool != NULL, "object pool does not exist");
duke@435 48 for (int i = _obj_pool->length() - 1; i >= 0; i--) {
duke@435 49 assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice");
duke@435 50 }
duke@435 51 #endif
duke@435 52 ObjectValue* result = new ObjectValue(id);
kvn@479 53 // Cache the object since an object field could reference it.
kvn@479 54 _obj_pool->push(result);
duke@435 55 result->read_object(this);
duke@435 56 return result;
duke@435 57 }
duke@435 58
duke@435 59 ScopeValue* DebugInfoReadStream::get_cached_object() {
duke@435 60 int id = read_int();
duke@435 61 assert(_obj_pool != NULL, "object pool does not exist");
duke@435 62 for (int i = _obj_pool->length() - 1; i >= 0; i--) {
kvn@479 63 ObjectValue* ov = (ObjectValue*) _obj_pool->at(i);
kvn@479 64 if (ov->id() == id) {
kvn@479 65 return ov;
duke@435 66 }
duke@435 67 }
duke@435 68 ShouldNotReachHere();
duke@435 69 return NULL;
duke@435 70 }
duke@435 71
duke@435 72 // Serializing scope values
duke@435 73
duke@435 74 enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1, CONSTANT_OOP_CODE = 2,
duke@435 75 CONSTANT_LONG_CODE = 3, CONSTANT_DOUBLE_CODE = 4,
duke@435 76 OBJECT_CODE = 5, OBJECT_ID_CODE = 6 };
duke@435 77
duke@435 78 ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) {
duke@435 79 ScopeValue* result = NULL;
duke@435 80 switch(stream->read_int()) {
duke@435 81 case LOCATION_CODE: result = new LocationValue(stream); break;
duke@435 82 case CONSTANT_INT_CODE: result = new ConstantIntValue(stream); break;
duke@435 83 case CONSTANT_OOP_CODE: result = new ConstantOopReadValue(stream); break;
duke@435 84 case CONSTANT_LONG_CODE: result = new ConstantLongValue(stream); break;
duke@435 85 case CONSTANT_DOUBLE_CODE: result = new ConstantDoubleValue(stream); break;
duke@435 86 case OBJECT_CODE: result = stream->read_object_value(); break;
duke@435 87 case OBJECT_ID_CODE: result = stream->get_cached_object(); break;
duke@435 88 default: ShouldNotReachHere();
duke@435 89 }
duke@435 90 return result;
duke@435 91 }
duke@435 92
duke@435 93 // LocationValue
duke@435 94
duke@435 95 LocationValue::LocationValue(DebugInfoReadStream* stream) {
duke@435 96 _location = Location(stream);
duke@435 97 }
duke@435 98
duke@435 99 void LocationValue::write_on(DebugInfoWriteStream* stream) {
duke@435 100 stream->write_int(LOCATION_CODE);
duke@435 101 location().write_on(stream);
duke@435 102 }
duke@435 103
duke@435 104 void LocationValue::print_on(outputStream* st) const {
duke@435 105 location().print_on(st);
duke@435 106 }
duke@435 107
duke@435 108 // ObjectValue
duke@435 109
duke@435 110 void ObjectValue::read_object(DebugInfoReadStream* stream) {
duke@435 111 _klass = read_from(stream);
duke@435 112 assert(_klass->is_constant_oop(), "should be constant klass oop");
duke@435 113 int length = stream->read_int();
duke@435 114 for (int i = 0; i < length; i++) {
duke@435 115 ScopeValue* val = read_from(stream);
duke@435 116 _field_values.append(val);
duke@435 117 }
duke@435 118 }
duke@435 119
duke@435 120 void ObjectValue::write_on(DebugInfoWriteStream* stream) {
duke@435 121 if (_visited) {
duke@435 122 stream->write_int(OBJECT_ID_CODE);
duke@435 123 stream->write_int(_id);
duke@435 124 } else {
duke@435 125 _visited = true;
duke@435 126 stream->write_int(OBJECT_CODE);
duke@435 127 stream->write_int(_id);
duke@435 128 _klass->write_on(stream);
duke@435 129 int length = _field_values.length();
duke@435 130 stream->write_int(length);
duke@435 131 for (int i = 0; i < length; i++) {
duke@435 132 _field_values.at(i)->write_on(stream);
duke@435 133 }
duke@435 134 }
duke@435 135 }
duke@435 136
duke@435 137 void ObjectValue::print_on(outputStream* st) const {
duke@435 138 st->print("obj[%d]", _id);
duke@435 139 }
duke@435 140
duke@435 141 void ObjectValue::print_fields_on(outputStream* st) const {
duke@435 142 #ifndef PRODUCT
duke@435 143 if (_field_values.length() > 0) {
duke@435 144 _field_values.at(0)->print_on(st);
duke@435 145 }
duke@435 146 for (int i = 1; i < _field_values.length(); i++) {
duke@435 147 st->print(", ");
duke@435 148 _field_values.at(i)->print_on(st);
duke@435 149 }
duke@435 150 #endif
duke@435 151 }
duke@435 152
duke@435 153 // ConstantIntValue
duke@435 154
duke@435 155 ConstantIntValue::ConstantIntValue(DebugInfoReadStream* stream) {
duke@435 156 _value = stream->read_signed_int();
duke@435 157 }
duke@435 158
duke@435 159 void ConstantIntValue::write_on(DebugInfoWriteStream* stream) {
duke@435 160 stream->write_int(CONSTANT_INT_CODE);
duke@435 161 stream->write_signed_int(value());
duke@435 162 }
duke@435 163
duke@435 164 void ConstantIntValue::print_on(outputStream* st) const {
duke@435 165 st->print("%d", value());
duke@435 166 }
duke@435 167
duke@435 168 // ConstantLongValue
duke@435 169
duke@435 170 ConstantLongValue::ConstantLongValue(DebugInfoReadStream* stream) {
duke@435 171 _value = stream->read_long();
duke@435 172 }
duke@435 173
duke@435 174 void ConstantLongValue::write_on(DebugInfoWriteStream* stream) {
duke@435 175 stream->write_int(CONSTANT_LONG_CODE);
duke@435 176 stream->write_long(value());
duke@435 177 }
duke@435 178
duke@435 179 void ConstantLongValue::print_on(outputStream* st) const {
duke@435 180 st->print(INT64_FORMAT, value());
duke@435 181 }
duke@435 182
duke@435 183 // ConstantDoubleValue
duke@435 184
duke@435 185 ConstantDoubleValue::ConstantDoubleValue(DebugInfoReadStream* stream) {
duke@435 186 _value = stream->read_double();
duke@435 187 }
duke@435 188
duke@435 189 void ConstantDoubleValue::write_on(DebugInfoWriteStream* stream) {
duke@435 190 stream->write_int(CONSTANT_DOUBLE_CODE);
duke@435 191 stream->write_double(value());
duke@435 192 }
duke@435 193
duke@435 194 void ConstantDoubleValue::print_on(outputStream* st) const {
duke@435 195 st->print("%f", value());
duke@435 196 }
duke@435 197
duke@435 198 // ConstantOopWriteValue
duke@435 199
duke@435 200 void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) {
duke@435 201 stream->write_int(CONSTANT_OOP_CODE);
duke@435 202 stream->write_handle(value());
duke@435 203 }
duke@435 204
duke@435 205 void ConstantOopWriteValue::print_on(outputStream* st) const {
duke@435 206 JNIHandles::resolve(value())->print_value_on(st);
duke@435 207 }
duke@435 208
duke@435 209
duke@435 210 // ConstantOopReadValue
duke@435 211
duke@435 212 ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) {
duke@435 213 _value = Handle(stream->read_oop());
duke@435 214 }
duke@435 215
duke@435 216 void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) {
duke@435 217 ShouldNotReachHere();
duke@435 218 }
duke@435 219
duke@435 220 void ConstantOopReadValue::print_on(outputStream* st) const {
duke@435 221 value()()->print_value_on(st);
duke@435 222 }
duke@435 223
duke@435 224
duke@435 225 // MonitorValue
duke@435 226
duke@435 227 MonitorValue::MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated) {
duke@435 228 _owner = owner;
duke@435 229 _basic_lock = basic_lock;
duke@435 230 _eliminated = eliminated;
duke@435 231 }
duke@435 232
duke@435 233 MonitorValue::MonitorValue(DebugInfoReadStream* stream) {
duke@435 234 _basic_lock = Location(stream);
duke@435 235 _owner = ScopeValue::read_from(stream);
duke@435 236 _eliminated = (stream->read_bool() != 0);
duke@435 237 }
duke@435 238
duke@435 239 void MonitorValue::write_on(DebugInfoWriteStream* stream) {
duke@435 240 _basic_lock.write_on(stream);
duke@435 241 _owner->write_on(stream);
duke@435 242 stream->write_bool(_eliminated);
duke@435 243 }
duke@435 244
duke@435 245 #ifndef PRODUCT
duke@435 246 void MonitorValue::print_on(outputStream* st) const {
duke@435 247 st->print("monitor{");
duke@435 248 owner()->print_on(st);
duke@435 249 st->print(",");
duke@435 250 basic_lock().print_on(st);
duke@435 251 st->print("}");
duke@435 252 if (_eliminated) {
duke@435 253 st->print(" (eliminated)");
duke@435 254 }
duke@435 255 }
duke@435 256 #endif

mercurial