annotate src/share/vm/c1/c1_ValueStack.cpp @ 1819:f02a8bbe6ed4

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