@@ -2026,8 +2026,11 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
20262026 int index = state ()->stack_size () - (target->arg_size_no_receiver () + 1 );
20272027 receiver = state ()->stack_at (index);
20282028 ciType* type = receiver->exact_type ();
2029- if (type != nullptr && type->is_loaded () &&
2030- type->is_instance_klass () && !type->as_instance_klass ()->is_interface ()) {
2029+ if (type != nullptr && type->is_loaded ()) {
2030+ assert (!type->is_instance_klass () || !type->as_instance_klass ()->is_interface (), " Must not be an interface" );
2031+ // Detects non-interface instances, primitive arrays, and some object arrays.
2032+ // Array receivers can only call Object methods, so we should be able to allow
2033+ // all object arrays here too, even those with unloaded types.
20312034 receiver_klass = (ciInstanceKlass*) type;
20322035 type_is_exact = true ;
20332036 }
@@ -2243,7 +2246,7 @@ void GraphBuilder::new_instance(int klass_index) {
22432246
22442247void GraphBuilder::new_type_array () {
22452248 ValueStack* state_before = copy_state_exhandling ();
2246- apush (append_split (new NewTypeArray (ipop (), (BasicType)stream ()->get_index (), state_before)));
2249+ apush (append_split (new NewTypeArray (ipop (), (BasicType)stream ()->get_index (), state_before, true )));
22472250}
22482251
22492252
@@ -3650,9 +3653,13 @@ void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee, bool ignore_retur
36503653 case vmIntrinsics::_getAndSetReference : append_unsafe_get_and_set (callee, false ); return ;
36513654 case vmIntrinsics::_getCharStringU : append_char_access (callee, false ); return ;
36523655 case vmIntrinsics::_putCharStringU : append_char_access (callee, true ); return ;
3656+ case vmIntrinsics::_clone : append_alloc_array_copy (callee); return ;
36533657 default :
36543658 break ;
36553659 }
3660+ if (_inline_bailout_msg != nullptr ) {
3661+ return ;
3662+ }
36563663
36573664 // create intrinsic node
36583665 const bool has_receiver = !callee->is_static ();
@@ -3714,6 +3721,9 @@ bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) {
37143721 }
37153722 }
37163723 build_graph_for_intrinsic (callee, ignore_return);
3724+ if (_inline_bailout_msg != nullptr ) {
3725+ return false ;
3726+ }
37173727 return true ;
37183728}
37193729
@@ -4427,6 +4437,43 @@ void GraphBuilder::append_char_access(ciMethod* callee, bool is_store) {
44274437 }
44284438}
44294439
4440+ void GraphBuilder::append_alloc_array_copy (ciMethod* callee) {
4441+ const int args_base = state ()->stack_size () - callee->arg_size ();
4442+ ciType* receiver_type = state ()->stack_at (args_base)->exact_type ();
4443+ if (receiver_type == nullptr ) {
4444+ inline_bailout (" must have a receiver" );
4445+ return ;
4446+ }
4447+ if (!receiver_type->is_type_array_klass ()) {
4448+ inline_bailout (" clone array not primitive" );
4449+ return ;
4450+ }
4451+
4452+ ValueStack* state_before = copy_state_before ();
4453+ state_before->set_force_reexecute ();
4454+ Value src = apop ();
4455+ BasicType basic_type = src->exact_type ()->as_array_klass ()->element_type ()->basic_type ();
4456+ Value length = append (new ArrayLength (src, state_before));
4457+ Value new_array = append_split (new NewTypeArray (length, basic_type, state_before, false ));
4458+
4459+ ValueType* result_type = as_ValueType (callee->return_type ());
4460+ vmIntrinsics::ID id = vmIntrinsics::_arraycopy;
4461+ Values* args = new Values (5 );
4462+ args->push (src);
4463+ args->push (append (new Constant (new IntConstant (0 ))));
4464+ args->push (new_array);
4465+ args->push (append (new Constant (new IntConstant (0 ))));
4466+ args->push (length);
4467+ const bool has_receiver = true ;
4468+ Intrinsic* array_copy = new Intrinsic (result_type, id,
4469+ args, has_receiver, state_before,
4470+ vmIntrinsics::preserves_state (id),
4471+ vmIntrinsics::can_trap (id));
4472+ array_copy->set_flag (Instruction::OmitChecksFlag, true );
4473+ append_split (array_copy);
4474+ apush (new_array);
4475+ }
4476+
44304477void GraphBuilder::print_inlining (ciMethod* callee, const char * msg, bool success) {
44314478 CompileLog* log = compilation ()->log ();
44324479 if (log != nullptr ) {
0 commit comments