3579 return true;
3580 }
3581
3582 // Not-subtype or the mirror's klass ptr is NULL (in case it is a primitive).
3583 enum { _bad_type_path = 1, _prim_path = 2, _npe_path = 3, PATH_LIMIT };
3584 RegionNode* region = new RegionNode(PATH_LIMIT);
3585 record_for_igvn(region);
3586
3587 // Now load the mirror's klass metaobject, and null-check it.
3588 // If kls is null, we have a primitive mirror and
3589 // nothing is an instance of a primitive type.
3590 Node* kls = load_klass_from_mirror(mirror, false, region, _prim_path);
3591
3592 Node* res = top();
3593 if (!stopped()) {
3594 // TODO move this into do_checkcast?
3595 if (EnableValhalla && !obj->is_ValueType() && !is_val_type) {
3596 // Check if (mirror == value_mirror && obj == null)
3597 RegionNode* r = new RegionNode(3);
3598 Node* p = basic_plus_adr(mirror, java_lang_Class::value_mirror_offset_in_bytes());
3599 Node* value_mirror = access_load_at(mirror, p, _gvn.type(p)->is_ptr(), TypeInstPtr::MIRROR, T_OBJECT, IN_HEAP);
3600 Node* cmp = _gvn.transform(new CmpPNode(mirror, value_mirror));
3601 Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne));
3602 Node* if_ne = generate_fair_guard(bol, NULL);
3603 r->init_req(1, if_ne);
3604
3605 // Casting to .val, check for null
3606 Node* null_ctr = top();
3607 null_check_oop(obj, &null_ctr);
3608 region->init_req(_npe_path, null_ctr);
3609 r->init_req(2, control());
3610
3611 set_control(_gvn.transform(r));
3612 }
3613
3614 Node* bad_type_ctrl = top();
3615 // Do checkcast optimizations.
3616 res = gen_checkcast(obj, kls, &bad_type_ctrl);
3617 region->init_req(_bad_type_path, bad_type_ctrl);
3618 }
3619 if (region->in(_prim_path) != top() ||
|
3579 return true;
3580 }
3581
3582 // Not-subtype or the mirror's klass ptr is NULL (in case it is a primitive).
3583 enum { _bad_type_path = 1, _prim_path = 2, _npe_path = 3, PATH_LIMIT };
3584 RegionNode* region = new RegionNode(PATH_LIMIT);
3585 record_for_igvn(region);
3586
3587 // Now load the mirror's klass metaobject, and null-check it.
3588 // If kls is null, we have a primitive mirror and
3589 // nothing is an instance of a primitive type.
3590 Node* kls = load_klass_from_mirror(mirror, false, region, _prim_path);
3591
3592 Node* res = top();
3593 if (!stopped()) {
3594 // TODO move this into do_checkcast?
3595 if (EnableValhalla && !obj->is_ValueType() && !is_val_type) {
3596 // Check if (mirror == value_mirror && obj == null)
3597 RegionNode* r = new RegionNode(3);
3598 Node* p = basic_plus_adr(mirror, java_lang_Class::value_mirror_offset_in_bytes());
3599 Node* value_mirror = access_load_at(mirror, p, _gvn.type(p)->is_ptr(), TypeInstPtr::MIRROR->cast_to_ptr_type(TypePtr::BotPTR), T_OBJECT, IN_HEAP);
3600 Node* cmp = _gvn.transform(new CmpPNode(mirror, value_mirror));
3601 Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne));
3602 Node* if_ne = generate_fair_guard(bol, NULL);
3603 r->init_req(1, if_ne);
3604
3605 // Casting to .val, check for null
3606 Node* null_ctr = top();
3607 null_check_oop(obj, &null_ctr);
3608 region->init_req(_npe_path, null_ctr);
3609 r->init_req(2, control());
3610
3611 set_control(_gvn.transform(r));
3612 }
3613
3614 Node* bad_type_ctrl = top();
3615 // Do checkcast optimizations.
3616 res = gen_checkcast(obj, kls, &bad_type_ctrl);
3617 region->init_req(_bad_type_path, bad_type_ctrl);
3618 }
3619 if (region->in(_prim_path) != top() ||
|