annotate src/hotspot/share/opto/arraycopynode.hpp @ 54048:744dc9c33676

8217417: Decorator name typo: C2_TIGHLY_COUPLED_ALLOC Summary: Fixed typo in decorator name, variables, and comments. Reviewed-by: tschatzl
author kbarrett
date Mon, 11 Mar 2019 02:05:07 -0400
parents 9807daeb47c4
children
rev   line source
roland@29337 1 /*
coleenp@53244 2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
roland@29337 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
roland@29337 4 *
roland@29337 5 * This code is free software; you can redistribute it and/or modify it
roland@29337 6 * under the terms of the GNU General Public License version 2 only, as
roland@29337 7 * published by the Free Software Foundation.
roland@29337 8 *
roland@29337 9 * This code is distributed in the hope that it will be useful, but WITHOUT
roland@29337 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
roland@29337 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
roland@29337 12 * version 2 for more details (a copy is included in the LICENSE file that
roland@29337 13 * accompanied this code).
roland@29337 14 *
roland@29337 15 * You should have received a copy of the GNU General Public License version
roland@29337 16 * 2 along with this work; if not, write to the Free Software Foundation,
roland@29337 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
roland@29337 18 *
roland@29337 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
roland@29337 20 * or visit www.oracle.com if you need additional information or have any
roland@29337 21 * questions.
roland@29337 22 *
roland@29337 23 */
roland@29337 24
coleenp@53244 25 #ifndef SHARE_OPTO_ARRAYCOPYNODE_HPP
coleenp@53244 26 #define SHARE_OPTO_ARRAYCOPYNODE_HPP
roland@29337 27
mdoerr@52435 28 #include "gc/shared/c2/barrierSetC2.hpp"
roland@29337 29 #include "opto/callnode.hpp"
roland@29337 30
roland@29337 31 class GraphKit;
roland@29337 32
roland@29337 33 class ArrayCopyNode : public CallNode {
roland@29337 34 private:
roland@29337 35
roland@29337 36 // What kind of arraycopy variant is this?
roland@29337 37 enum {
roland@29337 38 None, // not set yet
roland@29337 39 ArrayCopy, // System.arraycopy()
roland@29337 40 CloneBasic, // A clone that can be copied by 64 bit chunks
roland@29337 41 CloneOop, // An oop array clone
roland@29337 42 CopyOf, // Arrays.copyOf()
roland@29337 43 CopyOfRange // Arrays.copyOfRange()
roland@29337 44 } _kind;
roland@29337 45
roland@29337 46 #ifndef PRODUCT
roland@29337 47 static const char* _kind_names[CopyOfRange+1];
roland@29337 48 #endif
roland@29337 49 // Is the alloc obtained with
kbarrett@54048 50 // AllocateArrayNode::Ideal_array_allocation() tightly coupled
roland@29337 51 // (arraycopy follows immediately the allocation)?
roland@29337 52 // We cache the result of LibraryCallKit::tightly_coupled_allocation
roland@29337 53 // here because it's much easier to find whether there's a tightly
roland@29337 54 // couple allocation at parse time than at macro expansion time. At
roland@29337 55 // macro expansion time, for every use of the allocation node we
roland@29337 56 // would need to figure out whether it happens after the arraycopy (and
roland@29337 57 // can be ignored) or between the allocation and the arraycopy. At
roland@29337 58 // parse time, it's straightforward because whatever happens after
roland@29337 59 // the arraycopy is not parsed yet so doesn't exist when
roland@29337 60 // LibraryCallKit::tightly_coupled_allocation() is called.
roland@29337 61 bool _alloc_tightly_coupled;
simonis@42086 62 bool _has_negative_length_guard;
roland@29337 63
roland@29337 64 bool _arguments_validated;
roland@29337 65
roland@29337 66 static const TypeFunc* arraycopy_type() {
roland@29337 67 const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
roland@29337 68 fields[Src] = TypeInstPtr::BOTTOM;
roland@29337 69 fields[SrcPos] = TypeInt::INT;
roland@29337 70 fields[Dest] = TypeInstPtr::BOTTOM;
roland@29337 71 fields[DestPos] = TypeInt::INT;
roland@29337 72 fields[Length] = TypeInt::INT;
roland@29337 73 fields[SrcLen] = TypeInt::INT;
roland@29337 74 fields[DestLen] = TypeInt::INT;
roland@29337 75 fields[SrcKlass] = TypeKlassPtr::BOTTOM;
roland@29337 76 fields[DestKlass] = TypeKlassPtr::BOTTOM;
roland@29337 77 const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
roland@29337 78
roland@29337 79 // create result type (range)
roland@29337 80 fields = TypeTuple::fields(0);
roland@29337 81
roland@29337 82 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
roland@29337 83
roland@29337 84 return TypeFunc::make(domain, range);
roland@29337 85 }
roland@29337 86
simonis@42086 87 ArrayCopyNode(Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard);
roland@29337 88
roland@29337 89 intptr_t get_length_if_constant(PhaseGVN *phase) const;
roland@29337 90 int get_count(PhaseGVN *phase) const;
roland@29337 91 static const TypePtr* get_address_type(PhaseGVN *phase, Node* n);
roland@29337 92
roland@29337 93 Node* try_clone_instance(PhaseGVN *phase, bool can_reshape, int count);
roland@29337 94 bool prepare_array_copy(PhaseGVN *phase, bool can_reshape,
roland@29337 95 Node*& adr_src, Node*& base_src, Node*& adr_dest, Node*& base_dest,
roland@29337 96 BasicType& copy_type, const Type*& value_type, bool& disjoint_bases);
roland@29337 97 void array_copy_test_overlap(PhaseGVN *phase, bool can_reshape,
roland@29337 98 bool disjoint_bases, int count,
roland@29337 99 Node*& forward_ctl, Node*& backward_ctl);
roland@51984 100 Node* array_copy_forward(PhaseGVN *phase, bool can_reshape, Node*& ctl,
roland@51984 101 MergeMemNode* mm,
roland@29337 102 const TypePtr* atp_src, const TypePtr* atp_dest,
roland@29337 103 Node* adr_src, Node* base_src, Node* adr_dest, Node* base_dest,
roland@29337 104 BasicType copy_type, const Type* value_type, int count);
roland@51984 105 Node* array_copy_backward(PhaseGVN *phase, bool can_reshape, Node*& ctl,
roland@51984 106 MergeMemNode* mm,
roland@29337 107 const TypePtr* atp_src, const TypePtr* atp_dest,
roland@29337 108 Node* adr_src, Node* base_src, Node* adr_dest, Node* base_dest,
roland@29337 109 BasicType copy_type, const Type* value_type, int count);
roland@29337 110 bool finish_transform(PhaseGVN *phase, bool can_reshape,
roland@29337 111 Node* ctl, Node *mem);
roland@45427 112 static bool may_modify_helper(const TypeOopPtr *t_oop, Node* n, PhaseTransform *phase, CallNode*& call);
roland@29337 113
roland@52424 114 static Node* load(BarrierSetC2* bs, PhaseGVN *phase, Node*& ctl, MergeMemNode* mem, Node* addr, const TypePtr* adr_type, const Type *type, BasicType bt);
roland@52424 115 void store(BarrierSetC2* bs, PhaseGVN *phase, Node*& ctl, MergeMemNode* mem, Node* addr, const TypePtr* adr_type, Node* val, const Type *type, BasicType bt);
roland@52424 116
roland@29337 117 public:
roland@29337 118
roland@29337 119 enum {
roland@29337 120 Src = TypeFunc::Parms,
roland@29337 121 SrcPos,
roland@29337 122 Dest,
roland@29337 123 DestPos,
roland@29337 124 Length,
roland@29337 125 SrcLen,
roland@29337 126 DestLen,
roland@29337 127 SrcKlass,
roland@29337 128 DestKlass,
roland@29337 129 ParmLimit
roland@29337 130 };
roland@29337 131
roland@30629 132 // Results from escape analysis for non escaping inputs
roland@30629 133 const TypeOopPtr* _src_type;
roland@30629 134 const TypeOopPtr* _dest_type;
roland@30629 135
roland@29337 136 static ArrayCopyNode* make(GraphKit* kit, bool may_throw,
roland@29337 137 Node* src, Node* src_offset,
roland@29337 138 Node* dest, Node* dest_offset,
roland@29337 139 Node* length,
roland@29337 140 bool alloc_tightly_coupled,
simonis@42086 141 bool has_negative_length_guard,
roland@29337 142 Node* src_klass = NULL, Node* dest_klass = NULL,
roland@29337 143 Node* src_length = NULL, Node* dest_length = NULL);
roland@29337 144
roland@29337 145 void connect_outputs(GraphKit* kit);
roland@29337 146
roland@29337 147 bool is_arraycopy() const { assert(_kind != None, "should bet set"); return _kind == ArrayCopy; }
roland@29337 148 bool is_arraycopy_validated() const { assert(_kind != None, "should bet set"); return _kind == ArrayCopy && _arguments_validated; }
roland@29337 149 bool is_clonebasic() const { assert(_kind != None, "should bet set"); return _kind == CloneBasic; }
roland@29337 150 bool is_cloneoop() const { assert(_kind != None, "should bet set"); return _kind == CloneOop; }
roland@29337 151 bool is_copyof() const { assert(_kind != None, "should bet set"); return _kind == CopyOf; }
roland@29337 152 bool is_copyof_validated() const { assert(_kind != None, "should bet set"); return _kind == CopyOf && _arguments_validated; }
roland@29337 153 bool is_copyofrange() const { assert(_kind != None, "should bet set"); return _kind == CopyOfRange; }
roland@29337 154 bool is_copyofrange_validated() const { assert(_kind != None, "should bet set"); return _kind == CopyOfRange && _arguments_validated; }
roland@29337 155
roland@29337 156 void set_arraycopy(bool validated) { assert(_kind == None, "shouldn't bet set yet"); _kind = ArrayCopy; _arguments_validated = validated; }
roland@29337 157 void set_clonebasic() { assert(_kind == None, "shouldn't bet set yet"); _kind = CloneBasic; }
roland@29337 158 void set_cloneoop() { assert(_kind == None, "shouldn't bet set yet"); _kind = CloneOop; }
roland@29337 159 void set_copyof(bool validated) { assert(_kind == None, "shouldn't bet set yet"); _kind = CopyOf; _arguments_validated = validated; }
roland@29337 160 void set_copyofrange(bool validated) { assert(_kind == None, "shouldn't bet set yet"); _kind = CopyOfRange; _arguments_validated = validated; }
roland@29337 161
roland@29337 162 virtual int Opcode() const;
roland@29337 163 virtual uint size_of() const; // Size is bigger
roland@29337 164 virtual bool guaranteed_safepoint() { return false; }
roland@29337 165 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
roland@29337 166
roland@30629 167 virtual bool may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase);
roland@30629 168
roland@29337 169 bool is_alloc_tightly_coupled() const { return _alloc_tightly_coupled; }
roland@29337 170
simonis@42086 171 bool has_negative_length_guard() const { return _has_negative_length_guard; }
simonis@42086 172
thartmann@39254 173 static bool may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTransform *phase, ArrayCopyNode*& ac);
roland@45427 174 bool modifies(intptr_t offset_lo, intptr_t offset_hi, PhaseTransform* phase, bool must_modify) const;
roland@32370 175
roland@29337 176 #ifndef PRODUCT
roland@29337 177 virtual void dump_spec(outputStream *st) const;
mhaupt@32084 178 virtual void dump_compact_spec(outputStream* st) const;
roland@29337 179 #endif
roland@29337 180 };
coleenp@53244 181 #endif // SHARE_OPTO_ARRAYCOPYNODE_HPP