417 for (uint j = 1; j < length; j++) {
418 Node *in = mem->in(j);
419 if (in == NULL || in->is_top()) {
420 values.at_put(j, in);
421 } else {
422 Node *val = scan_mem_chain(in, alias_idx, offset, start_mem, alloc, &_igvn);
423 if (val == start_mem || val == alloc_mem) {
424 // hit a sentinel, return appropriate 0 value
425 values.at_put(j, _igvn.zerocon(ft));
426 continue;
427 }
428 if (val->is_Initialize()) {
429 val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn);
430 }
431 if (val == NULL) {
432 return NULL; // can't find a value on this path
433 }
434 if (val == mem) {
435 values.at_put(j, mem);
436 } else if (val->is_Store()) {
437 values.at_put(j, val->in(MemNode::ValueIn));
438 } else if(val->is_Proj() && val->in(0) == alloc) {
439 values.at_put(j, _igvn.zerocon(ft));
440 } else if (val->is_Phi()) {
441 val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1);
442 if (val == NULL) {
443 return NULL;
444 }
445 values.at_put(j, val);
446 } else if (val->Opcode() == Op_SCMemProj) {
447 assert(val->in(0)->is_LoadStore() ||
448 val->in(0)->Opcode() == Op_EncodeISOArray ||
449 val->in(0)->Opcode() == Op_StrCompressedCopy, "sanity");
450 assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field");
451 return NULL;
452 } else if (val->is_ArrayCopy()) {
453 Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), val->in(TypeFunc::Memory), ft, phi_type, alloc);
454 if (res == NULL) {
455 return NULL;
456 }
457 values.at_put(j, res);
529 unique_input = top;
530 break;
531 }
532 }
533 if (unique_input != NULL && unique_input != top) {
534 mem = unique_input;
535 } else {
536 done = true;
537 }
538 } else if (mem->is_ArrayCopy()) {
539 done = true;
540 } else {
541 assert(false, "unexpected node");
542 }
543 }
544 if (mem != NULL) {
545 if (mem == start_mem || mem == alloc_mem) {
546 // hit a sentinel, return appropriate 0 value
547 return _igvn.zerocon(ft);
548 } else if (mem->is_Store()) {
549 return mem->in(MemNode::ValueIn);
550 } else if (mem->is_Phi()) {
551 // attempt to produce a Phi reflecting the values on the input paths of the Phi
552 Node_Stack value_phis(a, 8);
553 Node * phi = value_from_mem_phi(mem, ft, ftype, adr_t, alloc, &value_phis, ValueSearchLimit);
554 if (phi != NULL) {
555 return phi;
556 } else {
557 // Kill all new Phis
558 while(value_phis.is_nonempty()) {
559 Node* n = value_phis.node();
560 _igvn.replace_node(n, C->top());
561 value_phis.pop();
562 }
563 }
564 } else if (mem->is_ArrayCopy()) {
565 Node* ctl = mem->in(0);
566 Node* m = mem->in(TypeFunc::Memory);
567 if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) {
568 // pin the loads in the uncommon trap path
569 ctl = sfpt_ctl;
917 }
918 #endif
919 _igvn.replace_node(n, n->in(MemNode::Memory));
920 } else if (n->is_ArrayCopy()) {
921 // Disconnect ArrayCopy node
922 ArrayCopyNode* ac = n->as_ArrayCopy();
923 assert(ac->is_clonebasic(), "unexpected array copy kind");
924 Node* membar_after = ac->proj_out(TypeFunc::Control)->unique_ctrl_out();
925 disconnect_projections(ac, _igvn);
926 assert(alloc->in(0)->is_Proj() && alloc->in(0)->in(0)->Opcode() == Op_MemBarCPUOrder, "mem barrier expected before allocation");
927 Node* membar_before = alloc->in(0)->in(0);
928 disconnect_projections(membar_before->as_MemBar(), _igvn);
929 if (membar_after->is_MemBar()) {
930 disconnect_projections(membar_after->as_MemBar(), _igvn);
931 }
932 } else {
933 eliminate_gc_barrier(n);
934 }
935 k -= (oc2 - use->outcnt());
936 }
937 } else if (use->is_ArrayCopy()) {
938 // Disconnect ArrayCopy node
939 ArrayCopyNode* ac = use->as_ArrayCopy();
940 assert(ac->is_arraycopy_validated() ||
941 ac->is_copyof_validated() ||
942 ac->is_copyofrange_validated(), "unsupported");
943 CallProjections callprojs;
944 ac->extract_projections(&callprojs, true);
945
946 _igvn.replace_node(callprojs.fallthrough_ioproj, ac->in(TypeFunc::I_O));
947 _igvn.replace_node(callprojs.fallthrough_memproj, ac->in(TypeFunc::Memory));
948 _igvn.replace_node(callprojs.fallthrough_catchproj, ac->in(TypeFunc::Control));
949
950 // Set control to top. IGVN will remove the remaining projections
951 ac->set_req(0, top());
952 ac->replace_edge(res, top());
953
954 // Disconnect src right away: it can help find new
955 // opportunities for allocation elimination
956 Node* src = ac->in(ArrayCopyNode::Src);
|
417 for (uint j = 1; j < length; j++) {
418 Node *in = mem->in(j);
419 if (in == NULL || in->is_top()) {
420 values.at_put(j, in);
421 } else {
422 Node *val = scan_mem_chain(in, alias_idx, offset, start_mem, alloc, &_igvn);
423 if (val == start_mem || val == alloc_mem) {
424 // hit a sentinel, return appropriate 0 value
425 values.at_put(j, _igvn.zerocon(ft));
426 continue;
427 }
428 if (val->is_Initialize()) {
429 val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn);
430 }
431 if (val == NULL) {
432 return NULL; // can't find a value on this path
433 }
434 if (val == mem) {
435 values.at_put(j, mem);
436 } else if (val->is_Store()) {
437 Node* n = val->in(MemNode::ValueIn);
438 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
439 n = bs->step_over_gc_barrier(n);
440 values.at_put(j, n);
441 } else if(val->is_Proj() && val->in(0) == alloc) {
442 values.at_put(j, _igvn.zerocon(ft));
443 } else if (val->is_Phi()) {
444 val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1);
445 if (val == NULL) {
446 return NULL;
447 }
448 values.at_put(j, val);
449 } else if (val->Opcode() == Op_SCMemProj) {
450 assert(val->in(0)->is_LoadStore() ||
451 val->in(0)->Opcode() == Op_EncodeISOArray ||
452 val->in(0)->Opcode() == Op_StrCompressedCopy, "sanity");
453 assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field");
454 return NULL;
455 } else if (val->is_ArrayCopy()) {
456 Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), val->in(TypeFunc::Memory), ft, phi_type, alloc);
457 if (res == NULL) {
458 return NULL;
459 }
460 values.at_put(j, res);
532 unique_input = top;
533 break;
534 }
535 }
536 if (unique_input != NULL && unique_input != top) {
537 mem = unique_input;
538 } else {
539 done = true;
540 }
541 } else if (mem->is_ArrayCopy()) {
542 done = true;
543 } else {
544 assert(false, "unexpected node");
545 }
546 }
547 if (mem != NULL) {
548 if (mem == start_mem || mem == alloc_mem) {
549 // hit a sentinel, return appropriate 0 value
550 return _igvn.zerocon(ft);
551 } else if (mem->is_Store()) {
552 Node* n = mem->in(MemNode::ValueIn);
553 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
554 n = bs->step_over_gc_barrier(n);
555 return n;
556 } else if (mem->is_Phi()) {
557 // attempt to produce a Phi reflecting the values on the input paths of the Phi
558 Node_Stack value_phis(a, 8);
559 Node * phi = value_from_mem_phi(mem, ft, ftype, adr_t, alloc, &value_phis, ValueSearchLimit);
560 if (phi != NULL) {
561 return phi;
562 } else {
563 // Kill all new Phis
564 while(value_phis.is_nonempty()) {
565 Node* n = value_phis.node();
566 _igvn.replace_node(n, C->top());
567 value_phis.pop();
568 }
569 }
570 } else if (mem->is_ArrayCopy()) {
571 Node* ctl = mem->in(0);
572 Node* m = mem->in(TypeFunc::Memory);
573 if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) {
574 // pin the loads in the uncommon trap path
575 ctl = sfpt_ctl;
923 }
924 #endif
925 _igvn.replace_node(n, n->in(MemNode::Memory));
926 } else if (n->is_ArrayCopy()) {
927 // Disconnect ArrayCopy node
928 ArrayCopyNode* ac = n->as_ArrayCopy();
929 assert(ac->is_clonebasic(), "unexpected array copy kind");
930 Node* membar_after = ac->proj_out(TypeFunc::Control)->unique_ctrl_out();
931 disconnect_projections(ac, _igvn);
932 assert(alloc->in(0)->is_Proj() && alloc->in(0)->in(0)->Opcode() == Op_MemBarCPUOrder, "mem barrier expected before allocation");
933 Node* membar_before = alloc->in(0)->in(0);
934 disconnect_projections(membar_before->as_MemBar(), _igvn);
935 if (membar_after->is_MemBar()) {
936 disconnect_projections(membar_after->as_MemBar(), _igvn);
937 }
938 } else {
939 eliminate_gc_barrier(n);
940 }
941 k -= (oc2 - use->outcnt());
942 }
943 _igvn.remove_dead_node(use);
944 } else if (use->is_ArrayCopy()) {
945 // Disconnect ArrayCopy node
946 ArrayCopyNode* ac = use->as_ArrayCopy();
947 assert(ac->is_arraycopy_validated() ||
948 ac->is_copyof_validated() ||
949 ac->is_copyofrange_validated(), "unsupported");
950 CallProjections callprojs;
951 ac->extract_projections(&callprojs, true);
952
953 _igvn.replace_node(callprojs.fallthrough_ioproj, ac->in(TypeFunc::I_O));
954 _igvn.replace_node(callprojs.fallthrough_memproj, ac->in(TypeFunc::Memory));
955 _igvn.replace_node(callprojs.fallthrough_catchproj, ac->in(TypeFunc::Control));
956
957 // Set control to top. IGVN will remove the remaining projections
958 ac->set_req(0, top());
959 ac->replace_edge(res, top());
960
961 // Disconnect src right away: it can help find new
962 // opportunities for allocation elimination
963 Node* src = ac->in(ArrayCopyNode::Src);
|