< prev index next >

src/hotspot/share/opto/graphKit.cpp

Print this page




1157 Node* GraphKit::ConvI2UL(Node* offset) {
1158   juint offset_con = (juint) find_int_con(offset, Type::OffsetBot);
1159   if (offset_con != (juint) Type::OffsetBot) {
1160     return longcon((julong) offset_con);
1161   }
1162   Node* conv = _gvn.transform( new ConvI2LNode(offset));
1163   Node* mask = _gvn.transform(ConLNode::make((julong) max_juint));
1164   return _gvn.transform( new AndLNode(conv, mask) );
1165 }
1166 
1167 Node* GraphKit::ConvL2I(Node* offset) {
1168   // short-circuit a common case
1169   jlong offset_con = find_long_con(offset, (jlong)Type::OffsetBot);
1170   if (offset_con != (jlong)Type::OffsetBot) {
1171     return intcon((int) offset_con);
1172   }
1173   return _gvn.transform( new ConvL2INode(offset));
1174 }
1175 
1176 //-------------------------load_object_klass-----------------------------------
1177 Node* GraphKit::load_object_klass(Node* obj) {
1178   // Special-case a fresh allocation to avoid building nodes:
1179   Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1180   if (akls != NULL)  return akls;
1181   Node* k_adr = basic_plus_adr(obj, oopDesc::klass_offset_in_bytes());
1182   return _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS));
1183 }
1184 
1185 //-------------------------load_array_length-----------------------------------
1186 Node* GraphKit::load_array_length(Node* array) {
1187   // Special-case a fresh allocation to avoid building nodes:
1188   AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array, &_gvn);
1189   Node *alen;
1190   if (alloc == NULL) {
1191     Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1192     alen = _gvn.transform( new LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS));
1193   } else {
1194     alen = alloc->Ideal_length();
1195     Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_oopptr(), &_gvn);
1196     if (ccast != alen) {
1197       alen = _gvn.transform(ccast);
1198     }
1199   }
1200   return alen;
1201 }
1202 


3444           // Casting array element to a non-flattenable type, mark array as not flat.
3445           Node* cast = _gvn.transform(new CheckCastPPNode(control(), array, ary_t->cast_to_not_flat()));
3446           replace_in_map(array, cast);
3447         }
3448       }
3449     }
3450   }
3451 
3452   if (!is_value) {
3453     res = record_profiled_receiver_for_speculation(res);
3454     if (toop->is_valuetypeptr() && toop->value_klass()->is_scalarizable() && !gvn().type(res)->maybe_null()) {
3455       res = ValueTypeNode::make_from_oop(this, res, toop->value_klass());
3456     }
3457   }
3458   return res;
3459 }
3460 
3461 Node* GraphKit::is_always_locked(Node* obj) {
3462   Node* mark_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
3463   Node* mark = make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
3464   Node* value_mask = _gvn.MakeConX(markWord::always_locked_pattern);
3465   return _gvn.transform(new AndXNode(mark, value_mask));


3466 }
3467 
3468 Node* GraphKit::is_value_mirror(Node* mirror) {
3469   Node* p = basic_plus_adr(mirror, java_lang_Class::inline_mirror_offset_in_bytes());
3470   Node* inline_mirror = access_load_at(mirror, p, _gvn.type(p)->is_ptr(), TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR), T_OBJECT, IN_HEAP);
3471   Node* cmp = _gvn.transform(new CmpPNode(mirror, inline_mirror));
3472   return _gvn.transform(new BoolNode(cmp, BoolTest::eq));
3473 }
3474 
3475 // Deoptimize if 'obj' is a value type
3476 void GraphKit::gen_value_type_guard(Node* obj, int nargs) {
3477   assert(EnableValhalla, "should only be used if value types are enabled");
3478   Node* bol = NULL;
3479   if (obj->is_ValueTypeBase()) {
3480     bol = intcon(0);
3481   } else {
3482     Node* is_value = is_always_locked(obj);
3483     Node* value_mask = _gvn.MakeConX(markWord::always_locked_pattern);
3484     Node* cmp = _gvn.transform(new CmpXNode(is_value, value_mask));
3485     bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne));
3486   }
3487   { BuildCutout unless(this, bol, PROB_MAX);
3488     inc_sp(nargs);
3489     uncommon_trap(Deoptimization::Reason_class_check,
3490                   Deoptimization::Action_none);
3491   }
3492 }
3493 
3494 // Check if 'ary' is a null-free value type array
3495 Node* GraphKit::gen_null_free_array_check(Node* ary) {
3496   assert(EnableValhalla, "should only be used if value types are enabled");
3497   // Extract null free property from klass pointer
3498   Node* k_adr = basic_plus_adr(ary, oopDesc::klass_offset_in_bytes());
3499   const TypePtr* k_adr_type = k_adr->bottom_type()->isa_ptr();
3500   Node* klass = NULL;
3501   if (k_adr_type->is_ptr_to_narrowklass()) {
3502     klass = _gvn.transform(new LoadNKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT->make_narrowklass(), MemNode::unordered));
3503   } else {
3504     klass = _gvn.transform(new LoadKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT, MemNode::unordered));
3505   }
3506   Node* null_free = _gvn.transform(new GetNullFreePropertyNode(klass));
3507   Node* cmp = NULL;
3508   if (_gvn.type(klass)->isa_klassptr()) {
3509     cmp = _gvn.transform(new CmpLNode(null_free, zerocon(T_LONG)));
3510   } else {
3511     cmp = _gvn.transform(new CmpINode(null_free, zerocon(T_INT)));
3512   }
3513   return _gvn.transform(new BoolNode(cmp, BoolTest::eq));
3514 }
3515 
3516 Node* GraphKit::gen_flattened_array_test(Node* ary) {
3517   assert(EnableValhalla, "should only be used if value types are enabled");
3518   // Extract flattened property from klass pointer
3519   Node* k_adr = basic_plus_adr(ary, oopDesc::klass_offset_in_bytes());
3520   const TypePtr* k_adr_type = k_adr->bottom_type()->isa_ptr();
3521   Node* klass = NULL;
3522   if (k_adr_type->is_ptr_to_narrowklass()) {
3523     klass = _gvn.transform(new LoadNKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT->make_narrowklass(), MemNode::unordered));
3524   } else {
3525     klass = _gvn.transform(new LoadKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT, MemNode::unordered));
3526   }
3527   return _gvn.transform(new GetFlattenedPropertyNode(klass));
3528 }
3529 
3530 // Deoptimize if 'ary' is a null-free value type array and 'val' is null
3531 Node* GraphKit::gen_value_array_null_guard(Node* ary, Node* val, int nargs, bool safe_for_replace) {
3532   const Type* val_t = _gvn.type(val);
3533   if (val->is_ValueType() || !TypePtr::NULL_PTR->higher_equal(val_t)) {
3534     return ary; // Never null
3535   }
3536   RegionNode* region = new RegionNode(3);
3537   Node* null_ctl = top();
3538   null_check_oop(val, &null_ctl);
3539   if (null_ctl != top()) {
3540     PreserveJVMState pjvms(this);
3541     set_control(null_ctl);
3542     // Deoptimize if null-free array
3543     Node* bol = gen_null_free_array_check(ary);
3544     { BuildCutout unless(this, bol, PROB_MAX);
3545       inc_sp(nargs);




1157 Node* GraphKit::ConvI2UL(Node* offset) {
1158   juint offset_con = (juint) find_int_con(offset, Type::OffsetBot);
1159   if (offset_con != (juint) Type::OffsetBot) {
1160     return longcon((julong) offset_con);
1161   }
1162   Node* conv = _gvn.transform( new ConvI2LNode(offset));
1163   Node* mask = _gvn.transform(ConLNode::make((julong) max_juint));
1164   return _gvn.transform( new AndLNode(conv, mask) );
1165 }
1166 
1167 Node* GraphKit::ConvL2I(Node* offset) {
1168   // short-circuit a common case
1169   jlong offset_con = find_long_con(offset, (jlong)Type::OffsetBot);
1170   if (offset_con != (jlong)Type::OffsetBot) {
1171     return intcon((int) offset_con);
1172   }
1173   return _gvn.transform( new ConvL2INode(offset));
1174 }
1175 
1176 //-------------------------load_object_klass-----------------------------------
1177 Node* GraphKit::load_object_klass(Node* obj, bool clear_prop_bits) {
1178   // Special-case a fresh allocation to avoid building nodes:
1179   Node* akls = AllocateNode::Ideal_klass(obj, &_gvn);
1180   if (akls != NULL)  return akls;
1181   Node* k_adr = basic_plus_adr(obj, oopDesc::klass_offset_in_bytes());
1182   return _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT, clear_prop_bits));
1183 }
1184 
1185 //-------------------------load_array_length-----------------------------------
1186 Node* GraphKit::load_array_length(Node* array) {
1187   // Special-case a fresh allocation to avoid building nodes:
1188   AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array, &_gvn);
1189   Node *alen;
1190   if (alloc == NULL) {
1191     Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1192     alen = _gvn.transform( new LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS));
1193   } else {
1194     alen = alloc->Ideal_length();
1195     Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_oopptr(), &_gvn);
1196     if (ccast != alen) {
1197       alen = _gvn.transform(ccast);
1198     }
1199   }
1200   return alen;
1201 }
1202 


3444           // Casting array element to a non-flattenable type, mark array as not flat.
3445           Node* cast = _gvn.transform(new CheckCastPPNode(control(), array, ary_t->cast_to_not_flat()));
3446           replace_in_map(array, cast);
3447         }
3448       }
3449     }
3450   }
3451 
3452   if (!is_value) {
3453     res = record_profiled_receiver_for_speculation(res);
3454     if (toop->is_valuetypeptr() && toop->value_klass()->is_scalarizable() && !gvn().type(res)->maybe_null()) {
3455       res = ValueTypeNode::make_from_oop(this, res, toop->value_klass());
3456     }
3457   }
3458   return res;
3459 }
3460 
3461 Node* GraphKit::is_always_locked(Node* obj) {
3462   Node* mark_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
3463   Node* mark = make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
3464   Node* mask = _gvn.MakeConX(markWord::always_locked_pattern);
3465   Node* andx = _gvn.transform(new AndXNode(mark, mask));
3466   Node* cmp = _gvn.transform(new CmpXNode(andx, mask));
3467   return _gvn.transform(new BoolNode(cmp, BoolTest::eq));
3468 }
3469 
3470 Node* GraphKit::is_value_mirror(Node* mirror) {
3471   Node* p = basic_plus_adr(mirror, java_lang_Class::inline_mirror_offset_in_bytes());
3472   Node* inline_mirror = access_load_at(mirror, p, _gvn.type(p)->is_ptr(), TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR), T_OBJECT, IN_HEAP);
3473   Node* cmp = _gvn.transform(new CmpPNode(mirror, inline_mirror));
3474   return _gvn.transform(new BoolNode(cmp, BoolTest::eq));
3475 }
3476 



















3477 // Check if 'ary' is a null-free value type array
3478 Node* GraphKit::gen_null_free_array_check(Node* ary) {
3479   assert(EnableValhalla, "should only be used if value types are enabled");
3480   // Extract null free property from klass pointer
3481   Node* k_adr = basic_plus_adr(ary, oopDesc::klass_offset_in_bytes());
3482   const TypePtr* k_adr_type = k_adr->bottom_type()->isa_ptr();
3483   Node* klass = NULL;
3484   if (k_adr_type->is_ptr_to_narrowklass()) {
3485     klass = _gvn.transform(new LoadNKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT->make_narrowklass(), MemNode::unordered, true));
3486   } else {
3487     klass = _gvn.transform(new LoadKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT, MemNode::unordered, true));
3488   }
3489   Node* null_free = _gvn.transform(new GetNullFreePropertyNode(klass));
3490   Node* cmp = NULL;
3491   if (_gvn.type(klass)->isa_klassptr()) {
3492     cmp = _gvn.transform(new CmpLNode(null_free, zerocon(T_LONG)));
3493   } else {
3494     cmp = _gvn.transform(new CmpINode(null_free, zerocon(T_INT)));
3495   }
3496   return _gvn.transform(new BoolNode(cmp, BoolTest::eq));
3497 }
3498 
3499 Node* GraphKit::gen_flattened_array_test(Node* ary) {
3500   assert(EnableValhalla, "should only be used if value types are enabled");
3501   // Extract flattened property from klass pointer
3502   Node* k_adr = basic_plus_adr(ary, oopDesc::klass_offset_in_bytes());
3503   const TypePtr* k_adr_type = k_adr->bottom_type()->isa_ptr();
3504   Node* klass = NULL;
3505   if (k_adr_type->is_ptr_to_narrowklass()) {
3506     klass = _gvn.transform(new LoadNKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT->make_narrowklass(), MemNode::unordered, true));
3507   } else {
3508     klass = _gvn.transform(new LoadKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT, MemNode::unordered, true));
3509   }
3510   return _gvn.transform(new GetFlattenedPropertyNode(klass));
3511 }
3512 
3513 // Deoptimize if 'ary' is a null-free value type array and 'val' is null
3514 Node* GraphKit::gen_value_array_null_guard(Node* ary, Node* val, int nargs, bool safe_for_replace) {
3515   const Type* val_t = _gvn.type(val);
3516   if (val->is_ValueType() || !TypePtr::NULL_PTR->higher_equal(val_t)) {
3517     return ary; // Never null
3518   }
3519   RegionNode* region = new RegionNode(3);
3520   Node* null_ctl = top();
3521   null_check_oop(val, &null_ctl);
3522   if (null_ctl != top()) {
3523     PreserveJVMState pjvms(this);
3524     set_control(null_ctl);
3525     // Deoptimize if null-free array
3526     Node* bol = gen_null_free_array_check(ary);
3527     { BuildCutout unless(this, bol, PROB_MAX);
3528       inc_sp(nargs);


< prev index next >