< prev index next >

src/share/vm/opto/library_call.cpp

Print this page




2619            "fieldOffset must be byte-scaled");
2620     // 32-bit machines ignore the high half!
2621     offset = ConvL2X(offset);
2622     adr = make_unsafe_address(base, offset);
2623     heap_base_oop = base;
2624     val = is_store ? argument(4) : NULL;
2625   } else {
2626     Node* ptr = argument(1);  // type: long
2627     ptr = ConvL2X(ptr);  // adjust Java long to machine word
2628     adr = make_unsafe_address(NULL, ptr);
2629     val = is_store ? argument(3) : NULL;
2630   }
2631 
2632   const TypePtr *adr_type = _gvn.type(adr)->isa_ptr();
2633 
2634   // Try to categorize the address.  If it comes up as TypeJavaPtr::BOTTOM,
2635   // there was not enough information to nail it down.
2636   Compile::AliasType* alias_type = C->alias_type(adr_type);
2637   assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here");
2638 
2639   assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
2640          alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown");





2641   bool mismatched = false;
2642   BasicType bt = alias_type->basic_type();
2643   if (bt != T_ILLEGAL) {
2644     if (bt == T_BYTE && adr_type->isa_aryptr()) {
2645       // Alias type doesn't differentiate between byte[] and boolean[]).
2646       // Use address type to get the element type.
2647       bt = adr_type->is_aryptr()->elem()->array_element_basic_type();
2648     }
2649     if (bt == T_ARRAY || bt == T_NARROWOOP) {
2650       // accessing an array field with getObject is not a mismatch
2651       bt = T_OBJECT;
2652     }
2653     if ((bt == T_OBJECT) != (type == T_OBJECT)) {
2654       // Don't intrinsify mismatched object accesses
2655       return false;
2656     }
2657     mismatched = (bt != type);
2658   }
2659 
2660   // First guess at the value type.


2943   Node* receiver = NULL;
2944   Node* base     = NULL;
2945   Node* offset   = NULL;
2946   Node* oldval   = NULL;
2947   Node* newval   = NULL;
2948   if (kind == LS_cmpxchg) {
2949     const bool two_slot_type = type2size[type] == 2;
2950     receiver = argument(0);  // type: oop
2951     base     = argument(1);  // type: oop
2952     offset   = argument(2);  // type: long
2953     oldval   = argument(4);  // type: oop, int, or long
2954     newval   = argument(two_slot_type ? 6 : 5);  // type: oop, int, or long
2955   } else if (kind == LS_xadd || kind == LS_xchg){
2956     receiver = argument(0);  // type: oop
2957     base     = argument(1);  // type: oop
2958     offset   = argument(2);  // type: long
2959     oldval   = NULL;
2960     newval   = argument(4);  // type: oop, int, or long
2961   }
2962 
2963   // Null check receiver.
2964   receiver = null_check(receiver);
2965   if (stopped()) {
2966     return true;
2967   }
2968 
2969   // Build field offset expression.
2970   // We currently rely on the cookies produced by Unsafe.xxxFieldOffset
2971   // to be plain byte offsets, which are also the same as those accepted
2972   // by oopDesc::field_base.
2973   assert(Unsafe_field_offset_to_byte_offset(11) == 11, "fieldOffset must be byte-scaled");
2974   // 32-bit machines ignore the high half of long offsets
2975   offset = ConvL2X(offset);
2976   Node* adr = make_unsafe_address(base, offset);
2977   const TypePtr *adr_type = _gvn.type(adr)->isa_ptr();
2978 
2979   Compile::AliasType* alias_type = C->alias_type(adr_type);
2980   assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
2981          alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown");
2982   BasicType bt = alias_type->basic_type();
2983   if (bt != T_ILLEGAL &&
2984       ((bt == T_OBJECT || bt == T_ARRAY) != (type == T_OBJECT))) {
2985     // Don't intrinsify mismatched object accesses.
2986     return false;
2987   }
2988 
2989   // For CAS, unlike inline_unsafe_access, there seems no point in
2990   // trying to refine types. Just use the coarse types here.
2991   assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here");
2992   const Type *value_type = Type::get_const_basic_type(type);
2993 
2994   if (kind == LS_xchg && type == T_OBJECT) {
2995     const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type);
2996     if (tjp != NULL) {
2997       value_type = tjp;
2998     }






2999   }
3000 
3001   int alias_idx = C->get_alias_index(adr_type);
3002 
3003   // Memory-model-wise, a LoadStore acts like a little synchronized
3004   // block, so needs barriers on each side.  These don't translate
3005   // into actual barriers on most machines, but we still need rest of
3006   // compiler to respect ordering.
3007 
3008   insert_mem_bar(Op_MemBarRelease);
3009   insert_mem_bar(Op_MemBarCPUOrder);
3010 
3011   // 4984716: MemBars must be inserted before this
3012   //          memory node in order to avoid a false
3013   //          dependency which will confuse the scheduler.
3014   Node *mem = memory(alias_idx);
3015 
3016   // For now, we handle only those cases that actually exist: ints,
3017   // longs, and Object. Adding others should be straightforward.
3018   Node* load_store = NULL;




2619            "fieldOffset must be byte-scaled");
2620     // 32-bit machines ignore the high half!
2621     offset = ConvL2X(offset);
2622     adr = make_unsafe_address(base, offset);
2623     heap_base_oop = base;
2624     val = is_store ? argument(4) : NULL;
2625   } else {
2626     Node* ptr = argument(1);  // type: long
2627     ptr = ConvL2X(ptr);  // adjust Java long to machine word
2628     adr = make_unsafe_address(NULL, ptr);
2629     val = is_store ? argument(3) : NULL;
2630   }
2631 
2632   const TypePtr *adr_type = _gvn.type(adr)->isa_ptr();
2633 
2634   // Try to categorize the address.  If it comes up as TypeJavaPtr::BOTTOM,
2635   // there was not enough information to nail it down.
2636   Compile::AliasType* alias_type = C->alias_type(adr_type);
2637   assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here");
2638 
2639   // Only field, array element or unknown locations are supported.
2640   if (alias_type->adr_type() != TypeRawPtr::BOTTOM &&
2641       alias_type->adr_type() != TypeOopPtr::BOTTOM &&
2642       alias_type->basic_type() == T_ILLEGAL) {
2643     return false;
2644   }
2645 
2646   bool mismatched = false;
2647   BasicType bt = alias_type->basic_type();
2648   if (bt != T_ILLEGAL) {
2649     if (bt == T_BYTE && adr_type->isa_aryptr()) {
2650       // Alias type doesn't differentiate between byte[] and boolean[]).
2651       // Use address type to get the element type.
2652       bt = adr_type->is_aryptr()->elem()->array_element_basic_type();
2653     }
2654     if (bt == T_ARRAY || bt == T_NARROWOOP) {
2655       // accessing an array field with getObject is not a mismatch
2656       bt = T_OBJECT;
2657     }
2658     if ((bt == T_OBJECT) != (type == T_OBJECT)) {
2659       // Don't intrinsify mismatched object accesses
2660       return false;
2661     }
2662     mismatched = (bt != type);
2663   }
2664 
2665   // First guess at the value type.


2948   Node* receiver = NULL;
2949   Node* base     = NULL;
2950   Node* offset   = NULL;
2951   Node* oldval   = NULL;
2952   Node* newval   = NULL;
2953   if (kind == LS_cmpxchg) {
2954     const bool two_slot_type = type2size[type] == 2;
2955     receiver = argument(0);  // type: oop
2956     base     = argument(1);  // type: oop
2957     offset   = argument(2);  // type: long
2958     oldval   = argument(4);  // type: oop, int, or long
2959     newval   = argument(two_slot_type ? 6 : 5);  // type: oop, int, or long
2960   } else if (kind == LS_xadd || kind == LS_xchg){
2961     receiver = argument(0);  // type: oop
2962     base     = argument(1);  // type: oop
2963     offset   = argument(2);  // type: long
2964     oldval   = NULL;
2965     newval   = argument(4);  // type: oop, int, or long
2966   }
2967 






2968   // Build field offset expression.
2969   // We currently rely on the cookies produced by Unsafe.xxxFieldOffset
2970   // to be plain byte offsets, which are also the same as those accepted
2971   // by oopDesc::field_base.
2972   assert(Unsafe_field_offset_to_byte_offset(11) == 11, "fieldOffset must be byte-scaled");
2973   // 32-bit machines ignore the high half of long offsets
2974   offset = ConvL2X(offset);
2975   Node* adr = make_unsafe_address(base, offset);
2976   const TypePtr *adr_type = _gvn.type(adr)->isa_ptr();
2977 
2978   Compile::AliasType* alias_type = C->alias_type(adr_type);


2979   BasicType bt = alias_type->basic_type();
2980   if (bt != T_ILLEGAL &&
2981       ((bt == T_OBJECT || bt == T_ARRAY) != (type == T_OBJECT))) {
2982     // Don't intrinsify mismatched object accesses.
2983     return false;
2984   }
2985 
2986   // For CAS, unlike inline_unsafe_access, there seems no point in
2987   // trying to refine types. Just use the coarse types here.
2988   assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here");
2989   const Type *value_type = Type::get_const_basic_type(type);
2990 
2991   if (kind == LS_xchg && type == T_OBJECT) {
2992     const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type);
2993     if (tjp != NULL) {
2994       value_type = tjp;
2995     }
2996   }
2997 
2998   // Null check receiver.
2999   receiver = null_check(receiver);
3000   if (stopped()) {
3001     return true;
3002   }
3003 
3004   int alias_idx = C->get_alias_index(adr_type);
3005 
3006   // Memory-model-wise, a LoadStore acts like a little synchronized
3007   // block, so needs barriers on each side.  These don't translate
3008   // into actual barriers on most machines, but we still need rest of
3009   // compiler to respect ordering.
3010 
3011   insert_mem_bar(Op_MemBarRelease);
3012   insert_mem_bar(Op_MemBarCPUOrder);
3013 
3014   // 4984716: MemBars must be inserted before this
3015   //          memory node in order to avoid a false
3016   //          dependency which will confuse the scheduler.
3017   Node *mem = memory(alias_idx);
3018 
3019   // For now, we handle only those cases that actually exist: ints,
3020   // longs, and Object. Adding others should be straightforward.
3021   Node* load_store = NULL;


< prev index next >