1434 compilation()->dependency_recorder()->assert_leaf_type(ik); 1435 exact_type = ik; 1436 } else { 1437 declared_type = ik; 1438 } 1439 } 1440 1441 // see if we know statically that registration isn't required 1442 bool needs_check = true; 1443 if (exact_type != NULL) { 1444 needs_check = exact_type->as_instance_klass()->has_finalizer(); 1445 } else if (declared_type != NULL) { 1446 ciInstanceKlass* ik = declared_type->as_instance_klass(); 1447 if (!Dependencies::has_finalizable_subclass(ik)) { 1448 compilation()->dependency_recorder()->assert_has_no_finalizable_subclasses(ik); 1449 needs_check = false; 1450 } 1451 } 1452 1453 if (needs_check) { 1454 // Not a trivial method because C2 can do better with inlined check. 1455 compilation()->set_would_profile(true); 1456 1457 // Perform the registration of finalizable objects. 1458 ValueStack* state_before = copy_state_for_exception(); 1459 load_local(objectType, 0); 1460 append_split(new Intrinsic(voidType, vmIntrinsics::_Object_init, 1461 state()->pop_arguments(1), 1462 true, state_before, true)); 1463 } 1464 } 1465 1466 1467 void GraphBuilder::method_return(Value x, bool ignore_return) { 1468 if (RegisterFinalizersAtInit && 1469 method()->intrinsic_id() == vmIntrinsics::_Object_init) { 1470 call_register_finalizer(); 1471 } 1472 1473 bool need_mem_bar = false; 1474 if (method()->name() == ciSymbol::object_initializer_name() && 1475 (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields()) 1476 || (support_IRIW_for_not_multiple_copy_atomic_cpu && scope()->wrote_volatile()) 3552 } 3553 } 3554 } 3555 3556 Intrinsic* result = new Intrinsic(result_type, callee->intrinsic_id(), 3557 args, has_receiver, state_before, 3558 vmIntrinsics::preserves_state(id), 3559 vmIntrinsics::can_trap(id)); 3560 // append instruction & push result 3561 Value value = append_split(result); 3562 if (result_type != voidType && !ignore_return) { 3563 push(result_type, value); 3564 } 3565 3566 if (callee != method() && profile_return() && result_type->is_object_kind()) { 3567 profile_return_type(result, callee); 3568 } 3569 } 3570 3571 bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) { 3572 // Not a trivial method because C2 may do intrinsics better. 3573 compilation()->set_would_profile(true); 3574 3575 // For calling is_intrinsic_available we need to transition to 3576 // the '_thread_in_vm' state because is_intrinsic_available() 3577 // accesses critical VM-internal data. 3578 bool is_available = false; 3579 { 3580 VM_ENTRY_MARK; 3581 methodHandle mh(THREAD, callee->get_Method()); 3582 is_available = _compilation->compiler()->is_intrinsic_available(mh, _compilation->directive()); 3583 } 3584 3585 if (!is_available) { 3586 if (!InlineNatives) { 3587 // Return false and also set message that the inlining of 3588 // intrinsics has been disabled in general. 3589 INLINE_BAILOUT("intrinsic method inlining disabled"); 3590 } else { 3591 return false; 3592 } 3593 } 3594 build_graph_for_intrinsic(callee, ignore_return); | 1434 compilation()->dependency_recorder()->assert_leaf_type(ik); 1435 exact_type = ik; 1436 } else { 1437 declared_type = ik; 1438 } 1439 } 1440 1441 // see if we know statically that registration isn't required 1442 bool needs_check = true; 1443 if (exact_type != NULL) { 1444 needs_check = exact_type->as_instance_klass()->has_finalizer(); 1445 } else if (declared_type != NULL) { 1446 ciInstanceKlass* ik = declared_type->as_instance_klass(); 1447 if (!Dependencies::has_finalizable_subclass(ik)) { 1448 compilation()->dependency_recorder()->assert_has_no_finalizable_subclasses(ik); 1449 needs_check = false; 1450 } 1451 } 1452 1453 if (needs_check) { 1454 // Perform the registration of finalizable objects. 1455 ValueStack* state_before = copy_state_for_exception(); 1456 load_local(objectType, 0); 1457 append_split(new Intrinsic(voidType, vmIntrinsics::_Object_init, 1458 state()->pop_arguments(1), 1459 true, state_before, true)); 1460 } 1461 } 1462 1463 1464 void GraphBuilder::method_return(Value x, bool ignore_return) { 1465 if (RegisterFinalizersAtInit && 1466 method()->intrinsic_id() == vmIntrinsics::_Object_init) { 1467 call_register_finalizer(); 1468 } 1469 1470 bool need_mem_bar = false; 1471 if (method()->name() == ciSymbol::object_initializer_name() && 1472 (scope()->wrote_final() || (AlwaysSafeConstructors && scope()->wrote_fields()) 1473 || (support_IRIW_for_not_multiple_copy_atomic_cpu && scope()->wrote_volatile()) 3549 } 3550 } 3551 } 3552 3553 Intrinsic* result = new Intrinsic(result_type, callee->intrinsic_id(), 3554 args, has_receiver, state_before, 3555 vmIntrinsics::preserves_state(id), 3556 vmIntrinsics::can_trap(id)); 3557 // append instruction & push result 3558 Value value = append_split(result); 3559 if (result_type != voidType && !ignore_return) { 3560 push(result_type, value); 3561 } 3562 3563 if (callee != method() && profile_return() && result_type->is_object_kind()) { 3564 profile_return_type(result, callee); 3565 } 3566 } 3567 3568 bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) { 3569 // For calling is_intrinsic_available we need to transition to 3570 // the '_thread_in_vm' state because is_intrinsic_available() 3571 // accesses critical VM-internal data. 3572 bool is_available = false; 3573 { 3574 VM_ENTRY_MARK; 3575 methodHandle mh(THREAD, callee->get_Method()); 3576 is_available = _compilation->compiler()->is_intrinsic_available(mh, _compilation->directive()); 3577 } 3578 3579 if (!is_available) { 3580 if (!InlineNatives) { 3581 // Return false and also set message that the inlining of 3582 // intrinsics has been disabled in general. 3583 INLINE_BAILOUT("intrinsic method inlining disabled"); 3584 } else { 3585 return false; 3586 } 3587 } 3588 build_graph_for_intrinsic(callee, ignore_return); |