src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/library_call.cpp

Print this page




2524         }
2525       }
2526       break;
2527     default:
2528       ShouldNotReachHere();
2529   }
2530 
2531   // Memory barrier to prevent normal and 'unsafe' accesses from
2532   // bypassing each other.  Happens after null checks, so the
2533   // exception paths do not take memory state from the memory barrier,
2534   // so there's no problems making a strong assert about mixing users
2535   // of safe & unsafe memory.
2536   if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder);
2537 
2538   assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
2539          alias_type->field() != NULL || alias_type->element() != NULL, "field, array element or unknown");
2540   bool mismatched = false;
2541   if (alias_type->element() != NULL || alias_type->field() != NULL) {
2542     BasicType bt;
2543     if (alias_type->element() != NULL) {
2544       const Type* element = alias_type->element();


2545       bt = element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type();
2546     } else {
2547       bt = alias_type->field()->type()->basic_type();
2548     }
2549     if (bt == T_ARRAY) {
2550       // accessing an array field with getObject is not a mismatch
2551       bt = T_OBJECT;
2552     }
2553     if (bt != type) {
2554       mismatched = true;
2555     }
2556   }
2557   assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type");
2558 
2559   if (!is_store) {
2560     Node* p = NULL;
2561     // Try to constant fold a load from a constant field
2562     ciField* field = alias_type->field();
2563     if (heap_base_oop != top() &&
2564         field != NULL && field->is_constant() && field->layout_type() == type) {
2565       // final or stable field
2566       const Type* con_type = Type::make_constant(alias_type->field(), heap_base_oop);
2567       if (con_type != NULL) {
2568         p = makecon(con_type);
2569       }
2570     }
2571     if (p == NULL) {
2572       // To be valid, unsafe loads may depend on other conditions than
2573       // the one that guards them: pin the Load node
2574       p = make_load(control(), adr, value_type, type, adr_type, mo, LoadNode::Pinned, requires_atomic_access, unaligned, mismatched);
2575       // load value
2576       switch (type) {
2577       case T_BOOLEAN:
2578       case T_CHAR:
2579       case T_BYTE:
2580       case T_SHORT:
2581       case T_INT:
2582       case T_LONG:
2583       case T_FLOAT:
2584       case T_DOUBLE:




2524         }
2525       }
2526       break;
2527     default:
2528       ShouldNotReachHere();
2529   }
2530 
2531   // Memory barrier to prevent normal and 'unsafe' accesses from
2532   // bypassing each other.  Happens after null checks, so the
2533   // exception paths do not take memory state from the memory barrier,
2534   // so there's no problems making a strong assert about mixing users
2535   // of safe & unsafe memory.
2536   if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder);
2537 
2538   assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM ||
2539          alias_type->field() != NULL || alias_type->element() != NULL, "field, array element or unknown");
2540   bool mismatched = false;
2541   if (alias_type->element() != NULL || alias_type->field() != NULL) {
2542     BasicType bt;
2543     if (alias_type->element() != NULL) {
2544       // Use address type to get the element type. Alias type doesn't provide
2545       // enough information (e.g., doesn't differentiate between byte[] and boolean[]).
2546       const Type* element = adr_type->is_aryptr()->elem();
2547       bt = element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type();
2548     } else {
2549       bt = alias_type->field()->layout_type();
2550     }
2551     if (bt == T_ARRAY) {
2552       // accessing an array field with getObject is not a mismatch
2553       bt = T_OBJECT;
2554     }
2555     if (bt != type) {
2556       mismatched = true;
2557     }
2558   }
2559   assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type");
2560 
2561   if (!is_store) {
2562     Node* p = NULL;
2563     // Try to constant fold a load from a constant field
2564     ciField* field = alias_type->field();
2565     if (heap_base_oop != top() &&
2566         field != NULL && field->is_constant() && !mismatched) {
2567       // final or stable field
2568       const Type* con_type = Type::make_constant(alias_type->field(), heap_base_oop);
2569       if (con_type != NULL) {
2570         p = makecon(con_type);
2571       }
2572     }
2573     if (p == NULL) {
2574       // To be valid, unsafe loads may depend on other conditions than
2575       // the one that guards them: pin the Load node
2576       p = make_load(control(), adr, value_type, type, adr_type, mo, LoadNode::Pinned, requires_atomic_access, unaligned, mismatched);
2577       // load value
2578       switch (type) {
2579       case T_BOOLEAN:
2580       case T_CHAR:
2581       case T_BYTE:
2582       case T_SHORT:
2583       case T_INT:
2584       case T_LONG:
2585       case T_FLOAT:
2586       case T_DOUBLE:


src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File