2360 Node* phi = _exits.argument(0); 2361 const TypeOopPtr* tr = phi->bottom_type()->isa_oopptr(); 2362 if (tr && tr->isa_instptr() && tr->klass()->is_loaded() && 2363 tr->klass()->is_interface()) { 2364 // If returning oops to an interface-return, there is a silent free 2365 // cast from oop to interface allowed by the Verifier. Make it explicit here. 2366 const TypeInstPtr* tp = value->bottom_type()->isa_instptr(); 2367 if (tp && tp->klass()->is_loaded() && !tp->klass()->is_interface()) { 2368 // sharpen the type eagerly; this eases certain assert checking 2369 if (tp->higher_equal(TypeInstPtr::NOTNULL)) { 2370 tr = tr->join_speculative(TypeInstPtr::NOTNULL)->is_instptr(); 2371 } 2372 value = _gvn.transform(new CheckCastPPNode(0, value, tr)); 2373 } 2374 } else if (tr && tr->isa_instptr() && value->is_ValueType()) { 2375 // Handle exact value type to Object return 2376 assert(tr->isa_instptr()->klass()->is_java_lang_Object(), "must be java.lang.Object"); 2377 ValueTypeNode* vt = value->as_ValueType()->allocate(this)->as_ValueType(); 2378 value = ValueTypePtrNode::make_from_value_type(_gvn, vt); 2379 } else if (phi->bottom_type()->isa_valuetype() && !value->is_ValueType()) { 2380 Node* null_ctl = top(); 2381 Node* not_null_obj = null_check_common(value, T_VALUETYPE, false, &null_ctl, false); 2382 if (null_ctl != top()) { 2383 // TODO For now, we just deoptimize if value type is NULL 2384 PreserveJVMState pjvms(this); 2385 set_control(null_ctl); 2386 replace_in_map(value, null()); 2387 inc_sp(1); 2388 uncommon_trap(Deoptimization::Reason_null_check, Deoptimization::Action_none); 2389 } 2390 if (stopped()) { 2391 value = null(); 2392 } else { 2393 value = ValueTypeNode::make_from_oop(this, not_null_obj, phi->bottom_type()->isa_valuetype()->value_klass()); 2394 } 2395 } else { 2396 // Handle returns of oop-arrays to an arrays-of-interface return 2397 const TypeInstPtr* phi_tip; 2398 const TypeInstPtr* val_tip; 2399 Type::get_arrays_base_elements(phi->bottom_type(), value->bottom_type(), &phi_tip, &val_tip); 2400 if (phi_tip != NULL && phi_tip->is_loaded() && phi_tip->klass()->is_interface() && 2401 val_tip != NULL && val_tip->is_loaded() && !val_tip->klass()->is_interface()) { 2402 value = _gvn.transform(new CheckCastPPNode(0, value, phi->bottom_type())); 2403 } 2404 } 2405 phi->add_req(value); 2406 } 2407 2408 SafePointNode* exit_return = _exits.map(); 2409 exit_return->in( TypeFunc::Control )->add_req( control() ); 2410 exit_return->in( TypeFunc::I_O )->add_req( i_o () ); 2411 Node *mem = exit_return->in( TypeFunc::Memory ); 2412 for (MergeMemStream mms(mem->as_MergeMem(), merged_memory()); mms.next_non_empty2(); ) { 2413 if (mms.is_empty()) { 2414 // get a copy of the base memory, and patch just this one input | 2360 Node* phi = _exits.argument(0); 2361 const TypeOopPtr* tr = phi->bottom_type()->isa_oopptr(); 2362 if (tr && tr->isa_instptr() && tr->klass()->is_loaded() && 2363 tr->klass()->is_interface()) { 2364 // If returning oops to an interface-return, there is a silent free 2365 // cast from oop to interface allowed by the Verifier. Make it explicit here. 2366 const TypeInstPtr* tp = value->bottom_type()->isa_instptr(); 2367 if (tp && tp->klass()->is_loaded() && !tp->klass()->is_interface()) { 2368 // sharpen the type eagerly; this eases certain assert checking 2369 if (tp->higher_equal(TypeInstPtr::NOTNULL)) { 2370 tr = tr->join_speculative(TypeInstPtr::NOTNULL)->is_instptr(); 2371 } 2372 value = _gvn.transform(new CheckCastPPNode(0, value, tr)); 2373 } 2374 } else if (tr && tr->isa_instptr() && value->is_ValueType()) { 2375 // Handle exact value type to Object return 2376 assert(tr->isa_instptr()->klass()->is_java_lang_Object(), "must be java.lang.Object"); 2377 ValueTypeNode* vt = value->as_ValueType()->allocate(this)->as_ValueType(); 2378 value = ValueTypePtrNode::make_from_value_type(_gvn, vt); 2379 } else if (phi->bottom_type()->isa_valuetype() && !value->is_ValueType()) { 2380 assert(value->bottom_type()->remove_speculative() == TypePtr::NULL_PTR, "Anything other than null?"); 2381 inc_sp(1); 2382 uncommon_trap(Deoptimization::Reason_null_check, Deoptimization::Action_none); 2383 dec_sp(1); 2384 return; 2385 } else { 2386 // Handle returns of oop-arrays to an arrays-of-interface return 2387 const TypeInstPtr* phi_tip; 2388 const TypeInstPtr* val_tip; 2389 Type::get_arrays_base_elements(phi->bottom_type(), value->bottom_type(), &phi_tip, &val_tip); 2390 if (phi_tip != NULL && phi_tip->is_loaded() && phi_tip->klass()->is_interface() && 2391 val_tip != NULL && val_tip->is_loaded() && !val_tip->klass()->is_interface()) { 2392 value = _gvn.transform(new CheckCastPPNode(0, value, phi->bottom_type())); 2393 } 2394 } 2395 phi->add_req(value); 2396 } 2397 2398 SafePointNode* exit_return = _exits.map(); 2399 exit_return->in( TypeFunc::Control )->add_req( control() ); 2400 exit_return->in( TypeFunc::I_O )->add_req( i_o () ); 2401 Node *mem = exit_return->in( TypeFunc::Memory ); 2402 for (MergeMemStream mms(mem->as_MergeMem(), merged_memory()); mms.next_non_empty2(); ) { 2403 if (mms.is_empty()) { 2404 // get a copy of the base memory, and patch just this one input |