annotate src/share/vm/code/scopeDesc.hpp @ 900:9987d9d5eb0e

6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot Summary: developed a reexecute logic for the interpreter to reexecute the bytecode when deopt happens Reviewed-by: kvn, never, jrose, twisti
author cfang
date Fri, 31 Jul 2009 17:12:33 -0700
parents a61af66fc99e
children 72088be4b386
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 // SimpleScopeDesc is used when all you need to extract from
duke@0 26 // a given pc,nmethod pair is a methodOop and a bci. This is
duke@0 27 // quite a bit faster than allocating a full ScopeDesc, but
duke@0 28 // very limited in abilities.
duke@0 29
duke@0 30 class SimpleScopeDesc : public StackObj {
duke@0 31 private:
duke@0 32 methodOop _method;
duke@0 33 int _bci;
duke@0 34
duke@0 35 public:
duke@0 36 SimpleScopeDesc(nmethod* code,address pc) {
duke@0 37 PcDesc* pc_desc = code->pc_desc_at(pc);
duke@0 38 assert(pc_desc != NULL, "Must be able to find matching PcDesc");
duke@0 39 DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset());
duke@0 40 int ignore_sender = buffer.read_int();
duke@0 41 _method = methodOop(buffer.read_oop());
cfang@900 42 bool dummy_reexecute; //only methodOop and bci are needed!
cfang@900 43 _bci = buffer.read_bci_and_reexecute(dummy_reexecute);
duke@0 44 }
duke@0 45
duke@0 46 methodOop method() { return _method; }
duke@0 47 int bci() { return _bci; }
duke@0 48 };
duke@0 49
duke@0 50 // ScopeDescs contain the information that makes source-level debugging of
duke@0 51 // nmethods possible; each scopeDesc describes a method activation
duke@0 52
duke@0 53 class ScopeDesc : public ResourceObj {
duke@0 54 public:
duke@0 55 // Constructor
duke@0 56 ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset);
duke@0 57
duke@0 58 // Calls above, giving default value of "serialized_null" to the
duke@0 59 // "obj_decode_offset" argument. (We don't use a default argument to
duke@0 60 // avoid a .hpp-.hpp dependency.)
duke@0 61 ScopeDesc(const nmethod* code, int decode_offset);
duke@0 62
duke@0 63 // JVM state
cfang@900 64 methodHandle method() const { return _method; }
cfang@900 65 int bci() const { return _bci; }
cfang@900 66 bool should_reexecute() const { return _reexecute; }
duke@0 67
duke@0 68 GrowableArray<ScopeValue*>* locals();
duke@0 69 GrowableArray<ScopeValue*>* expressions();
duke@0 70 GrowableArray<MonitorValue*>* monitors();
duke@0 71 GrowableArray<ScopeValue*>* objects();
duke@0 72
duke@0 73 // Stack walking, returns NULL if this is the outer most scope.
duke@0 74 ScopeDesc* sender() const;
duke@0 75
duke@0 76 // Returns where the scope was decoded
duke@0 77 int decode_offset() const { return _decode_offset; }
duke@0 78
duke@0 79 // Tells whether sender() returns NULL
duke@0 80 bool is_top() const;
duke@0 81 // Tells whether sd is equal to this
duke@0 82 bool is_equal(ScopeDesc* sd) const;
duke@0 83
duke@0 84 private:
duke@0 85 // Alternative constructor
duke@0 86 ScopeDesc(const ScopeDesc* parent);
duke@0 87
duke@0 88 // JVM state
duke@0 89 methodHandle _method;
duke@0 90 int _bci;
cfang@900 91 bool _reexecute;
duke@0 92
duke@0 93 // Decoding offsets
duke@0 94 int _decode_offset;
duke@0 95 int _sender_decode_offset;
duke@0 96 int _locals_decode_offset;
duke@0 97 int _expressions_decode_offset;
duke@0 98 int _monitors_decode_offset;
duke@0 99
duke@0 100 // Object pool
duke@0 101 GrowableArray<ScopeValue*>* _objects;
duke@0 102
duke@0 103 // Nmethod information
duke@0 104 const nmethod* _code;
duke@0 105
duke@0 106 // Decoding operations
duke@0 107 void decode_body();
duke@0 108 GrowableArray<ScopeValue*>* decode_scope_values(int decode_offset);
duke@0 109 GrowableArray<MonitorValue*>* decode_monitor_values(int decode_offset);
duke@0 110 GrowableArray<ScopeValue*>* decode_object_values(int decode_offset);
duke@0 111
duke@0 112 DebugInfoReadStream* stream_at(int decode_offset) const;
duke@0 113
duke@0 114
duke@0 115 public:
duke@0 116 // Verification
duke@0 117 void verify();
duke@0 118
duke@0 119 #ifndef PRODUCT
duke@0 120 public:
duke@0 121 // Printing support
duke@0 122 void print_on(outputStream* st) const;
duke@0 123 void print_on(outputStream* st, PcDesc* pd) const;
duke@0 124 void print_value_on(outputStream* st) const;
duke@0 125 #endif
duke@0 126 };