annotate src/share/vm/classfile/stackMapFrame.hpp @ 6725: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 4ee06e614636
children ab826603e572
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CLASSFILE_STACKMAPFRAME_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_STACKMAPFRAME_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/verificationType.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "classfile/verifier.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6605
diff changeset
30 #include "oops/method.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/handles.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/signature.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "utilities/exceptions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // A StackMapFrame represents one frame in the stack map attribute.
a61af66fc99e Initial load
duke
parents:
diff changeset
36
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
37 class TypeContext;
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
38
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 FLAG_THIS_UNINIT = 0x01
a61af66fc99e Initial load
duke
parents:
diff changeset
41 };
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class StackMapFrame : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
45 int32_t _offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // See comment in StackMapTable about _frame_count about why these
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // fields are int32_t instead of u2.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 int32_t _locals_size; // number of valid type elements in _locals
a61af66fc99e Initial load
duke
parents:
diff changeset
50 int32_t _stack_size; // number of valid type elements in _stack
a61af66fc99e Initial load
duke
parents:
diff changeset
51
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
52 int32_t _stack_mark; // Records the size of the stack prior to an
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
53 // instruction modification, to allow rewinding
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
54 // when/if an error occurs.
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
55
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int32_t _max_locals;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 int32_t _max_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 u1 _flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 VerificationType* _locals; // local variable type array
a61af66fc99e Initial load
duke
parents:
diff changeset
61 VerificationType* _stack; // operand stack type array
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 ClassVerifier* _verifier; // the verifier verifying this method
a61af66fc99e Initial load
duke
parents:
diff changeset
64
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
65 StackMapFrame(const StackMapFrame& cp) :
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
66 _offset(cp._offset), _locals_size(cp._locals_size),
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
67 _stack_size(cp._stack_size), _stack_mark(cp._stack_mark),
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
68 _max_locals(cp._max_locals), _max_stack(cp._max_stack),
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
69 _flags(cp._flags) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
70 _locals = NEW_RESOURCE_ARRAY(VerificationType, _max_locals);
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
71 for (int i = 0; i < _max_locals; ++i) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
72 if (i < _locals_size) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
73 _locals[i] = cp._locals[i];
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
74 } else {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
75 _locals[i] = VerificationType::bogus_type();
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
76 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
77 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
78 int ss = MAX2(_stack_size, _stack_mark);
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
79 _stack = NEW_RESOURCE_ARRAY(VerificationType, _max_stack);
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
80 for (int i = 0; i < _max_stack; ++i) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
81 if (i < ss) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
82 _stack[i] = cp._stack[i];
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
83 } else {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
84 _stack[i] = VerificationType::bogus_type();
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
85 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
86 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
87 _verifier = NULL;
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
88 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
89
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // constructors
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // This constructor is used by the type checker to allocate frames
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // in type state, which have _max_locals and _max_stack array elements
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // in _locals and _stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 StackMapFrame(u2 max_locals, u2 max_stack, ClassVerifier* verifier);
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // This constructor is used to initialize stackmap frames in stackmap table,
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // which have _locals_size and _stack_size array elements in _locals and _stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 StackMapFrame(int32_t offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 u1 flags,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 u2 locals_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
103 u2 stack_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
104 u2 max_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 u2 max_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
106 VerificationType* locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 VerificationType* stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 ClassVerifier* v) : _offset(offset), _flags(flags),
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _locals_size(locals_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _stack_size(stack_size),
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
111 _stack_mark(-1),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _max_locals(max_locals),
a61af66fc99e Initial load
duke
parents:
diff changeset
113 _max_stack(max_stack),
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _locals(locals), _stack(stack),
a61af66fc99e Initial load
duke
parents:
diff changeset
115 _verifier(v) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
117 static StackMapFrame* copy(StackMapFrame* smf) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
118 return new StackMapFrame(*smf);
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
119 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
120
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121 inline void set_offset(int32_t offset) { _offset = offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 inline void set_verifier(ClassVerifier* v) { _verifier = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 inline void set_flags(u1 flags) { _flags = flags; }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 inline void set_locals_size(u2 locals_size) { _locals_size = locals_size; }
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
125 inline void set_stack_size(u2 stack_size) { _stack_size = _stack_mark = stack_size; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
126 inline void clear_stack() { _stack_size = 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 inline int32_t offset() const { return _offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 inline ClassVerifier* verifier() const { return _verifier; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 inline u1 flags() const { return _flags; }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 inline int32_t locals_size() const { return _locals_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 inline VerificationType* locals() const { return _locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 inline int32_t stack_size() const { return _stack_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 inline VerificationType* stack() const { return _stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 inline int32_t max_locals() const { return _max_locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 inline int32_t max_stack() const { return _max_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 inline bool flag_this_uninit() const { return _flags & FLAG_THIS_UNINIT; }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Set locals and stack types to bogus
a61af66fc99e Initial load
duke
parents:
diff changeset
139 inline void reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 int32_t i;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 for (i = 0; i < _max_locals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _locals[i] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 for (i = 0; i < _max_stack; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 _stack[i] = VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Return a StackMapFrame with the same local variable array and empty stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Stack array is allocate with unused one element.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 StackMapFrame* frame_in_exception_handler(u1 flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Set local variable type array based on m's signature.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 VerificationType set_locals_from_arg(
a61af66fc99e Initial load
duke
parents:
diff changeset
155 const methodHandle m, VerificationType thisKlass, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // Search local variable type array and stack type array.
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Return true if an uninitialized object is found.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 bool has_new_object() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Search local variable type array and stack type array.
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Set every element with type of old_object to new_object.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void initialize_object(
a61af66fc99e Initial load
duke
parents:
diff changeset
164 VerificationType old_object, VerificationType new_object);
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Copy local variable type array in src into this local variable type array.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void copy_locals(const StackMapFrame* src);
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Copy stack type array in src into this stack type array.
a61af66fc99e Initial load
duke
parents:
diff changeset
170 void copy_stack(const StackMapFrame* src);
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Return true if this stack map frame is assignable to target.
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
173 bool is_assignable_to(
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
174 const StackMapFrame* target, bool is_exception_handler,
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
175 ErrorContext* ctx, TRAPS) const;
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
176
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
177 inline void set_mark() {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
178 #ifdef DEBUG
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
179 // Put bogus type to indicate it's no longer valid.
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
180 if (_stack_mark != -1) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
181 for (int i = _stack_mark; i >= _stack_size; --i) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
182 _stack[i] = VerificationType::bogus_type();
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
183 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
184 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
185 #endif // def DEBUG
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
186 _stack_mark = _stack_size;
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
187 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
188
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
189 // Used when an error occurs and we want to reset the stack to the state
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
190 // it was before operands were popped off.
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
191 void restore() {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
192 if (_stack_mark != -1) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
193 _stack_size = _stack_mark;
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
194 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
195 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Push type into stack type array.
a61af66fc99e Initial load
duke
parents:
diff changeset
198 inline void push_stack(VerificationType type, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 assert(!type.is_check(), "Must be a real type");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if (_stack_size >= _max_stack) {
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
201 verifier()->verify_error(
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
202 ErrorContext::stack_overflow(_offset, this),
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
203 "Operand stack overflow");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 _stack[_stack_size++] = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 inline void push_stack_2(
a61af66fc99e Initial load
duke
parents:
diff changeset
210 VerificationType type1, VerificationType type2, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 assert(type1.is_long() || type1.is_double(), "must be long/double");
a61af66fc99e Initial load
duke
parents:
diff changeset
212 assert(type2.is_long2() || type2.is_double2(), "must be long/double_2");
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (_stack_size >= _max_stack - 1) {
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
214 verifier()->verify_error(
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
215 ErrorContext::stack_overflow(_offset, this),
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
216 "Operand stack overflow");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 _stack[_stack_size++] = type1;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 _stack[_stack_size++] = type2;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // Pop and return the top type on stack without verifying.
a61af66fc99e Initial load
duke
parents:
diff changeset
224 inline VerificationType pop_stack(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 if (_stack_size <= 0) {
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
226 verifier()->verify_error(
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
227 ErrorContext::stack_underflow(_offset, this),
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
228 "Operand stack underflow");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
229 return VerificationType::bogus_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 VerificationType top = _stack[--_stack_size];
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return top;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // Pop and return the top type on stack type array after verifying it
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // is assignable to type.
a61af66fc99e Initial load
duke
parents:
diff changeset
237 inline VerificationType pop_stack(VerificationType type, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (_stack_size != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 VerificationType top = _stack[_stack_size - 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
240 bool subtype = type.is_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
241 top, verifier(), CHECK_(VerificationType::bogus_type()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
242 if (subtype) {
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
243 --_stack_size;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return top;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 return pop_stack_ex(type, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 inline void pop_stack_2(
a61af66fc99e Initial load
duke
parents:
diff changeset
251 VerificationType type1, VerificationType type2, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 assert(type1.is_long2() || type1.is_double2(), "must be long/double");
a61af66fc99e Initial load
duke
parents:
diff changeset
253 assert(type2.is_long() || type2.is_double(), "must be long/double_2");
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if (_stack_size >= 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 VerificationType top1 = _stack[_stack_size - 1];
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
256 bool subtype1 = type1.is_assignable_from(top1, verifier(), CHECK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
257 VerificationType top2 = _stack[_stack_size - 2];
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
258 bool subtype2 = type2.is_assignable_from(top2, verifier(), CHECK);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if (subtype1 && subtype2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 _stack_size -= 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 pop_stack_ex(type1, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 pop_stack_ex(type2, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
268 VerificationType local_at(int index) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
269 return _locals[index];
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
270 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
271
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
272 VerificationType stack_at(int index) {
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
273 return _stack[index];
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
274 }
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
275
0
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Uncommon case that throws exceptions.
a61af66fc99e Initial load
duke
parents:
diff changeset
277 VerificationType pop_stack_ex(VerificationType type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // Return the type at index in local variable array after verifying
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // it is assignable to type.
a61af66fc99e Initial load
duke
parents:
diff changeset
281 VerificationType get_local(int32_t index, VerificationType type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // For long/double.
a61af66fc99e Initial load
duke
parents:
diff changeset
283 void get_local_2(
a61af66fc99e Initial load
duke
parents:
diff changeset
284 int32_t index, VerificationType type1, VerificationType type2, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // Set element at index in local variable array to type.
a61af66fc99e Initial load
duke
parents:
diff changeset
287 void set_local(int32_t index, VerificationType type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // For long/double.
a61af66fc99e Initial load
duke
parents:
diff changeset
289 void set_local_2(
a61af66fc99e Initial load
duke
parents:
diff changeset
290 int32_t index, VerificationType type1, VerificationType type2, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // Private auxiliary method used only in is_assignable_to(StackMapFrame).
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // Returns true if src is assignable to target.
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
294 int is_assignable_to(
0
a61af66fc99e Initial load
duke
parents:
diff changeset
295 VerificationType* src, VerificationType* target, int32_t len, TRAPS) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
296
2303
c1a6154012c8 7020118: Alter frame assignability to allow for exception handler coverage of invokespecial <init>
kamg
parents: 2177
diff changeset
297 bool has_flag_match_exception(const StackMapFrame* target) const;
c1a6154012c8 7020118: Alter frame assignability to allow for exception handler coverage of invokespecial <init>
kamg
parents: 2177
diff changeset
298
6605
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
299 TypeOrigin stack_top_ctx();
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
300
4ee06e614636 7116786: RFE: Detailed information on VerifyErrors
kamg
parents: 2477
diff changeset
301 void print_on(outputStream* str) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
302 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
303
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
304 #endif // SHARE_VM_CLASSFILE_STACKMAPFRAME_HPP