annotate src/share/vm/runtime/vframeArray.hpp @ 3602:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children 0094485b46c7
rev   line source
duke@0 1 /*
coleenp@3602 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_RUNTIME_VFRAMEARRAY_HPP
stefank@1879 26 #define SHARE_VM_RUNTIME_VFRAMEARRAY_HPP
stefank@1879 27
stefank@1879 28 #include "oops/arrayOop.hpp"
stefank@1879 29 #include "runtime/deoptimization.hpp"
stefank@1879 30 #include "runtime/frame.inline.hpp"
stefank@1879 31 #include "runtime/monitorChunk.hpp"
stefank@1879 32 #include "utilities/growableArray.hpp"
stefank@1879 33
duke@0 34 // A vframeArray is an array used for momentarily storing off stack Java method activations
duke@0 35 // during deoptimization. Essentially it is an array of vframes where each vframe
duke@0 36 // data is stored off stack. This structure will never exist across a safepoint so
duke@0 37 // there is no need to gc any oops that are stored in the structure.
duke@0 38
duke@0 39
duke@0 40 class LocalsClosure;
duke@0 41 class ExpressionStackClosure;
duke@0 42 class MonitorStackClosure;
duke@0 43 class MonitorArrayElement;
duke@0 44 class StackValueCollection;
duke@0 45
duke@0 46 // A vframeArrayElement is an element of a vframeArray. Each element
duke@0 47 // represent an interpreter frame which will eventually be created.
duke@0 48
duke@0 49 class vframeArrayElement : public _ValueObj {
never@2703 50 friend class VMStructs;
never@2703 51
duke@0 52 private:
duke@0 53
duke@0 54 frame _frame; // the interpreter frame we will unpack into
cfang@900 55 int _bci; // raw bci for this vframe
cfang@900 56 bool _reexecute; // whether sould we reexecute this bytecode
coleenp@3602 57 Method* _method; // the method for this vframe
duke@0 58 MonitorChunk* _monitors; // active monitors for this vframe
duke@0 59 StackValueCollection* _locals;
duke@0 60 StackValueCollection* _expressions;
duke@0 61
duke@0 62 public:
duke@0 63
duke@0 64 frame* iframe(void) { return &_frame; }
duke@0 65
duke@0 66 int bci(void) const;
duke@0 67
duke@0 68 int raw_bci(void) const { return _bci; }
cfang@900 69 bool should_reexecute(void) const { return _reexecute; }
duke@0 70
coleenp@3602 71 Method* method(void) const { return _method; }
duke@0 72
duke@0 73 MonitorChunk* monitors(void) const { return _monitors; }
duke@0 74
duke@0 75 void free_monitors(JavaThread* jt);
duke@0 76
duke@0 77 StackValueCollection* locals(void) const { return _locals; }
duke@0 78
duke@0 79 StackValueCollection* expressions(void) const { return _expressions; }
duke@0 80
duke@0 81 void fill_in(compiledVFrame* vf);
duke@0 82
duke@0 83 // Formerly part of deoptimizedVFrame
duke@0 84
duke@0 85
duke@0 86 // Returns the on stack word size for this frame
duke@0 87 // callee_parameters is the number of callee locals residing inside this frame
never@2466 88 int on_stack_size(int caller_actual_parameters,
never@2466 89 int callee_parameters,
duke@0 90 int callee_locals,
duke@0 91 bool is_top_frame,
duke@0 92 int popframe_extra_stack_expression_els) const;
duke@0 93
duke@0 94 // Unpacks the element to skeletal interpreter frame
never@2466 95 void unpack_on_stack(int caller_actual_parameters,
never@2466 96 int callee_parameters,
duke@0 97 int callee_locals,
duke@0 98 frame* caller,
duke@0 99 bool is_top_frame,
duke@0 100 int exec_mode);
duke@0 101
duke@0 102 #ifndef PRODUCT
duke@0 103 void print(outputStream* st);
duke@0 104 #endif /* PRODUCT */
duke@0 105 };
duke@0 106
duke@0 107 // this can be a ResourceObj if we don't save the last one...
duke@0 108 // but it does make debugging easier even if we can't look
duke@0 109 // at the data in each vframeElement
duke@0 110
zgu@3465 111 class vframeArray: public CHeapObj<mtCompiler> {
never@2703 112 friend class VMStructs;
never@2703 113
duke@0 114 private:
duke@0 115
duke@0 116
duke@0 117 // Here is what a vframeArray looks like in memory
duke@0 118
duke@0 119 /*
duke@0 120 fixed part
duke@0 121 description of the original frame
duke@0 122 _frames - number of vframes in this array
duke@0 123 adapter info
duke@0 124 callee register save area
duke@0 125 variable part
duke@0 126 vframeArrayElement [ 0 ]
duke@0 127 ...
duke@0 128 vframeArrayElement [_frames - 1]
duke@0 129
duke@0 130 */
duke@0 131
duke@0 132 JavaThread* _owner_thread;
duke@0 133 vframeArray* _next;
duke@0 134 frame _original; // the original frame of the deoptee
duke@0 135 frame _caller; // caller of root frame in vframeArray
duke@0 136 frame _sender;
duke@0 137
duke@0 138 Deoptimization::UnrollBlock* _unroll_block;
duke@0 139 int _frame_size;
duke@0 140
duke@0 141 int _frames; // number of javavframes in the array (does not count any adapter)
duke@0 142
duke@0 143 intptr_t _callee_registers[RegisterMap::reg_count];
duke@0 144 unsigned char _valid[RegisterMap::reg_count];
duke@0 145
duke@0 146 vframeArrayElement _elements[1]; // First variable section.
duke@0 147
duke@0 148 void fill_in_element(int index, compiledVFrame* vf);
duke@0 149
duke@0 150 bool is_location_valid(int i) const { return _valid[i] != 0; }
duke@0 151 void set_location_valid(int i, bool valid) { _valid[i] = valid; }
duke@0 152
duke@0 153 public:
duke@0 154
duke@0 155
duke@0 156 // Tells whether index is within bounds.
duke@0 157 bool is_within_bounds(int index) const { return 0 <= index && index < frames(); }
duke@0 158
duke@0 159 // Accessores for instance variable
duke@0 160 int frames() const { return _frames; }
duke@0 161
duke@0 162 static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
duke@0 163 RegisterMap* reg_map, frame sender, frame caller, frame self);
duke@0 164
duke@0 165
duke@0 166 vframeArrayElement* element(int index) { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
duke@0 167
duke@0 168 // Allocates a new vframe in the array and fills the array with vframe information in chunk
duke@0 169 void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
duke@0 170
duke@0 171 // Returns the owner of this vframeArray
duke@0 172 JavaThread* owner_thread() const { return _owner_thread; }
duke@0 173
duke@0 174 // Accessors for next
duke@0 175 vframeArray* next() const { return _next; }
duke@0 176 void set_next(vframeArray* value) { _next = value; }
duke@0 177
duke@0 178 // Accessors for sp
duke@0 179 intptr_t* sp() const { return _original.sp(); }
duke@0 180
duke@0 181 intptr_t* unextended_sp() const { return _original.unextended_sp(); }
duke@0 182
duke@0 183 address original_pc() const { return _original.pc(); }
duke@0 184
duke@0 185 frame original() const { return _original; }
duke@0 186
duke@0 187 frame caller() const { return _caller; }
duke@0 188
duke@0 189 frame sender() const { return _sender; }
duke@0 190
duke@0 191 // Accessors for unroll block
duke@0 192 Deoptimization::UnrollBlock* unroll_block() const { return _unroll_block; }
duke@0 193 void set_unroll_block(Deoptimization::UnrollBlock* block) { _unroll_block = block; }
duke@0 194
duke@0 195 // Returns the size of the frame that got deoptimized
duke@0 196 int frame_size() const { return _frame_size; }
duke@0 197
duke@0 198 // Unpack the array on the stack passed in stack interval
never@2466 199 void unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters);
duke@0 200
duke@0 201 // Deallocates monitor chunks allocated during deoptimization.
duke@0 202 // This should be called when the array is not used anymore.
duke@0 203 void deallocate_monitor_chunks();
duke@0 204
duke@0 205
duke@0 206
duke@0 207 // Accessor for register map
duke@0 208 address register_location(int i) const;
duke@0 209
duke@0 210 void print_on_2(outputStream* st) PRODUCT_RETURN;
duke@0 211 void print_value_on(outputStream* st) const PRODUCT_RETURN;
duke@0 212
duke@0 213 #ifndef PRODUCT
duke@0 214 // Comparing
duke@0 215 bool structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk);
duke@0 216 #endif
duke@0 217
duke@0 218 };
stefank@1879 219
stefank@1879 220 #endif // SHARE_VM_RUNTIME_VFRAMEARRAY_HPP