1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/code/scopeDesc.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,123 @@ 1.4 +/* 1.5 + * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// SimpleScopeDesc is used when all you need to extract from 1.29 +// a given pc,nmethod pair is a methodOop and a bci. This is 1.30 +// quite a bit faster than allocating a full ScopeDesc, but 1.31 +// very limited in abilities. 1.32 + 1.33 +class SimpleScopeDesc : public StackObj { 1.34 + private: 1.35 + methodOop _method; 1.36 + int _bci; 1.37 + 1.38 + public: 1.39 + SimpleScopeDesc(nmethod* code,address pc) { 1.40 + PcDesc* pc_desc = code->pc_desc_at(pc); 1.41 + assert(pc_desc != NULL, "Must be able to find matching PcDesc"); 1.42 + DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset()); 1.43 + int ignore_sender = buffer.read_int(); 1.44 + _method = methodOop(buffer.read_oop()); 1.45 + _bci = buffer.read_bci(); 1.46 + } 1.47 + 1.48 + methodOop method() { return _method; } 1.49 + int bci() { return _bci; } 1.50 +}; 1.51 + 1.52 +// ScopeDescs contain the information that makes source-level debugging of 1.53 +// nmethods possible; each scopeDesc describes a method activation 1.54 + 1.55 +class ScopeDesc : public ResourceObj { 1.56 + public: 1.57 + // Constructor 1.58 + ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset); 1.59 + 1.60 + // Calls above, giving default value of "serialized_null" to the 1.61 + // "obj_decode_offset" argument. (We don't use a default argument to 1.62 + // avoid a .hpp-.hpp dependency.) 1.63 + ScopeDesc(const nmethod* code, int decode_offset); 1.64 + 1.65 + // JVM state 1.66 + methodHandle method() const { return _method; } 1.67 + int bci() const { return _bci; } 1.68 + 1.69 + GrowableArray<ScopeValue*>* locals(); 1.70 + GrowableArray<ScopeValue*>* expressions(); 1.71 + GrowableArray<MonitorValue*>* monitors(); 1.72 + GrowableArray<ScopeValue*>* objects(); 1.73 + 1.74 + // Stack walking, returns NULL if this is the outer most scope. 1.75 + ScopeDesc* sender() const; 1.76 + 1.77 + // Returns where the scope was decoded 1.78 + int decode_offset() const { return _decode_offset; } 1.79 + 1.80 + // Tells whether sender() returns NULL 1.81 + bool is_top() const; 1.82 + // Tells whether sd is equal to this 1.83 + bool is_equal(ScopeDesc* sd) const; 1.84 + 1.85 + private: 1.86 + // Alternative constructor 1.87 + ScopeDesc(const ScopeDesc* parent); 1.88 + 1.89 + // JVM state 1.90 + methodHandle _method; 1.91 + int _bci; 1.92 + 1.93 + // Decoding offsets 1.94 + int _decode_offset; 1.95 + int _sender_decode_offset; 1.96 + int _locals_decode_offset; 1.97 + int _expressions_decode_offset; 1.98 + int _monitors_decode_offset; 1.99 + 1.100 + // Object pool 1.101 + GrowableArray<ScopeValue*>* _objects; 1.102 + 1.103 + // Nmethod information 1.104 + const nmethod* _code; 1.105 + 1.106 + // Decoding operations 1.107 + void decode_body(); 1.108 + GrowableArray<ScopeValue*>* decode_scope_values(int decode_offset); 1.109 + GrowableArray<MonitorValue*>* decode_monitor_values(int decode_offset); 1.110 + GrowableArray<ScopeValue*>* decode_object_values(int decode_offset); 1.111 + 1.112 + DebugInfoReadStream* stream_at(int decode_offset) const; 1.113 + 1.114 + 1.115 + public: 1.116 + // Verification 1.117 + void verify(); 1.118 + 1.119 +#ifndef PRODUCT 1.120 + public: 1.121 + // Printing support 1.122 + void print_on(outputStream* st) const; 1.123 + void print_on(outputStream* st, PcDesc* pd) const; 1.124 + void print_value_on(outputStream* st) const; 1.125 +#endif 1.126 +};