Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/code/debugInfo.hpp
32285 views
/*1* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_CODE_DEBUGINFO_HPP25#define SHARE_VM_CODE_DEBUGINFO_HPP2627#include "code/compressedStream.hpp"28#include "code/location.hpp"29#include "code/nmethod.hpp"30#include "code/oopRecorder.hpp"31#include "runtime/stackValue.hpp"32#include "utilities/growableArray.hpp"3334// Classes used for serializing debugging information.35// These abstractions are introducted to provide symmetric36// read and write operations.3738// ScopeValue describes the value of a variable/expression in a scope39// - LocationValue describes a value in a given location (in frame or register)40// - ConstantValue describes a constant4142class ConstantOopReadValue;4344class ScopeValue: public ResourceObj {45public:46// Testers47virtual bool is_location() const { return false; }48virtual bool is_object() const { return false; }49virtual bool is_constant_int() const { return false; }50virtual bool is_constant_double() const { return false; }51virtual bool is_constant_long() const { return false; }52virtual bool is_constant_oop() const { return false; }53virtual bool equals(ScopeValue* other) const { return false; }5455ConstantOopReadValue* as_ConstantOopReadValue() {56assert(is_constant_oop(), "must be");57return (ConstantOopReadValue*) this;58}5960// Serialization of debugging information61virtual void write_on(DebugInfoWriteStream* stream) = 0;62static ScopeValue* read_from(DebugInfoReadStream* stream);63};646566// A Location value describes a value in a given location; i.e. the corresponding67// logical entity (e.g., a method temporary) lives in this location.6869class LocationValue: public ScopeValue {70private:71Location _location;72public:73LocationValue(Location location) { _location = location; }74bool is_location() const { return true; }75Location location() const { return _location; }7677// Serialization of debugging information78LocationValue(DebugInfoReadStream* stream);79void write_on(DebugInfoWriteStream* stream);8081// Printing82void print_on(outputStream* st) const;83};848586// An ObjectValue describes an object eliminated by escape analysis.8788class ObjectValue: public ScopeValue {89private:90int _id;91ScopeValue* _klass;92GrowableArray<ScopeValue*> _field_values;93Handle _value;94bool _visited;9596public:97ObjectValue(int id, ScopeValue* klass)98: _id(id)99, _klass(klass)100, _field_values()101, _value()102, _visited(false) {103assert(klass->is_constant_oop(), "should be constant java mirror oop");104}105106ObjectValue(int id)107: _id(id)108, _klass(NULL)109, _field_values()110, _value()111, _visited(false) {}112113// Accessors114bool is_object() const { return true; }115int id() const { return _id; }116ScopeValue* klass() const { return _klass; }117GrowableArray<ScopeValue*>* field_values() { return &_field_values; }118ScopeValue* field_at(int i) const { return _field_values.at(i); }119int field_size() { return _field_values.length(); }120Handle value() const { return _value; }121bool is_visited() const { return _visited; }122123void set_value(oop value) { _value = Handle(value); }124void set_visited(bool visited) { _visited = false; }125126// Serialization of debugging information127void read_object(DebugInfoReadStream* stream);128void write_on(DebugInfoWriteStream* stream);129130// Printing131void print_on(outputStream* st) const;132void print_fields_on(outputStream* st) const;133};134135136// A ConstantIntValue describes a constant int; i.e., the corresponding logical entity137// is either a source constant or its computation has been constant-folded.138139class ConstantIntValue: public ScopeValue {140private:141jint _value;142public:143ConstantIntValue(jint value) { _value = value; }144jint value() const { return _value; }145bool is_constant_int() const { return true; }146bool equals(ScopeValue* other) const { return false; }147148// Serialization of debugging information149ConstantIntValue(DebugInfoReadStream* stream);150void write_on(DebugInfoWriteStream* stream);151152// Printing153void print_on(outputStream* st) const;154};155156class ConstantLongValue: public ScopeValue {157private:158jlong _value;159public:160ConstantLongValue(jlong value) { _value = value; }161jlong value() const { return _value; }162bool is_constant_long() const { return true; }163bool equals(ScopeValue* other) const { return false; }164165// Serialization of debugging information166ConstantLongValue(DebugInfoReadStream* stream);167void write_on(DebugInfoWriteStream* stream);168169// Printing170void print_on(outputStream* st) const;171};172173class ConstantDoubleValue: public ScopeValue {174private:175jdouble _value;176public:177ConstantDoubleValue(jdouble value) { _value = value; }178jdouble value() const { return _value; }179bool is_constant_double() const { return true; }180bool equals(ScopeValue* other) const { return false; }181182// Serialization of debugging information183ConstantDoubleValue(DebugInfoReadStream* stream);184void write_on(DebugInfoWriteStream* stream);185186// Printing187void print_on(outputStream* st) const;188};189190// A ConstantOopWriteValue is created by the compiler to191// be written as debugging information.192193class ConstantOopWriteValue: public ScopeValue {194private:195jobject _value;196public:197ConstantOopWriteValue(jobject value) { _value = value; }198jobject value() const { return _value; }199bool is_constant_oop() const { return true; }200bool equals(ScopeValue* other) const { return false; }201202// Serialization of debugging information203void write_on(DebugInfoWriteStream* stream);204205// Printing206void print_on(outputStream* st) const;207};208209// A ConstantOopReadValue is created by the VM when reading210// debug information211212class ConstantOopReadValue: public ScopeValue {213private:214Handle _value;215public:216Handle value() const { return _value; }217bool is_constant_oop() const { return true; }218bool equals(ScopeValue* other) const { return false; }219220// Serialization of debugging information221ConstantOopReadValue(DebugInfoReadStream* stream);222void write_on(DebugInfoWriteStream* stream);223224// Printing225void print_on(outputStream* st) const;226};227228// MonitorValue describes the pair used for monitor_enter and monitor_exit.229230class MonitorValue: public ResourceObj {231private:232ScopeValue* _owner;233Location _basic_lock;234bool _eliminated;235public:236// Constructor237MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated = false);238239// Accessors240ScopeValue* owner() const { return _owner; }241Location basic_lock() const { return _basic_lock; }242bool eliminated() const { return _eliminated; }243244// Serialization of debugging information245MonitorValue(DebugInfoReadStream* stream);246void write_on(DebugInfoWriteStream* stream);247248// Printing249void print_on(outputStream* st) const;250};251252// DebugInfoReadStream specializes CompressedReadStream for reading253// debugging information. Used by ScopeDesc.254255class DebugInfoReadStream : public CompressedReadStream {256private:257const nmethod* _code;258const nmethod* code() const { return _code; }259GrowableArray<ScopeValue*>* _obj_pool;260public:261DebugInfoReadStream(const nmethod* code, int offset, GrowableArray<ScopeValue*>* obj_pool = NULL) :262CompressedReadStream(code->scopes_data_begin(), offset) {263_code = code;264_obj_pool = obj_pool;265266} ;267268oop read_oop() {269oop o = code()->oop_at(read_int());270assert(o == NULL || o->is_oop(), "oop only");271return o;272}273Method* read_method() {274Method* o = (Method*)(code()->metadata_at(read_int()));275// is_metadata() is a faster check than is_metaspace_object()276assert(o == NULL || o->is_metadata(), "meta data only");277return o;278}279ScopeValue* read_object_value();280ScopeValue* get_cached_object();281// BCI encoding is mostly unsigned, but -1 is a distinguished value282int read_bci() { return read_int() + InvocationEntryBci; }283};284285// DebugInfoWriteStream specializes CompressedWriteStream for286// writing debugging information. Used by ScopeDescRecorder.287288class DebugInfoWriteStream : public CompressedWriteStream {289private:290DebugInformationRecorder* _recorder;291DebugInformationRecorder* recorder() const { return _recorder; }292public:293DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size);294void write_handle(jobject h);295void write_bci(int bci) { write_int(bci - InvocationEntryBci); }296297void write_metadata(Metadata* m);298};299300#endif // SHARE_VM_CODE_DEBUGINFO_HPP301302303