2554 return NULL; |
2554 return NULL; |
2555 } |
2555 } |
2556 |
2556 |
2557 bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile, bool unaligned) { |
2557 bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile, bool unaligned) { |
2558 if (callee()->is_static()) return false; // caller must have the capability! |
2558 if (callee()->is_static()) return false; // caller must have the capability! |
|
2559 assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type"); |
2559 |
2560 |
2560 #ifndef PRODUCT |
2561 #ifndef PRODUCT |
2561 { |
2562 { |
2562 ResourceMark rm; |
2563 ResourceMark rm; |
2563 // Check the signatures. |
2564 // Check the signatures. |
2629 val = is_store ? argument(3) : NULL; |
2630 val = is_store ? argument(3) : NULL; |
2630 } |
2631 } |
2631 |
2632 |
2632 const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
2633 const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
2633 |
2634 |
2634 // First guess at the value type. |
|
2635 const Type *value_type = Type::get_const_basic_type(type); |
|
2636 |
|
2637 // Try to categorize the address. If it comes up as TypeJavaPtr::BOTTOM, |
2635 // Try to categorize the address. If it comes up as TypeJavaPtr::BOTTOM, |
2638 // there was not enough information to nail it down. |
2636 // there was not enough information to nail it down. |
2639 Compile::AliasType* alias_type = C->alias_type(adr_type); |
2637 Compile::AliasType* alias_type = C->alias_type(adr_type); |
2640 assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); |
2638 assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); |
|
2639 |
|
2640 assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM || |
|
2641 alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown"); |
|
2642 bool mismatched = false; |
|
2643 BasicType bt = alias_type->basic_type(); |
|
2644 if (bt != T_ILLEGAL) { |
|
2645 if (bt == T_BYTE && adr_type->isa_aryptr()) { |
|
2646 // Alias type doesn't differentiate between byte[] and boolean[]). |
|
2647 // Use address type to get the element type. |
|
2648 bt = adr_type->is_aryptr()->elem()->array_element_basic_type(); |
|
2649 } |
|
2650 if (bt == T_ARRAY || bt == T_NARROWOOP) { |
|
2651 // accessing an array field with getObject is not a mismatch |
|
2652 bt = T_OBJECT; |
|
2653 } |
|
2654 if ((bt == T_OBJECT) != (type == T_OBJECT)) { |
|
2655 // Don't intrinsify mismatched object accesses |
|
2656 return false; |
|
2657 } |
|
2658 mismatched = (bt != type); |
|
2659 } |
|
2660 |
|
2661 // First guess at the value type. |
|
2662 const Type *value_type = Type::get_const_basic_type(type); |
2641 |
2663 |
2642 // We will need memory barriers unless we can determine a unique |
2664 // We will need memory barriers unless we can determine a unique |
2643 // alias category for this reference. (Note: If for some reason |
2665 // alias category for this reference. (Note: If for some reason |
2644 // the barriers get omitted and the unsafe reference begins to "pollute" |
2666 // the barriers get omitted and the unsafe reference begins to "pollute" |
2645 // the alias analysis of the rest of the graph, either Compile::can_alias |
2667 // the alias analysis of the rest of the graph, either Compile::can_alias |
2694 // exception paths do not take memory state from the memory barrier, |
2716 // exception paths do not take memory state from the memory barrier, |
2695 // so there's no problems making a strong assert about mixing users |
2717 // so there's no problems making a strong assert about mixing users |
2696 // of safe & unsafe memory. Otherwise fails in a CTW of rt.jar |
2718 // of safe & unsafe memory. Otherwise fails in a CTW of rt.jar |
2697 // around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. |
2719 // around 5701, class sun/reflect/UnsafeBooleanFieldAccessorImpl. |
2698 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
2720 if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); |
2699 |
|
2700 assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM || |
|
2701 alias_type->field() != NULL || alias_type->element() != NULL, "field, array element or unknown"); |
|
2702 bool mismatched = false; |
|
2703 if (alias_type->element() != NULL || alias_type->field() != NULL) { |
|
2704 BasicType bt; |
|
2705 if (alias_type->element() != NULL) { |
|
2706 const Type* element = alias_type->element(); |
|
2707 bt = element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type(); |
|
2708 } else { |
|
2709 bt = alias_type->field()->type()->basic_type(); |
|
2710 } |
|
2711 if (bt != type) { |
|
2712 mismatched = true; |
|
2713 } |
|
2714 } |
|
2715 assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type"); |
|
2716 |
2721 |
2717 if (!is_store) { |
2722 if (!is_store) { |
2718 MemNode::MemOrd mo = is_volatile ? MemNode::acquire : MemNode::unordered; |
2723 MemNode::MemOrd mo = is_volatile ? MemNode::acquire : MemNode::unordered; |
2719 // To be valid, unsafe loads may depend on other conditions than |
2724 // To be valid, unsafe loads may depend on other conditions than |
2720 // the one that guards them: pin the Load node |
2725 // the one that guards them: pin the Load node |
2970 // 32-bit machines ignore the high half of long offsets |
2975 // 32-bit machines ignore the high half of long offsets |
2971 offset = ConvL2X(offset); |
2976 offset = ConvL2X(offset); |
2972 Node* adr = make_unsafe_address(base, offset); |
2977 Node* adr = make_unsafe_address(base, offset); |
2973 const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
2978 const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); |
2974 |
2979 |
|
2980 Compile::AliasType* alias_type = C->alias_type(adr_type); |
|
2981 assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM || |
|
2982 alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown"); |
|
2983 BasicType bt = alias_type->basic_type(); |
|
2984 if (bt != T_ILLEGAL && |
|
2985 ((bt == T_OBJECT || bt == T_ARRAY) != (type == T_OBJECT))) { |
|
2986 // Don't intrinsify mismatched object accesses. |
|
2987 return false; |
|
2988 } |
|
2989 |
2975 // For CAS, unlike inline_unsafe_access, there seems no point in |
2990 // For CAS, unlike inline_unsafe_access, there seems no point in |
2976 // trying to refine types. Just use the coarse types here. |
2991 // trying to refine types. Just use the coarse types here. |
|
2992 assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); |
2977 const Type *value_type = Type::get_const_basic_type(type); |
2993 const Type *value_type = Type::get_const_basic_type(type); |
2978 Compile::AliasType* alias_type = C->alias_type(adr_type); |
|
2979 assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); |
|
2980 |
2994 |
2981 if (kind == LS_xchg && type == T_OBJECT) { |
2995 if (kind == LS_xchg && type == T_OBJECT) { |
2982 const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type); |
2996 const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type); |
2983 if (tjp != NULL) { |
2997 if (tjp != NULL) { |
2984 value_type = tjp; |
2998 value_type = tjp; |