annotate src/share/vm/c1/c1_ValueStack.cpp @ 2607:008adfd6d850

Fixed the stateBefore of invokes and monitorenter instructions to include the arguments of the instruction. This is necessary to ensure correct continuation in the interpreter when the stateBefore is used as a deoptimization point.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Fri, 06 May 2011 17:47:17 +0200
parents f95d63e2154a
children 1d7922586cf6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1819
diff changeset
2 * Copyright (c) 1999, 2010, 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: 1819
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1819
diff changeset
26 #include "c1/c1_IR.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1819
diff changeset
27 #include "c1/c1_InstructionPrinter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1819
diff changeset
28 #include "c1/c1_ValueStack.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // Implementation of ValueStack
a61af66fc99e Initial load
duke
parents:
diff changeset
32
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
33 ValueStack::ValueStack(IRScope* scope, ValueStack* caller_state)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34 : _scope(scope)
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
35 , _caller_state(caller_state)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
36 , _bci(-99)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
37 , _kind(Parsing)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
38 , _locals(scope->method()->max_locals(), NULL)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
39 , _stack(scope->method()->max_stack())
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
40 , _locks()
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41 {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
42 verify();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
46 ValueStack::ValueStack(ValueStack* copy_from, Kind kind, int bci)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
47 : _scope(copy_from->scope())
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
48 , _caller_state(copy_from->caller_state())
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
49 , _bci(bci)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
50 , _kind(kind)
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
51 , _locals()
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
52 , _stack()
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
53 , _locks(copy_from->locks_size())
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
54 {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
55 assert(kind != EmptyExceptionState || !Compilation::current()->env()->jvmti_can_access_local_variables(), "need locals");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
56 if (kind != EmptyExceptionState) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
57 // only allocate space if we need to copy the locals-array
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
58 _locals = Values(copy_from->locals_size());
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
59 _locals.appendAll(&copy_from->_locals);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
61
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
62 if (kind != ExceptionState && kind != EmptyExceptionState) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
63 if (kind == Parsing) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
64 // stack will be modified, so reserve enough space to avoid resizing
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
65 _stack = Values(scope()->method()->max_stack());
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
66 } else {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
67 // stack will not be modified, so do not waste space
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
68 _stack = Values(copy_from->stack_size());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
70 _stack.appendAll(&copy_from->_stack);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
73 _locks.appendAll(&copy_from->_locks);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
74
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
75 verify();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
79 bool ValueStack::is_same(ValueStack* s) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
80 if (scope() != s->scope()) return false;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
81 if (caller_state() != s->caller_state()) return false;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
82
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
83 if (locals_size() != s->locals_size()) return false;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
84 if (stack_size() != s->stack_size()) return false;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
85 if (locks_size() != s->locks_size()) return false;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
86
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // compare each stack element with the corresponding stack element of s
a61af66fc99e Initial load
duke
parents:
diff changeset
88 int index;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 Value value;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 for_each_stack_value(this, index, value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (value->type()->tag() != s->stack_at(index)->type()->tag()) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 for_each_lock_value(this, index, value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (value != s->lock_at(index)) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void ValueStack::clear_locals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 for (int i = _locals.length() - 1; i >= 0; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _locals.at_put(i, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void ValueStack::pin_stack_for_linear_scan() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 for_each_state_value(this, v,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (v->as_Constant() == NULL && v->as_Local() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 v->pin(Instruction::PinStackForStateSplit);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 );
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // apply function to all values of a list; factored out from values_do(f)
1584
b812ff5abc73 6958292: C1: Enable parallel compilation
iveresov
parents: 1552
diff changeset
116 void ValueStack::apply(Values list, ValueVisitor* f) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117 for (int i = 0; i < list.length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 Value* va = list.adr_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 Value v0 = *va;
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
120 if (v0 != NULL && !v0->type()->is_illegal()) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
121 f->visit(va);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
122 #ifdef ASSERT
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
123 Value v1 = *va;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
124 assert(v1->type()->is_illegal() || v0->type()->tag() == v1->type()->tag(), "types must match");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
125 assert(!v1->type()->is_double_word() || list.at(i + 1) == NULL, "hi-word of doubleword value must be NULL");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
126 #endif
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
127 if (v0->type()->is_double_word()) i++;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132
1584
b812ff5abc73 6958292: C1: Enable parallel compilation
iveresov
parents: 1552
diff changeset
133 void ValueStack::values_do(ValueVisitor* f) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 ValueStack* state = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 for_each_state(state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 apply(state->_locals, f);
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
137 apply(state->_stack, f);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
138 apply(state->_locks, f);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 Values* ValueStack::pop_arguments(int argument_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 assert(stack_size() >= argument_size, "stack too small or too many arguments");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 int base = stack_size() - argument_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 Values* args = new Values(argument_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 for (int i = base; i < stack_size();) args->push(stack_at_inc(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 truncate_stack(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return args;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
153 int ValueStack::total_locks_size() const {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
154 int num_locks = 0;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
155 const ValueStack* state = this;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
156 for_each_state(state) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
157 num_locks += state->locks_size();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
158 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
159 return num_locks;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
160 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
161
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
162 int ValueStack::lock(Value obj) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 _locks.push(obj);
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
164 int num_locks = total_locks_size();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
165 scope()->set_min_number_of_locks(num_locks);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
166 return num_locks - 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int ValueStack::unlock() {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 _locks.pop();
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
172 return total_locks_size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 assert(stack_at(index)->as_Phi() == NULL || stack_at(index)->as_Phi()->block() != b, "phi function already created");
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 ValueType* t = stack_at(index)->type();
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Value phi = new Phi(t, b, -index - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _stack[index] = phi;
a61af66fc99e Initial load
duke
parents:
diff changeset
182
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
183 assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 void ValueStack::setup_phi_for_local(BlockBegin* b, int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 assert(local_at(index)->as_Phi() == NULL || local_at(index)->as_Phi()->block() != b, "phi function already created");
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 ValueType* t = local_at(index)->type();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 Value phi = new Phi(t, b, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 store_local(index, phi);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 #ifndef PRODUCT
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
195
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void ValueStack::print() {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
197 scope()->method()->print_name();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (stack_is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 tty->print_cr("empty stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 InstructionPrinter ip;
a61af66fc99e Initial load
duke
parents:
diff changeset
202 for (int i = 0; i < stack_size();) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 Value t = stack_at_inc(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 tty->print("%2d ", i);
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
205 tty->print("%c%d ", t->type()->tchar(), t->id());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206 ip.print_instr(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (!no_active_locks()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 InstructionPrinter ip;
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
212 for (int i = 0; i < locks_size(); i++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
213 Value t = lock_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 tty->print("lock %2d ", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (t == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 tty->print("this");
a61af66fc99e Initial load
duke
parents:
diff changeset
217 } else {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
218 tty->print("%c%d ", t->type()->tchar(), t->id());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
219 ip.print_instr(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (locals_size() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 InstructionPrinter ip;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 for (int i = 0; i < locals_size();) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 Value l = _locals[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
228 tty->print("local %d ", i);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (l == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 tty->print("null");
a61af66fc99e Initial load
duke
parents:
diff changeset
231 i ++;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 } else {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
233 tty->print("%c%d ", l->type()->tchar(), l->id());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
234 ip.print_instr(l);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 if (l->type()->is_illegal() || l->type()->is_single_word()) i ++; else i += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
240
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
241 if (caller_state() != NULL) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
242 caller_state()->print();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
243 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void ValueStack::verify() {
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
248 assert(scope() != NULL, "scope must exist");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
249 if (caller_state() != NULL) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
250 assert(caller_state()->scope() == scope()->caller(), "invalid caller scope");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
251 caller_state()->verify();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
252 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
253
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
254 if (kind() == Parsing) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
255 assert(bci() == -99, "bci not defined during parsing");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
256 } else {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
257 assert(bci() >= -1, "bci out of range");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
258 assert(bci() < scope()->method()->code_size(), "bci out of range");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
259 assert(bci() == SynchronizationEntryBCI || Bytecodes::is_defined(scope()->method()->java_code_at_bci(bci())), "make sure bci points at a real bytecode");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
260 assert(scope()->method()->liveness_at_bci(bci()).is_valid(), "liveness at bci must be valid");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
261 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
262
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
263 int i;
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
264 for (i = 0; i < stack_size(); i++) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
265 Value v = _stack.at(i);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
266 if (v == NULL) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
267 assert(_stack.at(i - 1)->type()->is_double_word(), "only hi-words are NULL on stack");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
268 } else if (v->type()->is_double_word()) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
269 assert(_stack.at(i + 1) == NULL, "hi-word must be NULL");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
270 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
271 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
272
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
273 for (i = 0; i < locals_size(); i++) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
274 Value v = _locals.at(i);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
275 if (v != NULL && v->type()->is_double_word()) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
276 assert(_locals.at(i + 1) == NULL, "hi-word must be NULL");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
277 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
278 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
279
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
280 for_each_state_value(this, v,
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
281 assert(v != NULL, "just test if state-iteration succeeds");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1584
diff changeset
282 );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 #endif // PRODUCT