@@ -2026,8 +2026,11 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
2026
2026
int index = state ()->stack_size () - (target->arg_size_no_receiver () + 1 );
2027
2027
receiver = state ()->stack_at (index );
2028
2028
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.
2031
2034
receiver_klass = (ciInstanceKlass*) type;
2032
2035
type_is_exact = true ;
2033
2036
}
@@ -2243,7 +2246,7 @@ void GraphBuilder::new_instance(int klass_index) {
2243
2246
2244
2247
void GraphBuilder::new_type_array () {
2245
2248
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 )));
2247
2250
}
2248
2251
2249
2252
@@ -3650,9 +3653,13 @@ void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee, bool ignore_retur
3650
3653
case vmIntrinsics::_getAndSetReference : append_unsafe_get_and_set (callee, false ); return ;
3651
3654
case vmIntrinsics::_getCharStringU : append_char_access (callee, false ); return ;
3652
3655
case vmIntrinsics::_putCharStringU : append_char_access (callee, true ); return ;
3656
+ case vmIntrinsics::_clone : append_alloc_array_copy (callee); return ;
3653
3657
default :
3654
3658
break ;
3655
3659
}
3660
+ if (_inline_bailout_msg != nullptr ) {
3661
+ return ;
3662
+ }
3656
3663
3657
3664
// create intrinsic node
3658
3665
const bool has_receiver = !callee->is_static ();
@@ -3714,6 +3721,9 @@ bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) {
3714
3721
}
3715
3722
}
3716
3723
build_graph_for_intrinsic (callee, ignore_return);
3724
+ if (_inline_bailout_msg != nullptr ) {
3725
+ return false ;
3726
+ }
3717
3727
return true ;
3718
3728
}
3719
3729
@@ -4427,6 +4437,43 @@ void GraphBuilder::append_char_access(ciMethod* callee, bool is_store) {
4427
4437
}
4428
4438
}
4429
4439
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
+
4430
4477
void GraphBuilder::print_inlining (ciMethod* callee, const char * msg, bool success) {
4431
4478
CompileLog* log = compilation ()->log ();
4432
4479
if (log != nullptr ) {
0 commit comments