aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_CODE_SCOPEDESC_HPP aoqi@0: #define SHARE_VM_CODE_SCOPEDESC_HPP aoqi@0: aoqi@0: #include "code/debugInfo.hpp" aoqi@0: #include "code/pcDesc.hpp" aoqi@0: #include "oops/method.hpp" aoqi@0: #include "utilities/growableArray.hpp" aoqi@0: aoqi@0: // SimpleScopeDesc is used when all you need to extract from aoqi@0: // a given pc,nmethod pair is a Method* and a bci. This is aoqi@0: // quite a bit faster than allocating a full ScopeDesc, but aoqi@0: // very limited in abilities. aoqi@0: aoqi@0: class SimpleScopeDesc : public StackObj { aoqi@0: private: aoqi@0: Method* _method; aoqi@0: int _bci; aoqi@0: aoqi@0: public: aoqi@0: SimpleScopeDesc(nmethod* code,address pc) { aoqi@0: PcDesc* pc_desc = code->pc_desc_at(pc); aoqi@0: assert(pc_desc != NULL, "Must be able to find matching PcDesc"); aoqi@0: DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset()); aoqi@0: int ignore_sender = buffer.read_int(); aoqi@0: _method = buffer.read_method(); aoqi@0: _bci = buffer.read_bci(); aoqi@0: } aoqi@0: aoqi@0: Method* method() { return _method; } aoqi@0: int bci() { return _bci; } aoqi@0: }; aoqi@0: aoqi@0: // ScopeDescs contain the information that makes source-level debugging of aoqi@0: // nmethods possible; each scopeDesc describes a method activation aoqi@0: aoqi@0: class ScopeDesc : public ResourceObj { aoqi@0: public: aoqi@0: // Constructor aoqi@0: ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool return_oop); aoqi@0: aoqi@0: // Calls above, giving default value of "serialized_null" to the aoqi@0: // "obj_decode_offset" argument. (We don't use a default argument to aoqi@0: // avoid a .hpp-.hpp dependency.) aoqi@0: ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool return_oop); aoqi@0: aoqi@0: // JVM state aoqi@0: Method* method() const { return _method; } aoqi@0: int bci() const { return _bci; } aoqi@0: bool should_reexecute() const { return _reexecute; } aoqi@0: bool return_oop() const { return _return_oop; } aoqi@0: aoqi@0: GrowableArray* locals(); aoqi@0: GrowableArray* expressions(); aoqi@0: GrowableArray* monitors(); aoqi@0: GrowableArray* objects(); aoqi@0: aoqi@0: // Stack walking, returns NULL if this is the outer most scope. aoqi@0: ScopeDesc* sender() const; aoqi@0: aoqi@0: // Returns where the scope was decoded aoqi@0: int decode_offset() const { return _decode_offset; } aoqi@0: aoqi@0: // Tells whether sender() returns NULL aoqi@0: bool is_top() const; aoqi@0: // Tells whether sd is equal to this aoqi@0: bool is_equal(ScopeDesc* sd) const; aoqi@0: aoqi@0: private: aoqi@0: // Alternative constructor aoqi@0: ScopeDesc(const ScopeDesc* parent); aoqi@0: aoqi@0: // JVM state aoqi@0: Method* _method; aoqi@0: int _bci; aoqi@0: bool _reexecute; aoqi@0: bool _return_oop; aoqi@0: aoqi@0: // Decoding offsets aoqi@0: int _decode_offset; aoqi@0: int _sender_decode_offset; aoqi@0: int _locals_decode_offset; aoqi@0: int _expressions_decode_offset; aoqi@0: int _monitors_decode_offset; aoqi@0: aoqi@0: // Object pool aoqi@0: GrowableArray* _objects; aoqi@0: aoqi@0: // Nmethod information aoqi@0: const nmethod* _code; aoqi@0: aoqi@0: // Decoding operations aoqi@0: void decode_body(); aoqi@0: GrowableArray* decode_scope_values(int decode_offset); aoqi@0: GrowableArray* decode_monitor_values(int decode_offset); aoqi@0: GrowableArray* decode_object_values(int decode_offset); aoqi@0: aoqi@0: DebugInfoReadStream* stream_at(int decode_offset) const; aoqi@0: aoqi@0: aoqi@0: public: aoqi@0: // Verification aoqi@0: void verify(); aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: public: aoqi@0: // Printing support aoqi@0: void print_on(outputStream* st) const; aoqi@0: void print_on(outputStream* st, PcDesc* pd) const; aoqi@0: void print_value_on(outputStream* st) const; aoqi@0: #endif aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_CODE_SCOPEDESC_HPP