src/share/vm/code/debugInfo.cpp

Wed, 31 Jan 2018 19:24:57 -0500

author
dbuck
date
Wed, 31 Jan 2018 19:24:57 -0500
changeset 9289
427b2fb1944f
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
child 9841
2e636385f137
permissions
-rw-r--r--

8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
Reviewed-by: dcubed

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

mercurial