|
1 | 1 | /* |
2 | | - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -723,8 +723,7 @@ void ConnectionGraph::add_to_congraph_unsafe_access(Node* n, uint opcode, Unique |
723 | 723 | if (adr_type->isa_oopptr() |
724 | 724 | || ((opcode == Op_StoreP || opcode == Op_StoreN || opcode == Op_StoreNKlass) |
725 | 725 | && adr_type == TypeRawPtr::NOTNULL |
726 | | - && adr->in(AddPNode::Address)->is_Proj() |
727 | | - && adr->in(AddPNode::Address)->in(0)->is_Allocate())) { |
| 726 | + && is_captured_store_address(adr))) { |
728 | 727 | delayed_worklist->push(n); // Process it later. |
729 | 728 | #ifdef ASSERT |
730 | 729 | assert (adr->is_AddP(), "expecting an AddP"); |
@@ -771,8 +770,7 @@ bool ConnectionGraph::add_final_edges_unsafe_access(Node* n, uint opcode) { |
771 | 770 | if (adr_type->isa_oopptr() |
772 | 771 | || ((opcode == Op_StoreP || opcode == Op_StoreN || opcode == Op_StoreNKlass) |
773 | 772 | && adr_type == TypeRawPtr::NOTNULL |
774 | | - && adr->in(AddPNode::Address)->is_Proj() |
775 | | - && adr->in(AddPNode::Address)->in(0)->is_Allocate())) { |
| 773 | + && is_captured_store_address(adr))) { |
776 | 774 | // Point Address to Value |
777 | 775 | PointsToNode* adr_ptn = ptnode_adr(adr->_idx); |
778 | 776 | assert(adr_ptn != NULL && |
@@ -1584,8 +1582,7 @@ int ConnectionGraph::find_init_values(JavaObjectNode* pta, PointsToNode* init_va |
1584 | 1582 | // Raw pointers are used for initializing stores so skip it |
1585 | 1583 | // since it should be recorded already |
1586 | 1584 | Node* base = get_addp_base(field->ideal_node()); |
1587 | | - assert(adr_type->isa_rawptr() && base->is_Proj() && |
1588 | | - (base->in(0) == alloc),"unexpected pointer type"); |
| 1585 | + assert(adr_type->isa_rawptr() && is_captured_store_address(field->ideal_node()), "unexpected pointer type"); |
1589 | 1586 | #endif |
1590 | 1587 | continue; |
1591 | 1588 | } |
@@ -1916,8 +1913,7 @@ void ConnectionGraph::optimize_ideal_graph(GrowableArray<Node*>& ptr_cmp_worklis |
1916 | 1913 | Node *n = storestore_worklist.pop(); |
1917 | 1914 | MemBarStoreStoreNode *storestore = n ->as_MemBarStoreStore(); |
1918 | 1915 | Node *alloc = storestore->in(MemBarNode::Precedent)->in(0); |
1919 | | - assert (alloc->is_Allocate(), "storestore should point to AllocateNode"); |
1920 | | - if (not_global_escape(alloc)) { |
| 1916 | + if (alloc->is_Allocate() && not_global_escape(alloc)) { |
1921 | 1917 | MemBarNode* mb = MemBarNode::make(C, Op_MemBarCPUOrder, Compile::AliasIdxBot); |
1922 | 1918 | mb->init_req(TypeFunc::Memory, storestore->in(TypeFunc::Memory)); |
1923 | 1919 | mb->init_req(TypeFunc::Control, storestore->in(TypeFunc::Control)); |
@@ -2251,11 +2247,29 @@ bool FieldNode::has_base(JavaObjectNode* jobj) const { |
2251 | 2247 | } |
2252 | 2248 | #endif |
2253 | 2249 |
|
| 2250 | +bool ConnectionGraph::is_captured_store_address(Node* addp) { |
| 2251 | + // Handle simple case first. |
| 2252 | + assert(_igvn->type(addp)->isa_oopptr() == NULL, "should be raw access"); |
| 2253 | + if (addp->in(AddPNode::Address)->is_Proj() && addp->in(AddPNode::Address)->in(0)->is_Allocate()) { |
| 2254 | + return true; |
| 2255 | + } else if (addp->in(AddPNode::Address)->is_Phi()) { |
| 2256 | + for (DUIterator_Fast imax, i = addp->fast_outs(imax); i < imax; i++) { |
| 2257 | + Node* addp_use = addp->fast_out(i); |
| 2258 | + if (addp_use->is_Store()) { |
| 2259 | + for (DUIterator_Fast jmax, j = addp_use->fast_outs(jmax); j < jmax; j++) { |
| 2260 | + if (addp_use->fast_out(j)->is_Initialize()) { |
| 2261 | + return true; |
| 2262 | + } |
| 2263 | + } |
| 2264 | + } |
| 2265 | + } |
| 2266 | + } |
| 2267 | + return false; |
| 2268 | +} |
| 2269 | + |
2254 | 2270 | int ConnectionGraph::address_offset(Node* adr, PhaseTransform *phase) { |
2255 | 2271 | const Type *adr_type = phase->type(adr); |
2256 | | - if (adr->is_AddP() && adr_type->isa_oopptr() == NULL && |
2257 | | - adr->in(AddPNode::Address)->is_Proj() && |
2258 | | - adr->in(AddPNode::Address)->in(0)->is_Allocate()) { |
| 2272 | + if (adr->is_AddP() && adr_type->isa_oopptr() == NULL && is_captured_store_address(adr)) { |
2259 | 2273 | // We are computing a raw address for a store captured by an Initialize |
2260 | 2274 | // compute an appropriate address type. AddP cases #3 and #5 (see below). |
2261 | 2275 | int offs = (int)phase->find_intptr_t_con(adr->in(AddPNode::Offset), Type::OffsetBot); |
@@ -2358,7 +2372,7 @@ Node* ConnectionGraph::get_addp_base(Node *addp) { |
2358 | 2372 | assert(opcode == Op_ConP || opcode == Op_ThreadLocal || |
2359 | 2373 | opcode == Op_CastX2P || uncast_base->is_DecodeNarrowPtr() || |
2360 | 2374 | (uncast_base->is_Mem() && (uncast_base->bottom_type()->isa_rawptr() != NULL)) || |
2361 | | - (uncast_base->is_Proj() && uncast_base->in(0)->is_Allocate()), "sanity"); |
| 2375 | + is_captured_store_address(addp), "sanity"); |
2362 | 2376 | } |
2363 | 2377 | } |
2364 | 2378 | return base; |
@@ -2974,7 +2988,10 @@ void ConnectionGraph::split_unique_types(GrowableArray<Node *> &alloc_worklist, |
2974 | 2988 | continue; |
2975 | 2989 | } |
2976 | 2990 | if (!n->is_CheckCastPP()) { // not unique CheckCastPP. |
2977 | | - assert(!alloc->is_Allocate(), "allocation should have unique type"); |
| 2991 | + // we could reach here for allocate case if one init is associated with many allocs. |
| 2992 | + if (alloc->is_Allocate()) { |
| 2993 | + alloc->as_Allocate()->_is_scalar_replaceable = false; |
| 2994 | + } |
2978 | 2995 | continue; |
2979 | 2996 | } |
2980 | 2997 |
|
|
0 commit comments