Print this page
rev 6883 : 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
Summary: In Parse::array_store_check(), add control edge FROM IfTrue branch of runtime type check of the destination array TO loading _element_klass from destination array.
Reviewed-by: kvn, roland, anoll
Contributed-by: Zoltan Majo <zoltan.majo@oracle.com>

Split Split Close
Expand all
Collapse all
          --- old/hotspot/src/share/vm/opto/library_call.cpp
          +++ new/hotspot/src/share/vm/opto/library_call.cpp
↓ open down ↓ 3390 lines elided ↑ open up ↑
3391 3391  // compile for the non-null case.
3392 3392  // If the region is NULL, force never_see_null = true.
3393 3393  Node* LibraryCallKit::load_klass_from_mirror_common(Node* mirror,
3394 3394                                                      bool never_see_null,
3395 3395                                                      RegionNode* region,
3396 3396                                                      int null_path,
3397 3397                                                      int offset) {
3398 3398    if (region == NULL)  never_see_null = true;
3399 3399    Node* p = basic_plus_adr(mirror, offset);
3400 3400    const TypeKlassPtr*  kls_type = TypeKlassPtr::OBJECT_OR_NULL;
3401      -  Node* kls = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, kls_type));
     3401 +  Node* kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, kls_type));
3402 3402    Node* null_ctl = top();
3403 3403    kls = null_check_oop(kls, &null_ctl, never_see_null);
3404 3404    if (region != NULL) {
3405 3405      // Set region->in(null_path) if the mirror is a primitive (e.g, int.class).
3406 3406      region->init_req(null_path, null_ctl);
3407 3407    } else {
3408 3408      assert(null_ctl == top(), "no loose ends");
3409 3409    }
3410 3410    return kls;
3411 3411  }
↓ open down ↓ 155 lines elided ↑ open up ↑
3567 3567      // Other types can report the actual _super.
3568 3568      // (To verify this code sequence, check the asserts in JVM_IsInterface.)
3569 3569      if (generate_interface_guard(kls, region) != NULL)
3570 3570        // A guard was added.  If the guard is taken, it was an interface.
3571 3571        phi->add_req(null());
3572 3572      if (generate_array_guard(kls, region) != NULL)
3573 3573        // A guard was added.  If the guard is taken, it was an array.
3574 3574        phi->add_req(makecon(TypeInstPtr::make(env()->Object_klass()->java_mirror())));
3575 3575      // If we fall through, it's a plain class.  Get its _super.
3576 3576      p = basic_plus_adr(kls, in_bytes(Klass::super_offset()));
3577      -    kls = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL));
     3577 +    kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL));
3578 3578      null_ctl = top();
3579 3579      kls = null_check_oop(kls, &null_ctl);
3580 3580      if (null_ctl != top()) {
3581 3581        // If the guard is taken, Object.superClass is null (both klass and mirror).
3582 3582        region->add_req(null_ctl);
3583 3583        phi   ->add_req(null());
3584 3584      }
3585 3585      if (!stopped()) {
3586 3586        query_value = load_mirror_from_klass(kls);
3587 3587      }
↓ open down ↓ 61 lines elided ↑ open up ↑
3649 3649  
3650 3650    // First null-check both mirrors and load each mirror's klass metaobject.
3651 3651    int which_arg;
3652 3652    for (which_arg = 0; which_arg <= 1; which_arg++) {
3653 3653      Node* arg = args[which_arg];
3654 3654      arg = null_check(arg);
3655 3655      if (stopped())  break;
3656 3656      args[which_arg] = arg;
3657 3657  
3658 3658      Node* p = basic_plus_adr(arg, class_klass_offset);
3659      -    Node* kls = LoadKlassNode::make(_gvn, immutable_memory(), p, adr_type, kls_type);
     3659 +    Node* kls = LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, adr_type, kls_type);
3660 3660      klasses[which_arg] = _gvn.transform(kls);
3661 3661    }
3662 3662  
3663 3663    // Having loaded both klasses, test each for null.
3664 3664    bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check);
3665 3665    for (which_arg = 0; which_arg <= 1; which_arg++) {
3666 3666      Node* kls = klasses[which_arg];
3667 3667      Node* null_ctl = top();
3668 3668      kls = null_check_oop(kls, &null_ctl, never_see_null);
3669 3669      int prim_path = (which_arg == 0 ? _prim_0_path : _prim_1_path);
↓ open down ↓ 1495 lines elided ↑ open up ↑
5165 5165      // the secondary supertype cache is less busy for S[] than S.
5166 5166      // This usually only matters when D is an interface.
5167 5167      Node* not_subtype_ctrl = gen_subtype_check(src_klass, dest_klass);
5168 5168      // Plug failing path into checked_oop_disjoint_arraycopy
5169 5169      if (not_subtype_ctrl != top()) {
5170 5170        PreserveJVMState pjvms(this);
5171 5171        set_control(not_subtype_ctrl);
5172 5172        // (At this point we can assume disjoint_bases, since types differ.)
5173 5173        int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
5174 5174        Node* p1 = basic_plus_adr(dest_klass, ek_offset);
5175      -      Node* n1 = LoadKlassNode::make(_gvn, immutable_memory(), p1, TypeRawPtr::BOTTOM);
     5175 +      Node* n1 = LoadKlassNode::make(_gvn, NULL, immutable_memory(), p1, TypeRawPtr::BOTTOM);
5176 5176        Node* dest_elem_klass = _gvn.transform(n1);
5177 5177        Node* cv = generate_checkcast_arraycopy(adr_type,
5178 5178                                                dest_elem_klass,
5179 5179                                                src, src_offset, dest, dest_offset,
5180 5180                                                ConvI2X(copy_length), dest_uninitialized);
5181 5181        if (cv == NULL)  cv = intcon(-1);  // failure (no stub available)
5182 5182        checked_control = control();
5183 5183        checked_i_o     = i_o();
5184 5184        checked_mem     = memory(adr_type);
5185 5185        checked_value   = cv;
↓ open down ↓ 1361 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX