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

     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "code/debugInfo.hpp"
    27 #include "code/debugInfoRec.hpp"
    28 #include "code/nmethod.hpp"
    29 #include "runtime/handles.inline.hpp"
    31 // Comstructors
    33 DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size)
    34 : CompressedWriteStream(initial_size) {
    35   _recorder = recorder;
    36 }
    38 // Serializing oops
    40 void DebugInfoWriteStream::write_handle(jobject h) {
    41   write_int(recorder()->oop_recorder()->find_index(h));
    42 }
    44 ScopeValue* DebugInfoReadStream::read_object_value() {
    45   int id = read_int();
    46 #ifdef ASSERT
    47   assert(_obj_pool != NULL, "object pool does not exist");
    48   for (int i = _obj_pool->length() - 1; i >= 0; i--) {
    49     assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice");
    50   }
    51 #endif
    52   ObjectValue* result = new ObjectValue(id);
    53   // Cache the object since an object field could reference it.
    54   _obj_pool->push(result);
    55   result->read_object(this);
    56   return result;
    57 }
    59 ScopeValue* DebugInfoReadStream::get_cached_object() {
    60   int id = read_int();
    61   assert(_obj_pool != NULL, "object pool does not exist");
    62   for (int i = _obj_pool->length() - 1; i >= 0; i--) {
    63     ObjectValue* ov = (ObjectValue*) _obj_pool->at(i);
    64     if (ov->id() == id) {
    65       return ov;
    66     }
    67   }
    68   ShouldNotReachHere();
    69   return NULL;
    70 }
    72 // Serializing scope values
    74 enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1,  CONSTANT_OOP_CODE = 2,
    75                           CONSTANT_LONG_CODE = 3, CONSTANT_DOUBLE_CODE = 4,
    76                           OBJECT_CODE = 5,        OBJECT_ID_CODE = 6 };
    78 ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) {
    79   ScopeValue* result = NULL;
    80   switch(stream->read_int()) {
    81    case LOCATION_CODE:        result = new LocationValue(stream);        break;
    82    case CONSTANT_INT_CODE:    result = new ConstantIntValue(stream);     break;
    83    case CONSTANT_OOP_CODE:    result = new ConstantOopReadValue(stream); break;
    84    case CONSTANT_LONG_CODE:   result = new ConstantLongValue(stream);    break;
    85    case CONSTANT_DOUBLE_CODE: result = new ConstantDoubleValue(stream);  break;
    86    case OBJECT_CODE:          result = stream->read_object_value();      break;
    87    case OBJECT_ID_CODE:       result = stream->get_cached_object();      break;
    88    default: ShouldNotReachHere();
    89   }
    90   return result;
    91 }
    93 // LocationValue
    95 LocationValue::LocationValue(DebugInfoReadStream* stream) {
    96   _location = Location(stream);
    97 }
    99 void LocationValue::write_on(DebugInfoWriteStream* stream) {
   100   stream->write_int(LOCATION_CODE);
   101   location().write_on(stream);
   102 }
   104 void LocationValue::print_on(outputStream* st) const {
   105   location().print_on(st);
   106 }
   108 // ObjectValue
   110 void ObjectValue::read_object(DebugInfoReadStream* stream) {
   111   _klass = read_from(stream);
   112   assert(_klass->is_constant_oop(), "should be constant klass oop");
   113   int length = stream->read_int();
   114   for (int i = 0; i < length; i++) {
   115     ScopeValue* val = read_from(stream);
   116     _field_values.append(val);
   117   }
   118 }
   120 void ObjectValue::write_on(DebugInfoWriteStream* stream) {
   121   if (_visited) {
   122     stream->write_int(OBJECT_ID_CODE);
   123     stream->write_int(_id);
   124   } else {
   125     _visited = true;
   126     stream->write_int(OBJECT_CODE);
   127     stream->write_int(_id);
   128     _klass->write_on(stream);
   129     int length = _field_values.length();
   130     stream->write_int(length);
   131     for (int i = 0; i < length; i++) {
   132       _field_values.at(i)->write_on(stream);
   133     }
   134   }
   135 }
   137 void ObjectValue::print_on(outputStream* st) const {
   138   st->print("obj[%d]", _id);
   139 }
   141 void ObjectValue::print_fields_on(outputStream* st) const {
   142 #ifndef PRODUCT
   143   if (_field_values.length() > 0) {
   144     _field_values.at(0)->print_on(st);
   145   }
   146   for (int i = 1; i < _field_values.length(); i++) {
   147     st->print(", ");
   148     _field_values.at(i)->print_on(st);
   149   }
   150 #endif
   151 }
   153 // ConstantIntValue
   155 ConstantIntValue::ConstantIntValue(DebugInfoReadStream* stream) {
   156   _value = stream->read_signed_int();
   157 }
   159 void ConstantIntValue::write_on(DebugInfoWriteStream* stream) {
   160   stream->write_int(CONSTANT_INT_CODE);
   161   stream->write_signed_int(value());
   162 }
   164 void ConstantIntValue::print_on(outputStream* st) const {
   165   st->print("%d", value());
   166 }
   168 // ConstantLongValue
   170 ConstantLongValue::ConstantLongValue(DebugInfoReadStream* stream) {
   171   _value = stream->read_long();
   172 }
   174 void ConstantLongValue::write_on(DebugInfoWriteStream* stream) {
   175   stream->write_int(CONSTANT_LONG_CODE);
   176   stream->write_long(value());
   177 }
   179 void ConstantLongValue::print_on(outputStream* st) const {
   180   st->print(INT64_FORMAT, value());
   181 }
   183 // ConstantDoubleValue
   185 ConstantDoubleValue::ConstantDoubleValue(DebugInfoReadStream* stream) {
   186   _value = stream->read_double();
   187 }
   189 void ConstantDoubleValue::write_on(DebugInfoWriteStream* stream) {
   190   stream->write_int(CONSTANT_DOUBLE_CODE);
   191   stream->write_double(value());
   192 }
   194 void ConstantDoubleValue::print_on(outputStream* st) const {
   195   st->print("%f", value());
   196 }
   198 // ConstantOopWriteValue
   200 void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) {
   201   stream->write_int(CONSTANT_OOP_CODE);
   202   stream->write_handle(value());
   203 }
   205 void ConstantOopWriteValue::print_on(outputStream* st) const {
   206   JNIHandles::resolve(value())->print_value_on(st);
   207 }
   210 // ConstantOopReadValue
   212 ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) {
   213   _value = Handle(stream->read_oop());
   214 }
   216 void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) {
   217   ShouldNotReachHere();
   218 }
   220 void ConstantOopReadValue::print_on(outputStream* st) const {
   221   value()()->print_value_on(st);
   222 }
   225 // MonitorValue
   227 MonitorValue::MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated) {
   228   _owner       = owner;
   229   _basic_lock  = basic_lock;
   230   _eliminated  = eliminated;
   231 }
   233 MonitorValue::MonitorValue(DebugInfoReadStream* stream) {
   234   _basic_lock  = Location(stream);
   235   _owner       = ScopeValue::read_from(stream);
   236   _eliminated  = (stream->read_bool() != 0);
   237 }
   239 void MonitorValue::write_on(DebugInfoWriteStream* stream) {
   240   _basic_lock.write_on(stream);
   241   _owner->write_on(stream);
   242   stream->write_bool(_eliminated);
   243 }
   245 #ifndef PRODUCT
   246 void MonitorValue::print_on(outputStream* st) const {
   247   st->print("monitor{");
   248   owner()->print_on(st);
   249   st->print(",");
   250   basic_lock().print_on(st);
   251   st->print("}");
   252   if (_eliminated) {
   253     st->print(" (eliminated)");
   254   }
   255 }
   256 #endif

mercurial