comparison src/hotspot/share/c1/c1_ValueStack.cpp @ 56025:854e828d6b5b

8227442: Make young_index_in_cset zero-based Summary: Avoid unnecessary increment of young_index_in_cset in copy_to_survivor_space. Reviewed-by: kbarrett, sangheki
author tschatzl
date Tue, 20 Aug 2019 09:22:18 +0200
parents 71c04702a3d5
children
comparison
equal deleted inserted replaced
0:1f0bc0d47cd9 1:41860718e6f9
35 , _caller_state(caller_state) 35 , _caller_state(caller_state)
36 , _bci(-99) 36 , _bci(-99)
37 , _kind(Parsing) 37 , _kind(Parsing)
38 , _locals(scope->method()->max_locals(), scope->method()->max_locals(), NULL) 38 , _locals(scope->method()->max_locals(), scope->method()->max_locals(), NULL)
39 , _stack(scope->method()->max_stack()) 39 , _stack(scope->method()->max_stack())
40 , _locks() 40 , _locks(NULL)
41 { 41 {
42 verify(); 42 verify();
43 } 43 }
44 44
45 45
48 , _caller_state(copy_from->caller_state()) 48 , _caller_state(copy_from->caller_state())
49 , _bci(bci) 49 , _bci(bci)
50 , _kind(kind) 50 , _kind(kind)
51 , _locals() 51 , _locals()
52 , _stack() 52 , _stack()
53 , _locks(copy_from->locks_size()) 53 , _locks(copy_from->locks_size() == 0 ? NULL : new Values(copy_from->locks_size()))
54 { 54 {
55 assert(kind != EmptyExceptionState || !Compilation::current()->env()->should_retain_local_variables(), "need locals"); 55 assert(kind != EmptyExceptionState || !Compilation::current()->env()->should_retain_local_variables(), "need locals");
56 if (kind != EmptyExceptionState) { 56 if (kind != EmptyExceptionState) {
57 // only allocate space if we need to copy the locals-array 57 // only allocate space if we need to copy the locals-array
58 _locals = Values(copy_from->locals_size()); 58 _locals = Values(copy_from->locals_size());
68 _stack = Values(copy_from->stack_size()); 68 _stack = Values(copy_from->stack_size());
69 } 69 }
70 _stack.appendAll(&copy_from->_stack); 70 _stack.appendAll(&copy_from->_stack);
71 } 71 }
72 72
73 _locks.appendAll(&copy_from->_locks); 73 if (copy_from->locks_size() > 0) {
74 _locks->appendAll(copy_from->_locks);
75 }
74 76
75 verify(); 77 verify();
76 } 78 }
77 79
78 80
88 int index; 90 int index;
89 Value value; 91 Value value;
90 for_each_stack_value(this, index, value) { 92 for_each_stack_value(this, index, value) {
91 if (value->type()->tag() != s->stack_at(index)->type()->tag()) return false; 93 if (value->type()->tag() != s->stack_at(index)->type()->tag()) return false;
92 } 94 }
93 for_each_lock_value(this, index, value) { 95 for (int i = 0; i < locks_size(); i++) {
94 if (value != s->lock_at(index)) return false; 96 value = lock_at(i);
97 if (value != NULL && value != s->lock_at(i)) {
98 return false;
99 }
95 } 100 }
96 return true; 101 return true;
97 } 102 }
98 103
99 void ValueStack::clear_locals() { 104 void ValueStack::clear_locals() {
111 ); 116 );
112 } 117 }
113 118
114 119
115 // apply function to all values of a list; factored out from values_do(f) 120 // apply function to all values of a list; factored out from values_do(f)
116 void ValueStack::apply(Values list, ValueVisitor* f) { 121 void ValueStack::apply(const Values& list, ValueVisitor* f) {
117 for (int i = 0; i < list.length(); i++) { 122 for (int i = 0; i < list.length(); i++) {
118 Value* va = list.adr_at(i); 123 Value* va = list.adr_at(i);
119 Value v0 = *va; 124 Value v0 = *va;
120 if (v0 != NULL && !v0->type()->is_illegal()) { 125 if (v0 != NULL && !v0->type()->is_illegal()) {
121 f->visit(va); 126 f->visit(va);
133 void ValueStack::values_do(ValueVisitor* f) { 138 void ValueStack::values_do(ValueVisitor* f) {
134 ValueStack* state = this; 139 ValueStack* state = this;
135 for_each_state(state) { 140 for_each_state(state) {
136 apply(state->_locals, f); 141 apply(state->_locals, f);
137 apply(state->_stack, f); 142 apply(state->_stack, f);
138 apply(state->_locks, f); 143 if (state->_locks != NULL) {
144 apply(*state->_locks, f);
145 }
139 } 146 }
140 } 147 }
141 148
142 149
143 Values* ValueStack::pop_arguments(int argument_size) { 150 Values* ValueStack::pop_arguments(int argument_size) {
158 } 165 }
159 return num_locks; 166 return num_locks;
160 } 167 }
161 168
162 int ValueStack::lock(Value obj) { 169 int ValueStack::lock(Value obj) {
163 _locks.push(obj); 170 if (_locks == NULL) {
171 _locks = new Values();
172 }
173 _locks->push(obj);
164 int num_locks = total_locks_size(); 174 int num_locks = total_locks_size();
165 scope()->set_min_number_of_locks(num_locks); 175 scope()->set_min_number_of_locks(num_locks);
166 return num_locks - 1; 176 return num_locks - 1;
167 } 177 }
168 178
169 179
170 int ValueStack::unlock() { 180 int ValueStack::unlock() {
171 _locks.pop(); 181 assert(locks_size() > 0, "sanity");
182 _locks->pop();
172 return total_locks_size(); 183 return total_locks_size();
173 } 184 }
174 185
175 186
176 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) { 187 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) {