src/share/vm/code/debugInfo.cpp

Tue, 05 Jan 2010 16:12:26 -0800

author
never
date
Tue, 05 Jan 2010 16:12:26 -0800
changeset 1576
b1f619d38249
parent 631
d1605aabd0a1
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6914002: unsigned compare problem after 5057818
Reviewed-by: kvn, twisti

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

mercurial