Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8251046: [lworld] [lw3] C1 should avoid heap allocations in withfield when possible #137

Closed
wants to merge 10 commits into from
@@ -1104,27 +1104,27 @@ void GraphBuilder::stack_op(Bytecodes::Code code) {
switch (code) {
case Bytecodes::_pop:
{ Value w = state()->raw_pop();
NewInlineTypeInstance::update_stack_count(w);
update_larva_stack_count(w);
}
break;
case Bytecodes::_pop2:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
NewInlineTypeInstance::update_stack_count(w1);
NewInlineTypeInstance::update_stack_count(w2);
update_larva_stack_count(w1);
update_larva_stack_count(w2);
}
break;
case Bytecodes::_dup:
{ Value w = state()->raw_pop();
NewInlineTypeInstance::update_larval_state(w);
update_larval_state(w);
state()->raw_push(w);
state()->raw_push(w);
}
break;
case Bytecodes::_dup_x1:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
NewInlineTypeInstance::update_larval_state(w1);
update_larval_state(w1);
state()->raw_push(w1);
state()->raw_push(w2);
state()->raw_push(w1);
@@ -1134,6 +1134,7 @@ void GraphBuilder::stack_op(Bytecodes::Code code) {
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
Value w3 = state()->raw_pop();
// special handling for the dup_x2/pop sequence (see JDK-8251046)
if (w1 != NULL && w1->as_NewInlineTypeInstance() != NULL) {
ciBytecodeStream s(method());
s.force_bci(bci());
@@ -1153,8 +1154,8 @@ void GraphBuilder::stack_op(Bytecodes::Code code) {
case Bytecodes::_dup2:
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
NewInlineTypeInstance::update_larval_state(w1);
NewInlineTypeInstance::update_larval_state(w2);
update_larval_state(w1);
update_larval_state(w2);
state()->raw_push(w2);
state()->raw_push(w1);
state()->raw_push(w2);
@@ -1165,8 +1166,8 @@ void GraphBuilder::stack_op(Bytecodes::Code code) {
{ Value w1 = state()->raw_pop();
Value w2 = state()->raw_pop();
Value w3 = state()->raw_pop();
NewInlineTypeInstance::update_larval_state(w1);
NewInlineTypeInstance::update_larval_state(w2);
update_larval_state(w1);
update_larval_state(w2);
state()->raw_push(w2);
state()->raw_push(w1);
state()->raw_push(w3);
@@ -1179,8 +1180,8 @@ void GraphBuilder::stack_op(Bytecodes::Code code) {
Value w2 = state()->raw_pop();
Value w3 = state()->raw_pop();
Value w4 = state()->raw_pop();
NewInlineTypeInstance::update_larval_state(w1);
NewInlineTypeInstance::update_larval_state(w2);
update_larval_state(w1);
update_larval_state(w2);
state()->raw_push(w2);
state()->raw_push(w1);
state()->raw_push(w4);
@@ -366,6 +366,18 @@ class GraphBuilder {
// JSR 292 support
bool try_method_handle_inline(ciMethod* callee, bool ignore_return);

// Inline type support
void update_larval_state(Value v) {
if (v != NULL && v->as_NewInlineTypeInstance() != NULL) {
v->as_NewInlineTypeInstance()->update_larval_state();
}
}
void update_larva_stack_count(Value v) {
if (v != NULL && v->as_NewInlineTypeInstance() != NULL) {
v->as_NewInlineTypeInstance()->update_stack_count();
}
}

// helpers
void inline_bailout(const char* msg);
BlockBegin* header_block(BlockBegin* entry, BlockBegin::Flag f, ValueStack* state);
@@ -420,7 +420,7 @@ void BlockBegin::state_values_do(ValueVisitor* f) {


StoreField::StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,

This comment has been minimized.

@TobiHartmann

TobiHartmann Aug 6, 2020
Member Outdated

Indentation should be fixed.

ValueStack* state_before, bool needs_patching)
ValueStack* state_before, bool needs_patching)
: AccessField(obj, offset, field, is_static, state_before, needs_patching)
, _value(value)
{
@@ -435,8 +435,8 @@ void BlockBegin::state_values_do(ValueVisitor* f) {
}
}

StoreIndexed::StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
bool check_boolean, bool mismatched)
StoreIndexed::StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value,
ValueStack* state_before, bool check_boolean, bool mismatched)
: AccessIndexed(array, index, length, elt_type, state_before, mismatched)
, _value(value), _check_boolean(check_boolean)
{
@@ -1415,22 +1415,19 @@ LEAF(NewInlineTypeInstance, StateSplit)
}

virtual bool in_larval_state() const { return _in_larval_state; }
virtual void set_not_larva_anymore() {
_in_larval_state = false; }
virtual void set_not_larva_anymore() { _in_larval_state = false; }

virtual int on_stack_count() { return _on_stack_count; }
virtual void increment_on_stack_count() { _on_stack_count++; }
virtual void decrement_on_stack_count() { _on_stack_count--; }

static void update_larval_state(Value v) {
if (v != NULL && v->as_NewInlineTypeInstance() != NULL) {
v->as_NewInlineTypeInstance()->set_not_larva_anymore();
}
void update_larval_state() {
set_not_larva_anymore();
}

static void update_stack_count(Value v) {
if (v != NULL && v->as_NewInlineTypeInstance() != NULL && v->as_NewInlineTypeInstance()->in_larval_state()) {
v->as_NewInlineTypeInstance()->decrement_on_stack_count();
void update_stack_count() {
if (in_larval_state()) {
decrement_on_stack_count();
}
}