--- a/src/hotspot/share/c1/c1_ValueStack.cpp Tue Mar 12 09:59:58 2019 -0400
+++ b/src/hotspot/share/c1/c1_ValueStack.cpp Tue Mar 12 15:29:59 2019 +0100
@@ -37,7 +37,7 @@
, _kind(Parsing)
, _locals(scope->method()->max_locals(), scope->method()->max_locals(), NULL)
, _stack(scope->method()->max_stack())
-, _locks()
+, _locks(NULL)
{
verify();
}
@@ -50,7 +50,7 @@
, _kind(kind)
, _locals()
, _stack()
- , _locks(copy_from->locks_size())
+ , _locks(copy_from->locks_size() == 0 ? NULL : new Values(copy_from->locks_size()))
{
assert(kind != EmptyExceptionState || !Compilation::current()->env()->should_retain_local_variables(), "need locals");
if (kind != EmptyExceptionState) {
@@ -70,7 +70,9 @@
_stack.appendAll(©_from->_stack);
}
- _locks.appendAll(©_from->_locks);
+ if (copy_from->locks_size() > 0) {
+ _locks->appendAll(copy_from->_locks);
+ }
verify();
}
@@ -90,8 +92,11 @@
for_each_stack_value(this, index, value) {
if (value->type()->tag() != s->stack_at(index)->type()->tag()) return false;
}
- for_each_lock_value(this, index, value) {
- if (value != s->lock_at(index)) return false;
+ for (int i = 0; i < locks_size(); i++) {
+ value = lock_at(i);
+ if (value != NULL && value != s->lock_at(i)) {
+ return false;
+ }
}
return true;
}
@@ -113,7 +118,7 @@
// apply function to all values of a list; factored out from values_do(f)
-void ValueStack::apply(Values list, ValueVisitor* f) {
+void ValueStack::apply(const Values& list, ValueVisitor* f) {
for (int i = 0; i < list.length(); i++) {
Value* va = list.adr_at(i);
Value v0 = *va;
@@ -135,7 +140,9 @@
for_each_state(state) {
apply(state->_locals, f);
apply(state->_stack, f);
- apply(state->_locks, f);
+ if (state->_locks != NULL) {
+ apply(*state->_locks, f);
+ }
}
}
@@ -160,7 +167,10 @@
}
int ValueStack::lock(Value obj) {
- _locks.push(obj);
+ if (_locks == NULL) {
+ _locks = new Values();
+ }
+ _locks->push(obj);
int num_locks = total_locks_size();
scope()->set_min_number_of_locks(num_locks);
return num_locks - 1;
@@ -168,7 +178,8 @@
int ValueStack::unlock() {
- _locks.pop();
+ assert(locks_size() > 0, "sanity");
+ _locks->pop();
return total_locks_size();
}
--- a/src/hotspot/share/c1/c1_ValueStack.hpp Tue Mar 12 09:59:58 2019 -0400
+++ b/src/hotspot/share/c1/c1_ValueStack.hpp Tue Mar 12 15:29:59 2019 +0100
@@ -47,7 +47,7 @@
Values _locals; // the locals
Values _stack; // the expression stack
- Values _locks; // the monitor stack (holding the locked values)
+ Values* _locks; // the monitor stack (holding the locked values)
Value check(ValueTag tag, Value t) {
assert(tag == t->type()->tag() || tag == objectTag && t->type()->tag() == addressTag, "types must correspond");
@@ -60,7 +60,7 @@
}
// helper routine
- static void apply(Values list, ValueVisitor* f);
+ static void apply(const Values& list, ValueVisitor* f);
// for simplified copying
ValueStack(ValueStack* copy_from, Kind kind, int bci);
@@ -90,9 +90,9 @@
int locals_size() const { return _locals.length(); }
int stack_size() const { return _stack.length(); }
- int locks_size() const { return _locks.length(); }
+ int locks_size() const { return _locks == NULL ? 0 : _locks->length(); }
bool stack_is_empty() const { return _stack.is_empty(); }
- bool no_active_locks() const { return _locks.is_empty(); }
+ bool no_active_locks() const { return _locks == NULL || _locks->is_empty(); }
int total_locks_size() const;
// locals access
@@ -201,7 +201,7 @@
// locks access
int lock (Value obj);
int unlock();
- Value lock_at(int i) const { return _locks.at(i); }
+ Value lock_at(int i) const { return _locks->at(i); }
// SSA form IR support
void setup_phi_for_stack(BlockBegin* b, int index);
@@ -261,14 +261,6 @@
index += value->type()->size())
-#define for_each_lock_value(state, index, value) \
- int temp_var = state->locks_size(); \
- for (index = 0; \
- index < temp_var && (value = state->lock_at(index), true); \
- index++) \
- if (value != NULL)
-
-
// Macro definition for simple iteration of all state values of a ValueStack
// Because the code cannot be executed in a single loop, the code must be passed
// as a macro parameter.