Path: blob/master/src/hotspot/share/code/scopeDesc.hpp
40948 views
/*1* Copyright (c) 1997, 2020, 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_CODE_SCOPEDESC_HPP25#define SHARE_CODE_SCOPEDESC_HPP2627#include "code/debugInfo.hpp"28#include "code/pcDesc.hpp"29#include "oops/method.hpp"30#include "utilities/growableArray.hpp"3132// SimpleScopeDesc is used when all you need to extract from33// a given pc,nmethod pair is a Method* and a bci. This is34// quite a bit faster than allocating a full ScopeDesc, but35// very limited in abilities.3637class SimpleScopeDesc : public StackObj {38private:39Method* _method;40int _bci;41bool _is_optimized_linkToNative;4243public:44SimpleScopeDesc(CompiledMethod* code, address pc) {45PcDesc* pc_desc = code->pc_desc_at(pc);46assert(pc_desc != NULL, "Must be able to find matching PcDesc");47// save this here so we only have to look up the PcDesc once48_is_optimized_linkToNative = pc_desc->is_optimized_linkToNative();49DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset());50int ignore_sender = buffer.read_int();51_method = buffer.read_method();52_bci = buffer.read_bci();53}5455Method* method() { return _method; }56int bci() { return _bci; }57bool is_optimized_linkToNative() { return _is_optimized_linkToNative; }58};5960// ScopeDescs contain the information that makes source-level debugging of61// nmethods possible; each scopeDesc describes a method activation6263class ScopeDesc : public ResourceObj {64public:65// Constructor66ScopeDesc(const CompiledMethod* code, PcDesc* pd, bool ignore_objects = false);6768// Direct access to scope69ScopeDesc* at_offset(int decode_offset) { return new ScopeDesc(this, decode_offset); }7071// JVM state72Method* method() const { return _method; }73int bci() const { return _bci; }74bool should_reexecute() const { return _reexecute; }75bool rethrow_exception() const { return _rethrow_exception; }76bool return_oop() const { return _return_oop; }77// Returns true if one or more NoEscape or ArgEscape objects exist in78// any of the scopes at compiled pc.79bool has_ea_local_in_scope() const { return _has_ea_local_in_scope; }80bool arg_escape() const { return _arg_escape; }8182GrowableArray<ScopeValue*>* locals();83GrowableArray<ScopeValue*>* expressions();84GrowableArray<MonitorValue*>* monitors();85GrowableArray<ScopeValue*>* objects();8687// Stack walking, returns NULL if this is the outer most scope.88ScopeDesc* sender() const;8990// Returns where the scope was decoded91int decode_offset() const { return _decode_offset; }9293int sender_decode_offset() const { return _sender_decode_offset; }9495// Tells whether sender() returns NULL96bool is_top() const;9798private:99void initialize(const ScopeDesc* parent, int decode_offset);100// Alternative constructors101ScopeDesc(const ScopeDesc* parent);102ScopeDesc(const ScopeDesc* parent, int decode_offset);103104// JVM state105Method* _method;106int _bci;107bool _reexecute;108bool _rethrow_exception;109bool _return_oop;110bool _has_ea_local_in_scope; // One or more NoEscape or ArgEscape objects exist in111// any of the scopes at compiled pc.112bool _arg_escape; // Compiled Java call in youngest scope passes ArgEscape113114// Decoding offsets115int _decode_offset;116int _sender_decode_offset;117int _locals_decode_offset;118int _expressions_decode_offset;119int _monitors_decode_offset;120121// Object pool122GrowableArray<ScopeValue*>* _objects;123124// Nmethod information125const CompiledMethod* _code;126127// Decoding operations128void decode_body();129GrowableArray<ScopeValue*>* decode_scope_values(int decode_offset);130GrowableArray<MonitorValue*>* decode_monitor_values(int decode_offset);131GrowableArray<ScopeValue*>* decode_object_values(int decode_offset);132133DebugInfoReadStream* stream_at(int decode_offset) const;134135136public:137// Verification138void verify();139140#ifndef PRODUCT141public:142// Printing support143void print_on(outputStream* st) const;144void print_on(outputStream* st, PcDesc* pd) const;145void print_value_on(outputStream* st) const;146#endif147};148149#endif // SHARE_CODE_SCOPEDESC_HPP150151152