src/share/vm/runtime/vframeArray.hpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 7535
7ae4e26cb1e0
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_RUNTIME_VFRAMEARRAY_HPP
aoqi@0 26 #define SHARE_VM_RUNTIME_VFRAMEARRAY_HPP
aoqi@0 27
aoqi@0 28 #include "oops/arrayOop.hpp"
aoqi@0 29 #include "runtime/deoptimization.hpp"
aoqi@0 30 #include "runtime/frame.inline.hpp"
aoqi@0 31 #include "runtime/monitorChunk.hpp"
aoqi@0 32 #include "utilities/growableArray.hpp"
aoqi@0 33
aoqi@0 34 // A vframeArray is an array used for momentarily storing off stack Java method activations
aoqi@0 35 // during deoptimization. Essentially it is an array of vframes where each vframe
aoqi@0 36 // data is stored off stack. This structure will never exist across a safepoint so
aoqi@0 37 // there is no need to gc any oops that are stored in the structure.
aoqi@0 38
aoqi@0 39
aoqi@0 40 class LocalsClosure;
aoqi@0 41 class ExpressionStackClosure;
aoqi@0 42 class MonitorStackClosure;
aoqi@0 43 class MonitorArrayElement;
aoqi@0 44 class StackValueCollection;
aoqi@0 45
aoqi@0 46 // A vframeArrayElement is an element of a vframeArray. Each element
aoqi@0 47 // represent an interpreter frame which will eventually be created.
aoqi@0 48
aoqi@0 49 class vframeArrayElement : public _ValueObj {
aoqi@0 50 friend class VMStructs;
aoqi@0 51
aoqi@0 52 private:
aoqi@0 53
aoqi@0 54 frame _frame; // the interpreter frame we will unpack into
aoqi@0 55 int _bci; // raw bci for this vframe
aoqi@0 56 bool _reexecute; // whether sould we reexecute this bytecode
aoqi@0 57 Method* _method; // the method for this vframe
aoqi@0 58 MonitorChunk* _monitors; // active monitors for this vframe
aoqi@0 59 StackValueCollection* _locals;
aoqi@0 60 StackValueCollection* _expressions;
roland@7419 61 #ifdef ASSERT
roland@7419 62 bool _removed_monitors;
roland@7419 63 #endif
aoqi@0 64
aoqi@0 65 public:
aoqi@0 66
aoqi@0 67 frame* iframe(void) { return &_frame; }
aoqi@0 68
aoqi@0 69 int bci(void) const;
aoqi@0 70
aoqi@0 71 int raw_bci(void) const { return _bci; }
aoqi@0 72 bool should_reexecute(void) const { return _reexecute; }
aoqi@0 73
aoqi@0 74 Method* method(void) const { return _method; }
aoqi@0 75
aoqi@0 76 MonitorChunk* monitors(void) const { return _monitors; }
aoqi@0 77
aoqi@0 78 void free_monitors(JavaThread* jt);
aoqi@0 79
aoqi@0 80 StackValueCollection* locals(void) const { return _locals; }
aoqi@0 81
aoqi@0 82 StackValueCollection* expressions(void) const { return _expressions; }
aoqi@0 83
roland@7419 84 void fill_in(compiledVFrame* vf, bool realloc_failures);
aoqi@0 85
aoqi@0 86 // Formerly part of deoptimizedVFrame
aoqi@0 87
aoqi@0 88
aoqi@0 89 // Returns the on stack word size for this frame
aoqi@0 90 // callee_parameters is the number of callee locals residing inside this frame
aoqi@0 91 int on_stack_size(int callee_parameters,
aoqi@0 92 int callee_locals,
aoqi@0 93 bool is_top_frame,
aoqi@0 94 int popframe_extra_stack_expression_els) const;
aoqi@0 95
aoqi@0 96 // Unpacks the element to skeletal interpreter frame
aoqi@0 97 void unpack_on_stack(int caller_actual_parameters,
aoqi@0 98 int callee_parameters,
aoqi@0 99 int callee_locals,
aoqi@0 100 frame* caller,
aoqi@0 101 bool is_top_frame,
aoqi@0 102 bool is_bottom_frame,
aoqi@0 103 int exec_mode);
aoqi@0 104
roland@7419 105 #ifdef ASSERT
roland@7419 106 void set_removed_monitors() {
roland@7419 107 _removed_monitors = true;
roland@7419 108 }
roland@7419 109 #endif
roland@7419 110
aoqi@0 111 #ifndef PRODUCT
aoqi@0 112 void print(outputStream* st);
aoqi@0 113 #endif /* PRODUCT */
aoqi@0 114 };
aoqi@0 115
aoqi@0 116 // this can be a ResourceObj if we don't save the last one...
aoqi@0 117 // but it does make debugging easier even if we can't look
aoqi@0 118 // at the data in each vframeElement
aoqi@0 119
aoqi@0 120 class vframeArray: public CHeapObj<mtCompiler> {
aoqi@0 121 friend class VMStructs;
aoqi@0 122
aoqi@0 123 private:
aoqi@0 124
aoqi@0 125
aoqi@0 126 // Here is what a vframeArray looks like in memory
aoqi@0 127
aoqi@0 128 /*
aoqi@0 129 fixed part
aoqi@0 130 description of the original frame
aoqi@0 131 _frames - number of vframes in this array
aoqi@0 132 adapter info
aoqi@0 133 callee register save area
aoqi@0 134 variable part
aoqi@0 135 vframeArrayElement [ 0 ]
aoqi@0 136 ...
aoqi@0 137 vframeArrayElement [_frames - 1]
aoqi@0 138
aoqi@0 139 */
aoqi@0 140
aoqi@0 141 JavaThread* _owner_thread;
aoqi@0 142 vframeArray* _next;
aoqi@0 143 frame _original; // the original frame of the deoptee
aoqi@0 144 frame _caller; // caller of root frame in vframeArray
aoqi@0 145 frame _sender;
aoqi@0 146
aoqi@0 147 Deoptimization::UnrollBlock* _unroll_block;
aoqi@0 148 int _frame_size;
aoqi@0 149
aoqi@0 150 int _frames; // number of javavframes in the array (does not count any adapter)
aoqi@0 151
aoqi@0 152 intptr_t _callee_registers[RegisterMap::reg_count];
aoqi@0 153 unsigned char _valid[RegisterMap::reg_count];
aoqi@0 154
aoqi@0 155 vframeArrayElement _elements[1]; // First variable section.
aoqi@0 156
aoqi@0 157 void fill_in_element(int index, compiledVFrame* vf);
aoqi@0 158
aoqi@0 159 bool is_location_valid(int i) const { return _valid[i] != 0; }
aoqi@0 160 void set_location_valid(int i, bool valid) { _valid[i] = valid; }
aoqi@0 161
aoqi@0 162 public:
aoqi@0 163
aoqi@0 164
aoqi@0 165 // Tells whether index is within bounds.
aoqi@0 166 bool is_within_bounds(int index) const { return 0 <= index && index < frames(); }
aoqi@0 167
aoqi@0 168 // Accessores for instance variable
aoqi@0 169 int frames() const { return _frames; }
aoqi@0 170
aoqi@0 171 static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
roland@7419 172 RegisterMap* reg_map, frame sender, frame caller, frame self,
roland@7419 173 bool realloc_failures);
aoqi@0 174
aoqi@0 175
aoqi@0 176 vframeArrayElement* element(int index) { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
aoqi@0 177
aoqi@0 178 // Allocates a new vframe in the array and fills the array with vframe information in chunk
roland@7419 179 void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map, bool realloc_failures);
aoqi@0 180
aoqi@0 181 // Returns the owner of this vframeArray
aoqi@0 182 JavaThread* owner_thread() const { return _owner_thread; }
aoqi@0 183
aoqi@0 184 // Accessors for next
aoqi@0 185 vframeArray* next() const { return _next; }
aoqi@0 186 void set_next(vframeArray* value) { _next = value; }
aoqi@0 187
aoqi@0 188 // Accessors for sp
aoqi@0 189 intptr_t* sp() const { return _original.sp(); }
aoqi@0 190
aoqi@0 191 intptr_t* unextended_sp() const { return _original.unextended_sp(); }
aoqi@0 192
aoqi@0 193 address original_pc() const { return _original.pc(); }
aoqi@0 194
aoqi@0 195 frame original() const { return _original; }
aoqi@0 196
aoqi@0 197 frame caller() const { return _caller; }
aoqi@0 198
aoqi@0 199 frame sender() const { return _sender; }
aoqi@0 200
aoqi@0 201 // Accessors for unroll block
aoqi@0 202 Deoptimization::UnrollBlock* unroll_block() const { return _unroll_block; }
aoqi@0 203 void set_unroll_block(Deoptimization::UnrollBlock* block) { _unroll_block = block; }
aoqi@0 204
aoqi@0 205 // Returns the size of the frame that got deoptimized
aoqi@0 206 int frame_size() const { return _frame_size; }
aoqi@0 207
aoqi@0 208 // Unpack the array on the stack passed in stack interval
aoqi@0 209 void unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters);
aoqi@0 210
aoqi@0 211 // Deallocates monitor chunks allocated during deoptimization.
aoqi@0 212 // This should be called when the array is not used anymore.
aoqi@0 213 void deallocate_monitor_chunks();
aoqi@0 214
aoqi@0 215
aoqi@0 216
aoqi@0 217 // Accessor for register map
aoqi@0 218 address register_location(int i) const;
aoqi@0 219
aoqi@0 220 void print_on_2(outputStream* st) PRODUCT_RETURN;
aoqi@0 221 void print_value_on(outputStream* st) const PRODUCT_RETURN;
aoqi@0 222
aoqi@0 223 #ifndef PRODUCT
aoqi@0 224 // Comparing
aoqi@0 225 bool structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk);
aoqi@0 226 #endif
aoqi@0 227
aoqi@0 228 };
aoqi@0 229
aoqi@0 230 #endif // SHARE_VM_RUNTIME_VFRAMEARRAY_HPP

mercurial