src/share/vm/code/scopeDesc.hpp

Fri, 31 Jul 2009 17:12:33 -0700

author
cfang
date
Fri, 31 Jul 2009 17:12:33 -0700
changeset 1335
9987d9d5eb0e
parent 435
a61af66fc99e
child 1366
72088be4b386
permissions
-rw-r--r--

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

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

mercurial