355 void BlockListBuilder::mark_loops() { |
355 void BlockListBuilder::mark_loops() { |
356 ResourceMark rm; |
356 ResourceMark rm; |
357 |
357 |
358 _active = BitMap(BlockBegin::number_of_blocks()); _active.clear(); |
358 _active = BitMap(BlockBegin::number_of_blocks()); _active.clear(); |
359 _visited = BitMap(BlockBegin::number_of_blocks()); _visited.clear(); |
359 _visited = BitMap(BlockBegin::number_of_blocks()); _visited.clear(); |
360 _loop_map = intArray(BlockBegin::number_of_blocks(), 0); |
360 _loop_map = intArray(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), 0); |
361 _next_loop_index = 0; |
361 _next_loop_index = 0; |
362 _next_block_number = _blocks.length(); |
362 _next_block_number = _blocks.length(); |
363 |
363 |
364 // recursively iterate the control flow graph |
364 // recursively iterate the control flow graph |
365 mark_loops(_bci2block->at(0), false); |
365 mark_loops(_bci2block->at(0), false); |
1352 ValueStack* state_before = copy_state_if_bb(is_bb);; |
1352 ValueStack* state_before = copy_state_if_bb(is_bb);; |
1353 append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); |
1353 append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); |
1354 } else { |
1354 } else { |
1355 // collect successors & keys |
1355 // collect successors & keys |
1356 BlockList* sux = new BlockList(l + 1, NULL); |
1356 BlockList* sux = new BlockList(l + 1, NULL); |
1357 intArray* keys = new intArray(l, 0); |
1357 intArray* keys = new intArray(l, l, 0); |
1358 int i; |
1358 int i; |
1359 bool has_bb = false; |
1359 bool has_bb = false; |
1360 for (i = 0; i < l; i++) { |
1360 for (i = 0; i < l; i++) { |
1361 LookupswitchPair pair = sw.pair_at(i); |
1361 LookupswitchPair pair = sw.pair_at(i); |
1362 if (pair.offset() < 0) has_bb = true; |
1362 if (pair.offset() < 0) has_bb = true; |
1519 |
1519 |
1520 append(new Return(x)); |
1520 append(new Return(x)); |
1521 } |
1521 } |
1522 |
1522 |
1523 Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) { |
1523 Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) { |
|
1524 if (!field_value.is_valid()) return NULL; |
|
1525 |
1524 BasicType field_type = field_value.basic_type(); |
1526 BasicType field_type = field_value.basic_type(); |
1525 ValueType* value = as_ValueType(field_value); |
1527 ValueType* value = as_ValueType(field_value); |
1526 |
1528 |
1527 // Attach dimension info to stable arrays. |
1529 // Attach dimension info to stable arrays. |
1528 if (FoldStableValues && |
1530 if (FoldStableValues && |
1586 const int offset = !needs_patching ? field->offset() : -1; |
1588 const int offset = !needs_patching ? field->offset() : -1; |
1587 switch (code) { |
1589 switch (code) { |
1588 case Bytecodes::_getstatic: { |
1590 case Bytecodes::_getstatic: { |
1589 // check for compile-time constants, i.e., initialized static final fields |
1591 // check for compile-time constants, i.e., initialized static final fields |
1590 Value constant = NULL; |
1592 Value constant = NULL; |
1591 if (field->is_constant() && !PatchALot) { |
1593 if (field->is_static_constant() && !PatchALot) { |
1592 ciConstant field_value = field->constant_value(); |
1594 ciConstant field_value = field->constant_value(); |
1593 // Stable static fields are checked for non-default values in ciField::initialize_from(). |
|
1594 assert(!field->is_stable() || !field_value.is_null_or_zero(), |
1595 assert(!field->is_stable() || !field_value.is_null_or_zero(), |
1595 "stable static w/ default value shouldn't be a constant"); |
1596 "stable static w/ default value shouldn't be a constant"); |
1596 constant = make_constant(field_value, field); |
1597 constant = make_constant(field_value, field); |
1597 } |
1598 } |
1598 if (constant != NULL) { |
1599 if (constant != NULL) { |
1617 case Bytecodes::_getfield: { |
1618 case Bytecodes::_getfield: { |
1618 // Check for compile-time constants, i.e., trusted final non-static fields. |
1619 // Check for compile-time constants, i.e., trusted final non-static fields. |
1619 Value constant = NULL; |
1620 Value constant = NULL; |
1620 obj = apop(); |
1621 obj = apop(); |
1621 ObjectType* obj_type = obj->type()->as_ObjectType(); |
1622 ObjectType* obj_type = obj->type()->as_ObjectType(); |
1622 if (obj_type->is_constant() && !PatchALot) { |
1623 if (field->is_constant() && obj_type->is_constant() && !PatchALot) { |
1623 ciObject* const_oop = obj_type->constant_value(); |
1624 ciObject* const_oop = obj_type->constant_value(); |
1624 if (!const_oop->is_null_object() && const_oop->is_loaded()) { |
1625 if (!const_oop->is_null_object() && const_oop->is_loaded()) { |
1625 if (field->is_constant()) { |
1626 ciConstant field_value = field->constant_value_of(const_oop); |
1626 ciConstant field_value = field->constant_value_of(const_oop); |
1627 if (field_value.is_valid()) { |
1627 if (FoldStableValues && field->is_stable() && field_value.is_null_or_zero()) { |
1628 constant = make_constant(field_value, field); |
1628 // Stable field with default value can't be constant. |
1629 // For CallSite objects add a dependency for invalidation of the optimization. |
1629 constant = NULL; |
1630 if (field->is_call_site_target()) { |
1630 } else { |
|
1631 constant = make_constant(field_value, field); |
|
1632 } |
|
1633 } else { |
|
1634 // For CallSite objects treat the target field as a compile time constant. |
|
1635 if (const_oop->is_call_site()) { |
|
1636 ciCallSite* call_site = const_oop->as_call_site(); |
1631 ciCallSite* call_site = const_oop->as_call_site(); |
1637 if (field->is_call_site_target()) { |
1632 if (!call_site->is_constant_call_site()) { |
1638 ciMethodHandle* target = call_site->get_target(); |
1633 ciMethodHandle* target = field_value.as_object()->as_method_handle(); |
1639 if (target != NULL) { // just in case |
1634 dependency_recorder()->assert_call_site_target_value(call_site, target); |
1640 ciConstant field_val(T_OBJECT, target); |
|
1641 constant = new Constant(as_ValueType(field_val)); |
|
1642 // Add a dependence for invalidation of the optimization. |
|
1643 if (!call_site->is_constant_call_site()) { |
|
1644 dependency_recorder()->assert_call_site_target_value(call_site, target); |
|
1645 } |
|
1646 } |
|
1647 } |
1635 } |
1648 } |
1636 } |
1649 } |
1637 } |
1650 } |
1638 } |
1651 } |
1639 } |
1720 void GraphBuilder::check_args_for_profiling(Values* obj_args, int expected) { |
1708 void GraphBuilder::check_args_for_profiling(Values* obj_args, int expected) { |
1721 #ifdef ASSERT |
1709 #ifdef ASSERT |
1722 bool ignored_will_link; |
1710 bool ignored_will_link; |
1723 ciSignature* declared_signature = NULL; |
1711 ciSignature* declared_signature = NULL; |
1724 ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); |
1712 ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); |
1725 assert(expected == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); |
1713 assert(expected == obj_args->max_length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); |
1726 #endif |
1714 #endif |
1727 } |
1715 } |
1728 |
1716 |
1729 // Collect arguments that we want to profile in a list |
1717 // Collect arguments that we want to profile in a list |
1730 Values* GraphBuilder::collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver) { |
1718 Values* GraphBuilder::collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver) { |
1731 int start = 0; |
1719 int start = 0; |
1732 Values* obj_args = args_list_for_profiling(target, start, may_have_receiver); |
1720 Values* obj_args = args_list_for_profiling(target, start, may_have_receiver); |
1733 if (obj_args == NULL) { |
1721 if (obj_args == NULL) { |
1734 return NULL; |
1722 return NULL; |
1735 } |
1723 } |
1736 int s = obj_args->size(); |
1724 int s = obj_args->max_length(); |
1737 // if called through method handle invoke, some arguments may have been popped |
1725 // if called through method handle invoke, some arguments may have been popped |
1738 for (int i = start, j = 0; j < s && i < args->length(); i++) { |
1726 for (int i = start, j = 0; j < s && i < args->length(); i++) { |
1739 if (args->at(i)->type()->is_object_kind()) { |
1727 if (args->at(i)->type()->is_object_kind()) { |
1740 obj_args->push(args->at(i)); |
1728 obj_args->push(args->at(i)); |
1741 j++; |
1729 j++; |
2168 void GraphBuilder::new_multi_array(int dimensions) { |
2156 void GraphBuilder::new_multi_array(int dimensions) { |
2169 bool will_link; |
2157 bool will_link; |
2170 ciKlass* klass = stream()->get_klass(will_link); |
2158 ciKlass* klass = stream()->get_klass(will_link); |
2171 ValueStack* state_before = !klass->is_loaded() || PatchALot ? copy_state_before() : copy_state_exhandling(); |
2159 ValueStack* state_before = !klass->is_loaded() || PatchALot ? copy_state_before() : copy_state_exhandling(); |
2172 |
2160 |
2173 Values* dims = new Values(dimensions, NULL); |
2161 Values* dims = new Values(dimensions, dimensions, NULL); |
2174 // fill in all dimensions |
2162 // fill in all dimensions |
2175 int i = dimensions; |
2163 int i = dimensions; |
2176 while (i-- > 0) dims->at_put(i, ipop()); |
2164 while (i-- > 0) dims->at_put(i, ipop()); |
2177 // create array |
2165 // create array |
2178 NewArray* n = new NewMultiArray(klass, dims, state_before); |
2166 NewArray* n = new NewMultiArray(klass, dims, state_before); |
3771 |
3759 |
3772 if (profile_calls()) { |
3760 if (profile_calls()) { |
3773 int start = 0; |
3761 int start = 0; |
3774 Values* obj_args = args_list_for_profiling(callee, start, has_receiver); |
3762 Values* obj_args = args_list_for_profiling(callee, start, has_receiver); |
3775 if (obj_args != NULL) { |
3763 if (obj_args != NULL) { |
3776 int s = obj_args->size(); |
3764 int s = obj_args->max_length(); |
3777 // if called through method handle invoke, some arguments may have been popped |
3765 // if called through method handle invoke, some arguments may have been popped |
3778 for (int i = args_base+start, j = 0; j < obj_args->size() && i < state()->stack_size(); ) { |
3766 for (int i = args_base+start, j = 0; j < obj_args->max_length() && i < state()->stack_size(); ) { |
3779 Value v = state()->stack_at_inc(i); |
3767 Value v = state()->stack_at_inc(i); |
3780 if (v->type()->is_object_kind()) { |
3768 if (v->type()->is_object_kind()) { |
3781 obj_args->push(v); |
3769 obj_args->push(v); |
3782 j++; |
3770 j++; |
3783 } |
3771 } |
4090 data->set_jsr_return_address_local(-1); |
4078 data->set_jsr_return_address_local(-1); |
4091 // Must clone bci2block list as we will be mutating it in order to |
4079 // Must clone bci2block list as we will be mutating it in order to |
4092 // properly clone all blocks in jsr region as well as exception |
4080 // properly clone all blocks in jsr region as well as exception |
4093 // handlers containing rets |
4081 // handlers containing rets |
4094 BlockList* new_bci2block = new BlockList(bci2block()->length()); |
4082 BlockList* new_bci2block = new BlockList(bci2block()->length()); |
4095 new_bci2block->push_all(bci2block()); |
4083 new_bci2block->appendAll(bci2block()); |
4096 data->set_bci2block(new_bci2block); |
4084 data->set_bci2block(new_bci2block); |
4097 data->set_scope(scope()); |
4085 data->set_scope(scope()); |
4098 data->setup_jsr_xhandlers(); |
4086 data->setup_jsr_xhandlers(); |
4099 data->set_continuation(continuation()); |
4087 data->set_continuation(continuation()); |
4100 data->set_jsr_continuation(jsr_continuation); |
4088 data->set_jsr_continuation(jsr_continuation); |