362 if (!ClearArrayNode::step_through(&mem, alloc->_idx, phase)) { 363 // Can not bypass initialization of the instance 364 // we are looking. 365 debug_only(intptr_t offset;) 366 assert(alloc == AllocateNode::Ideal_allocation(mem->in(3), phase, offset), "sanity"); 367 InitializeNode* init = alloc->as_Allocate()->initialization(); 368 // We are looking for stored value, return Initialize node 369 // or memory edge from Allocate node. 370 if (init != NULL) 371 return init; 372 else 373 return alloc->in(TypeFunc::Memory); // It will produce zero value (see callers). 374 } 375 // Otherwise skip it (the call updated 'mem' value). 376 } else if (mem->Opcode() == Op_SCMemProj) { 377 mem = mem->in(0); 378 Node* adr = NULL; 379 if (mem->is_LoadStore()) { 380 adr = mem->in(MemNode::Address); 381 } else { 382 assert(mem->Opcode() == Op_EncodeISOArray, "sanity"); 383 adr = mem->in(3); // Destination array 384 } 385 const TypePtr* atype = adr->bottom_type()->is_ptr(); 386 int adr_idx = phase->C->get_alias_index(atype); 387 if (adr_idx == alias_idx) { 388 assert(false, "Object is not scalar replaceable if a LoadStore node access its field"); 389 return NULL; 390 } 391 mem = mem->in(MemNode::Memory); 392 } else { 393 return mem; 394 } 395 assert(mem != orig_mem, "dead memory loop"); 396 } 397 } 398 399 // Generate loads from source of the arraycopy for fields of 400 // destination needed at a deoptimization point 401 Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, Node* ctl, BasicType ft, const Type *ftype, AllocateNode *alloc) { 402 BasicType bt = ft; 403 const Type *type = ftype; 404 if (ft == T_NARROWOOP) { 405 bt = T_OBJECT; 406 type = ftype->make_oopptr(); 407 } 408 Node* res = NULL; 499 } 500 if (val->is_Initialize()) { 501 val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn); 502 } 503 if (val == NULL) { 504 return NULL; // can't find a value on this path 505 } 506 if (val == mem) { 507 values.at_put(j, mem); 508 } else if (val->is_Store()) { 509 values.at_put(j, val->in(MemNode::ValueIn)); 510 } else if(val->is_Proj() && val->in(0) == alloc) { 511 values.at_put(j, _igvn.zerocon(ft)); 512 } else if (val->is_Phi()) { 513 val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1); 514 if (val == NULL) { 515 return NULL; 516 } 517 values.at_put(j, val); 518 } else if (val->Opcode() == Op_SCMemProj) { 519 assert(val->in(0)->is_LoadStore() || val->in(0)->Opcode() == Op_EncodeISOArray, "sanity"); 520 assert(false, "Object is not scalar replaceable if a LoadStore node access its field"); 521 return NULL; 522 } else if (val->is_ArrayCopy()) { 523 Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), ft, phi_type, alloc); 524 if (res == NULL) { 525 return NULL; 526 } 527 values.at_put(j, res); 528 } else { 529 #ifdef ASSERT 530 val->dump(); 531 assert(false, "unknown node on this path"); 532 #endif 533 return NULL; // unknown node on this path 534 } 535 } 536 } 537 // Set Phi's inputs 538 for (uint j = 1; j < length; j++) { 539 if (values.at(j) == mem) { 540 phi->init_req(j, phi); | 362 if (!ClearArrayNode::step_through(&mem, alloc->_idx, phase)) { 363 // Can not bypass initialization of the instance 364 // we are looking. 365 debug_only(intptr_t offset;) 366 assert(alloc == AllocateNode::Ideal_allocation(mem->in(3), phase, offset), "sanity"); 367 InitializeNode* init = alloc->as_Allocate()->initialization(); 368 // We are looking for stored value, return Initialize node 369 // or memory edge from Allocate node. 370 if (init != NULL) 371 return init; 372 else 373 return alloc->in(TypeFunc::Memory); // It will produce zero value (see callers). 374 } 375 // Otherwise skip it (the call updated 'mem' value). 376 } else if (mem->Opcode() == Op_SCMemProj) { 377 mem = mem->in(0); 378 Node* adr = NULL; 379 if (mem->is_LoadStore()) { 380 adr = mem->in(MemNode::Address); 381 } else { 382 assert(mem->Opcode() == Op_EncodeISOArray || 383 mem->Opcode() == Op_StrCompressedCopy, "sanity"); 384 adr = mem->in(3); // Destination array 385 } 386 const TypePtr* atype = adr->bottom_type()->is_ptr(); 387 int adr_idx = phase->C->get_alias_index(atype); 388 if (adr_idx == alias_idx) { 389 DEBUG_ONLY(mem->dump();) 390 assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field"); 391 return NULL; 392 } 393 mem = mem->in(MemNode::Memory); 394 } else if (mem->Opcode() == Op_StrInflatedCopy) { 395 Node* adr = mem->in(3); // Destination array 396 const TypePtr* atype = adr->bottom_type()->is_ptr(); 397 int adr_idx = phase->C->get_alias_index(atype); 398 if (adr_idx == alias_idx) { 399 DEBUG_ONLY(mem->dump();) 400 assert(false, "Object is not scalar replaceable if a StrInflatedCopy node accesses its field"); 401 return NULL; 402 } 403 mem = mem->in(MemNode::Memory); 404 } else { 405 return mem; 406 } 407 assert(mem != orig_mem, "dead memory loop"); 408 } 409 } 410 411 // Generate loads from source of the arraycopy for fields of 412 // destination needed at a deoptimization point 413 Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, Node* ctl, BasicType ft, const Type *ftype, AllocateNode *alloc) { 414 BasicType bt = ft; 415 const Type *type = ftype; 416 if (ft == T_NARROWOOP) { 417 bt = T_OBJECT; 418 type = ftype->make_oopptr(); 419 } 420 Node* res = NULL; 511 } 512 if (val->is_Initialize()) { 513 val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn); 514 } 515 if (val == NULL) { 516 return NULL; // can't find a value on this path 517 } 518 if (val == mem) { 519 values.at_put(j, mem); 520 } else if (val->is_Store()) { 521 values.at_put(j, val->in(MemNode::ValueIn)); 522 } else if(val->is_Proj() && val->in(0) == alloc) { 523 values.at_put(j, _igvn.zerocon(ft)); 524 } else if (val->is_Phi()) { 525 val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1); 526 if (val == NULL) { 527 return NULL; 528 } 529 values.at_put(j, val); 530 } else if (val->Opcode() == Op_SCMemProj) { 531 assert(val->in(0)->is_LoadStore() || 532 val->in(0)->Opcode() == Op_EncodeISOArray || 533 val->in(0)->Opcode() == Op_StrCompressedCopy, "sanity"); 534 assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field"); 535 return NULL; 536 } else if (val->is_ArrayCopy()) { 537 Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), ft, phi_type, alloc); 538 if (res == NULL) { 539 return NULL; 540 } 541 values.at_put(j, res); 542 } else { 543 #ifdef ASSERT 544 val->dump(); 545 assert(false, "unknown node on this path"); 546 #endif 547 return NULL; // unknown node on this path 548 } 549 } 550 } 551 // Set Phi's inputs 552 for (uint j = 1; j < length; j++) { 553 if (values.at(j) == mem) { 554 phi->init_req(j, phi); |