Mercurial > hg > graal-jvmci-8
annotate src/share/vm/opto/compile.cpp @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | 9b69cec6d01b |
children |
rev | line source |
---|---|
0 | 1 /* |
22851
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
7199
cd3d6a6b95d9
8003240: x86: move MacroAssembler into separate file
twisti
parents:
7196
diff
changeset
|
26 #include "asm/macroAssembler.hpp" |
cd3d6a6b95d9
8003240: x86: move MacroAssembler into separate file
twisti
parents:
7196
diff
changeset
|
27 #include "asm/macroAssembler.inline.hpp" |
14232 | 28 #include "ci/ciReplay.hpp" |
1972 | 29 #include "classfile/systemDictionary.hpp" |
30 #include "code/exceptionHandlerTable.hpp" | |
31 #include "code/nmethod.hpp" | |
32 #include "compiler/compileLog.hpp" | |
7199
cd3d6a6b95d9
8003240: x86: move MacroAssembler into separate file
twisti
parents:
7196
diff
changeset
|
33 #include "compiler/disassembler.hpp" |
1972 | 34 #include "compiler/oopMap.hpp" |
35 #include "opto/addnode.hpp" | |
36 #include "opto/block.hpp" | |
37 #include "opto/c2compiler.hpp" | |
38 #include "opto/callGenerator.hpp" | |
39 #include "opto/callnode.hpp" | |
40 #include "opto/cfgnode.hpp" | |
41 #include "opto/chaitin.hpp" | |
42 #include "opto/compile.hpp" | |
43 #include "opto/connode.hpp" | |
44 #include "opto/divnode.hpp" | |
45 #include "opto/escape.hpp" | |
46 #include "opto/idealGraphPrinter.hpp" | |
47 #include "opto/loopnode.hpp" | |
48 #include "opto/machnode.hpp" | |
49 #include "opto/macro.hpp" | |
50 #include "opto/matcher.hpp" | |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12295
diff
changeset
|
51 #include "opto/mathexactnode.hpp" |
1972 | 52 #include "opto/memnode.hpp" |
53 #include "opto/mulnode.hpp" | |
54 #include "opto/node.hpp" | |
55 #include "opto/opcodes.hpp" | |
56 #include "opto/output.hpp" | |
57 #include "opto/parse.hpp" | |
58 #include "opto/phaseX.hpp" | |
59 #include "opto/rootnode.hpp" | |
60 #include "opto/runtime.hpp" | |
61 #include "opto/stringopts.hpp" | |
62 #include "opto/type.hpp" | |
63 #include "opto/vectornode.hpp" | |
64 #include "runtime/arguments.hpp" | |
65 #include "runtime/signature.hpp" | |
66 #include "runtime/stubRoutines.hpp" | |
67 #include "runtime/timer.hpp" | |
10405 | 68 #include "trace/tracing.hpp" |
1972 | 69 #include "utilities/copy.hpp" |
22851
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
70 #if defined AD_MD_HPP |
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
71 # include AD_MD_HPP |
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
72 #elif defined TARGET_ARCH_MODEL_x86_32 |
1972 | 73 # include "adfiles/ad_x86_32.hpp" |
22851
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
74 #elif defined TARGET_ARCH_MODEL_x86_64 |
1972 | 75 # include "adfiles/ad_x86_64.hpp" |
22851
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
76 #elif defined TARGET_ARCH_MODEL_sparc |
1972 | 77 # include "adfiles/ad_sparc.hpp" |
22851
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
78 #elif defined TARGET_ARCH_MODEL_zero |
1972 | 79 # include "adfiles/ad_zero.hpp" |
22851
ddce0b7cee93
8072383: resolve conflicts between open and closed ports
dlong
parents:
20671
diff
changeset
|
80 #elif defined TARGET_ARCH_MODEL_ppc_64 |
14391 | 81 # include "adfiles/ad_ppc_64.hpp" |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2091
diff
changeset
|
82 #endif |
0 | 83 |
2008 | 84 |
85 // -------------------- Compile::mach_constant_base_node ----------------------- | |
86 // Constant table base node singleton. | |
87 MachConstantBaseNode* Compile::mach_constant_base_node() { | |
88 if (_mach_constant_base_node == NULL) { | |
89 _mach_constant_base_node = new (C) MachConstantBaseNode(); | |
90 _mach_constant_base_node->add_req(C->root()); | |
91 } | |
92 return _mach_constant_base_node; | |
93 } | |
94 | |
95 | |
0 | 96 /// Support for intrinsics. |
97 | |
98 // Return the index at which m must be inserted (or already exists). | |
99 // The sort order is by the address of the ciMethod, with is_virtual as minor key. | |
100 int Compile::intrinsic_insertion_index(ciMethod* m, bool is_virtual) { | |
101 #ifdef ASSERT | |
102 for (int i = 1; i < _intrinsics->length(); i++) { | |
103 CallGenerator* cg1 = _intrinsics->at(i-1); | |
104 CallGenerator* cg2 = _intrinsics->at(i); | |
105 assert(cg1->method() != cg2->method() | |
106 ? cg1->method() < cg2->method() | |
107 : cg1->is_virtual() < cg2->is_virtual(), | |
108 "compiler intrinsics list must stay sorted"); | |
109 } | |
110 #endif | |
111 // Binary search sorted list, in decreasing intervals [lo, hi]. | |
112 int lo = 0, hi = _intrinsics->length()-1; | |
113 while (lo <= hi) { | |
114 int mid = (uint)(hi + lo) / 2; | |
115 ciMethod* mid_m = _intrinsics->at(mid)->method(); | |
116 if (m < mid_m) { | |
117 hi = mid-1; | |
118 } else if (m > mid_m) { | |
119 lo = mid+1; | |
120 } else { | |
121 // look at minor sort key | |
122 bool mid_virt = _intrinsics->at(mid)->is_virtual(); | |
123 if (is_virtual < mid_virt) { | |
124 hi = mid-1; | |
125 } else if (is_virtual > mid_virt) { | |
126 lo = mid+1; | |
127 } else { | |
128 return mid; // exact match | |
129 } | |
130 } | |
131 } | |
132 return lo; // inexact match | |
133 } | |
134 | |
135 void Compile::register_intrinsic(CallGenerator* cg) { | |
136 if (_intrinsics == NULL) { | |
7473 | 137 _intrinsics = new (comp_arena())GrowableArray<CallGenerator*>(comp_arena(), 60, 0, NULL); |
0 | 138 } |
139 // This code is stolen from ciObjectFactory::insert. | |
140 // Really, GrowableArray should have methods for | |
141 // insert_at, remove_at, and binary_search. | |
142 int len = _intrinsics->length(); | |
143 int index = intrinsic_insertion_index(cg->method(), cg->is_virtual()); | |
144 if (index == len) { | |
145 _intrinsics->append(cg); | |
146 } else { | |
147 #ifdef ASSERT | |
148 CallGenerator* oldcg = _intrinsics->at(index); | |
149 assert(oldcg->method() != cg->method() || oldcg->is_virtual() != cg->is_virtual(), "don't register twice"); | |
150 #endif | |
151 _intrinsics->append(_intrinsics->at(len-1)); | |
152 int pos; | |
153 for (pos = len-2; pos >= index; pos--) { | |
154 _intrinsics->at_put(pos+1,_intrinsics->at(pos)); | |
155 } | |
156 _intrinsics->at_put(index, cg); | |
157 } | |
158 assert(find_intrinsic(cg->method(), cg->is_virtual()) == cg, "registration worked"); | |
159 } | |
160 | |
161 CallGenerator* Compile::find_intrinsic(ciMethod* m, bool is_virtual) { | |
162 assert(m->is_loaded(), "don't try this on unloaded methods"); | |
163 if (_intrinsics != NULL) { | |
164 int index = intrinsic_insertion_index(m, is_virtual); | |
165 if (index < _intrinsics->length() | |
166 && _intrinsics->at(index)->method() == m | |
167 && _intrinsics->at(index)->is_virtual() == is_virtual) { | |
168 return _intrinsics->at(index); | |
169 } | |
170 } | |
171 // Lazily create intrinsics for intrinsic IDs well-known in the runtime. | |
856
75596850f863
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
647
diff
changeset
|
172 if (m->intrinsic_id() != vmIntrinsics::_none && |
75596850f863
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
647
diff
changeset
|
173 m->intrinsic_id() <= vmIntrinsics::LAST_COMPILER_INLINE) { |
0 | 174 CallGenerator* cg = make_vm_intrinsic(m, is_virtual); |
175 if (cg != NULL) { | |
176 // Save it for next time: | |
177 register_intrinsic(cg); | |
178 return cg; | |
179 } else { | |
180 gather_intrinsic_statistics(m->intrinsic_id(), is_virtual, _intrinsic_disabled); | |
181 } | |
182 } | |
183 return NULL; | |
184 } | |
185 | |
186 // Compile:: register_library_intrinsics and make_vm_intrinsic are defined | |
187 // in library_call.cpp. | |
188 | |
189 | |
190 #ifndef PRODUCT | |
191 // statistics gathering... | |
192 | |
193 juint Compile::_intrinsic_hist_count[vmIntrinsics::ID_LIMIT] = {0}; | |
194 jubyte Compile::_intrinsic_hist_flags[vmIntrinsics::ID_LIMIT] = {0}; | |
195 | |
196 bool Compile::gather_intrinsic_statistics(vmIntrinsics::ID id, bool is_virtual, int flags) { | |
197 assert(id > vmIntrinsics::_none && id < vmIntrinsics::ID_LIMIT, "oob"); | |
198 int oflags = _intrinsic_hist_flags[id]; | |
199 assert(flags != 0, "what happened?"); | |
200 if (is_virtual) { | |
201 flags |= _intrinsic_virtual; | |
202 } | |
203 bool changed = (flags != oflags); | |
204 if ((flags & _intrinsic_worked) != 0) { | |
205 juint count = (_intrinsic_hist_count[id] += 1); | |
206 if (count == 1) { | |
207 changed = true; // first time | |
208 } | |
209 // increment the overall count also: | |
210 _intrinsic_hist_count[vmIntrinsics::_none] += 1; | |
211 } | |
212 if (changed) { | |
213 if (((oflags ^ flags) & _intrinsic_virtual) != 0) { | |
214 // Something changed about the intrinsic's virtuality. | |
215 if ((flags & _intrinsic_virtual) != 0) { | |
216 // This is the first use of this intrinsic as a virtual call. | |
217 if (oflags != 0) { | |
218 // We already saw it as a non-virtual, so note both cases. | |
219 flags |= _intrinsic_both; | |
220 } | |
221 } else if ((oflags & _intrinsic_both) == 0) { | |
222 // This is the first use of this intrinsic as a non-virtual | |
223 flags |= _intrinsic_both; | |
224 } | |
225 } | |
226 _intrinsic_hist_flags[id] = (jubyte) (oflags | flags); | |
227 } | |
228 // update the overall flags also: | |
229 _intrinsic_hist_flags[vmIntrinsics::_none] |= (jubyte) flags; | |
230 return changed; | |
231 } | |
232 | |
233 static char* format_flags(int flags, char* buf) { | |
234 buf[0] = 0; | |
235 if ((flags & Compile::_intrinsic_worked) != 0) strcat(buf, ",worked"); | |
236 if ((flags & Compile::_intrinsic_failed) != 0) strcat(buf, ",failed"); | |
237 if ((flags & Compile::_intrinsic_disabled) != 0) strcat(buf, ",disabled"); | |
238 if ((flags & Compile::_intrinsic_virtual) != 0) strcat(buf, ",virtual"); | |
239 if ((flags & Compile::_intrinsic_both) != 0) strcat(buf, ",nonvirtual"); | |
240 if (buf[0] == 0) strcat(buf, ","); | |
241 assert(buf[0] == ',', "must be"); | |
242 return &buf[1]; | |
243 } | |
244 | |
245 void Compile::print_intrinsic_statistics() { | |
246 char flagsbuf[100]; | |
247 ttyLocker ttyl; | |
248 if (xtty != NULL) xtty->head("statistics type='intrinsic'"); | |
249 tty->print_cr("Compiler intrinsic usage:"); | |
250 juint total = _intrinsic_hist_count[vmIntrinsics::_none]; | |
251 if (total == 0) total = 1; // avoid div0 in case of no successes | |
252 #define PRINT_STAT_LINE(name, c, f) \ | |
253 tty->print_cr(" %4d (%4.1f%%) %s (%s)", (int)(c), ((c) * 100.0) / total, name, f); | |
254 for (int index = 1 + (int)vmIntrinsics::_none; index < (int)vmIntrinsics::ID_LIMIT; index++) { | |
255 vmIntrinsics::ID id = (vmIntrinsics::ID) index; | |
256 int flags = _intrinsic_hist_flags[id]; | |
257 juint count = _intrinsic_hist_count[id]; | |
258 if ((flags | count) != 0) { | |
259 PRINT_STAT_LINE(vmIntrinsics::name_at(id), count, format_flags(flags, flagsbuf)); | |
260 } | |
261 } | |
262 PRINT_STAT_LINE("total", total, format_flags(_intrinsic_hist_flags[vmIntrinsics::_none], flagsbuf)); | |
263 if (xtty != NULL) xtty->tail("statistics"); | |
264 } | |
265 | |
266 void Compile::print_statistics() { | |
267 { ttyLocker ttyl; | |
268 if (xtty != NULL) xtty->head("statistics type='opto'"); | |
269 Parse::print_statistics(); | |
270 PhaseCCP::print_statistics(); | |
271 PhaseRegAlloc::print_statistics(); | |
272 Scheduling::print_statistics(); | |
273 PhasePeephole::print_statistics(); | |
274 PhaseIdealLoop::print_statistics(); | |
275 if (xtty != NULL) xtty->tail("statistics"); | |
276 } | |
277 if (_intrinsic_hist_flags[vmIntrinsics::_none] != 0) { | |
278 // put this under its own <statistics> element. | |
279 print_intrinsic_statistics(); | |
280 } | |
281 } | |
282 #endif //PRODUCT | |
283 | |
284 // Support for bundling info | |
285 Bundle* Compile::node_bundling(const Node *n) { | |
286 assert(valid_bundle_info(n), "oob"); | |
287 return &_node_bundling_base[n->_idx]; | |
288 } | |
289 | |
290 bool Compile::valid_bundle_info(const Node *n) { | |
291 return (_node_bundling_limit > n->_idx); | |
292 } | |
293 | |
294 | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
295 void Compile::gvn_replace_by(Node* n, Node* nn) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
296 for (DUIterator_Last imin, i = n->last_outs(imin); i >= imin; ) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
297 Node* use = n->last_out(i); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
298 bool is_in_table = initial_gvn()->hash_delete(use); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
299 uint uses_found = 0; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
300 for (uint j = 0; j < use->len(); j++) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
301 if (use->in(j) == n) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
302 if (j < use->req()) |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
303 use->set_req(j, nn); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
304 else |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
305 use->set_prec(j, nn); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
306 uses_found++; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
307 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
308 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
309 if (is_in_table) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
310 // reinsert into table |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
311 initial_gvn()->hash_find_insert(use); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
312 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
313 record_for_igvn(use); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
314 i -= uses_found; // we deleted 1 or more copies of this edge |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
315 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
316 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
317 |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
318 |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
319 static inline bool not_a_node(const Node* n) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
320 if (n == NULL) return true; |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
321 if (((intptr_t)n & 1) != 0) return true; // uninitialized, etc. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
322 if (*(address*)n == badAddress) return true; // kill by Node::destruct |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
323 return false; |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
324 } |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
325 |
0 | 326 // Identify all nodes that are reachable from below, useful. |
327 // Use breadth-first pass that records state in a Unique_Node_List, | |
328 // recursive traversal is slower. | |
329 void Compile::identify_useful_nodes(Unique_Node_List &useful) { | |
23421
c1091733abe6
8011858: Use Compile::live_nodes() instead of Compile::unique() in appropriate places
zmajo
parents:
23086
diff
changeset
|
330 int estimated_worklist_size = live_nodes(); |
0 | 331 useful.map( estimated_worklist_size, NULL ); // preallocate space |
332 | |
333 // Initialize worklist | |
334 if (root() != NULL) { useful.push(root()); } | |
335 // If 'top' is cached, declare it useful to preserve cached node | |
336 if( cached_top_node() ) { useful.push(cached_top_node()); } | |
337 | |
338 // Push all useful nodes onto the list, breadthfirst | |
339 for( uint next = 0; next < useful.size(); ++next ) { | |
340 assert( next < unique(), "Unique useful nodes < total nodes"); | |
341 Node *n = useful.at(next); | |
342 uint max = n->len(); | |
343 for( uint i = 0; i < max; ++i ) { | |
344 Node *m = n->in(i); | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
345 if (not_a_node(m)) continue; |
0 | 346 useful.push(m); |
347 } | |
348 } | |
349 } | |
350 | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
351 // Update dead_node_list with any missing dead nodes using useful |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
352 // list. Consider all non-useful nodes to be useless i.e., dead nodes. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
353 void Compile::update_dead_node_list(Unique_Node_List &useful) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
354 uint max_idx = unique(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
355 VectorSet& useful_node_set = useful.member_set(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
356 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
357 for (uint node_idx = 0; node_idx < max_idx; node_idx++) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
358 // If node with index node_idx is not in useful set, |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
359 // mark it as dead in dead node list. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
360 if (! useful_node_set.test(node_idx) ) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
361 record_dead_node(node_idx); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
362 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
363 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
364 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
365 |
7473 | 366 void Compile::remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful) { |
367 int shift = 0; | |
368 for (int i = 0; i < inlines->length(); i++) { | |
369 CallGenerator* cg = inlines->at(i); | |
370 CallNode* call = cg->call_node(); | |
371 if (shift > 0) { | |
372 inlines->at_put(i-shift, cg); | |
373 } | |
374 if (!useful.member(call)) { | |
375 shift++; | |
376 } | |
377 } | |
378 inlines->trunc_to(inlines->length()-shift); | |
379 } | |
380 | |
0 | 381 // Disconnect all useless nodes by disconnecting those at the boundary. |
382 void Compile::remove_useless_nodes(Unique_Node_List &useful) { | |
383 uint next = 0; | |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
384 while (next < useful.size()) { |
0 | 385 Node *n = useful.at(next++); |
20327
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
386 if (n->is_SafePoint()) { |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
387 // We're done with a parsing phase. Replaced nodes are not valid |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
388 // beyond that point. |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
389 n->as_SafePoint()->delete_replaced_nodes(); |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
390 } |
0 | 391 // Use raw traversal of out edges since this code removes out edges |
392 int max = n->outcnt(); | |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
393 for (int j = 0; j < max; ++j) { |
0 | 394 Node* child = n->raw_out(j); |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
395 if (! useful.member(child)) { |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
396 assert(!child->is_top() || child != top(), |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
397 "If top is cached in Compile object it is in useful list"); |
0 | 398 // Only need to remove this out-edge to the useless node |
399 n->raw_del_out(j); | |
400 --j; | |
401 --max; | |
402 } | |
403 } | |
404 if (n->outcnt() == 1 && n->has_special_unique_user()) { | |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
405 record_for_igvn(n->unique_out()); |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
406 } |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
407 } |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
408 // Remove useless macro and predicate opaq nodes |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
409 for (int i = C->macro_count()-1; i >= 0; i--) { |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
410 Node* n = C->macro_node(i); |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
411 if (!useful.member(n)) { |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
412 remove_macro_node(n); |
0 | 413 } |
414 } | |
23872
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
415 // Remove useless CastII nodes with range check dependency |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
416 for (int i = range_check_cast_count() - 1; i >= 0; i--) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
417 Node* cast = range_check_cast_node(i); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
418 if (!useful.member(cast)) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
419 remove_range_check_cast(cast); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
420 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
421 } |
8048
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
422 // Remove useless expensive node |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
423 for (int i = C->expensive_count()-1; i >= 0; i--) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
424 Node* n = C->expensive_node(i); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
425 if (!useful.member(n)) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
426 remove_expensive_node(n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
427 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
428 } |
7473 | 429 // clean up the late inline lists |
430 remove_useless_late_inlines(&_string_late_inlines, useful); | |
10278 | 431 remove_useless_late_inlines(&_boxing_late_inlines, useful); |
7473 | 432 remove_useless_late_inlines(&_late_inlines, useful); |
0 | 433 debug_only(verify_graph_edges(true/*check for no_dead_code*/);) |
434 } | |
435 | |
436 //------------------------------frame_size_in_words----------------------------- | |
437 // frame_slots in units of words | |
438 int Compile::frame_size_in_words() const { | |
439 // shift is 0 in LP32 and 1 in LP64 | |
440 const int shift = (LogBytesPerWord - LogBytesPerInt); | |
441 int words = _frame_slots >> shift; | |
442 assert( words << shift == _frame_slots, "frame size must be properly aligned in LP64" ); | |
443 return words; | |
444 } | |
445 | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
446 // To bang the stack of this compiled method we use the stack size |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
447 // that the interpreter would need in case of a deoptimization. This |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
448 // removes the need to bang the stack in the deoptimization blob which |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
449 // in turn simplifies stack overflow handling. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
450 int Compile::bang_size_in_bytes() const { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
451 return MAX2(_interpreter_frame_size, frame_size_in_bytes()); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
452 } |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
453 |
0 | 454 // ============================================================================ |
455 //------------------------------CompileWrapper--------------------------------- | |
456 class CompileWrapper : public StackObj { | |
457 Compile *const _compile; | |
458 public: | |
459 CompileWrapper(Compile* compile); | |
460 | |
461 ~CompileWrapper(); | |
462 }; | |
463 | |
464 CompileWrapper::CompileWrapper(Compile* compile) : _compile(compile) { | |
465 // the Compile* pointer is stored in the current ciEnv: | |
466 ciEnv* env = compile->env(); | |
467 assert(env == ciEnv::current(), "must already be a ciEnv active"); | |
468 assert(env->compiler_data() == NULL, "compile already active?"); | |
469 env->set_compiler_data(compile); | |
470 assert(compile == Compile::current(), "sanity"); | |
471 | |
472 compile->set_type_dict(NULL); | |
473 compile->set_type_hwm(NULL); | |
474 compile->set_type_last_size(0); | |
475 compile->set_last_tf(NULL, NULL); | |
476 compile->set_indexSet_arena(NULL); | |
477 compile->set_indexSet_free_block_list(NULL); | |
478 compile->init_type_arena(); | |
479 Type::Initialize(compile); | |
480 _compile->set_scratch_buffer_blob(NULL); | |
481 _compile->begin_method(); | |
482 } | |
483 CompileWrapper::~CompileWrapper() { | |
484 _compile->end_method(); | |
485 if (_compile->scratch_buffer_blob() != NULL) | |
486 BufferBlob::free(_compile->scratch_buffer_blob()); | |
487 _compile->env()->set_compiler_data(NULL); | |
488 } | |
489 | |
490 | |
491 //----------------------------print_compile_messages--------------------------- | |
492 void Compile::print_compile_messages() { | |
493 #ifndef PRODUCT | |
494 // Check if recompiling | |
495 if (_subsume_loads == false && PrintOpto) { | |
496 // Recompiling without allowing machine instructions to subsume loads | |
497 tty->print_cr("*********************************************************"); | |
498 tty->print_cr("** Bailout: Recompile without subsuming loads **"); | |
499 tty->print_cr("*********************************************************"); | |
500 } | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
501 if (_do_escape_analysis != DoEscapeAnalysis && PrintOpto) { |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
502 // Recompiling without escape analysis |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
503 tty->print_cr("*********************************************************"); |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
504 tty->print_cr("** Bailout: Recompile without escape analysis **"); |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
505 tty->print_cr("*********************************************************"); |
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
506 } |
10278 | 507 if (_eliminate_boxing != EliminateAutoBox && PrintOpto) { |
508 // Recompiling without boxing elimination | |
509 tty->print_cr("*********************************************************"); | |
510 tty->print_cr("** Bailout: Recompile without boxing elimination **"); | |
511 tty->print_cr("*********************************************************"); | |
512 } | |
0 | 513 if (env()->break_at_compile()) { |
605 | 514 // Open the debugger when compiling this method. |
0 | 515 tty->print("### Breaking when compiling: "); |
516 method()->print_short_name(); | |
517 tty->cr(); | |
518 BREAKPOINT; | |
519 } | |
520 | |
521 if( PrintOpto ) { | |
522 if (is_osr_compilation()) { | |
523 tty->print("[OSR]%3d", _compile_id); | |
524 } else { | |
525 tty->print("%3d", _compile_id); | |
526 } | |
527 } | |
528 #endif | |
529 } | |
530 | |
531 | |
2091
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
532 //-----------------------init_scratch_buffer_blob------------------------------ |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
533 // Construct a temporary BufferBlob and cache it for this compile. |
2008 | 534 void Compile::init_scratch_buffer_blob(int const_size) { |
2091
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
535 // If there is already a scratch buffer blob allocated and the |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
536 // constant section is big enough, use it. Otherwise free the |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
537 // current and allocate a new one. |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
538 BufferBlob* blob = scratch_buffer_blob(); |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
539 if ((blob != NULL) && (const_size <= _scratch_const_size)) { |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
540 // Use the current blob. |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
541 } else { |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
542 if (blob != NULL) { |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
543 BufferBlob::free(blob); |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
544 } |
0 | 545 |
2091
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
546 ResourceMark rm; |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
547 _scratch_const_size = const_size; |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
548 int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
549 blob = BufferBlob::create("Compile::scratch_buffer", size); |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
550 // Record the buffer blob for next time. |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
551 set_scratch_buffer_blob(blob); |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
552 // Have we run out of code space? |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
553 if (scratch_buffer_blob() == NULL) { |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
554 // Let CompilerBroker disable further compilations. |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
555 record_failure("Not enough space for scratch buffer in CodeCache"); |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
556 return; |
51bd2d261853
7008325: CodeCache exhausted on sparc starting from hs20b04
kvn
parents:
2008
diff
changeset
|
557 } |
163 | 558 } |
0 | 559 |
560 // Initialize the relocation buffers | |
1748 | 561 relocInfo* locs_buf = (relocInfo*) blob->content_end() - MAX_locs_size; |
0 | 562 set_scratch_locs_memory(locs_buf); |
563 } | |
564 | |
565 | |
566 //-----------------------scratch_emit_size------------------------------------- | |
567 // Helper function that computes size by emitting code | |
568 uint Compile::scratch_emit_size(const Node* n) { | |
2008 | 569 // Start scratch_emit_size section. |
570 set_in_scratch_emit_size(true); | |
571 | |
0 | 572 // Emit into a trash buffer and count bytes emitted. |
573 // This is a pretty expensive way to compute a size, | |
574 // but it works well enough if seldom used. | |
575 // All common fixed-size instructions are given a size | |
576 // method by the AD file. | |
577 // Note that the scratch buffer blob and locs memory are | |
578 // allocated at the beginning of the compile task, and | |
579 // may be shared by several calls to scratch_emit_size. | |
580 // The allocation of the scratch buffer blob is particularly | |
581 // expensive, since it has to grab the code cache lock. | |
582 BufferBlob* blob = this->scratch_buffer_blob(); | |
583 assert(blob != NULL, "Initialize BufferBlob at start"); | |
584 assert(blob->size() > MAX_inst_size, "sanity"); | |
585 relocInfo* locs_buf = scratch_locs_memory(); | |
1748 | 586 address blob_begin = blob->content_begin(); |
0 | 587 address blob_end = (address)locs_buf; |
1748 | 588 assert(blob->content_contains(blob_end), "sanity"); |
0 | 589 CodeBuffer buf(blob_begin, blob_end - blob_begin); |
2008 | 590 buf.initialize_consts_size(_scratch_const_size); |
0 | 591 buf.initialize_stubs_size(MAX_stubs_size); |
592 assert(locs_buf != NULL, "sanity"); | |
2008 | 593 int lsize = MAX_locs_size / 3; |
594 buf.consts()->initialize_shared_locs(&locs_buf[lsize * 0], lsize); | |
595 buf.insts()->initialize_shared_locs( &locs_buf[lsize * 1], lsize); | |
596 buf.stubs()->initialize_shared_locs( &locs_buf[lsize * 2], lsize); | |
597 | |
598 // Do the emission. | |
3839 | 599 |
600 Label fakeL; // Fake label for branch instructions. | |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
601 Label* saveL = NULL; |
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
602 uint save_bnum = 0; |
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
603 bool is_branch = n->is_MachBranch(); |
3839 | 604 if (is_branch) { |
605 MacroAssembler masm(&buf); | |
606 masm.bind(fakeL); | |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
607 n->as_MachBranch()->save_label(&saveL, &save_bnum); |
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
608 n->as_MachBranch()->label_set(&fakeL, 0); |
3839 | 609 } |
0 | 610 n->emit(buf, this->regalloc()); |
24000
c3d0bd36ab28
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
vkempik
parents:
23822
diff
changeset
|
611 |
c3d0bd36ab28
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
vkempik
parents:
23822
diff
changeset
|
612 // Emitting into the scratch buffer should not fail |
c3d0bd36ab28
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
vkempik
parents:
23822
diff
changeset
|
613 assert (!failing(), err_msg_res("Must not have pending failure. Reason is: %s", failure_reason())); |
c3d0bd36ab28
8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
vkempik
parents:
23822
diff
changeset
|
614 |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
615 if (is_branch) // Restore label. |
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3839
diff
changeset
|
616 n->as_MachBranch()->label_set(saveL, save_bnum); |
2008 | 617 |
618 // End scratch_emit_size section. | |
619 set_in_scratch_emit_size(false); | |
620 | |
1748 | 621 return buf.insts_size(); |
0 | 622 } |
623 | |
624 | |
625 // ============================================================================ | |
626 //------------------------------Compile standard------------------------------- | |
627 debug_only( int Compile::_debug_idx = 100000; ) | |
628 | |
629 // Compile a method. entry_bci is -1 for normal compilations and indicates | |
630 // the continuation bci for on stack replacement. | |
631 | |
632 | |
10278 | 633 Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, |
634 bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing ) | |
0 | 635 : Phase(Compiler), |
636 _env(ci_env), | |
637 _log(ci_env->log()), | |
638 _compile_id(ci_env->compile_id()), | |
639 _save_argument_registers(false), | |
640 _stub_name(NULL), | |
641 _stub_function(NULL), | |
642 _stub_entry_point(NULL), | |
643 _method(target), | |
644 _entry_bci(osr_bci), | |
645 _initial_gvn(NULL), | |
646 _for_igvn(NULL), | |
647 _warm_calls(NULL), | |
648 _subsume_loads(subsume_loads), | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
649 _do_escape_analysis(do_escape_analysis), |
10278 | 650 _eliminate_boxing(eliminate_boxing), |
0 | 651 _failure_reason(NULL), |
652 _code_buffer("Compile::Fill_buffer"), | |
653 _orig_pc_slot(0), | |
654 _orig_pc_slot_offset_in_bytes(0), | |
1265 | 655 _has_method_handle_invokes(false), |
2008 | 656 _mach_constant_base_node(NULL), |
0 | 657 _node_bundling_limit(0), |
658 _node_bundling_base(NULL), | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
659 _java_calls(0), |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
660 _inner_loops(0), |
2008 | 661 _scratch_const_size(-1), |
662 _in_scratch_emit_size(false), | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
663 _dead_node_list(comp_arena()), |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
664 _dead_node_count(0), |
0 | 665 #ifndef PRODUCT |
666 _trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")), | |
14438
4cdf4f71177d
8029025: PPC64 (part 203): opto: Move static _in_dump_cnt to Compile object.
goetz
parents:
14435
diff
changeset
|
667 _in_dump_cnt(0), |
0 | 668 _printer(IdealGraphPrinter::printer()), |
669 #endif | |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
670 _congraph(NULL), |
20360 | 671 _comp_arena(mtCompiler), |
672 _node_arena(mtCompiler), | |
673 _old_arena(mtCompiler), | |
674 _Compile_types(mtCompiler), | |
14232 | 675 _replay_inline_data(NULL), |
7473 | 676 _late_inlines(comp_arena(), 2, 0, NULL), |
677 _string_late_inlines(comp_arena(), 2, 0, NULL), | |
10278 | 678 _boxing_late_inlines(comp_arena(), 2, 0, NULL), |
7473 | 679 _late_inlines_pos(0), |
680 _number_of_mh_late_inlines(0), | |
681 _inlining_progress(false), | |
682 _inlining_incrementally(false), | |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
683 _print_inlining_list(NULL), |
12956
3213ba4d3dff
8024069: replace_in_map() should operate on parent maps
roland
parents:
12888
diff
changeset
|
684 _print_inlining_idx(0), |
20671
9e69e8d1c900
8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents:
20360
diff
changeset
|
685 _interpreter_frame_size(0), |
9e69e8d1c900
8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents:
20360
diff
changeset
|
686 _max_node_limit(MaxNodeLimit) { |
0 | 687 C = this; |
688 | |
689 CompileWrapper cw(this); | |
690 #ifndef PRODUCT | |
691 if (TimeCompiler2) { | |
692 tty->print(" "); | |
693 target->holder()->name()->print(); | |
694 tty->print("."); | |
695 target->print_short_name(); | |
696 tty->print(" "); | |
697 } | |
698 TraceTime t1("Total compilation time", &_t_totalCompilation, TimeCompiler, TimeCompiler2); | |
699 TraceTime t2(NULL, &_t_methodCompilation, TimeCompiler, false); | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
700 bool print_opto_assembly = PrintOptoAssembly || _method->has_option("PrintOptoAssembly"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
701 if (!print_opto_assembly) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
702 bool print_assembly = (PrintAssembly || _method->should_print_assembly()); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
703 if (print_assembly && !Disassembler::can_decode()) { |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
704 tty->print_cr("PrintAssembly request changed to PrintOptoAssembly"); |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
705 print_opto_assembly = true; |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
706 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
707 } |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
65
diff
changeset
|
708 set_print_assembly(print_opto_assembly); |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
333
diff
changeset
|
709 set_parsed_irreducible_loop(false); |
14232 | 710 |
711 if (method()->has_option("ReplayInline")) { | |
712 _replay_inline_data = ciReplay::load_inline_data(method(), entry_bci(), ci_env->comp_level()); | |
713 } | |
0 | 714 #endif |
12295 | 715 set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining)); |
716 set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics")); | |
17914
3636afd5ec1a
8039298: assert(base == NULL || t_adr->isa_rawptr() || !phase->type(base)->higher_equal(TypePtr::NULL_PTR))
kvn
parents:
17895
diff
changeset
|
717 set_has_irreducible_loop(true); // conservative until build_loop_tree() reset it |
0 | 718 |
17780 | 719 if (ProfileTraps RTM_OPT_ONLY( || UseRTMLocking )) { |
0 | 720 // Make sure the method being compiled gets its own MDO, |
721 // so we can at least track the decompile_count(). | |
17780 | 722 // Need MDO to record RTM code generation state. |
2007
5ddfcf4b079e
7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents:
1972
diff
changeset
|
723 method()->ensure_method_data(); |
0 | 724 } |
725 | |
726 Init(::AliasLevel); | |
727 | |
728 | |
729 print_compile_messages(); | |
730 | |
14384 | 731 _ilt = InlineTree::build_inline_tree_root(); |
0 | 732 |
733 // Even if NO memory addresses are used, MergeMem nodes must have at least 1 slice | |
734 assert(num_alias_types() >= AliasIdxRaw, ""); | |
735 | |
736 #define MINIMUM_NODE_HASH 1023 | |
737 // Node list that Iterative GVN will start with | |
738 Unique_Node_List for_igvn(comp_arena()); | |
739 set_for_igvn(&for_igvn); | |
740 | |
741 // GVN that will be run immediately on new nodes | |
742 uint estimated_size = method()->code_size()*4+64; | |
743 estimated_size = (estimated_size < MINIMUM_NODE_HASH ? MINIMUM_NODE_HASH : estimated_size); | |
744 PhaseGVN gvn(node_arena(), estimated_size); | |
745 set_initial_gvn(&gvn); | |
746 | |
12295 | 747 if (print_inlining() || print_intrinsics()) { |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
748 _print_inlining_list = new (comp_arena())GrowableArray<PrintInliningBuffer>(comp_arena(), 1, 1, PrintInliningBuffer()); |
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
749 } |
0 | 750 { // Scope for timing the parser |
751 TracePhase t3("parse", &_t_parser, true); | |
752 | |
753 // Put top into the hash table ASAP. | |
754 initial_gvn()->transform_no_reclaim(top()); | |
755 | |
756 // Set up tf(), start(), and find a CallGenerator. | |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
757 CallGenerator* cg = NULL; |
0 | 758 if (is_osr_compilation()) { |
759 const TypeTuple *domain = StartOSRNode::osr_domain(); | |
760 const TypeTuple *range = TypeTuple::make_range(method()->signature()); | |
761 init_tf(TypeFunc::make(domain, range)); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
762 StartNode* s = new (this) StartOSRNode(root(), domain); |
0 | 763 initial_gvn()->set_type_bottom(s); |
764 init_start(s); | |
765 cg = CallGenerator::for_osr(method(), entry_bci()); | |
766 } else { | |
767 // Normal case. | |
768 init_tf(TypeFunc::make(method())); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
769 StartNode* s = new (this) StartNode(root(), tf()->domain()); |
0 | 770 initial_gvn()->set_type_bottom(s); |
771 init_start(s); | |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
772 if (method()->intrinsic_id() == vmIntrinsics::_Reference_get && UseG1GC) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
773 // With java.lang.ref.reference.get() we must go through the |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
774 // intrinsic when G1 is enabled - even when get() is the root |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
775 // method of the compile - so that, if necessary, the value in |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
776 // the referent field of the reference object gets recorded by |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
777 // the pre-barrier code. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
778 // Specifically, if G1 is enabled, the value in the referent |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
779 // field is recorded by the G1 SATB pre barrier. This will |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
780 // result in the referent being marked live and the reference |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
781 // object removed from the list of discovered references during |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
782 // reference processing. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
783 cg = find_intrinsic(method(), false); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
784 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
785 if (cg == NULL) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
786 float past_uses = method()->interpreter_invocation_count(); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
787 float expected_uses = past_uses; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
788 cg = CallGenerator::for_inline(method(), expected_uses); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
3248
diff
changeset
|
789 } |
0 | 790 } |
791 if (failing()) return; | |
792 if (cg == NULL) { | |
793 record_method_not_compilable_all_tiers("cannot parse method"); | |
794 return; | |
795 } | |
796 JVMState* jvms = build_start_state(start(), tf()); | |
20327
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
797 if ((jvms = cg->generate(jvms)) == NULL) { |
23848
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
23822
diff
changeset
|
798 if (!failure_reason_is(C2Compiler::retry_class_loading_during_parsing())) { |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
23822
diff
changeset
|
799 record_method_not_compilable("method parse failed"); |
3e1cd663c2d3
8055530: assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty()) failed: return value must be well defined
shshahma
parents:
23822
diff
changeset
|
800 } |
0 | 801 return; |
802 } | |
803 GraphKit kit(jvms); | |
804 | |
805 if (!kit.stopped()) { | |
806 // Accept return values, and transfer control we know not where. | |
807 // This is done by a special, unique ReturnNode bound to root. | |
808 return_values(kit.jvms()); | |
809 } | |
810 | |
811 if (kit.has_exceptions()) { | |
812 // Any exceptions that escape from this call must be rethrown | |
813 // to whatever caller is dynamically above us on the stack. | |
814 // This is done by a special, unique RethrowNode bound to root. | |
815 rethrow_exceptions(kit.transfer_exceptions_into_jvms()); | |
816 } | |
817 | |
7473 | 818 assert(IncrementalInline || (_late_inlines.length() == 0 && !has_mh_late_inlines()), "incremental inlining is off"); |
819 | |
820 if (_late_inlines.length() == 0 && !has_mh_late_inlines() && !failing() && has_stringbuilder()) { | |
821 inline_string_calls(true); | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
822 } |
7473 | 823 |
824 if (failing()) return; | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
825 |
10405 | 826 print_method(PHASE_BEFORE_REMOVEUSELESS, 3); |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
333
diff
changeset
|
827 |
0 | 828 // Remove clutter produced by parsing. |
829 if (!failing()) { | |
830 ResourceMark rm; | |
831 PhaseRemoveUseless pru(initial_gvn(), &for_igvn); | |
832 } | |
833 } | |
834 | |
835 // Note: Large methods are capped off in do_one_bytecode(). | |
836 if (failing()) return; | |
837 | |
838 // After parsing, node notes are no longer automagic. | |
839 // They must be propagated by register_new_node_with_optimizer(), | |
840 // clone(), or the like. | |
841 set_default_node_notes(NULL); | |
842 | |
843 for (;;) { | |
844 int successes = Inline_Warm(); | |
845 if (failing()) return; | |
846 if (successes == 0) break; | |
847 } | |
848 | |
849 // Drain the list. | |
850 Finish_Warm(); | |
851 #ifndef PRODUCT | |
852 if (_printer) { | |
853 _printer->print_inlining(this); | |
854 } | |
855 #endif | |
856 | |
857 if (failing()) return; | |
858 NOT_PRODUCT( verify_graph_edges(); ) | |
859 | |
860 // Now optimize | |
861 Optimize(); | |
862 if (failing()) return; | |
863 NOT_PRODUCT( verify_graph_edges(); ) | |
864 | |
865 #ifndef PRODUCT | |
866 if (PrintIdeal) { | |
867 ttyLocker ttyl; // keep the following output all in one block | |
868 // This output goes directly to the tty, not the compiler log. | |
869 // To enable tools to match it up with the compilation activity, | |
870 // be sure to tag this tty output with the compile ID. | |
871 if (xtty != NULL) { | |
872 xtty->head("ideal compile_id='%d'%s", compile_id(), | |
873 is_osr_compilation() ? " compile_kind='osr'" : | |
874 ""); | |
875 } | |
876 root()->dump(9999); | |
877 if (xtty != NULL) { | |
878 xtty->tail("ideal"); | |
879 } | |
880 } | |
881 #endif | |
882 | |
13045
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
883 NOT_PRODUCT( verify_barriers(); ) |
14232 | 884 |
885 // Dump compilation data to replay it. | |
886 if (method()->has_option("DumpReplay")) { | |
887 env()->dump_replay_data(_compile_id); | |
888 } | |
889 if (method()->has_option("DumpInline") && (ilt() != NULL)) { | |
890 env()->dump_inline_data(_compile_id); | |
891 } | |
892 | |
0 | 893 // Now that we know the size of all the monitors we can add a fixed slot |
894 // for the original deopt pc. | |
895 | |
896 _orig_pc_slot = fixed_slots(); | |
897 int next_slot = _orig_pc_slot + (sizeof(address) / VMRegImpl::stack_slot_size); | |
898 set_fixed_slots(next_slot); | |
899 | |
14440
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
900 // Compute when to use implicit null checks. Used by matching trap based |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
901 // nodes and NullCheck optimization. |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
902 set_allowed_deopt_reasons(); |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
903 |
0 | 904 // Now generate code |
905 Code_Gen(); | |
906 if (failing()) return; | |
907 | |
908 // Check if we want to skip execution of all compiled code. | |
909 { | |
910 #ifndef PRODUCT | |
911 if (OptoNoExecute) { | |
912 record_method_not_compilable("+OptoNoExecute"); // Flag as failed | |
913 return; | |
914 } | |
915 TracePhase t2("install_code", &_t_registerMethod, TimeCompiler); | |
916 #endif | |
917 | |
918 if (is_osr_compilation()) { | |
919 _code_offsets.set_value(CodeOffsets::Verified_Entry, 0); | |
920 _code_offsets.set_value(CodeOffsets::OSR_Entry, _first_block_size); | |
921 } else { | |
922 _code_offsets.set_value(CodeOffsets::Verified_Entry, _first_block_size); | |
923 _code_offsets.set_value(CodeOffsets::OSR_Entry, 0); | |
924 } | |
925 | |
926 env()->register_method(_method, _entry_bci, | |
927 &_code_offsets, | |
928 _orig_pc_slot_offset_in_bytes, | |
929 code_buffer(), | |
930 frame_size_in_words(), _oop_map_set, | |
931 &_handler_table, &_inc_table, | |
932 compiler, | |
933 env()->comp_level(), | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6725
diff
changeset
|
934 has_unsafe_access(), |
17780 | 935 SharedRuntime::is_wide_vector(max_vector_size()), |
936 rtm_state() | |
0 | 937 ); |
6843 | 938 |
939 if (log() != NULL) // Print code cache state into compiler log | |
940 log()->code_cache_state(); | |
0 | 941 } |
942 } | |
943 | |
944 //------------------------------Compile---------------------------------------- | |
945 // Compile a runtime stub | |
946 Compile::Compile( ciEnv* ci_env, | |
947 TypeFunc_generator generator, | |
948 address stub_function, | |
949 const char *stub_name, | |
950 int is_fancy_jump, | |
951 bool pass_tls, | |
952 bool save_arg_registers, | |
953 bool return_pc ) | |
954 : Phase(Compiler), | |
955 _env(ci_env), | |
956 _log(ci_env->log()), | |
8730
b7c2c5b2572c
8005772: Stubs report compile id -1 in phase events
neliasso
parents:
8694
diff
changeset
|
957 _compile_id(0), |
0 | 958 _save_argument_registers(save_arg_registers), |
959 _method(NULL), | |
960 _stub_name(stub_name), | |
961 _stub_function(stub_function), | |
962 _stub_entry_point(NULL), | |
963 _entry_bci(InvocationEntryBci), | |
964 _initial_gvn(NULL), | |
965 _for_igvn(NULL), | |
966 _warm_calls(NULL), | |
967 _orig_pc_slot(0), | |
968 _orig_pc_slot_offset_in_bytes(0), | |
969 _subsume_loads(true), | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
970 _do_escape_analysis(false), |
10278 | 971 _eliminate_boxing(false), |
0 | 972 _failure_reason(NULL), |
973 _code_buffer("Compile::Fill_buffer"), | |
1265 | 974 _has_method_handle_invokes(false), |
2008 | 975 _mach_constant_base_node(NULL), |
0 | 976 _node_bundling_limit(0), |
977 _node_bundling_base(NULL), | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
978 _java_calls(0), |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
979 _inner_loops(0), |
0 | 980 #ifndef PRODUCT |
981 _trace_opto_output(TraceOptoOutput), | |
14438
4cdf4f71177d
8029025: PPC64 (part 203): opto: Move static _in_dump_cnt to Compile object.
goetz
parents:
14435
diff
changeset
|
982 _in_dump_cnt(0), |
0 | 983 _printer(NULL), |
984 #endif | |
20360 | 985 _comp_arena(mtCompiler), |
986 _node_arena(mtCompiler), | |
987 _old_arena(mtCompiler), | |
988 _Compile_types(mtCompiler), | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
989 _dead_node_list(comp_arena()), |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
990 _dead_node_count(0), |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
991 _congraph(NULL), |
14232 | 992 _replay_inline_data(NULL), |
7473 | 993 _number_of_mh_late_inlines(0), |
994 _inlining_progress(false), | |
995 _inlining_incrementally(false), | |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
996 _print_inlining_list(NULL), |
12956
3213ba4d3dff
8024069: replace_in_map() should operate on parent maps
roland
parents:
12888
diff
changeset
|
997 _print_inlining_idx(0), |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
998 _allowed_reasons(0), |
20671
9e69e8d1c900
8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents:
20360
diff
changeset
|
999 _interpreter_frame_size(0), |
9e69e8d1c900
8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents:
20360
diff
changeset
|
1000 _max_node_limit(MaxNodeLimit) { |
0 | 1001 C = this; |
1002 | |
1003 #ifndef PRODUCT | |
1004 TraceTime t1(NULL, &_t_totalCompilation, TimeCompiler, false); | |
1005 TraceTime t2(NULL, &_t_stubCompilation, TimeCompiler, false); | |
1006 set_print_assembly(PrintFrameConverterAssembly); | |
367
194b8e3a2fc4
6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents:
333
diff
changeset
|
1007 set_parsed_irreducible_loop(false); |
0 | 1008 #endif |
17914
3636afd5ec1a
8039298: assert(base == NULL || t_adr->isa_rawptr() || !phase->type(base)->higher_equal(TypePtr::NULL_PTR))
kvn
parents:
17895
diff
changeset
|
1009 set_has_irreducible_loop(false); // no loops |
3636afd5ec1a
8039298: assert(base == NULL || t_adr->isa_rawptr() || !phase->type(base)->higher_equal(TypePtr::NULL_PTR))
kvn
parents:
17895
diff
changeset
|
1010 |
0 | 1011 CompileWrapper cw(this); |
1012 Init(/*AliasLevel=*/ 0); | |
1013 init_tf((*generator)()); | |
1014 | |
1015 { | |
1016 // The following is a dummy for the sake of GraphKit::gen_stub | |
1017 Unique_Node_List for_igvn(comp_arena()); | |
1018 set_for_igvn(&for_igvn); // not used, but some GraphKit guys push on this | |
1019 PhaseGVN gvn(Thread::current()->resource_area(),255); | |
1020 set_initial_gvn(&gvn); // not significant, but GraphKit guys use it pervasively | |
1021 gvn.transform_no_reclaim(top()); | |
1022 | |
1023 GraphKit kit; | |
1024 kit.gen_stub(stub_function, stub_name, is_fancy_jump, pass_tls, return_pc); | |
1025 } | |
1026 | |
1027 NOT_PRODUCT( verify_graph_edges(); ) | |
1028 Code_Gen(); | |
1029 if (failing()) return; | |
1030 | |
1031 | |
1032 // Entry point will be accessed using compile->stub_entry_point(); | |
1033 if (code_buffer() == NULL) { | |
1034 Matcher::soft_match_failure(); | |
1035 } else { | |
1036 if (PrintAssembly && (WizardMode || Verbose)) | |
1037 tty->print_cr("### Stub::%s", stub_name); | |
1038 | |
1039 if (!failing()) { | |
1040 assert(_fixed_slots == 0, "no fixed slots used for runtime stubs"); | |
1041 | |
1042 // Make the NMethod | |
1043 // For now we mark the frame as never safe for profile stackwalking | |
1044 RuntimeStub *rs = RuntimeStub::new_runtime_stub(stub_name, | |
1045 code_buffer(), | |
1046 CodeOffsets::frame_never_safe, | |
1047 // _code_offsets.value(CodeOffsets::Frame_Complete), | |
1048 frame_size_in_words(), | |
1049 _oop_map_set, | |
1050 save_arg_registers); | |
1051 assert(rs != NULL && rs->is_runtime_stub(), "sanity check"); | |
1052 | |
1053 _stub_entry_point = rs->entry_point(); | |
1054 } | |
1055 } | |
1056 } | |
1057 | |
1058 //------------------------------Init------------------------------------------- | |
1059 // Prepare for a single compilation | |
1060 void Compile::Init(int aliaslevel) { | |
1061 _unique = 0; | |
1062 _regalloc = NULL; | |
1063 | |
1064 _tf = NULL; // filled in later | |
1065 _top = NULL; // cached later | |
1066 _matcher = NULL; // filled in later | |
1067 _cfg = NULL; // filled in later | |
1068 | |
1069 set_24_bit_selection_and_mode(Use24BitFP, false); | |
1070 | |
1071 _node_note_array = NULL; | |
1072 _default_node_notes = NULL; | |
1073 | |
1074 _immutable_memory = NULL; // filled in at first inquiry | |
1075 | |
1076 // Globally visible Nodes | |
1077 // First set TOP to NULL to give safe behavior during creation of RootNode | |
1078 set_cached_top_node(NULL); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1079 set_root(new (this) RootNode()); |
0 | 1080 // Now that you have a Root to point to, create the real TOP |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6795
diff
changeset
|
1081 set_cached_top_node( new (this) ConNode(Type::TOP) ); |
0 | 1082 set_recent_alloc(NULL, NULL); |
1083 | |
1084 // Create Debug Information Recorder to record scopes, oopmaps, etc. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
1085 env()->set_oop_recorder(new OopRecorder(env()->arena())); |
0 | 1086 env()->set_debug_info(new DebugInformationRecorder(env()->oop_recorder())); |
1087 env()->set_dependencies(new Dependencies(env())); | |
1088 | |
1089 _fixed_slots = 0; | |
1090 set_has_split_ifs(false); | |
1091 set_has_loops(has_method() && method()->has_loops()); // first approximation | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
1092 set_has_stringbuilder(false); |
10278 | 1093 set_has_boxed_value(false); |
0 | 1094 _trap_can_recompile = false; // no traps emitted yet |
1095 _major_progress = true; // start out assuming good things will happen | |
1096 set_has_unsafe_access(false); | |
6792
137868b7aa6f
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
6725
diff
changeset
|
1097 set_max_vector_size(0); |
0 | 1098 Copy::zero_to_bytes(_trap_hist, sizeof(_trap_hist)); |
1099 set_decompile_count(0); | |
1100 | |
418 | 1101 set_do_freq_based_layout(BlockLayoutByFrequency || method_has_option("BlockLayoutByFrequency")); |
1783 | 1102 set_num_loop_opts(LoopOptsCount); |
1103 set_do_inlining(Inline); | |
1104 set_max_inline_size(MaxInlineSize); | |
1105 set_freq_inline_size(FreqInlineSize); | |
1106 set_do_scheduling(OptoScheduling); | |
1107 set_do_count_invocations(false); | |
1108 set_do_method_data_update(false); | |
17780 | 1109 set_rtm_state(NoRTM); // No RTM lock eliding by default |
20671
9e69e8d1c900
8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents:
20360
diff
changeset
|
1110 method_has_option_value("MaxNodeLimit", _max_node_limit); |
17780 | 1111 #if INCLUDE_RTM_OPT |
1112 if (UseRTMLocking && has_method() && (method()->method_data_or_null() != NULL)) { | |
1113 int rtm_state = method()->method_data()->rtm_state(); | |
1114 if (method_has_option("NoRTMLockEliding") || ((rtm_state & NoRTM) != 0)) { | |
1115 // Don't generate RTM lock eliding code. | |
1116 set_rtm_state(NoRTM); | |
1117 } else if (method_has_option("UseRTMLockEliding") || ((rtm_state & UseRTM) != 0) || !UseRTMDeopt) { | |
1118 // Generate RTM lock eliding code without abort ratio calculation code. | |
1119 set_rtm_state(UseRTM); | |
1120 } else if (UseRTMDeopt) { | |
1121 // Generate RTM lock eliding code and include abort ratio calculation | |
1122 // code if UseRTMDeopt is on. | |
1123 set_rtm_state(ProfileRTM); | |
1124 } | |
1125 } | |
1126 #endif | |
0 | 1127 if (debug_info()->recording_non_safepoints()) { |
1128 set_node_note_array(new(comp_arena()) GrowableArray<Node_Notes*> | |
1129 (comp_arena(), 8, 0, NULL)); | |
1130 set_default_node_notes(Node_Notes::make(this)); | |
1131 } | |
1132 | |
1133 // // -- Initialize types before each compile -- | |
1134 // // Update cached type information | |
1135 // if( _method && _method->constants() ) | |
1136 // Type::update_loaded_types(_method, _method->constants()); | |
1137 | |
1138 // Init alias_type map. | |
38
b789bcaf2dd9
6667610: (Escape Analysis) retry compilation without EA if it fails
kvn
parents:
0
diff
changeset
|
1139 if (!_do_escape_analysis && aliaslevel == 3) |
0 | 1140 aliaslevel = 2; // No unique types without escape analysis |
1141 _AliasLevel = aliaslevel; | |
1142 const int grow_ats = 16; | |
1143 _max_alias_types = grow_ats; | |
1144 _alias_types = NEW_ARENA_ARRAY(comp_arena(), AliasType*, grow_ats); | |
1145 AliasType* ats = NEW_ARENA_ARRAY(comp_arena(), AliasType, grow_ats); | |
1146 Copy::zero_to_bytes(ats, sizeof(AliasType)*grow_ats); | |
1147 { | |
1148 for (int i = 0; i < grow_ats; i++) _alias_types[i] = &ats[i]; | |
1149 } | |
1150 // Initialize the first few types. | |
1151 _alias_types[AliasIdxTop]->Init(AliasIdxTop, NULL); | |
1152 _alias_types[AliasIdxBot]->Init(AliasIdxBot, TypePtr::BOTTOM); | |
1153 _alias_types[AliasIdxRaw]->Init(AliasIdxRaw, TypeRawPtr::BOTTOM); | |
1154 _num_alias_types = AliasIdxRaw+1; | |
1155 // Zero out the alias type cache. | |
1156 Copy::zero_to_bytes(_alias_cache, sizeof(_alias_cache)); | |
1157 // A NULL adr_type hits in the cache right away. Preload the right answer. | |
1158 probe_alias_cache(NULL)->_index = AliasIdxTop; | |
1159 | |
1160 _intrinsics = NULL; | |
1685 | 1161 _macro_nodes = new(comp_arena()) GrowableArray<Node*>(comp_arena(), 8, 0, NULL); |
1162 _predicate_opaqs = new(comp_arena()) GrowableArray<Node*>(comp_arena(), 8, 0, NULL); | |
8048
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
1163 _expensive_nodes = new(comp_arena()) GrowableArray<Node*>(comp_arena(), 8, 0, NULL); |
23872
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1164 _range_check_casts = new(comp_arena()) GrowableArray<Node*>(comp_arena(), 8, 0, NULL); |
0 | 1165 register_library_intrinsics(); |
1166 } | |
1167 | |
1168 //---------------------------init_start---------------------------------------- | |
1169 // Install the StartNode on this compile object. | |
1170 void Compile::init_start(StartNode* s) { | |
1171 if (failing()) | |
1172 return; // already failing | |
1173 assert(s == start(), ""); | |
1174 } | |
1175 | |
1176 StartNode* Compile::start() const { | |
1177 assert(!failing(), ""); | |
1178 for (DUIterator_Fast imax, i = root()->fast_outs(imax); i < imax; i++) { | |
1179 Node* start = root()->fast_out(i); | |
1180 if( start->is_Start() ) | |
1181 return start->as_Start(); | |
1182 } | |
17914
3636afd5ec1a
8039298: assert(base == NULL || t_adr->isa_rawptr() || !phase->type(base)->higher_equal(TypePtr::NULL_PTR))
kvn
parents:
17895
diff
changeset
|
1183 fatal("Did not find Start node!"); |
0 | 1184 return NULL; |
1185 } | |
1186 | |
1187 //-------------------------------immutable_memory------------------------------------- | |
1188 // Access immutable memory | |
1189 Node* Compile::immutable_memory() { | |
1190 if (_immutable_memory != NULL) { | |
1191 return _immutable_memory; | |
1192 } | |
1193 StartNode* s = start(); | |
1194 for (DUIterator_Fast imax, i = s->fast_outs(imax); true; i++) { | |
1195 Node *p = s->fast_out(i); | |
1196 if (p != s && p->as_Proj()->_con == TypeFunc::Memory) { | |
1197 _immutable_memory = p; | |
1198 return _immutable_memory; | |
1199 } | |
1200 } | |
1201 ShouldNotReachHere(); | |
1202 return NULL; | |
1203 } | |
1204 | |
1205 //----------------------set_cached_top_node------------------------------------ | |
1206 // Install the cached top node, and make sure Node::is_top works correctly. | |
1207 void Compile::set_cached_top_node(Node* tn) { | |
1208 if (tn != NULL) verify_top(tn); | |
1209 Node* old_top = _top; | |
1210 _top = tn; | |
1211 // Calling Node::setup_is_top allows the nodes the chance to adjust | |
1212 // their _out arrays. | |
1213 if (_top != NULL) _top->setup_is_top(); | |
1214 if (old_top != NULL) old_top->setup_is_top(); | |
1215 assert(_top == NULL || top()->is_top(), ""); | |
1216 } | |
1217 | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1218 #ifdef ASSERT |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1219 uint Compile::count_live_nodes_by_graph_walk() { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1220 Unique_Node_List useful(comp_arena()); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1221 // Get useful node list by walking the graph. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1222 identify_useful_nodes(useful); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1223 return useful.size(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1224 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1225 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1226 void Compile::print_missing_nodes() { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1227 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1228 // Return if CompileLog is NULL and PrintIdealNodeCount is false. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1229 if ((_log == NULL) && (! PrintIdealNodeCount)) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1230 return; |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1231 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1232 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1233 // This is an expensive function. It is executed only when the user |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1234 // specifies VerifyIdealNodeCount option or otherwise knows the |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1235 // additional work that needs to be done to identify reachable nodes |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1236 // by walking the flow graph and find the missing ones using |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1237 // _dead_node_list. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1238 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1239 Unique_Node_List useful(comp_arena()); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1240 // Get useful node list by walking the graph. |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1241 identify_useful_nodes(useful); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1242 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1243 uint l_nodes = C->live_nodes(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1244 uint l_nodes_by_walk = useful.size(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1245 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1246 if (l_nodes != l_nodes_by_walk) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1247 if (_log != NULL) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1248 _log->begin_head("mismatched_nodes count='%d'", abs((int) (l_nodes - l_nodes_by_walk))); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1249 _log->stamp(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1250 _log->end_head(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1251 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1252 VectorSet& useful_member_set = useful.member_set(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1253 int last_idx = l_nodes_by_walk; |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1254 for (int i = 0; i < last_idx; i++) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1255 if (useful_member_set.test(i)) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1256 if (_dead_node_list.test(i)) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1257 if (_log != NULL) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1258 _log->elem("mismatched_node_info node_idx='%d' type='both live and dead'", i); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1259 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1260 if (PrintIdealNodeCount) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1261 // Print the log message to tty |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1262 tty->print_cr("mismatched_node idx='%d' both live and dead'", i); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1263 useful.at(i)->dump(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1264 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1265 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1266 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1267 else if (! _dead_node_list.test(i)) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1268 if (_log != NULL) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1269 _log->elem("mismatched_node_info node_idx='%d' type='neither live nor dead'", i); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1270 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1271 if (PrintIdealNodeCount) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1272 // Print the log message to tty |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1273 tty->print_cr("mismatched_node idx='%d' type='neither live nor dead'", i); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1274 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1275 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1276 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1277 if (_log != NULL) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1278 _log->tail("mismatched_nodes"); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1279 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1280 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1281 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1282 #endif |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
1283 |
0 | 1284 #ifndef PRODUCT |
1285 void Compile::verify_top(Node* tn) const { | |
1286 if (tn != NULL) { | |
1287 assert(tn->is_Con(), "top node must be a constant"); | |
1288 assert(((ConNode*)tn)->type() == Type::TOP, "top node must have correct type"); | |
1289 assert(tn->in(0) != NULL, "must have live top node"); | |
1290 } | |
1291 } | |
1292 #endif | |
1293 | |
1294 | |
1295 ///-------------------Managing Per-Node Debug & Profile Info------------------- | |
1296 | |
1297 void Compile::grow_node_notes(GrowableArray<Node_Notes*>* arr, int grow_by) { | |
1298 guarantee(arr != NULL, ""); | |
1299 int num_blocks = arr->length(); | |
1300 if (grow_by < num_blocks) grow_by = num_blocks; | |
1301 int num_notes = grow_by * _node_notes_block_size; | |
1302 Node_Notes* notes = NEW_ARENA_ARRAY(node_arena(), Node_Notes, num_notes); | |
1303 Copy::zero_to_bytes(notes, num_notes * sizeof(Node_Notes)); | |
1304 while (num_notes > 0) { | |
1305 arr->append(notes); | |
1306 notes += _node_notes_block_size; | |
1307 num_notes -= _node_notes_block_size; | |
1308 } | |
1309 assert(num_notes == 0, "exact multiple, please"); | |
1310 } | |
1311 | |
1312 bool Compile::copy_node_notes_to(Node* dest, Node* source) { | |
1313 if (source == NULL || dest == NULL) return false; | |
1314 | |
1315 if (dest->is_Con()) | |
1316 return false; // Do not push debug info onto constants. | |
1317 | |
1318 #ifdef ASSERT | |
1319 // Leave a bread crumb trail pointing to the original node: | |
1320 if (dest != NULL && dest != source && dest->debug_orig() == NULL) { | |
1321 dest->set_debug_orig(source); | |
1322 } | |
1323 #endif | |
1324 | |
1325 if (node_note_array() == NULL) | |
1326 return false; // Not collecting any notes now. | |
1327 | |
1328 // This is a copy onto a pre-existing node, which may already have notes. | |
1329 // If both nodes have notes, do not overwrite any pre-existing notes. | |
1330 Node_Notes* source_notes = node_notes_at(source->_idx); | |
1331 if (source_notes == NULL || source_notes->is_clear()) return false; | |
1332 Node_Notes* dest_notes = node_notes_at(dest->_idx); | |
1333 if (dest_notes == NULL || dest_notes->is_clear()) { | |
1334 return set_node_notes_at(dest->_idx, source_notes); | |
1335 } | |
1336 | |
1337 Node_Notes merged_notes = (*source_notes); | |
1338 // The order of operations here ensures that dest notes will win... | |
1339 merged_notes.update_from(dest_notes); | |
1340 return set_node_notes_at(dest->_idx, &merged_notes); | |
1341 } | |
1342 | |
1343 | |
1344 //--------------------------allow_range_check_smearing------------------------- | |
1345 // Gating condition for coalescing similar range checks. | |
1346 // Sometimes we try 'speculatively' replacing a series of a range checks by a | |
1347 // single covering check that is at least as strong as any of them. | |
1348 // If the optimization succeeds, the simplified (strengthened) range check | |
1349 // will always succeed. If it fails, we will deopt, and then give up | |
1350 // on the optimization. | |
1351 bool Compile::allow_range_check_smearing() const { | |
1352 // If this method has already thrown a range-check, | |
1353 // assume it was because we already tried range smearing | |
1354 // and it failed. | |
1355 uint already_trapped = trap_count(Deoptimization::Reason_range_check); | |
1356 return !already_trapped; | |
1357 } | |
1358 | |
1359 | |
1360 //------------------------------flatten_alias_type----------------------------- | |
1361 const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { | |
1362 int offset = tj->offset(); | |
1363 TypePtr::PTR ptr = tj->ptr(); | |
1364 | |
247 | 1365 // Known instance (scalarizable allocation) alias only with itself. |
1366 bool is_known_inst = tj->isa_oopptr() != NULL && | |
1367 tj->is_oopptr()->is_known_instance(); | |
1368 | |
0 | 1369 // Process weird unsafe references. |
1370 if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) { | |
1371 assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops"); | |
247 | 1372 assert(!is_known_inst, "scalarizable allocation should not have unsafe references"); |
0 | 1373 tj = TypeOopPtr::BOTTOM; |
1374 ptr = tj->ptr(); | |
1375 offset = tj->offset(); | |
1376 } | |
1377 | |
1378 // Array pointers need some flattening | |
1379 const TypeAryPtr *ta = tj->isa_aryptr(); | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1380 if (ta && ta->is_stable()) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1381 // Erase stability property for alias analysis. |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1382 tj = ta = ta->cast_to_stable(false); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1383 } |
247 | 1384 if( ta && is_known_inst ) { |
1385 if ( offset != Type::OffsetBot && | |
1386 offset > arrayOopDesc::length_offset_in_bytes() ) { | |
1387 offset = Type::OffsetBot; // Flatten constant access into array body only | |
1388 tj = ta = TypeAryPtr::make(ptr, ta->ary(), ta->klass(), true, offset, ta->instance_id()); | |
1389 } | |
1390 } else if( ta && _AliasLevel >= 2 ) { | |
0 | 1391 // For arrays indexed by constant indices, we flatten the alias |
1392 // space to include all of the array body. Only the header, klass | |
1393 // and array length can be accessed un-aliased. | |
1394 if( offset != Type::OffsetBot ) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
1395 if( ta->const_oop() ) { // MethodData* or Method* |
0 | 1396 offset = Type::OffsetBot; // Flatten constant access into array body |
247 | 1397 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset); |
0 | 1398 } else if( offset == arrayOopDesc::length_offset_in_bytes() ) { |
1399 // range is OK as-is. | |
1400 tj = ta = TypeAryPtr::RANGE; | |
1401 } else if( offset == oopDesc::klass_offset_in_bytes() ) { | |
1402 tj = TypeInstPtr::KLASS; // all klass loads look alike | |
1403 ta = TypeAryPtr::RANGE; // generic ignored junk | |
1404 ptr = TypePtr::BotPTR; | |
1405 } else if( offset == oopDesc::mark_offset_in_bytes() ) { | |
1406 tj = TypeInstPtr::MARK; | |
1407 ta = TypeAryPtr::RANGE; // generic ignored junk | |
1408 ptr = TypePtr::BotPTR; | |
1409 } else { // Random constant offset into array body | |
1410 offset = Type::OffsetBot; // Flatten constant access into array body | |
247 | 1411 tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset); |
0 | 1412 } |
1413 } | |
1414 // Arrays of fixed size alias with arrays of unknown size. | |
1415 if (ta->size() != TypeInt::POS) { | |
1416 const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS); | |
247 | 1417 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset); |
0 | 1418 } |
1419 // Arrays of known objects become arrays of unknown objects. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
1420 if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
1421 const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size()); |
247 | 1422 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
1423 } |
0 | 1424 if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) { |
1425 const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size()); | |
247 | 1426 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset); |
0 | 1427 } |
1428 // Arrays of bytes and of booleans both use 'bastore' and 'baload' so | |
1429 // cannot be distinguished by bytecode alone. | |
1430 if (ta->elem() == TypeInt::BOOL) { | |
1431 const TypeAry *tary = TypeAry::make(TypeInt::BYTE, ta->size()); | |
1432 ciKlass* aklass = ciTypeArrayKlass::make(T_BYTE); | |
247 | 1433 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,aklass,false,offset); |
0 | 1434 } |
1435 // During the 2nd round of IterGVN, NotNull castings are removed. | |
1436 // Make sure the Bottom and NotNull variants alias the same. | |
1437 // Also, make sure exact and non-exact variants alias the same. | |
12966 | 1438 if (ptr == TypePtr::NotNull || ta->klass_is_exact() || ta->speculative() != NULL) { |
3789 | 1439 tj = ta = TypeAryPtr::make(TypePtr::BotPTR,ta->ary(),ta->klass(),false,offset); |
0 | 1440 } |
1441 } | |
1442 | |
1443 // Oop pointers need some flattening | |
1444 const TypeInstPtr *to = tj->isa_instptr(); | |
1445 if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) { | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1446 ciInstanceKlass *k = to->klass()->as_instance_klass(); |
0 | 1447 if( ptr == TypePtr::Constant ) { |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1448 if (to->klass() != ciEnv::current()->Class_klass() || |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1449 offset < k->size_helper() * wordSize) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1450 // No constant oop pointers (such as Strings); they alias with |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1451 // unknown strings. |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1452 assert(!is_known_inst, "not scalarizable allocation"); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1453 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1454 } |
247 | 1455 } else if( is_known_inst ) { |
163 | 1456 tj = to; // Keep NotNull and klass_is_exact for instance type |
0 | 1457 } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) { |
1458 // During the 2nd round of IterGVN, NotNull castings are removed. | |
1459 // Make sure the Bottom and NotNull variants alias the same. | |
1460 // Also, make sure exact and non-exact variants alias the same. | |
247 | 1461 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
0 | 1462 } |
12966 | 1463 if (to->speculative() != NULL) { |
1464 tj = to = TypeInstPtr::make(to->ptr(),to->klass(),to->klass_is_exact(),to->const_oop(),to->offset(), to->instance_id()); | |
1465 } | |
0 | 1466 // Canonicalize the holder of this field |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
1467 if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) { |
0 | 1468 // First handle header references such as a LoadKlassNode, even if the |
1469 // object's klass is unloaded at compile time (4965979). | |
247 | 1470 if (!is_known_inst) { // Do it only for non-instance types |
1471 tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset); | |
1472 } | |
0 | 1473 } else if (offset < 0 || offset >= k->size_helper() * wordSize) { |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1474 // Static fields are in the space above the normal instance |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1475 // fields in the java.lang.Class instance. |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1476 if (to->klass() != ciEnv::current()->Class_klass()) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1477 to = NULL; |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1478 tj = TypeOopPtr::BOTTOM; |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1479 offset = tj->offset(); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1480 } |
0 | 1481 } else { |
1482 ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset); | |
1483 if (!k->equals(canonical_holder) || tj->offset() != offset) { | |
247 | 1484 if( is_known_inst ) { |
1485 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id()); | |
1486 } else { | |
1487 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset); | |
1488 } | |
0 | 1489 } |
1490 } | |
1491 } | |
1492 | |
1493 // Klass pointers to object array klasses need some flattening | |
1494 const TypeKlassPtr *tk = tj->isa_klassptr(); | |
1495 if( tk ) { | |
1496 // If we are referencing a field within a Klass, we need | |
1497 // to assume the worst case of an Object. Both exact and | |
4760
669f6a7d5b70
7121073: secondary_super_cache memory slice has incorrect bounds in flatten_alias_type
never
parents:
4115
diff
changeset
|
1498 // inexact types must flatten to the same alias class so |
669f6a7d5b70
7121073: secondary_super_cache memory slice has incorrect bounds in flatten_alias_type
never
parents:
4115
diff
changeset
|
1499 // use NotNull as the PTR. |
0 | 1500 if ( offset == Type::OffsetBot || (offset >= 0 && (size_t)offset < sizeof(Klass)) ) { |
1501 | |
4760
669f6a7d5b70
7121073: secondary_super_cache memory slice has incorrect bounds in flatten_alias_type
never
parents:
4115
diff
changeset
|
1502 tj = tk = TypeKlassPtr::make(TypePtr::NotNull, |
0 | 1503 TypeKlassPtr::OBJECT->klass(), |
1504 offset); | |
1505 } | |
1506 | |
1507 ciKlass* klass = tk->klass(); | |
1508 if( klass->is_obj_array_klass() ) { | |
1509 ciKlass* k = TypeAryPtr::OOPS->klass(); | |
1510 if( !k || !k->is_loaded() ) // Only fails for some -Xcomp runs | |
1511 k = TypeInstPtr::BOTTOM->klass(); | |
1512 tj = tk = TypeKlassPtr::make( TypePtr::NotNull, k, offset ); | |
1513 } | |
1514 | |
1515 // Check for precise loads from the primary supertype array and force them | |
1516 // to the supertype cache alias index. Check for generic array loads from | |
1517 // the primary supertype array and also force them to the supertype cache | |
1518 // alias index. Since the same load can reach both, we need to merge | |
1519 // these 2 disparate memories into the same alias class. Since the | |
1520 // primary supertype array is read-only, there's no chance of confusion | |
1521 // where we bypass an array load and an array store. | |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1522 int primary_supers_offset = in_bytes(Klass::primary_supers_offset()); |
4760
669f6a7d5b70
7121073: secondary_super_cache memory slice has incorrect bounds in flatten_alias_type
never
parents:
4115
diff
changeset
|
1523 if (offset == Type::OffsetBot || |
669f6a7d5b70
7121073: secondary_super_cache memory slice has incorrect bounds in flatten_alias_type
never
parents:
4115
diff
changeset
|
1524 (offset >= primary_supers_offset && |
669f6a7d5b70
7121073: secondary_super_cache memory slice has incorrect bounds in flatten_alias_type
never
parents:
4115
diff
changeset
|
1525 offset < (int)(primary_supers_offset + Klass::primary_super_limit() * wordSize)) || |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1526 offset == (int)in_bytes(Klass::secondary_super_cache_offset())) { |
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1527 offset = in_bytes(Klass::secondary_super_cache_offset()); |
0 | 1528 tj = tk = TypeKlassPtr::make( TypePtr::NotNull, tk->klass(), offset ); |
1529 } | |
1530 } | |
1531 | |
1532 // Flatten all Raw pointers together. | |
1533 if (tj->base() == Type::RawPtr) | |
1534 tj = TypeRawPtr::BOTTOM; | |
1535 | |
1536 if (tj->base() == Type::AnyPtr) | |
1537 tj = TypePtr::BOTTOM; // An error, which the caller must check for. | |
1538 | |
1539 // Flatten all to bottom for now | |
1540 switch( _AliasLevel ) { | |
1541 case 0: | |
1542 tj = TypePtr::BOTTOM; | |
1543 break; | |
1544 case 1: // Flatten to: oop, static, field or array | |
1545 switch (tj->base()) { | |
1546 //case Type::AryPtr: tj = TypeAryPtr::RANGE; break; | |
1547 case Type::RawPtr: tj = TypeRawPtr::BOTTOM; break; | |
1548 case Type::AryPtr: // do not distinguish arrays at all | |
1549 case Type::InstPtr: tj = TypeInstPtr::BOTTOM; break; | |
1550 case Type::KlassPtr: tj = TypeKlassPtr::OBJECT; break; | |
1551 case Type::AnyPtr: tj = TypePtr::BOTTOM; break; // caller checks it | |
1552 default: ShouldNotReachHere(); | |
1553 } | |
1554 break; | |
605 | 1555 case 2: // No collapsing at level 2; keep all splits |
1556 case 3: // No collapsing at level 3; keep all splits | |
0 | 1557 break; |
1558 default: | |
1559 Unimplemented(); | |
1560 } | |
1561 | |
1562 offset = tj->offset(); | |
1563 assert( offset != Type::OffsetTop, "Offset has fallen from constant" ); | |
1564 | |
1565 assert( (offset != Type::OffsetBot && tj->base() != Type::AryPtr) || | |
1566 (offset == Type::OffsetBot && tj->base() == Type::AryPtr) || | |
1567 (offset == Type::OffsetBot && tj == TypeOopPtr::BOTTOM) || | |
1568 (offset == Type::OffsetBot && tj == TypePtr::BOTTOM) || | |
1569 (offset == oopDesc::mark_offset_in_bytes() && tj->base() == Type::AryPtr) || | |
1570 (offset == oopDesc::klass_offset_in_bytes() && tj->base() == Type::AryPtr) || | |
1571 (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr) , | |
1572 "For oops, klasses, raw offset must be constant; for arrays the offset is never known" ); | |
1573 assert( tj->ptr() != TypePtr::TopPTR && | |
1574 tj->ptr() != TypePtr::AnyNull && | |
1575 tj->ptr() != TypePtr::Null, "No imprecise addresses" ); | |
1576 // assert( tj->ptr() != TypePtr::Constant || | |
1577 // tj->base() == Type::RawPtr || | |
1578 // tj->base() == Type::KlassPtr, "No constant oop addresses" ); | |
1579 | |
1580 return tj; | |
1581 } | |
1582 | |
1583 void Compile::AliasType::Init(int i, const TypePtr* at) { | |
1584 _index = i; | |
1585 _adr_type = at; | |
1586 _field = NULL; | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1587 _element = NULL; |
0 | 1588 _is_rewritable = true; // default |
1589 const TypeOopPtr *atoop = (at != NULL) ? at->isa_oopptr() : NULL; | |
223 | 1590 if (atoop != NULL && atoop->is_known_instance()) { |
1591 const TypeOopPtr *gt = atoop->cast_to_instance_id(TypeOopPtr::InstanceBot); | |
0 | 1592 _general_index = Compile::current()->get_alias_index(gt); |
1593 } else { | |
1594 _general_index = 0; | |
1595 } | |
1596 } | |
1597 | |
1598 //---------------------------------print_on------------------------------------ | |
1599 #ifndef PRODUCT | |
1600 void Compile::AliasType::print_on(outputStream* st) { | |
1601 if (index() < 10) | |
1602 st->print("@ <%d> ", index()); | |
1603 else st->print("@ <%d>", index()); | |
1604 st->print(is_rewritable() ? " " : " RO"); | |
1605 int offset = adr_type()->offset(); | |
1606 if (offset == Type::OffsetBot) | |
1607 st->print(" +any"); | |
1608 else st->print(" +%-3d", offset); | |
1609 st->print(" in "); | |
1610 adr_type()->dump_on(st); | |
1611 const TypeOopPtr* tjp = adr_type()->isa_oopptr(); | |
1612 if (field() != NULL && tjp) { | |
1613 if (tjp->klass() != field()->holder() || | |
1614 tjp->offset() != field()->offset_in_bytes()) { | |
1615 st->print(" != "); | |
1616 field()->print(); | |
1617 st->print(" ***"); | |
1618 } | |
1619 } | |
1620 } | |
1621 | |
1622 void print_alias_types() { | |
1623 Compile* C = Compile::current(); | |
1624 tty->print_cr("--- Alias types, AliasIdxBot .. %d", C->num_alias_types()-1); | |
1625 for (int idx = Compile::AliasIdxBot; idx < C->num_alias_types(); idx++) { | |
1626 C->alias_type(idx)->print_on(tty); | |
1627 tty->cr(); | |
1628 } | |
1629 } | |
1630 #endif | |
1631 | |
1632 | |
1633 //----------------------------probe_alias_cache-------------------------------- | |
1634 Compile::AliasCacheEntry* Compile::probe_alias_cache(const TypePtr* adr_type) { | |
1635 intptr_t key = (intptr_t) adr_type; | |
1636 key ^= key >> logAliasCacheSize; | |
1637 return &_alias_cache[key & right_n_bits(logAliasCacheSize)]; | |
1638 } | |
1639 | |
1640 | |
1641 //-----------------------------grow_alias_types-------------------------------- | |
1642 void Compile::grow_alias_types() { | |
1643 const int old_ats = _max_alias_types; // how many before? | |
1644 const int new_ats = old_ats; // how many more? | |
1645 const int grow_ats = old_ats+new_ats; // how many now? | |
1646 _max_alias_types = grow_ats; | |
1647 _alias_types = REALLOC_ARENA_ARRAY(comp_arena(), AliasType*, _alias_types, old_ats, grow_ats); | |
1648 AliasType* ats = NEW_ARENA_ARRAY(comp_arena(), AliasType, new_ats); | |
1649 Copy::zero_to_bytes(ats, sizeof(AliasType)*new_ats); | |
1650 for (int i = 0; i < new_ats; i++) _alias_types[old_ats+i] = &ats[i]; | |
1651 } | |
1652 | |
1653 | |
1654 //--------------------------------find_alias_type------------------------------ | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1655 Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) { |
0 | 1656 if (_AliasLevel == 0) |
1657 return alias_type(AliasIdxBot); | |
1658 | |
1659 AliasCacheEntry* ace = probe_alias_cache(adr_type); | |
1660 if (ace->_adr_type == adr_type) { | |
1661 return alias_type(ace->_index); | |
1662 } | |
1663 | |
1664 // Handle special cases. | |
1665 if (adr_type == NULL) return alias_type(AliasIdxTop); | |
1666 if (adr_type == TypePtr::BOTTOM) return alias_type(AliasIdxBot); | |
1667 | |
1668 // Do it the slow way. | |
1669 const TypePtr* flat = flatten_alias_type(adr_type); | |
1670 | |
1671 #ifdef ASSERT | |
1672 assert(flat == flatten_alias_type(flat), "idempotent"); | |
1673 assert(flat != TypePtr::BOTTOM, "cannot alias-analyze an untyped ptr"); | |
1674 if (flat->isa_oopptr() && !flat->isa_klassptr()) { | |
1675 const TypeOopPtr* foop = flat->is_oopptr(); | |
247 | 1676 // Scalarizable allocations have exact klass always. |
1677 bool exact = !foop->klass_is_exact() || foop->is_known_instance(); | |
1678 const TypePtr* xoop = foop->cast_to_exactness(exact)->is_ptr(); | |
0 | 1679 assert(foop == flatten_alias_type(xoop), "exactness must not affect alias type"); |
1680 } | |
1681 assert(flat == flatten_alias_type(flat), "exact bit doesn't matter"); | |
1682 #endif | |
1683 | |
1684 int idx = AliasIdxTop; | |
1685 for (int i = 0; i < num_alias_types(); i++) { | |
1686 if (alias_type(i)->adr_type() == flat) { | |
1687 idx = i; | |
1688 break; | |
1689 } | |
1690 } | |
1691 | |
1692 if (idx == AliasIdxTop) { | |
1693 if (no_create) return NULL; | |
1694 // Grow the array if necessary. | |
1695 if (_num_alias_types == _max_alias_types) grow_alias_types(); | |
1696 // Add a new alias type. | |
1697 idx = _num_alias_types++; | |
1698 _alias_types[idx]->Init(idx, flat); | |
1699 if (flat == TypeInstPtr::KLASS) alias_type(idx)->set_rewritable(false); | |
1700 if (flat == TypeAryPtr::RANGE) alias_type(idx)->set_rewritable(false); | |
1701 if (flat->isa_instptr()) { | |
1702 if (flat->offset() == java_lang_Class::klass_offset_in_bytes() | |
1703 && flat->is_instptr()->klass() == env()->Class_klass()) | |
1704 alias_type(idx)->set_rewritable(false); | |
1705 } | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1706 if (flat->isa_aryptr()) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1707 #ifdef ASSERT |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1708 const int header_size_min = arrayOopDesc::base_offset_in_bytes(T_BYTE); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1709 // (T_BYTE has the weakest alignment and size restrictions...) |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1710 assert(flat->offset() < header_size_min, "array body reference must be OffsetBot"); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1711 #endif |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1712 if (flat->offset() == TypePtr::OffsetBot) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1713 alias_type(idx)->set_element(flat->is_aryptr()->elem()); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1714 } |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1715 } |
0 | 1716 if (flat->isa_klassptr()) { |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1717 if (flat->offset() == in_bytes(Klass::super_check_offset_offset())) |
0 | 1718 alias_type(idx)->set_rewritable(false); |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1719 if (flat->offset() == in_bytes(Klass::modifier_flags_offset())) |
0 | 1720 alias_type(idx)->set_rewritable(false); |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1721 if (flat->offset() == in_bytes(Klass::access_flags_offset())) |
0 | 1722 alias_type(idx)->set_rewritable(false); |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4760
diff
changeset
|
1723 if (flat->offset() == in_bytes(Klass::java_mirror_offset())) |
0 | 1724 alias_type(idx)->set_rewritable(false); |
1725 } | |
1726 // %%% (We would like to finalize JavaThread::threadObj_offset(), | |
1727 // but the base pointer type is not distinctive enough to identify | |
1728 // references into JavaThread.) | |
1729 | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1730 // Check for final fields. |
0 | 1731 const TypeInstPtr* tinst = flat->isa_instptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
1732 if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) { |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1733 ciField* field; |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1734 if (tinst->const_oop() != NULL && |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1735 tinst->klass() == ciEnv::current()->Class_klass() && |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1736 tinst->offset() >= (tinst->klass()->as_instance_klass()->size_helper() * wordSize)) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1737 // static field |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1738 ciInstanceKlass* k = tinst->const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass(); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1739 field = k->get_field_by_offset(tinst->offset(), true); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1740 } else { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1741 ciInstanceKlass *k = tinst->klass()->as_instance_klass(); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1742 field = k->get_field_by_offset(tinst->offset(), false); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1743 } |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1744 assert(field == NULL || |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1745 original_field == NULL || |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1746 (field->holder() == original_field->holder() && |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1747 field->offset() == original_field->offset() && |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1748 field->is_static() == original_field->is_static()), "wrong field?"); |
0 | 1749 // Set field() and is_rewritable() attributes. |
1750 if (field != NULL) alias_type(idx)->set_field(field); | |
1751 } | |
1752 } | |
1753 | |
1754 // Fill the cache for next time. | |
1755 ace->_adr_type = adr_type; | |
1756 ace->_index = idx; | |
1757 assert(alias_type(adr_type) == alias_type(idx), "type must be installed"); | |
1758 | |
1759 // Might as well try to fill the cache for the flattened version, too. | |
1760 AliasCacheEntry* face = probe_alias_cache(flat); | |
1761 if (face->_adr_type == NULL) { | |
1762 face->_adr_type = flat; | |
1763 face->_index = idx; | |
1764 assert(alias_type(flat) == alias_type(idx), "flat type must work too"); | |
1765 } | |
1766 | |
1767 return alias_type(idx); | |
1768 } | |
1769 | |
1770 | |
1771 Compile::AliasType* Compile::alias_type(ciField* field) { | |
1772 const TypeOopPtr* t; | |
1773 if (field->is_static()) | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1774 t = TypeInstPtr::make(field->holder()->java_mirror()); |
0 | 1775 else |
1776 t = TypeOopPtr::make_from_klass_raw(field->holder()); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1777 AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field); |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
12167
diff
changeset
|
1778 assert((field->is_final() || field->is_stable()) == !atp->is_rewritable(), "must get the rewritable bits correct"); |
0 | 1779 return atp; |
1780 } | |
1781 | |
1782 | |
1783 //------------------------------have_alias_type-------------------------------- | |
1784 bool Compile::have_alias_type(const TypePtr* adr_type) { | |
1785 AliasCacheEntry* ace = probe_alias_cache(adr_type); | |
1786 if (ace->_adr_type == adr_type) { | |
1787 return true; | |
1788 } | |
1789 | |
1790 // Handle special cases. | |
1791 if (adr_type == NULL) return true; | |
1792 if (adr_type == TypePtr::BOTTOM) return true; | |
1793 | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2192
diff
changeset
|
1794 return find_alias_type(adr_type, true, NULL) != NULL; |
0 | 1795 } |
1796 | |
1797 //-----------------------------must_alias-------------------------------------- | |
1798 // True if all values of the given address type are in the given alias category. | |
1799 bool Compile::must_alias(const TypePtr* adr_type, int alias_idx) { | |
1800 if (alias_idx == AliasIdxBot) return true; // the universal category | |
1801 if (adr_type == NULL) return true; // NULL serves as TypePtr::TOP | |
1802 if (alias_idx == AliasIdxTop) return false; // the empty category | |
1803 if (adr_type->base() == Type::AnyPtr) return false; // TypePtr::BOTTOM or its twins | |
1804 | |
1805 // the only remaining possible overlap is identity | |
1806 int adr_idx = get_alias_index(adr_type); | |
1807 assert(adr_idx != AliasIdxBot && adr_idx != AliasIdxTop, ""); | |
1808 assert(adr_idx == alias_idx || | |
1809 (alias_type(alias_idx)->adr_type() != TypeOopPtr::BOTTOM | |
1810 && adr_type != TypeOopPtr::BOTTOM), | |
1811 "should not be testing for overlap with an unsafe pointer"); | |
1812 return adr_idx == alias_idx; | |
1813 } | |
1814 | |
1815 //------------------------------can_alias-------------------------------------- | |
1816 // True if any values of the given address type are in the given alias category. | |
1817 bool Compile::can_alias(const TypePtr* adr_type, int alias_idx) { | |
1818 if (alias_idx == AliasIdxTop) return false; // the empty category | |
1819 if (adr_type == NULL) return false; // NULL serves as TypePtr::TOP | |
1820 if (alias_idx == AliasIdxBot) return true; // the universal category | |
1821 if (adr_type->base() == Type::AnyPtr) return true; // TypePtr::BOTTOM or its twins | |
1822 | |
1823 // the only remaining possible overlap is identity | |
1824 int adr_idx = get_alias_index(adr_type); | |
1825 assert(adr_idx != AliasIdxBot && adr_idx != AliasIdxTop, ""); | |
1826 return adr_idx == alias_idx; | |
1827 } | |
1828 | |
1829 | |
1830 | |
1831 //---------------------------pop_warm_call------------------------------------- | |
1832 WarmCallInfo* Compile::pop_warm_call() { | |
1833 WarmCallInfo* wci = _warm_calls; | |
1834 if (wci != NULL) _warm_calls = wci->remove_from(wci); | |
1835 return wci; | |
1836 } | |
1837 | |
1838 //----------------------------Inline_Warm-------------------------------------- | |
1839 int Compile::Inline_Warm() { | |
1840 // If there is room, try to inline some more warm call sites. | |
1841 // %%% Do a graph index compaction pass when we think we're out of space? | |
1842 if (!InlineWarmCalls) return 0; | |
1843 | |
1844 int calls_made_hot = 0; | |
1845 int room_to_grow = NodeCountInliningCutoff - unique(); | |
1846 int amount_to_grow = MIN2(room_to_grow, (int)NodeCountInliningStep); | |
1847 int amount_grown = 0; | |
1848 WarmCallInfo* call; | |
1849 while (amount_to_grow > 0 && (call = pop_warm_call()) != NULL) { | |
1850 int est_size = (int)call->size(); | |
1851 if (est_size > (room_to_grow - amount_grown)) { | |
1852 // This one won't fit anyway. Get rid of it. | |
1853 call->make_cold(); | |
1854 continue; | |
1855 } | |
1856 call->make_hot(); | |
1857 calls_made_hot++; | |
1858 amount_grown += est_size; | |
1859 amount_to_grow -= est_size; | |
1860 } | |
1861 | |
1862 if (calls_made_hot > 0) set_major_progress(); | |
1863 return calls_made_hot; | |
1864 } | |
1865 | |
1866 | |
1867 //----------------------------Finish_Warm-------------------------------------- | |
1868 void Compile::Finish_Warm() { | |
1869 if (!InlineWarmCalls) return; | |
1870 if (failing()) return; | |
1871 if (warm_calls() == NULL) return; | |
1872 | |
1873 // Clean up loose ends, if we are out of space for inlining. | |
1874 WarmCallInfo* call; | |
1875 while ((call = pop_warm_call()) != NULL) { | |
1876 call->make_cold(); | |
1877 } | |
1878 } | |
1879 | |
1172 | 1880 //---------------------cleanup_loop_predicates----------------------- |
1881 // Remove the opaque nodes that protect the predicates so that all unused | |
1882 // checks and uncommon_traps will be eliminated from the ideal graph | |
1883 void Compile::cleanup_loop_predicates(PhaseIterGVN &igvn) { | |
1884 if (predicate_count()==0) return; | |
1885 for (int i = predicate_count(); i > 0; i--) { | |
1886 Node * n = predicate_opaque1_node(i-1); | |
1887 assert(n->Opcode() == Op_Opaque1, "must be"); | |
1888 igvn.replace_node(n, n->in(1)); | |
1889 } | |
1890 assert(predicate_count()==0, "should be clean!"); | |
1891 } | |
0 | 1892 |
23872
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1893 void Compile::add_range_check_cast(Node* n) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1894 assert(n->isa_CastII()->has_range_check(), "CastII should have range check dependency"); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1895 assert(!_range_check_casts->contains(n), "duplicate entry in range check casts"); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1896 _range_check_casts->append(n); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1897 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1898 |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1899 // Remove all range check dependent CastIINodes. |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1900 void Compile::remove_range_check_casts(PhaseIterGVN &igvn) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1901 for (int i = range_check_cast_count(); i > 0; i--) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1902 Node* cast = range_check_cast_node(i-1); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1903 assert(cast->isa_CastII()->has_range_check(), "CastII should have range check dependency"); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1904 igvn.replace_node(cast, cast->in(1)); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1905 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1906 assert(range_check_cast_count() == 0, "should be empty"); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1907 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
1908 |
7473 | 1909 // StringOpts and late inlining of string methods |
1910 void Compile::inline_string_calls(bool parse_time) { | |
1911 { | |
1912 // remove useless nodes to make the usage analysis simpler | |
1913 ResourceMark rm; | |
1914 PhaseRemoveUseless pru(initial_gvn(), for_igvn()); | |
1915 } | |
1916 | |
1917 { | |
1918 ResourceMark rm; | |
10405 | 1919 print_method(PHASE_BEFORE_STRINGOPTS, 3); |
7473 | 1920 PhaseStringOpts pso(initial_gvn(), for_igvn()); |
10405 | 1921 print_method(PHASE_AFTER_STRINGOPTS, 3); |
7473 | 1922 } |
1923 | |
1924 // now inline anything that we skipped the first time around | |
1925 if (!parse_time) { | |
1926 _late_inlines_pos = _late_inlines.length(); | |
1927 } | |
1928 | |
1929 while (_string_late_inlines.length() > 0) { | |
1930 CallGenerator* cg = _string_late_inlines.pop(); | |
1931 cg->do_late_inline(); | |
1932 if (failing()) return; | |
1933 } | |
1934 _string_late_inlines.trunc_to(0); | |
1935 } | |
1936 | |
10278 | 1937 // Late inlining of boxing methods |
1938 void Compile::inline_boxing_calls(PhaseIterGVN& igvn) { | |
1939 if (_boxing_late_inlines.length() > 0) { | |
1940 assert(has_boxed_value(), "inconsistent"); | |
1941 | |
1942 PhaseGVN* gvn = initial_gvn(); | |
1943 set_inlining_incrementally(true); | |
1944 | |
1945 assert( igvn._worklist.size() == 0, "should be done with igvn" ); | |
1946 for_igvn()->clear(); | |
1947 gvn->replace_with(&igvn); | |
1948 | |
20327
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
1949 _late_inlines_pos = _late_inlines.length(); |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
1950 |
10278 | 1951 while (_boxing_late_inlines.length() > 0) { |
1952 CallGenerator* cg = _boxing_late_inlines.pop(); | |
1953 cg->do_late_inline(); | |
1954 if (failing()) return; | |
1955 } | |
1956 _boxing_late_inlines.trunc_to(0); | |
1957 | |
1958 { | |
1959 ResourceMark rm; | |
1960 PhaseRemoveUseless pru(gvn, for_igvn()); | |
1961 } | |
1962 | |
1963 igvn = PhaseIterGVN(gvn); | |
1964 igvn.optimize(); | |
1965 | |
1966 set_inlining_progress(false); | |
1967 set_inlining_incrementally(false); | |
1968 } | |
1969 } | |
1970 | |
7473 | 1971 void Compile::inline_incrementally_one(PhaseIterGVN& igvn) { |
1972 assert(IncrementalInline, "incremental inlining should be on"); | |
1973 PhaseGVN* gvn = initial_gvn(); | |
1974 | |
1975 set_inlining_progress(false); | |
1976 for_igvn()->clear(); | |
1977 gvn->replace_with(&igvn); | |
1978 | |
1979 int i = 0; | |
1980 | |
1981 for (; i <_late_inlines.length() && !inlining_progress(); i++) { | |
1982 CallGenerator* cg = _late_inlines.at(i); | |
1983 _late_inlines_pos = i+1; | |
1984 cg->do_late_inline(); | |
1985 if (failing()) return; | |
1986 } | |
1987 int j = 0; | |
1988 for (; i < _late_inlines.length(); i++, j++) { | |
1989 _late_inlines.at_put(j, _late_inlines.at(i)); | |
1990 } | |
1991 _late_inlines.trunc_to(j); | |
1992 | |
1993 { | |
1994 ResourceMark rm; | |
10278 | 1995 PhaseRemoveUseless pru(gvn, for_igvn()); |
7473 | 1996 } |
1997 | |
1998 igvn = PhaseIterGVN(gvn); | |
1999 } | |
2000 | |
2001 // Perform incremental inlining until bound on number of live nodes is reached | |
2002 void Compile::inline_incrementally(PhaseIterGVN& igvn) { | |
2003 PhaseGVN* gvn = initial_gvn(); | |
2004 | |
2005 set_inlining_incrementally(true); | |
2006 set_inlining_progress(true); | |
2007 uint low_live_nodes = 0; | |
2008 | |
2009 while(inlining_progress() && _late_inlines.length() > 0) { | |
2010 | |
2011 if (live_nodes() > (uint)LiveNodeCountInliningCutoff) { | |
2012 if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) { | |
2013 // PhaseIdealLoop is expensive so we only try it once we are | |
20327
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
2014 // out of live nodes and we only try it again if the previous |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
2015 // helped got the number of nodes down significantly |
7473 | 2016 PhaseIdealLoop ideal_loop( igvn, false, true ); |
2017 if (failing()) return; | |
2018 low_live_nodes = live_nodes(); | |
2019 _major_progress = true; | |
2020 } | |
2021 | |
2022 if (live_nodes() > (uint)LiveNodeCountInliningCutoff) { | |
2023 break; | |
2024 } | |
2025 } | |
2026 | |
2027 inline_incrementally_one(igvn); | |
2028 | |
2029 if (failing()) return; | |
2030 | |
2031 igvn.optimize(); | |
2032 | |
2033 if (failing()) return; | |
2034 } | |
2035 | |
2036 assert( igvn._worklist.size() == 0, "should be done with igvn" ); | |
2037 | |
2038 if (_string_late_inlines.length() > 0) { | |
2039 assert(has_stringbuilder(), "inconsistent"); | |
2040 for_igvn()->clear(); | |
2041 initial_gvn()->replace_with(&igvn); | |
2042 | |
2043 inline_string_calls(false); | |
2044 | |
2045 if (failing()) return; | |
2046 | |
2047 { | |
2048 ResourceMark rm; | |
2049 PhaseRemoveUseless pru(initial_gvn(), for_igvn()); | |
2050 } | |
2051 | |
2052 igvn = PhaseIterGVN(gvn); | |
2053 | |
2054 igvn.optimize(); | |
2055 } | |
2056 | |
2057 set_inlining_incrementally(false); | |
2058 } | |
2059 | |
2060 | |
0 | 2061 //------------------------------Optimize--------------------------------------- |
2062 // Given a graph, optimize it. | |
2063 void Compile::Optimize() { | |
2064 TracePhase t1("optimizer", &_t_optimizer, true); | |
2065 | |
2066 #ifndef PRODUCT | |
2067 if (env()->break_at_compile()) { | |
2068 BREAKPOINT; | |
2069 } | |
2070 | |
2071 #endif | |
2072 | |
2073 ResourceMark rm; | |
2074 int loop_opts_cnt; | |
2075 | |
2076 NOT_PRODUCT( verify_graph_edges(); ) | |
2077 | |
10405 | 2078 print_method(PHASE_AFTER_PARSING); |
0 | 2079 |
2080 { | |
2081 // Iterative Global Value Numbering, including ideal transforms | |
2082 // Initialize IterGVN with types and values from parse-time GVN | |
2083 PhaseIterGVN igvn(initial_gvn()); | |
2084 { | |
2085 NOT_PRODUCT( TracePhase t2("iterGVN", &_t_iterGVN, TimeCompiler); ) | |
2086 igvn.optimize(); | |
2087 } | |
2088 | |
10405 | 2089 print_method(PHASE_ITER_GVN1, 2); |
0 | 2090 |
2091 if (failing()) return; | |
2092 | |
10278 | 2093 { |
2094 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) | |
2095 inline_incrementally(igvn); | |
2096 } | |
7473 | 2097 |
10405 | 2098 print_method(PHASE_INCREMENTAL_INLINE, 2); |
7473 | 2099 |
2100 if (failing()) return; | |
2101 | |
10278 | 2102 if (eliminate_boxing()) { |
2103 NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); ) | |
2104 // Inline valueOf() methods now. | |
2105 inline_boxing_calls(igvn); | |
2106 | |
20327
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
2107 if (AlwaysIncrementalInline) { |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
2108 inline_incrementally(igvn); |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
2109 } |
411e30e5fbb8
8026796: Make replace_in_map() on parent maps generic
roland
parents:
17980
diff
changeset
|
2110 |
10405 | 2111 print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2); |
10278 | 2112 |
2113 if (failing()) return; | |
2114 } | |
2115 | |
12966 | 2116 // Remove the speculative part of types and clean up the graph from |
2117 // the extra CastPP nodes whose only purpose is to carry them. Do | |
2118 // that early so that optimizations are not disrupted by the extra | |
2119 // CastPP nodes. | |
2120 remove_speculative_types(igvn); | |
2121 | |
8048
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
2122 // No more new expensive nodes will be added to the list from here |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
2123 // so keep only the actual candidates for optimizations. |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
2124 cleanup_expensive_nodes(igvn); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
2125 |
23471
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2126 if (!failing() && RenumberLiveNodes && live_nodes() + NodeLimitFudgeFactor < unique()) { |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2127 NOT_PRODUCT(Compile::TracePhase t2("", &_t_renumberLive, TimeCompiler);) |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2128 initial_gvn()->replace_with(&igvn); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2129 for_igvn()->clear(); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2130 Unique_Node_List new_worklist(C->comp_arena()); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2131 { |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2132 ResourceMark rm; |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2133 PhaseRenumberLive prl = PhaseRenumberLive(initial_gvn(), for_igvn(), &new_worklist); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2134 } |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2135 set_for_igvn(&new_worklist); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2136 igvn = PhaseIterGVN(initial_gvn()); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2137 igvn.optimize(); |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2138 } |
70649f10b88c
8129847: Compiling methods generated by Nashorn triggers high memory usage in C2
zmajo
parents:
23421
diff
changeset
|
2139 |
1634
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2140 // Perform escape analysis |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2141 if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) { |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
2142 if (has_loops()) { |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
2143 // Cleanup graph (remove dead nodes). |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
2144 TracePhase t2("idealLoop", &_t_idealLoop, true); |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
2145 PhaseIdealLoop ideal_loop( igvn, false, true ); |
10405 | 2146 if (major_progress()) print_method(PHASE_PHASEIDEAL_BEFORE_EA, 2); |
4064
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
2147 if (failing()) return; |
670a74b863fc
7107042: assert(no_dead_loop) failed: dead loop detected
kvn
parents:
3899
diff
changeset
|
2148 } |
1634
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2149 ConnectionGraph::do_analysis(this, &igvn); |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2150 |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2151 if (failing()) return; |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2152 |
4115 | 2153 // Optimize out fields loads from scalar replaceable allocations. |
1634
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2154 igvn.optimize(); |
10405 | 2155 print_method(PHASE_ITER_GVN_AFTER_EA, 2); |
1634
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2156 |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2157 if (failing()) return; |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2158 |
4115 | 2159 if (congraph() != NULL && macro_count() > 0) { |
5948
ee138854b3a6
7147744: CTW: assert(false) failed: infinite EA connection graph build
kvn
parents:
4767
diff
changeset
|
2160 NOT_PRODUCT( TracePhase t2("macroEliminate", &_t_macroEliminate, TimeCompiler); ) |
4115 | 2161 PhaseMacroExpand mexp(igvn); |
2162 mexp.eliminate_macro_nodes(); | |
2163 igvn.set_delay_transform(false); | |
2164 | |
2165 igvn.optimize(); | |
10405 | 2166 print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2); |
4115 | 2167 |
2168 if (failing()) return; | |
2169 } | |
1634
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2170 } |
60a14ad85270
6966411: escape.cpp:450 assert(base->Opcode() == Op_ConP
kvn
parents:
1609
diff
changeset
|
2171 |
0 | 2172 // Loop transforms on the ideal graph. Range Check Elimination, |
2173 // peeling, unrolling, etc. | |
2174 | |
2175 // Set loop opts counter | |
2176 loop_opts_cnt = num_loop_opts(); | |
2177 if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) { | |
2178 { | |
2179 TracePhase t2("idealLoop", &_t_idealLoop, true); | |
2445 | 2180 PhaseIdealLoop ideal_loop( igvn, true ); |
0 | 2181 loop_opts_cnt--; |
10405 | 2182 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP1, 2); |
0 | 2183 if (failing()) return; |
2184 } | |
2185 // Loop opts pass if partial peeling occurred in previous pass | |
2186 if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) { | |
2187 TracePhase t3("idealLoop", &_t_idealLoop, true); | |
2445 | 2188 PhaseIdealLoop ideal_loop( igvn, false ); |
0 | 2189 loop_opts_cnt--; |
10405 | 2190 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP2, 2); |
0 | 2191 if (failing()) return; |
2192 } | |
2193 // Loop opts pass for loop-unrolling before CCP | |
2194 if(major_progress() && (loop_opts_cnt > 0)) { | |
2195 TracePhase t4("idealLoop", &_t_idealLoop, true); | |
2445 | 2196 PhaseIdealLoop ideal_loop( igvn, false ); |
0 | 2197 loop_opts_cnt--; |
10405 | 2198 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP3, 2); |
0 | 2199 } |
921
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2200 if (!failing()) { |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2201 // Verify that last round of loop opts produced a valid graph |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2202 NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2203 PhaseIdealLoop::verify(igvn); |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2204 } |
0 | 2205 } |
2206 if (failing()) return; | |
2207 | |
2208 // Conditional Constant Propagation; | |
2209 PhaseCCP ccp( &igvn ); | |
2210 assert( true, "Break here to ccp.dump_nodes_and_types(_root,999,1)"); | |
2211 { | |
2212 TracePhase t2("ccp", &_t_ccp, true); | |
2213 ccp.do_transform(); | |
2214 } | |
10405 | 2215 print_method(PHASE_CPP1, 2); |
0 | 2216 |
2217 assert( true, "Break here to ccp.dump_old2new_map()"); | |
2218 | |
2219 // Iterative Global Value Numbering, including ideal transforms | |
2220 { | |
2221 NOT_PRODUCT( TracePhase t2("iterGVN2", &_t_iterGVN2, TimeCompiler); ) | |
2222 igvn = ccp; | |
2223 igvn.optimize(); | |
2224 } | |
2225 | |
10405 | 2226 print_method(PHASE_ITER_GVN2, 2); |
0 | 2227 |
2228 if (failing()) return; | |
2229 | |
2230 // Loop transforms on the ideal graph. Range Check Elimination, | |
2231 // peeling, unrolling, etc. | |
2232 if(loop_opts_cnt > 0) { | |
2233 debug_only( int cnt = 0; ); | |
2234 while(major_progress() && (loop_opts_cnt > 0)) { | |
2235 TracePhase t2("idealLoop", &_t_idealLoop, true); | |
2236 assert( cnt++ < 40, "infinite cycle in loop optimization" ); | |
2445 | 2237 PhaseIdealLoop ideal_loop( igvn, true); |
0 | 2238 loop_opts_cnt--; |
10405 | 2239 if (major_progress()) print_method(PHASE_PHASEIDEALLOOP_ITERATIONS, 2); |
0 | 2240 if (failing()) return; |
2241 } | |
2242 } | |
19824
8b7a143aea6b
Local fix for JDK-8075105
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18041
diff
changeset
|
2243 // Ensure that major progress is now clear |
8b7a143aea6b
Local fix for JDK-8075105
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18041
diff
changeset
|
2244 C->clear_major_progress(); |
921
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2245 |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2246 { |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2247 // Verify that all previous optimizations produced a valid graph |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2248 // at least to this point, even if no loop optimizations were done. |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2249 NOT_PRODUCT( TracePhase t2("idealLoopVerify", &_t_idealLoopVerify, TimeCompiler); ) |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2250 PhaseIdealLoop::verify(igvn); |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2251 } |
046932b72aa2
6862956: PhaseIdealLoop should have a CFG verification mode
never
parents:
859
diff
changeset
|
2252 |
23872
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
2253 if (range_check_cast_count() > 0) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
2254 // No more loop optimizations. Remove all range check dependent CastIINodes. |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
2255 C->remove_range_check_casts(igvn); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
2256 igvn.optimize(); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
2257 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
2258 |
0 | 2259 { |
2260 NOT_PRODUCT( TracePhase t2("macroExpand", &_t_macroExpand, TimeCompiler); ) | |
2261 PhaseMacroExpand mex(igvn); | |
2262 if (mex.expand_macro_nodes()) { | |
2263 assert(failing(), "must bail out w/ explicit message"); | |
2264 return; | |
2265 } | |
2266 } | |
2267 | |
2268 } // (End scope of igvn; run destructor if necessary for asserts.) | |
2269 | |
7605 | 2270 dump_inlining(); |
0 | 2271 // A method with only infinite loops has no edges entering loops from root |
2272 { | |
2273 NOT_PRODUCT( TracePhase t2("graphReshape", &_t_graphReshaping, TimeCompiler); ) | |
2274 if (final_graph_reshaping()) { | |
2275 assert(failing(), "must bail out w/ explicit message"); | |
2276 return; | |
2277 } | |
2278 } | |
2279 | |
10405 | 2280 print_method(PHASE_OPTIMIZE_FINISHED, 2); |
0 | 2281 } |
2282 | |
2283 | |
2284 //------------------------------Code_Gen--------------------------------------- | |
2285 // Given a graph, generate code for it | |
2286 void Compile::Code_Gen() { | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2287 if (failing()) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2288 return; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2289 } |
0 | 2290 |
2291 // Perform instruction selection. You might think we could reclaim Matcher | |
2292 // memory PDQ, but actually the Matcher is used in generating spill code. | |
2293 // Internals of the Matcher (including some VectorSets) must remain live | |
2294 // for awhile - thus I cannot reclaim Matcher memory lest a VectorSet usage | |
2295 // set a bit in reclaimed memory. | |
2296 | |
2297 // In debug mode can dump m._nodes.dump() for mapping of ideal to machine | |
2298 // nodes. Mapping is only valid at the root of each matched subtree. | |
2299 NOT_PRODUCT( verify_graph_edges(); ) | |
2300 | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2301 Matcher matcher; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2302 _matcher = &matcher; |
0 | 2303 { |
2304 TracePhase t2("matcher", &_t_matcher, true); | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2305 matcher.match(); |
0 | 2306 } |
2307 // In debug mode can dump m._nodes.dump() for mapping of ideal to machine | |
2308 // nodes. Mapping is only valid at the root of each matched subtree. | |
2309 NOT_PRODUCT( verify_graph_edges(); ) | |
2310 | |
2311 // If you have too many nodes, or if matching has failed, bail out | |
2312 check_node_count(0, "out of nodes matching instructions"); | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2313 if (failing()) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2314 return; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2315 } |
0 | 2316 |
2317 // Build a proper-looking CFG | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2318 PhaseCFG cfg(node_arena(), root(), matcher); |
0 | 2319 _cfg = &cfg; |
2320 { | |
2321 NOT_PRODUCT( TracePhase t2("scheduler", &_t_scheduler, TimeCompiler); ) | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2322 bool success = cfg.do_global_code_motion(); |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2323 if (!success) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2324 return; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2325 } |
0 | 2326 |
10405 | 2327 print_method(PHASE_GLOBAL_CODE_MOTION, 2); |
0 | 2328 NOT_PRODUCT( verify_graph_edges(); ) |
2329 debug_only( cfg.verify(); ) | |
2330 } | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2331 |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2332 PhaseChaitin regalloc(unique(), cfg, matcher); |
0 | 2333 _regalloc = ®alloc; |
2334 { | |
2335 TracePhase t2("regalloc", &_t_registerAllocation, true); | |
2336 // Perform register allocation. After Chaitin, use-def chains are | |
2337 // no longer accurate (at spill code) and so must be ignored. | |
2338 // Node->LRG->reg mappings are still accurate. | |
2339 _regalloc->Register_Allocate(); | |
2340 | |
2341 // Bail out if the allocator builds too many nodes | |
10111 | 2342 if (failing()) { |
2343 return; | |
2344 } | |
0 | 2345 } |
2346 | |
2347 // Prior to register allocation we kept empty basic blocks in case the | |
2348 // the allocator needed a place to spill. After register allocation we | |
2349 // are not adding any new instructions. If any basic block is empty, we | |
2350 // can now safely remove it. | |
2351 { | |
418 | 2352 NOT_PRODUCT( TracePhase t2("blockOrdering", &_t_blockOrdering, TimeCompiler); ) |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2353 cfg.remove_empty_blocks(); |
418 | 2354 if (do_freq_based_layout()) { |
2355 PhaseBlockLayout layout(cfg); | |
2356 } else { | |
2357 cfg.set_loop_alignment(); | |
2358 } | |
2359 cfg.fixup_flow(); | |
0 | 2360 } |
2361 | |
2362 // Apply peephole optimizations | |
2363 if( OptoPeephole ) { | |
2364 NOT_PRODUCT( TracePhase t2("peephole", &_t_peephole, TimeCompiler); ) | |
2365 PhasePeephole peep( _regalloc, cfg); | |
2366 peep.do_transform(); | |
2367 } | |
2368 | |
14428
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
2369 // Do late expand if CPU requires this. |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
2370 if (Matcher::require_postalloc_expand) { |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
2371 NOT_PRODUCT(TracePhase t2c("postalloc_expand", &_t_postalloc_expand, true)); |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
2372 cfg.postalloc_expand(_regalloc); |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
2373 } |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
2374 |
0 | 2375 // Convert Nodes to instruction bits in a buffer |
2376 { | |
2377 // %%%% workspace merge brought two timers together for one job | |
2378 TracePhase t2a("output", &_t_output, true); | |
2379 NOT_PRODUCT( TraceTime t2b(NULL, &_t_codeGeneration, TimeCompiler, false); ) | |
2380 Output(); | |
2381 } | |
2382 | |
10405 | 2383 print_method(PHASE_FINAL_CODE); |
0 | 2384 |
2385 // He's dead, Jim. | |
2386 _cfg = (PhaseCFG*)0xdeadbeef; | |
2387 _regalloc = (PhaseChaitin*)0xdeadbeef; | |
2388 } | |
2389 | |
2390 | |
2391 //------------------------------dump_asm--------------------------------------- | |
2392 // Dump formatted assembly | |
2393 #ifndef PRODUCT | |
2394 void Compile::dump_asm(int *pcs, uint pc_limit) { | |
2395 bool cut_short = false; | |
2396 tty->print_cr("#"); | |
2397 tty->print("# "); _tf->dump(); tty->cr(); | |
2398 tty->print_cr("#"); | |
2399 | |
2400 // For all blocks | |
2401 int pc = 0x0; // Program counter | |
2402 char starts_bundle = ' '; | |
2403 _regalloc->dump_frame(); | |
2404 | |
2405 Node *n = NULL; | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2406 for (uint i = 0; i < _cfg->number_of_blocks(); i++) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2407 if (VMThread::should_terminate()) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2408 cut_short = true; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2409 break; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2410 } |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2411 Block* block = _cfg->get_block(i); |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2412 if (block->is_connector() && !Verbose) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2413 continue; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2414 } |
12167
650868c062a9
8023691: Create interface for nodes in class Block
adlertz
parents:
12071
diff
changeset
|
2415 n = block->head(); |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2416 if (pcs && n->_idx < pc_limit) { |
0 | 2417 tty->print("%3.3x ", pcs[n->_idx]); |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2418 } else { |
0 | 2419 tty->print(" "); |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2420 } |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2421 block->dump_head(_cfg); |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2422 if (block->is_connector()) { |
0 | 2423 tty->print_cr(" # Empty connector block"); |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2424 } else if (block->num_preds() == 2 && block->pred(1)->is_CatchProj() && block->pred(1)->as_CatchProj()->_con == CatchProjNode::fall_through_index) { |
0 | 2425 tty->print_cr(" # Block is sole successor of call"); |
2426 } | |
2427 | |
2428 // For all instructions | |
2429 Node *delay = NULL; | |
12167
650868c062a9
8023691: Create interface for nodes in class Block
adlertz
parents:
12071
diff
changeset
|
2430 for (uint j = 0; j < block->number_of_nodes(); j++) { |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2431 if (VMThread::should_terminate()) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2432 cut_short = true; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2433 break; |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2434 } |
12167
650868c062a9
8023691: Create interface for nodes in class Block
adlertz
parents:
12071
diff
changeset
|
2435 n = block->get_node(j); |
0 | 2436 if (valid_bundle_info(n)) { |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2437 Bundle* bundle = node_bundling(n); |
0 | 2438 if (bundle->used_in_unconditional_delay()) { |
2439 delay = n; | |
2440 continue; | |
2441 } | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2442 if (bundle->starts_bundle()) { |
0 | 2443 starts_bundle = '+'; |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2444 } |
0 | 2445 } |
2446 | |
12071
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2447 if (WizardMode) { |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2448 n->dump(); |
adb9a7d94cb5
8023003: Cleanup the public interface to PhaseCFG
adlertz
parents:
12023
diff
changeset
|
2449 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2450 |
0 | 2451 if( !n->is_Region() && // Dont print in the Assembly |
2452 !n->is_Phi() && // a few noisely useless nodes | |
2453 !n->is_Proj() && | |
2454 !n->is_MachTemp() && | |
1100
f96a1a986f7b
6895383: JCK test throws NPE for method compiled with Escape Analysis
kvn
parents:
1080
diff
changeset
|
2455 !n->is_SafePointScalarObject() && |
0 | 2456 !n->is_Catch() && // Would be nice to print exception table targets |
2457 !n->is_MergeMem() && // Not very interesting | |
2458 !n->is_top() && // Debug info table constants | |
2459 !(n->is_Con() && !n->is_Mach())// Debug info table constants | |
2460 ) { | |
2461 if (pcs && n->_idx < pc_limit) | |
2462 tty->print("%3.3x", pcs[n->_idx]); | |
2463 else | |
2464 tty->print(" "); | |
2465 tty->print(" %c ", starts_bundle); | |
2466 starts_bundle = ' '; | |
2467 tty->print("\t"); | |
2468 n->format(_regalloc, tty); | |
2469 tty->cr(); | |
2470 } | |
2471 | |
2472 // If we have an instruction with a delay slot, and have seen a delay, | |
2473 // then back up and print it | |
2474 if (valid_bundle_info(n) && node_bundling(n)->use_unconditional_delay()) { | |
2475 assert(delay != NULL, "no unconditional delay instruction"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2476 if (WizardMode) delay->dump(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2477 |
0 | 2478 if (node_bundling(delay)->starts_bundle()) |
2479 starts_bundle = '+'; | |
2480 if (pcs && n->_idx < pc_limit) | |
2481 tty->print("%3.3x", pcs[n->_idx]); | |
2482 else | |
2483 tty->print(" "); | |
2484 tty->print(" %c ", starts_bundle); | |
2485 starts_bundle = ' '; | |
2486 tty->print("\t"); | |
2487 delay->format(_regalloc, tty); | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
2488 tty->cr(); |
0 | 2489 delay = NULL; |
2490 } | |
2491 | |
2492 // Dump the exception table as well | |
2493 if( n->is_Catch() && (Verbose || WizardMode) ) { | |
2494 // Print the exception table for this offset | |
2495 _handler_table.print_subtable_for(pc); | |
2496 } | |
2497 } | |
2498 | |
2499 if (pcs && n->_idx < pc_limit) | |
2500 tty->print_cr("%3.3x", pcs[n->_idx]); | |
2501 else | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
2502 tty->cr(); |
0 | 2503 |
2504 assert(cut_short || delay == NULL, "no unconditional delay branch"); | |
2505 | |
2506 } // End of per-block dump | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
2507 tty->cr(); |
0 | 2508 |
2509 if (cut_short) tty->print_cr("*** disassembly is cut short ***"); | |
2510 } | |
2511 #endif | |
2512 | |
2513 //------------------------------Final_Reshape_Counts--------------------------- | |
2514 // This class defines counters to help identify when a method | |
2515 // may/must be executed using hardware with only 24-bit precision. | |
2516 struct Final_Reshape_Counts : public StackObj { | |
2517 int _call_count; // count non-inlined 'common' calls | |
2518 int _float_count; // count float ops requiring 24-bit precision | |
2519 int _double_count; // count double ops requiring more precision | |
2520 int _java_call_count; // count non-inlined 'java' calls | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2521 int _inner_loop_count; // count loops which need alignment |
0 | 2522 VectorSet _visited; // Visitation flags |
2523 Node_List _tests; // Set of IfNodes & PCTableNodes | |
2524 | |
2525 Final_Reshape_Counts() : | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2526 _call_count(0), _float_count(0), _double_count(0), |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2527 _java_call_count(0), _inner_loop_count(0), |
0 | 2528 _visited( Thread::current()->resource_area() ) { } |
2529 | |
2530 void inc_call_count () { _call_count ++; } | |
2531 void inc_float_count () { _float_count ++; } | |
2532 void inc_double_count() { _double_count++; } | |
2533 void inc_java_call_count() { _java_call_count++; } | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2534 void inc_inner_loop_count() { _inner_loop_count++; } |
0 | 2535 |
2536 int get_call_count () const { return _call_count ; } | |
2537 int get_float_count () const { return _float_count ; } | |
2538 int get_double_count() const { return _double_count; } | |
2539 int get_java_call_count() const { return _java_call_count; } | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2540 int get_inner_loop_count() const { return _inner_loop_count; } |
0 | 2541 }; |
2542 | |
9060
cc32ccaaf47f
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
8730
diff
changeset
|
2543 #ifdef ASSERT |
0 | 2544 static bool oop_offset_is_sane(const TypeInstPtr* tp) { |
2545 ciInstanceKlass *k = tp->klass()->as_instance_klass(); | |
2546 // Make sure the offset goes inside the instance layout. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2547 return k->contains_field_offset(tp->offset()); |
0 | 2548 // Note that OffsetBot and OffsetTop are very negative. |
2549 } | |
9060
cc32ccaaf47f
8003310: Enable -Wunused-function when compiling with gcc
mikael
parents:
8730
diff
changeset
|
2550 #endif |
0 | 2551 |
3248
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2552 // Eliminate trivially redundant StoreCMs and accumulate their |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2553 // precedence edges. |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2554 void Compile::eliminate_redundant_card_marks(Node* n) { |
3248
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2555 assert(n->Opcode() == Op_StoreCM, "expected StoreCM"); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2556 if (n->in(MemNode::Address)->outcnt() > 1) { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2557 // There are multiple users of the same address so it might be |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2558 // possible to eliminate some of the StoreCMs |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2559 Node* mem = n->in(MemNode::Memory); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2560 Node* adr = n->in(MemNode::Address); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2561 Node* val = n->in(MemNode::ValueIn); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2562 Node* prev = n; |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2563 bool done = false; |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2564 // Walk the chain of StoreCMs eliminating ones that match. As |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2565 // long as it's a chain of single users then the optimization is |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2566 // safe. Eliminating partially redundant StoreCMs would require |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2567 // cloning copies down the other paths. |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2568 while (mem->Opcode() == Op_StoreCM && mem->outcnt() == 1 && !done) { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2569 if (adr == mem->in(MemNode::Address) && |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2570 val == mem->in(MemNode::ValueIn)) { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2571 // redundant StoreCM |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2572 if (mem->req() > MemNode::OopStore) { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2573 // Hasn't been processed by this code yet. |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2574 n->add_prec(mem->in(MemNode::OopStore)); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2575 } else { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2576 // Already converted to precedence edge |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2577 for (uint i = mem->req(); i < mem->len(); i++) { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2578 // Accumulate any precedence edges |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2579 if (mem->in(i) != NULL) { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2580 n->add_prec(mem->in(i)); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2581 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2582 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2583 // Everything above this point has been processed. |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2584 done = true; |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2585 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2586 // Eliminate the previous StoreCM |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2587 prev->set_req(MemNode::Memory, mem->in(MemNode::Memory)); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2588 assert(mem->outcnt() == 0, "should be dead"); |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2589 mem->disconnect_inputs(NULL, this); |
3248
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2590 } else { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2591 prev = mem; |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2592 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2593 mem = prev->in(MemNode::Memory); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2594 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2595 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2596 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2597 |
0 | 2598 //------------------------------final_graph_reshaping_impl---------------------- |
2599 // Implement items 1-5 from final_graph_reshaping below. | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2600 void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { |
0 | 2601 |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
2602 if ( n->outcnt() == 0 ) return; // dead node |
0 | 2603 uint nop = n->Opcode(); |
2604 | |
2605 // Check for 2-input instruction with "last use" on right input. | |
2606 // Swap to left input. Implements item (2). | |
2607 if( n->req() == 3 && // two-input instruction | |
2608 n->in(1)->outcnt() > 1 && // left use is NOT a last use | |
2609 (!n->in(1)->is_Phi() || n->in(1)->in(2) != n) && // it is not data loop | |
2610 n->in(2)->outcnt() == 1 &&// right use IS a last use | |
2611 !n->in(2)->is_Con() ) { // right use is not a constant | |
2612 // Check for commutative opcode | |
2613 switch( nop ) { | |
2614 case Op_AddI: case Op_AddF: case Op_AddD: case Op_AddL: | |
2615 case Op_MaxI: case Op_MinI: | |
2616 case Op_MulI: case Op_MulF: case Op_MulD: case Op_MulL: | |
2617 case Op_AndL: case Op_XorL: case Op_OrL: | |
2618 case Op_AndI: case Op_XorI: case Op_OrI: { | |
2619 // Move "last use" input to left by swapping inputs | |
2620 n->swap_edges(1, 2); | |
2621 break; | |
2622 } | |
2623 default: | |
2624 break; | |
2625 } | |
2626 } | |
2627 | |
1609 | 2628 #ifdef ASSERT |
2629 if( n->is_Mem() ) { | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2630 int alias_idx = get_alias_index(n->as_Mem()->adr_type()); |
1609 | 2631 assert( n->in(0) != NULL || alias_idx != Compile::AliasIdxRaw || |
2632 // oop will be recorded in oop map if load crosses safepoint | |
2633 n->is_Load() && (n->as_Load()->bottom_type()->isa_oopptr() || | |
2634 LoadNode::is_immutable_value(n->in(MemNode::Address))), | |
2635 "raw memory operations should have control edge"); | |
2636 } | |
2637 #endif | |
0 | 2638 // Count FPU ops and common calls, implements item (3) |
2639 switch( nop ) { | |
2640 // Count all float operations that may use FPU | |
2641 case Op_AddF: | |
2642 case Op_SubF: | |
2643 case Op_MulF: | |
2644 case Op_DivF: | |
2645 case Op_NegF: | |
2646 case Op_ModF: | |
2647 case Op_ConvI2F: | |
2648 case Op_ConF: | |
2649 case Op_CmpF: | |
2650 case Op_CmpF3: | |
2651 // case Op_ConvL2F: // longs are split into 32-bit halves | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2652 frc.inc_float_count(); |
0 | 2653 break; |
2654 | |
2655 case Op_ConvF2D: | |
2656 case Op_ConvD2F: | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2657 frc.inc_float_count(); |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2658 frc.inc_double_count(); |
0 | 2659 break; |
2660 | |
2661 // Count all double operations that may use FPU | |
2662 case Op_AddD: | |
2663 case Op_SubD: | |
2664 case Op_MulD: | |
2665 case Op_DivD: | |
2666 case Op_NegD: | |
2667 case Op_ModD: | |
2668 case Op_ConvI2D: | |
2669 case Op_ConvD2I: | |
2670 // case Op_ConvL2D: // handled by leaf call | |
2671 // case Op_ConvD2L: // handled by leaf call | |
2672 case Op_ConD: | |
2673 case Op_CmpD: | |
2674 case Op_CmpD3: | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2675 frc.inc_double_count(); |
0 | 2676 break; |
2677 case Op_Opaque1: // Remove Opaque Nodes before matching | |
2678 case Op_Opaque2: // Remove Opaque Nodes before matching | |
17780 | 2679 case Op_Opaque3: |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2680 n->subsume_by(n->in(1), this); |
0 | 2681 break; |
2682 case Op_CallStaticJava: | |
2683 case Op_CallJava: | |
2684 case Op_CallDynamicJava: | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2685 frc.inc_java_call_count(); // Count java call site; |
0 | 2686 case Op_CallRuntime: |
2687 case Op_CallLeaf: | |
2688 case Op_CallLeafNoFP: { | |
2689 assert( n->is_Call(), "" ); | |
2690 CallNode *call = n->as_Call(); | |
2691 // Count call sites where the FP mode bit would have to be flipped. | |
2692 // Do not count uncommon runtime calls: | |
2693 // uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking, | |
2694 // _new_Java, _new_typeArray, _new_objArray, _rethrow_Java, ... | |
2695 if( !call->is_CallStaticJava() || !call->as_CallStaticJava()->_name ) { | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2696 frc.inc_call_count(); // Count the call site |
0 | 2697 } else { // See if uncommon argument is shared |
2698 Node *n = call->in(TypeFunc::Parms); | |
2699 int nop = n->Opcode(); | |
2700 // Clone shared simple arguments to uncommon calls, item (1). | |
2701 if( n->outcnt() > 1 && | |
2702 !n->is_Proj() && | |
2703 nop != Op_CreateEx && | |
2704 nop != Op_CheckCastPP && | |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2705 nop != Op_DecodeN && |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2706 nop != Op_DecodeNKlass && |
0 | 2707 !n->is_Mem() ) { |
2708 Node *x = n->clone(); | |
2709 call->set_req( TypeFunc::Parms, x ); | |
2710 } | |
2711 } | |
2712 break; | |
2713 } | |
2714 | |
2715 case Op_StoreD: | |
2716 case Op_LoadD: | |
2717 case Op_LoadD_unaligned: | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2718 frc.inc_double_count(); |
0 | 2719 goto handle_mem; |
2720 case Op_StoreF: | |
2721 case Op_LoadF: | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
2722 frc.inc_float_count(); |
0 | 2723 goto handle_mem; |
2724 | |
3248
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2725 case Op_StoreCM: |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2726 { |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2727 // Convert OopStore dependence into precedence edge |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2728 Node* prec = n->in(MemNode::OopStore); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2729 n->del_req(MemNode::OopStore); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2730 n->add_prec(prec); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2731 eliminate_redundant_card_marks(n); |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2732 } |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2733 |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2734 // fall through |
e6beb62de02d
7032963: StoreCM shouldn't participate in store elimination
never
parents:
2376
diff
changeset
|
2735 |
0 | 2736 case Op_StoreB: |
2737 case Op_StoreC: | |
2738 case Op_StorePConditional: | |
2739 case Op_StoreI: | |
2740 case Op_StoreL: | |
420
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
418
diff
changeset
|
2741 case Op_StoreIConditional: |
0 | 2742 case Op_StoreLConditional: |
2743 case Op_CompareAndSwapI: | |
2744 case Op_CompareAndSwapL: | |
2745 case Op_CompareAndSwapP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2746 case Op_CompareAndSwapN: |
6795
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6792
diff
changeset
|
2747 case Op_GetAndAddI: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6792
diff
changeset
|
2748 case Op_GetAndAddL: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6792
diff
changeset
|
2749 case Op_GetAndSetI: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6792
diff
changeset
|
2750 case Op_GetAndSetL: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6792
diff
changeset
|
2751 case Op_GetAndSetP: |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6792
diff
changeset
|
2752 case Op_GetAndSetN: |
0 | 2753 case Op_StoreP: |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2754 case Op_StoreN: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2755 case Op_StoreNKlass: |
0 | 2756 case Op_LoadB: |
624 | 2757 case Op_LoadUB: |
558
3b5ac9e7e6ea
6796746: rename LoadC (char) opcode class to LoadUS (unsigned short)
twisti
parents:
492
diff
changeset
|
2758 case Op_LoadUS: |
0 | 2759 case Op_LoadI: |
2760 case Op_LoadKlass: | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2761 case Op_LoadNKlass: |
0 | 2762 case Op_LoadL: |
2763 case Op_LoadL_unaligned: | |
2764 case Op_LoadPLocked: | |
2765 case Op_LoadP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
2766 case Op_LoadN: |
0 | 2767 case Op_LoadRange: |
2768 case Op_LoadS: { | |
2769 handle_mem: | |
2770 #ifdef ASSERT | |
2771 if( VerifyOptoOopOffsets ) { | |
2772 assert( n->is_Mem(), "" ); | |
2773 MemNode *mem = (MemNode*)n; | |
2774 // Check to see if address types have grounded out somehow. | |
2775 const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr(); | |
2776 assert( !tp || oop_offset_is_sane(tp), "" ); | |
2777 } | |
2778 #endif | |
2779 break; | |
2780 } | |
2781 | |
2782 case Op_AddP: { // Assert sane base pointers | |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2783 Node *addp = n->in(AddPNode::Address); |
0 | 2784 assert( !addp->is_AddP() || |
2785 addp->in(AddPNode::Base)->is_top() || // Top OK for allocation | |
2786 addp->in(AddPNode::Base) == n->in(AddPNode::Base), | |
2787 "Base pointers must match" ); | |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2788 #ifdef _LP64 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12167
diff
changeset
|
2789 if ((UseCompressedOops || UseCompressedClassPointers) && |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2790 addp->Opcode() == Op_ConP && |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2791 addp == n->in(AddPNode::Base) && |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2792 n->in(AddPNode::Offset)->is_Con()) { |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2793 // Use addressing with narrow klass to load with offset on x86. |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2794 // On sparc loading 32-bits constant and decoding it have less |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2795 // instructions (4) then load 64-bits constant (7). |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2796 // Do this transformation here since IGVN will convert ConN back to ConP. |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2797 const Type* t = addp->bottom_type(); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2798 if (t->isa_oopptr() || t->isa_klassptr()) { |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2799 Node* nn = NULL; |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2800 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2801 int op = t->isa_oopptr() ? Op_ConN : Op_ConNKlass; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2802 |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2803 // Look for existing ConN node of the same exact type. |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2804 Node* r = root(); |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2805 uint cnt = r->outcnt(); |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2806 for (uint i = 0; i < cnt; i++) { |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2807 Node* m = r->raw_out(i); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2808 if (m!= NULL && m->Opcode() == op && |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
182
diff
changeset
|
2809 m->bottom_type()->make_ptr() == t) { |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2810 nn = m; |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2811 break; |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2812 } |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2813 } |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2814 if (nn != NULL) { |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2815 // Decode a narrow oop to match address |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2816 // [R12 + narrow_oop_reg<<3 + offset] |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2817 if (t->isa_oopptr()) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2818 nn = new (this) DecodeNNode(nn, t); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2819 } else { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2820 nn = new (this) DecodeNKlassNode(nn, t); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2821 } |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2822 n->set_req(AddPNode::Base, nn); |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2823 n->set_req(AddPNode::Address, nn); |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2824 if (addp->outcnt() == 0) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2825 addp->disconnect_inputs(NULL, this); |
182
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2826 } |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2827 } |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2828 } |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2829 } |
44abbb0d4c18
6709093: Compressed Oops: reduce size of compiled methods
kvn
parents:
168
diff
changeset
|
2830 #endif |
0 | 2831 break; |
2832 } | |
2833 | |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2834 #ifdef _LP64 |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2835 case Op_CastPP: |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2836 if (n->in(1)->is_DecodeN() && Matcher::gen_narrow_oop_implicit_null_checks()) { |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2837 Node* in1 = n->in(1); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2838 const Type* t = n->bottom_type(); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2839 Node* new_in1 = in1->clone(); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2840 new_in1->as_DecodeN()->set_type(t); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2841 |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2842 if (!Matcher::narrow_oop_use_complex_address()) { |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2843 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2844 // x86, ARM and friends can handle 2 adds in addressing mode |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2845 // and Matcher can fold a DecodeN node into address by using |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2846 // a narrow oop directly and do implicit NULL check in address: |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2847 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2848 // [R12 + narrow_oop_reg<<3 + offset] |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2849 // NullCheck narrow_oop_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2850 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2851 // On other platforms (Sparc) we have to keep new DecodeN node and |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2852 // use it to do implicit NULL check in address: |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2853 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2854 // decode_not_null narrow_oop_reg, base_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2855 // [base_reg + offset] |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2856 // NullCheck base_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2857 // |
605 | 2858 // Pin the new DecodeN node to non-null path on these platform (Sparc) |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2859 // to keep the information to which NULL check the new DecodeN node |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2860 // corresponds to use it as value in implicit_null_check(). |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2861 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2862 new_in1->set_req(0, n->in(0)); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2863 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2864 |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2865 n->subsume_by(new_in1, this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2866 if (in1->outcnt() == 0) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2867 in1->disconnect_inputs(NULL, this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2868 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2869 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2870 break; |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2871 |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2872 case Op_CmpP: |
168
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
2873 // Do this transformation here to preserve CmpPNode::sub() and |
7793bd37a336
6705887: Compressed Oops: generate x64 addressing and implicit null checks with narrow oops
kvn
parents:
164
diff
changeset
|
2874 // other TypePtr related Ideal optimizations (for example, ptr nullness). |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2875 if (n->in(1)->is_DecodeNarrowPtr() || n->in(2)->is_DecodeNarrowPtr()) { |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2876 Node* in1 = n->in(1); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2877 Node* in2 = n->in(2); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2878 if (!in1->is_DecodeNarrowPtr()) { |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2879 in2 = in1; |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2880 in1 = n->in(2); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2881 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2882 assert(in1->is_DecodeNarrowPtr(), "sanity"); |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2883 |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2884 Node* new_in2 = NULL; |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2885 if (in2->is_DecodeNarrowPtr()) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2886 assert(in2->Opcode() == in1->Opcode(), "must be same node type"); |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2887 new_in2 = in2->in(1); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2888 } else if (in2->Opcode() == Op_ConP) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2889 const Type* t = in2->bottom_type(); |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2890 if (t == TypePtr::NULL_PTR) { |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2891 assert(in1->is_DecodeN(), "compare klass to null?"); |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2892 // Don't convert CmpP null check into CmpN if compressed |
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2893 // oops implicit null check is not generated. |
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2894 // This will allow to generate normal oop implicit null check. |
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2895 if (Matcher::gen_narrow_oop_implicit_null_checks()) |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2896 new_in2 = ConNode::make(this, TypeNarrowOop::NULL_PTR); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2897 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2898 // This transformation together with CastPP transformation above |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2899 // will generated code for implicit NULL checks for compressed oops. |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2900 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2901 // The original code after Optimize() |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2902 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2903 // LoadN memory, narrow_oop_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2904 // decode narrow_oop_reg, base_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2905 // CmpP base_reg, NULL |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2906 // CastPP base_reg // NotNull |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2907 // Load [base_reg + offset], val_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2908 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2909 // after these transformations will be |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2910 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2911 // LoadN memory, narrow_oop_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2912 // CmpN narrow_oop_reg, NULL |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2913 // decode_not_null narrow_oop_reg, base_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2914 // Load [base_reg + offset], val_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2915 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2916 // and the uncommon path (== NULL) will use narrow_oop_reg directly |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2917 // since narrow oops can be used in debug info now (see the code in |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2918 // final_graph_reshaping_walk()). |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2919 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2920 // At the end the code will be matched to |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2921 // on x86: |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2922 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2923 // Load_narrow_oop memory, narrow_oop_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2924 // Load [R12 + narrow_oop_reg<<3 + offset], val_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2925 // NullCheck narrow_oop_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2926 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2927 // and on sparc: |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2928 // |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2929 // Load_narrow_oop memory, narrow_oop_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2930 // decode_not_null narrow_oop_reg, base_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2931 // Load [base_reg + offset], val_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2932 // NullCheck base_reg |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2933 // |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2934 } else if (t->isa_oopptr()) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2935 new_in2 = ConNode::make(this, t->make_narrowoop()); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2936 } else if (t->isa_klassptr()) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2937 new_in2 = ConNode::make(this, t->make_narrowklass()); |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2938 } |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2939 } |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2940 if (new_in2 != NULL) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2941 Node* cmpN = new (this) CmpNNode(in1->in(1), new_in2); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2942 n->subsume_by(cmpN, this); |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2943 if (in1->outcnt() == 0) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2944 in1->disconnect_inputs(NULL, this); |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2945 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2946 if (in2->outcnt() == 0) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2947 in2->disconnect_inputs(NULL, this); |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
2948 } |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2949 } |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
2950 } |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
253
diff
changeset
|
2951 break; |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2952 |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2953 case Op_DecodeN: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2954 case Op_DecodeNKlass: |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2955 assert(!n->in(1)->is_EncodeNarrowPtr(), "should be optimized out"); |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
2956 // DecodeN could be pinned when it can't be fold into |
492
5496e074077f
6787050: assert(n->in(0) == 0L,"no control") with UseCompressedOops on sparcv9
kvn
parents:
490
diff
changeset
|
2957 // an address expression, see the code for Op_CastPP above. |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2958 assert(n->in(0) == NULL || (UseCompressedOops && !Matcher::narrow_oop_use_complex_address()), "no control"); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2959 break; |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2960 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2961 case Op_EncodeP: |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2962 case Op_EncodePKlass: { |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2963 Node* in1 = n->in(1); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2964 if (in1->is_DecodeNarrowPtr()) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2965 n->subsume_by(in1->in(1), this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2966 } else if (in1->Opcode() == Op_ConP) { |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2967 const Type* t = in1->bottom_type(); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2968 if (t == TypePtr::NULL_PTR) { |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2969 assert(t->isa_oopptr(), "null klass?"); |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2970 n->subsume_by(ConNode::make(this, TypeNarrowOop::NULL_PTR), this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2971 } else if (t->isa_oopptr()) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2972 n->subsume_by(ConNode::make(this, t->make_narrowoop()), this); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
2973 } else if (t->isa_klassptr()) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2974 n->subsume_by(ConNode::make(this, t->make_narrowklass()), this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2975 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2976 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2977 if (in1->outcnt() == 0) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
2978 in1->disconnect_inputs(NULL, this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2979 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2980 break; |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2981 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
2982 |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2983 case Op_Proj: { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2984 if (OptimizeStringConcat) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2985 ProjNode* p = n->as_Proj(); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2986 if (p->_is_io_use) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2987 // Separate projections were used for the exception path which |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2988 // are normally removed by a late inline. If it wasn't inlined |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2989 // then they will hang around and should just be replaced with |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2990 // the original one. |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2991 Node* proj = NULL; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2992 // Replace with just one |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2993 for (SimpleDUIterator i(p->in(0)); i.has_next(); i.next()) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2994 Node *use = i.get(); |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2995 if (use->is_Proj() && p != use && use->as_Proj()->_con == p->_con) { |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2996 proj = use; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2997 break; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2998 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
2999 } |
4767 | 3000 assert(proj != NULL, "must be found"); |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3001 p->subsume_by(proj, this); |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
3002 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
3003 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
3004 break; |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
3005 } |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
929
diff
changeset
|
3006 |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3007 case Op_Phi: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
3008 if (n->as_Phi()->bottom_type()->isa_narrowoop() || n->as_Phi()->bottom_type()->isa_narrowklass()) { |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3009 // The EncodeP optimization may create Phi with the same edges |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3010 // for all paths. It is not handled well by Register Allocator. |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3011 Node* unique_in = n->in(1); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3012 assert(unique_in != NULL, ""); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3013 uint cnt = n->req(); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3014 for (uint i = 2; i < cnt; i++) { |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3015 Node* m = n->in(i); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3016 assert(m != NULL, ""); |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3017 if (unique_in != m) |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3018 unique_in = NULL; |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3019 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3020 if (unique_in != NULL) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3021 n->subsume_by(unique_in, this); |
368
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3022 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3023 } |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3024 break; |
36ccc817fca4
6747051: Improve code and implicit null check generation for compressed oops
kvn
parents:
367
diff
changeset
|
3025 |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
3026 #endif |
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
163
diff
changeset
|
3027 |
23872
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3028 #ifdef ASSERT |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3029 case Op_CastII: |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3030 // Verify that all range check dependent CastII nodes were removed. |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3031 if (n->isa_CastII()->has_range_check()) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3032 n->dump(3); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3033 assert(false, "Range check dependent CastII node was not removed"); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3034 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3035 break; |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3036 #endif |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
3037 |
0 | 3038 case Op_ModI: |
3039 if (UseDivMod) { | |
3040 // Check if a%b and a/b both exist | |
3041 Node* d = n->find_similar(Op_DivI); | |
3042 if (d) { | |
3043 // Replace them with a fused divmod if supported | |
3044 if (Matcher::has_match_rule(Op_DivModI)) { | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3045 DivModINode* divmod = DivModINode::make(this, n); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3046 d->subsume_by(divmod->div_proj(), this); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3047 n->subsume_by(divmod->mod_proj(), this); |
0 | 3048 } else { |
3049 // replace a%b with a-((a/b)*b) | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3050 Node* mult = new (this) MulINode(d, d->in(2)); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3051 Node* sub = new (this) SubINode(d->in(1), mult); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3052 n->subsume_by(sub, this); |
0 | 3053 } |
3054 } | |
3055 } | |
3056 break; | |
3057 | |
3058 case Op_ModL: | |
3059 if (UseDivMod) { | |
3060 // Check if a%b and a/b both exist | |
3061 Node* d = n->find_similar(Op_DivL); | |
3062 if (d) { | |
3063 // Replace them with a fused divmod if supported | |
3064 if (Matcher::has_match_rule(Op_DivModL)) { | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3065 DivModLNode* divmod = DivModLNode::make(this, n); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3066 d->subsume_by(divmod->div_proj(), this); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3067 n->subsume_by(divmod->mod_proj(), this); |
0 | 3068 } else { |
3069 // replace a%b with a-((a/b)*b) | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3070 Node* mult = new (this) MulLNode(d, d->in(2)); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3071 Node* sub = new (this) SubLNode(d->in(1), mult); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3072 n->subsume_by(sub, this); |
0 | 3073 } |
3074 } | |
3075 } | |
3076 break; | |
3077 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3078 case Op_LoadVector: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3079 case Op_StoreVector: |
0 | 3080 break; |
3081 | |
3082 case Op_PackB: | |
3083 case Op_PackS: | |
3084 case Op_PackI: | |
3085 case Op_PackF: | |
3086 case Op_PackL: | |
3087 case Op_PackD: | |
3088 if (n->req()-1 > 2) { | |
3089 // Replace many operand PackNodes with a binary tree for matching | |
3090 PackNode* p = (PackNode*) n; | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3091 Node* btp = p->binary_tree_pack(this, 1, n->req()); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3092 n->subsume_by(btp, this); |
0 | 3093 } |
3094 break; | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3095 case Op_Loop: |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3096 case Op_CountedLoop: |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3097 if (n->as_Loop()->is_inner_loop()) { |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3098 frc.inc_inner_loop_count(); |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3099 } |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3100 break; |
2401
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3101 case Op_LShiftI: |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3102 case Op_RShiftI: |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3103 case Op_URShiftI: |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3104 case Op_LShiftL: |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3105 case Op_RShiftL: |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3106 case Op_URShiftL: |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3107 if (Matcher::need_masked_shift_count) { |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3108 // The cpu's shift instructions don't restrict the count to the |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3109 // lower 5/6 bits. We need to do the masking ourselves. |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3110 Node* in2 = n->in(2); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3111 juint mask = (n->bottom_type() == TypeInt::INT) ? (BitsPerInt - 1) : (BitsPerLong - 1); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3112 const TypeInt* t = in2->find_int_type(); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3113 if (t != NULL && t->is_con()) { |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3114 juint shift = t->get_con(); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3115 if (shift > mask) { // Unsigned cmp |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3116 n->set_req(2, ConNode::make(this, TypeInt::make(shift & mask))); |
2401
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3117 } |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3118 } else { |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3119 if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3120 Node* shift = new (this) AndINode(in2, ConNode::make(this, TypeInt::make(mask))); |
2401
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3121 n->set_req(2, shift); |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3122 } |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3123 } |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3124 if (in2->outcnt() == 0) { // Remove dead node |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3125 in2->disconnect_inputs(NULL, this); |
2401
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3126 } |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3127 } |
7e88bdae86ec
7029017: Additional architecture support for c2 compiler
roland
parents:
2376
diff
changeset
|
3128 break; |
8694
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3129 case Op_MemBarStoreStore: |
10278 | 3130 case Op_MemBarRelease: |
8694
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3131 // Break the link with AllocateNode: it is no longer useful and |
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3132 // confuses register allocation. |
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3133 if (n->req() > MemBarNode::Precedent) { |
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3134 n->set_req(MemBarNode::Precedent, top()); |
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3135 } |
8651f608fea4
8009460: C2compiler crash in machnode::in_regmask(unsigned int)
roland
parents:
8691
diff
changeset
|
3136 break; |
0 | 3137 default: |
3138 assert( !n->is_Call(), "" ); | |
3139 assert( !n->is_Mem(), "" ); | |
22985
eb8b5cc64669
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
22851
diff
changeset
|
3140 assert( nop != Op_ProfileBoolean, "should be eliminated during IGVN"); |
0 | 3141 break; |
3142 } | |
127 | 3143 |
3144 // Collect CFG split points | |
3145 if (n->is_MultiBranch()) | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3146 frc._tests.push(n); |
0 | 3147 } |
3148 | |
3149 //------------------------------final_graph_reshaping_walk--------------------- | |
3150 // Replacing Opaque nodes with their input in final_graph_reshaping_impl(), | |
3151 // requires that the walk visits a node's inputs before visiting the node. | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3152 void Compile::final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc ) { |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3153 ResourceArea *area = Thread::current()->resource_area(); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3154 Unique_Node_List sfpt(area); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3155 |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3156 frc._visited.set(root->_idx); // first, mark node as visited |
0 | 3157 uint cnt = root->req(); |
3158 Node *n = root; | |
3159 uint i = 0; | |
3160 while (true) { | |
3161 if (i < cnt) { | |
3162 // Place all non-visited non-null inputs onto stack | |
3163 Node* m = n->in(i); | |
3164 ++i; | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3165 if (m != NULL && !frc._visited.test_set(m->_idx)) { |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
3166 if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL) { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
3167 // compute worst case interpreter size in case of a deoptimization |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
3168 update_interpreter_frame_size(m->as_SafePoint()->jvms()->interpreter_frame_size()); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
3169 |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3170 sfpt.push(m); |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17937
diff
changeset
|
3171 } |
0 | 3172 cnt = m->req(); |
3173 nstack.push(n, i); // put on stack parent and next input's index | |
3174 n = m; | |
3175 i = 0; | |
3176 } | |
3177 } else { | |
3178 // Now do post-visit work | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3179 final_graph_reshaping_impl( n, frc ); |
0 | 3180 if (nstack.is_empty()) |
3181 break; // finished | |
3182 n = nstack.node(); // Get node from stack | |
3183 cnt = n->req(); | |
3184 i = nstack.index(); | |
3185 nstack.pop(); // Shift to the next node on stack | |
3186 } | |
3187 } | |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3188 |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
3189 // Skip next transformation if compressed oops are not used. |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
3190 if ((UseCompressedOops && !Matcher::gen_narrow_oop_implicit_null_checks()) || |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12167
diff
changeset
|
3191 (!UseCompressedOops && !UseCompressedClassPointers)) |
1575
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
3192 return; |
3657cb01ffc5
6954029: Improve implicit null check generation with compressed oops
kvn
parents:
1397
diff
changeset
|
3193 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
3194 // Go over safepoints nodes to skip DecodeN/DecodeNKlass nodes for debug edges. |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3195 // It could be done for an uncommon traps or any safepoints/calls |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
3196 // if the DecodeN/DecodeNKlass node is referenced only in a debug info. |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3197 while (sfpt.size() > 0) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3198 n = sfpt.pop(); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3199 JVMState *jvms = n->as_SafePoint()->jvms(); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3200 assert(jvms != NULL, "sanity"); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3201 int start = jvms->debug_start(); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3202 int end = n->req(); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3203 bool is_uncommon = (n->is_CallStaticJava() && |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3204 n->as_CallStaticJava()->uncommon_trap_request() != 0); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3205 for (int j = start; j < end; j++) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3206 Node* in = n->in(j); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6843
diff
changeset
|
3207 if (in->is_DecodeNarrowPtr()) { |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3208 bool safe_to_skip = true; |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3209 if (!is_uncommon ) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3210 // Is it safe to skip? |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3211 for (uint i = 0; i < in->outcnt(); i++) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3212 Node* u = in->raw_out(i); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3213 if (!u->is_SafePoint() || |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3214 u->is_Call() && u->as_Call()->has_non_debug_use(n)) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3215 safe_to_skip = false; |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3216 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3217 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3218 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3219 if (safe_to_skip) { |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3220 n->set_req(j, in->in(1)); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3221 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3222 if (in->outcnt() == 0) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3223 in->disconnect_inputs(NULL, this); |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3224 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3225 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3226 } |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
293
diff
changeset
|
3227 } |
0 | 3228 } |
3229 | |
3230 //------------------------------final_graph_reshaping-------------------------- | |
3231 // Final Graph Reshaping. | |
3232 // | |
3233 // (1) Clone simple inputs to uncommon calls, so they can be scheduled late | |
3234 // and not commoned up and forced early. Must come after regular | |
3235 // optimizations to avoid GVN undoing the cloning. Clone constant | |
3236 // inputs to Loop Phis; these will be split by the allocator anyways. | |
3237 // Remove Opaque nodes. | |
3238 // (2) Move last-uses by commutative operations to the left input to encourage | |
3239 // Intel update-in-place two-address operations and better register usage | |
3240 // on RISCs. Must come after regular optimizations to avoid GVN Ideal | |
3241 // calls canonicalizing them back. | |
3242 // (3) Count the number of double-precision FP ops, single-precision FP ops | |
3243 // and call sites. On Intel, we can get correct rounding either by | |
3244 // forcing singles to memory (requires extra stores and loads after each | |
3245 // FP bytecode) or we can set a rounding mode bit (requires setting and | |
3246 // clearing the mode bit around call sites). The mode bit is only used | |
3247 // if the relative frequency of single FP ops to calls is low enough. | |
3248 // This is a key transform for SPEC mpeg_audio. | |
3249 // (4) Detect infinite loops; blobs of code reachable from above but not | |
3250 // below. Several of the Code_Gen algorithms fail on such code shapes, | |
3251 // so we simply bail out. Happens a lot in ZKM.jar, but also happens | |
3252 // from time to time in other codes (such as -Xcomp finalizer loops, etc). | |
3253 // Detection is by looking for IfNodes where only 1 projection is | |
3254 // reachable from below or CatchNodes missing some targets. | |
3255 // (5) Assert for insane oop offsets in debug mode. | |
3256 | |
3257 bool Compile::final_graph_reshaping() { | |
3258 // an infinite loop may have been eliminated by the optimizer, | |
3259 // in which case the graph will be empty. | |
3260 if (root()->req() == 1) { | |
3261 record_method_not_compilable("trivial infinite loop"); | |
3262 return true; | |
3263 } | |
3264 | |
8048
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3265 // Expensive nodes have their control input set to prevent the GVN |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3266 // from freely commoning them. There's no GVN beyond this point so |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3267 // no need to keep the control input. We want the expensive nodes to |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3268 // be freely moved to the least frequent code path by gcm. |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3269 assert(OptimizeExpensiveOps || expensive_count() == 0, "optimization off but list non empty?"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3270 for (int i = 0; i < expensive_count(); i++) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3271 _expensive_nodes->at(i)->set_req(0, NULL); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3272 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3273 |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3274 Final_Reshape_Counts frc; |
0 | 3275 |
3276 // Visit everybody reachable! | |
23421
c1091733abe6
8011858: Use Compile::live_nodes() instead of Compile::unique() in appropriate places
zmajo
parents:
23086
diff
changeset
|
3277 // Allocate stack of size C->live_nodes()/2 to avoid frequent realloc |
c1091733abe6
8011858: Use Compile::live_nodes() instead of Compile::unique() in appropriate places
zmajo
parents:
23086
diff
changeset
|
3278 Node_Stack nstack(live_nodes() >> 1); |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3279 final_graph_reshaping_walk(nstack, root(), frc); |
0 | 3280 |
3281 // Check for unreachable (from below) code (i.e., infinite loops). | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3282 for( uint i = 0; i < frc._tests.size(); i++ ) { |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3283 MultiBranchNode *n = frc._tests[i]->as_MultiBranch(); |
127 | 3284 // Get number of CFG targets. |
0 | 3285 // Note that PCTables include exception targets after calls. |
127 | 3286 uint required_outcnt = n->required_outcnt(); |
3287 if (n->outcnt() != required_outcnt) { | |
0 | 3288 // Check for a few special cases. Rethrow Nodes never take the |
3289 // 'fall-thru' path, so expected kids is 1 less. | |
3290 if (n->is_PCTable() && n->in(0) && n->in(0)->in(0)) { | |
3291 if (n->in(0)->in(0)->is_Call()) { | |
3292 CallNode *call = n->in(0)->in(0)->as_Call(); | |
3293 if (call->entry_point() == OptoRuntime::rethrow_stub()) { | |
127 | 3294 required_outcnt--; // Rethrow always has 1 less kid |
0 | 3295 } else if (call->req() > TypeFunc::Parms && |
3296 call->is_CallDynamicJava()) { | |
3297 // Check for null receiver. In such case, the optimizer has | |
3298 // detected that the virtual call will always result in a null | |
3299 // pointer exception. The fall-through projection of this CatchNode | |
3300 // will not be populated. | |
3301 Node *arg0 = call->in(TypeFunc::Parms); | |
3302 if (arg0->is_Type() && | |
3303 arg0->as_Type()->type()->higher_equal(TypePtr::NULL_PTR)) { | |
127 | 3304 required_outcnt--; |
0 | 3305 } |
3306 } else if (call->entry_point() == OptoRuntime::new_array_Java() && | |
3307 call->req() > TypeFunc::Parms+1 && | |
3308 call->is_CallStaticJava()) { | |
3309 // Check for negative array length. In such case, the optimizer has | |
3310 // detected that the allocation attempt will always result in an | |
3311 // exception. There is no fall-through projection of this CatchNode . | |
3312 Node *arg1 = call->in(TypeFunc::Parms+1); | |
3313 if (arg1->is_Type() && | |
3314 arg1->as_Type()->type()->join(TypeInt::POS)->empty()) { | |
127 | 3315 required_outcnt--; |
0 | 3316 } |
3317 } | |
3318 } | |
3319 } | |
127 | 3320 // Recheck with a better notion of 'required_outcnt' |
3321 if (n->outcnt() != required_outcnt) { | |
0 | 3322 record_method_not_compilable("malformed control flow"); |
3323 return true; // Not all targets reachable! | |
3324 } | |
3325 } | |
3326 // Check that I actually visited all kids. Unreached kids | |
3327 // must be infinite loops. | |
3328 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3329 if (!frc._visited.test(n->fast_out(j)->_idx)) { |
0 | 3330 record_method_not_compilable("infinite loop"); |
3331 return true; // Found unvisited kid; must be unreach | |
3332 } | |
3333 } | |
3334 | |
3335 // If original bytecodes contained a mixture of floats and doubles | |
3336 // check if the optimizer has made it homogenous, item (3). | |
929
cd18bd5e667c
6873777: FPU control word optimization still performed with SSE
never
parents:
921
diff
changeset
|
3337 if( Use24BitFPMode && Use24BitFP && UseSSE == 0 && |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3338 frc.get_float_count() > 32 && |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3339 frc.get_double_count() == 0 && |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3340 (10 * frc.get_call_count() < frc.get_float_count()) ) { |
0 | 3341 set_24_bit_selection_and_mode( false, true ); |
3342 } | |
3343 | |
859
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3344 set_java_calls(frc.get_java_call_count()); |
ea3f9723b5cf
6860599: nodes limit could be reached during Output phase
kvn
parents:
856
diff
changeset
|
3345 set_inner_loops(frc.get_inner_loop_count()); |
0 | 3346 |
3347 // No infinite loops, no reason to bail out. | |
3348 return false; | |
3349 } | |
3350 | |
3351 //-----------------------------too_many_traps---------------------------------- | |
3352 // Report if there are too many traps at the current method and bci. | |
3353 // Return true if there was a trap, and/or PerMethodTrapLimit is exceeded. | |
3354 bool Compile::too_many_traps(ciMethod* method, | |
3355 int bci, | |
3356 Deoptimization::DeoptReason reason) { | |
3357 ciMethodData* md = method->method_data(); | |
3358 if (md->is_empty()) { | |
3359 // Assume the trap has not occurred, or that it occurred only | |
3360 // because of a transient condition during start-up in the interpreter. | |
3361 return false; | |
3362 } | |
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
17726
diff
changeset
|
3363 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
17726
diff
changeset
|
3364 if (md->has_trap_at(bci, m, reason) != 0) { |
0 | 3365 // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic. |
3366 // Also, if there are multiple reasons, or if there is no per-BCI record, | |
3367 // assume the worst. | |
3368 if (log()) | |
3369 log()->elem("observe trap='%s' count='%d'", | |
3370 Deoptimization::trap_reason_name(reason), | |
3371 md->trap_count(reason)); | |
3372 return true; | |
3373 } else { | |
3374 // Ignore method/bci and see if there have been too many globally. | |
3375 return too_many_traps(reason, md); | |
3376 } | |
3377 } | |
3378 | |
3379 // Less-accurate variant which does not require a method and bci. | |
3380 bool Compile::too_many_traps(Deoptimization::DeoptReason reason, | |
3381 ciMethodData* logmd) { | |
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
17726
diff
changeset
|
3382 if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) { |
0 | 3383 // Too many traps globally. |
3384 // Note that we use cumulative trap_count, not just md->trap_count. | |
3385 if (log()) { | |
3386 int mcount = (logmd == NULL)? -1: (int)logmd->trap_count(reason); | |
3387 log()->elem("observe trap='%s' count='0' mcount='%d' ccount='%d'", | |
3388 Deoptimization::trap_reason_name(reason), | |
3389 mcount, trap_count(reason)); | |
3390 } | |
3391 return true; | |
3392 } else { | |
3393 // The coast is clear. | |
3394 return false; | |
3395 } | |
3396 } | |
3397 | |
3398 //--------------------------too_many_recompiles-------------------------------- | |
3399 // Report if there are too many recompiles at the current method and bci. | |
3400 // Consults PerBytecodeRecompilationCutoff and PerMethodRecompilationCutoff. | |
3401 // Is not eager to return true, since this will cause the compiler to use | |
3402 // Action_none for a trap point, to avoid too many recompilations. | |
3403 bool Compile::too_many_recompiles(ciMethod* method, | |
3404 int bci, | |
3405 Deoptimization::DeoptReason reason) { | |
3406 ciMethodData* md = method->method_data(); | |
3407 if (md->is_empty()) { | |
3408 // Assume the trap has not occurred, or that it occurred only | |
3409 // because of a transient condition during start-up in the interpreter. | |
3410 return false; | |
3411 } | |
3412 // Pick a cutoff point well within PerBytecodeRecompilationCutoff. | |
3413 uint bc_cutoff = (uint) PerBytecodeRecompilationCutoff / 8; | |
3414 uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero | |
3415 Deoptimization::DeoptReason per_bc_reason | |
3416 = Deoptimization::reason_recorded_per_bytecode_if_any(reason); | |
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
17726
diff
changeset
|
3417 ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL; |
0 | 3418 if ((per_bc_reason == Deoptimization::Reason_none |
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
17726
diff
changeset
|
3419 || md->has_trap_at(bci, m, reason) != 0) |
0 | 3420 // The trap frequency measure we care about is the recompile count: |
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
17726
diff
changeset
|
3421 && md->trap_recompiled_at(bci, m) |
0 | 3422 && md->overflow_recompile_count() >= bc_cutoff) { |
3423 // Do not emit a trap here if it has already caused recompilations. | |
3424 // Also, if there are multiple reasons, or if there is no per-BCI record, | |
3425 // assume the worst. | |
3426 if (log()) | |
3427 log()->elem("observe trap='%s recompiled' count='%d' recompiles2='%d'", | |
3428 Deoptimization::trap_reason_name(reason), | |
3429 md->trap_count(reason), | |
3430 md->overflow_recompile_count()); | |
3431 return true; | |
3432 } else if (trap_count(reason) != 0 | |
3433 && decompile_count() >= m_cutoff) { | |
3434 // Too many recompiles globally, and we have seen this sort of trap. | |
3435 // Use cumulative decompile_count, not just md->decompile_count. | |
3436 if (log()) | |
3437 log()->elem("observe trap='%s' count='%d' mcount='%d' decompiles='%d' mdecompiles='%d'", | |
3438 Deoptimization::trap_reason_name(reason), | |
3439 md->trap_count(reason), trap_count(reason), | |
3440 md->decompile_count(), decompile_count()); | |
3441 return true; | |
3442 } else { | |
3443 // The coast is clear. | |
3444 return false; | |
3445 } | |
3446 } | |
3447 | |
14440
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3448 // Compute when not to trap. Used by matching trap based nodes and |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3449 // NullCheck optimization. |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3450 void Compile::set_allowed_deopt_reasons() { |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3451 _allowed_reasons = 0; |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3452 if (is_method_compilation()) { |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3453 for (int rs = (int)Deoptimization::Reason_none+1; rs < Compile::trapHistLength; rs++) { |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3454 assert(rs < BitsPerInt, "recode bit map"); |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3455 if (!too_many_traps((Deoptimization::DeoptReason) rs)) { |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3456 _allowed_reasons |= nth_bit(rs); |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3457 } |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3458 } |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3459 } |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14438
diff
changeset
|
3460 } |
0 | 3461 |
3462 #ifndef PRODUCT | |
3463 //------------------------------verify_graph_edges--------------------------- | |
3464 // Walk the Graph and verify that there is a one-to-one correspondence | |
3465 // between Use-Def edges and Def-Use edges in the graph. | |
3466 void Compile::verify_graph_edges(bool no_dead_code) { | |
3467 if (VerifyGraphEdges) { | |
3468 ResourceArea *area = Thread::current()->resource_area(); | |
3469 Unique_Node_List visited(area); | |
3470 // Call recursive graph walk to check edges | |
3471 _root->verify_edges(visited); | |
3472 if (no_dead_code) { | |
3473 // Now make sure that no visited node is used by an unvisited node. | |
3474 bool dead_nodes = 0; | |
3475 Unique_Node_List checked(area); | |
3476 while (visited.size() > 0) { | |
3477 Node* n = visited.pop(); | |
3478 checked.push(n); | |
3479 for (uint i = 0; i < n->outcnt(); i++) { | |
3480 Node* use = n->raw_out(i); | |
3481 if (checked.member(use)) continue; // already checked | |
3482 if (visited.member(use)) continue; // already in the graph | |
3483 if (use->is_Con()) continue; // a dead ConNode is OK | |
3484 // At this point, we have found a dead node which is DU-reachable. | |
3485 if (dead_nodes++ == 0) | |
3486 tty->print_cr("*** Dead nodes reachable via DU edges:"); | |
3487 use->dump(2); | |
3488 tty->print_cr("---"); | |
3489 checked.push(use); // No repeats; pretend it is now checked. | |
3490 } | |
3491 } | |
3492 assert(dead_nodes == 0, "using nodes must be reachable from root"); | |
3493 } | |
3494 } | |
3495 } | |
13045
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3496 |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3497 // Verify GC barriers consistency |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3498 // Currently supported: |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3499 // - G1 pre-barriers (see GraphKit::g1_write_barrier_pre()) |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3500 void Compile::verify_barriers() { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3501 if (UseG1GC) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3502 // Verify G1 pre-barriers |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3503 const int marking_offset = in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_active()); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3504 |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3505 ResourceArea *area = Thread::current()->resource_area(); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3506 Unique_Node_List visited(area); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3507 Node_List worklist(area); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3508 // We're going to walk control flow backwards starting from the Root |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3509 worklist.push(_root); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3510 while (worklist.size() > 0) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3511 Node* x = worklist.pop(); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3512 if (x == NULL || x == top()) continue; |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3513 if (visited.member(x)) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3514 continue; |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3515 } else { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3516 visited.push(x); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3517 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3518 |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3519 if (x->is_Region()) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3520 for (uint i = 1; i < x->req(); i++) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3521 worklist.push(x->in(i)); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3522 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3523 } else { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3524 worklist.push(x->in(0)); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3525 // We are looking for the pattern: |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3526 // /->ThreadLocal |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3527 // If->Bool->CmpI->LoadB->AddP->ConL(marking_offset) |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3528 // \->ConI(0) |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3529 // We want to verify that the If and the LoadB have the same control |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3530 // See GraphKit::g1_write_barrier_pre() |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3531 if (x->is_If()) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3532 IfNode *iff = x->as_If(); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3533 if (iff->in(1)->is_Bool() && iff->in(1)->in(1)->is_Cmp()) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3534 CmpNode *cmp = iff->in(1)->in(1)->as_Cmp(); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3535 if (cmp->Opcode() == Op_CmpI && cmp->in(2)->is_Con() && cmp->in(2)->bottom_type()->is_int()->get_con() == 0 |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3536 && cmp->in(1)->is_Load()) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3537 LoadNode* load = cmp->in(1)->as_Load(); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3538 if (load->Opcode() == Op_LoadB && load->in(2)->is_AddP() && load->in(2)->in(2)->Opcode() == Op_ThreadLocal |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3539 && load->in(2)->in(3)->is_Con() |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3540 && load->in(2)->in(3)->bottom_type()->is_intptr_t()->get_con() == marking_offset) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3541 |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3542 Node* if_ctrl = iff->in(0); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3543 Node* load_ctrl = load->in(0); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3544 |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3545 if (if_ctrl != load_ctrl) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3546 // Skip possible CProj->NeverBranch in infinite loops |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3547 if ((if_ctrl->is_Proj() && if_ctrl->Opcode() == Op_CProj) |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3548 && (if_ctrl->in(0)->is_MultiBranch() && if_ctrl->in(0)->Opcode() == Op_NeverBranch)) { |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3549 if_ctrl = if_ctrl->in(0)->in(0); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3550 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3551 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3552 assert(load_ctrl != NULL && if_ctrl == load_ctrl, "controls must match"); |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3553 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3554 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3555 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3556 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3557 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3558 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3559 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3560 } |
94a83e0f9ce1
8017065: C2 allows safepoint checks to leak into G1 pre-barriers
iveresov
parents:
12966
diff
changeset
|
3561 |
0 | 3562 #endif |
3563 | |
3564 // The Compile object keeps track of failure reasons separately from the ciEnv. | |
3565 // This is required because there is not quite a 1-1 relation between the | |
3566 // ciEnv and its compilation task and the Compile object. Note that one | |
3567 // ciEnv might use two Compile objects, if C2Compiler::compile_method decides | |
3568 // to backtrack and retry without subsuming loads. Other than this backtracking | |
3569 // behavior, the Compile's failure reason is quietly copied up to the ciEnv | |
3570 // by the logic in C2Compiler. | |
3571 void Compile::record_failure(const char* reason) { | |
3572 if (log() != NULL) { | |
3573 log()->elem("failure reason='%s' phase='compile'", reason); | |
3574 } | |
3575 if (_failure_reason == NULL) { | |
3576 // Record the first failure reason. | |
3577 _failure_reason = reason; | |
3578 } | |
10405 | 3579 |
3580 EventCompilerFailure event; | |
3581 if (event.should_commit()) { | |
3582 event.set_compileID(Compile::compile_id()); | |
3583 event.set_failure(reason); | |
3584 event.commit(); | |
3585 } | |
3586 | |
222 | 3587 if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { |
10405 | 3588 C->print_method(PHASE_FAILURE); |
222 | 3589 } |
0 | 3590 _root = NULL; // flush the graph, too |
3591 } | |
3592 | |
3593 Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator, bool dolog) | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3594 : TraceTime(NULL, accumulator, false NOT_PRODUCT( || TimeCompiler ), false), |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3595 _phase_name(name), _dolog(dolog) |
0 | 3596 { |
3597 if (dolog) { | |
3598 C = Compile::current(); | |
3599 _log = C->log(); | |
3600 } else { | |
3601 C = NULL; | |
3602 _log = NULL; | |
3603 } | |
3604 if (_log != NULL) { | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3605 _log->begin_head("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes()); |
0 | 3606 _log->stamp(); |
3607 _log->end_head(); | |
3608 } | |
3609 } | |
3610 | |
3611 Compile::TracePhase::~TracePhase() { | |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3612 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3613 C = Compile::current(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3614 if (_dolog) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3615 _log = C->log(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3616 } else { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3617 _log = NULL; |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3618 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3619 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3620 #ifdef ASSERT |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3621 if (PrintIdealNodeCount) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3622 tty->print_cr("phase name='%s' nodes='%d' live='%d' live_graph_walk='%d'", |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3623 _phase_name, C->unique(), C->live_nodes(), C->count_live_nodes_by_graph_walk()); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3624 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3625 |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3626 if (VerifyIdealNodeCount) { |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3627 Compile::current()->print_missing_nodes(); |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3628 } |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3629 #endif |
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3630 |
0 | 3631 if (_log != NULL) { |
7196
2aff40cb4703
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
6888
diff
changeset
|
3632 _log->done("phase name='%s' nodes='%d' live='%d'", _phase_name, C->unique(), C->live_nodes()); |
0 | 3633 } |
3634 } | |
2008 | 3635 |
3636 //============================================================================= | |
3637 // Two Constant's are equal when the type and the value are equal. | |
3638 bool Compile::Constant::operator==(const Constant& other) { | |
3639 if (type() != other.type() ) return false; | |
3640 if (can_be_reused() != other.can_be_reused()) return false; | |
3641 // For floating point values we compare the bit pattern. | |
3642 switch (type()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3643 case T_FLOAT: return (_v._value.i == other._v._value.i); |
2008 | 3644 case T_LONG: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3645 case T_DOUBLE: return (_v._value.j == other._v._value.j); |
2008 | 3646 case T_OBJECT: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3647 case T_ADDRESS: return (_v._value.l == other._v._value.l); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3648 case T_VOID: return (_v._value.l == other._v._value.l); // jump-table entries |
6888
cfe522e6461c
8000623: tools/javac/Diagnostics/6769027/T6769027.java crashes in PSPromotionManager::copy_to_survivor_space
kvn
parents:
6849
diff
changeset
|
3649 case T_METADATA: return (_v._metadata == other._v._metadata); |
2008 | 3650 default: ShouldNotReachHere(); |
3651 } | |
3652 return false; | |
3653 } | |
3654 | |
3655 static int type_to_size_in_bytes(BasicType t) { | |
3656 switch (t) { | |
3657 case T_LONG: return sizeof(jlong ); | |
3658 case T_FLOAT: return sizeof(jfloat ); | |
3659 case T_DOUBLE: return sizeof(jdouble); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3660 case T_METADATA: return sizeof(Metadata*); |
2008 | 3661 // We use T_VOID as marker for jump-table entries (labels) which |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3662 // need an internal word relocation. |
2008 | 3663 case T_VOID: |
3664 case T_ADDRESS: | |
3665 case T_OBJECT: return sizeof(jobject); | |
3666 } | |
3667 | |
3668 ShouldNotReachHere(); | |
3669 return -1; | |
3670 } | |
3671 | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3672 int Compile::ConstantTable::qsort_comparator(Constant* a, Constant* b) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3673 // sort descending |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3674 if (a->freq() > b->freq()) return -1; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3675 if (a->freq() < b->freq()) return 1; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3676 return 0; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3677 } |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3678 |
2008 | 3679 void Compile::ConstantTable::calculate_offsets_and_size() { |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3680 // First, sort the array by frequencies. |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3681 _constants.sort(qsort_comparator); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3682 |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3683 #ifdef ASSERT |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3684 // Make sure all jump-table entries were sorted to the end of the |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3685 // array (they have a negative frequency). |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3686 bool found_void = false; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3687 for (int i = 0; i < _constants.length(); i++) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3688 Constant con = _constants.at(i); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3689 if (con.type() == T_VOID) |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3690 found_void = true; // jump-tables |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3691 else |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3692 assert(!found_void, "wrong sorting"); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3693 } |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3694 #endif |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3695 |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3696 int offset = 0; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3697 for (int i = 0; i < _constants.length(); i++) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3698 Constant* con = _constants.adr_at(i); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3699 |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3700 // Align offset for type. |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3701 int typesize = type_to_size_in_bytes(con->type()); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3702 offset = align_size_up(offset, typesize); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3703 con->set_offset(offset); // set constant's offset |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3704 |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3705 if (con->type() == T_VOID) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3706 MachConstantNode* n = (MachConstantNode*) con->get_jobject(); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3707 offset = offset + typesize * n->outcnt(); // expand jump-table |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3708 } else { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3709 offset = offset + typesize; |
2008 | 3710 } |
3711 } | |
3712 | |
3713 // Align size up to the next section start (which is insts; see | |
3714 // CodeBuffer::align_at_start). | |
3715 assert(_size == -1, "already set?"); | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3716 _size = align_size_up(offset, CodeEntryAlignment); |
2008 | 3717 } |
3718 | |
3719 void Compile::ConstantTable::emit(CodeBuffer& cb) { | |
3720 MacroAssembler _masm(&cb); | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3721 for (int i = 0; i < _constants.length(); i++) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3722 Constant con = _constants.at(i); |
23822
626f594dffa6
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
csahu
parents:
23799
diff
changeset
|
3723 address constant_addr = NULL; |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3724 switch (con.type()) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3725 case T_LONG: constant_addr = _masm.long_constant( con.get_jlong() ); break; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3726 case T_FLOAT: constant_addr = _masm.float_constant( con.get_jfloat() ); break; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3727 case T_DOUBLE: constant_addr = _masm.double_constant(con.get_jdouble()); break; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3728 case T_OBJECT: { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3729 jobject obj = con.get_jobject(); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3730 int oop_index = _masm.oop_recorder()->find_index(obj); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3731 constant_addr = _masm.address_constant((address) obj, oop_Relocation::spec(oop_index)); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3732 break; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3733 } |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3734 case T_ADDRESS: { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3735 address addr = (address) con.get_jobject(); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3736 constant_addr = _masm.address_constant(addr); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3737 break; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3738 } |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3739 // We use T_VOID as marker for jump-table entries (labels) which |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3740 // need an internal word relocation. |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3741 case T_VOID: { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3742 MachConstantNode* n = (MachConstantNode*) con.get_jobject(); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3743 // Fill the jump-table with a dummy word. The real value is |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3744 // filled in later in fill_jump_table. |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3745 address dummy = (address) n; |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3746 constant_addr = _masm.address_constant(dummy); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3747 // Expand jump-table |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3748 for (uint i = 1; i < n->outcnt(); i++) { |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3749 address temp_addr = _masm.address_constant(dummy + i); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3750 assert(temp_addr, "consts section too small"); |
2008 | 3751 } |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3752 break; |
2008 | 3753 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3754 case T_METADATA: { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3755 Metadata* obj = con.get_metadata(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3756 int metadata_index = _masm.oop_recorder()->find_index(obj); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3757 constant_addr = _masm.address_constant((address) obj, metadata_Relocation::spec(metadata_index)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3758 break; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3759 } |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3760 default: ShouldNotReachHere(); |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3761 } |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3762 assert(constant_addr, "consts section too small"); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
3763 assert((constant_addr - _masm.code()->consts()->start()) == con.offset(), |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
3764 err_msg_res("must be: %d == %d", (int) (constant_addr - _masm.code()->consts()->start()), (int)(con.offset()))); |
2008 | 3765 } |
3766 } | |
3767 | |
3768 int Compile::ConstantTable::find_offset(Constant& con) const { | |
3769 int idx = _constants.find(con); | |
3770 assert(idx != -1, "constant must be in constant table"); | |
3771 int offset = _constants.at(idx).offset(); | |
3772 assert(offset != -1, "constant table not emitted yet?"); | |
3773 return offset; | |
3774 } | |
3775 | |
3776 void Compile::ConstantTable::add(Constant& con) { | |
3777 if (con.can_be_reused()) { | |
3778 int idx = _constants.find(con); | |
3779 if (idx != -1 && _constants.at(idx).can_be_reused()) { | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3780 _constants.adr_at(idx)->inc_freq(con.freq()); // increase the frequency by the current value |
2008 | 3781 return; |
3782 } | |
3783 } | |
3784 (void) _constants.append(con); | |
3785 } | |
3786 | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3787 Compile::Constant Compile::ConstantTable::add(MachConstantNode* n, BasicType type, jvalue value) { |
12023
d1034bd8cefc
8022284: Hide internal data structure in PhaseCFG
adlertz
parents:
10405
diff
changeset
|
3788 Block* b = Compile::current()->cfg()->get_block_for_node(n); |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3789 Constant con(type, value, b->_freq); |
2008 | 3790 add(con); |
3791 return con; | |
3792 } | |
3793 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3794 Compile::Constant Compile::ConstantTable::add(Metadata* metadata) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3795 Constant con(metadata); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3796 add(con); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3797 return con; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3798 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3799 |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3800 Compile::Constant Compile::ConstantTable::add(MachConstantNode* n, MachOper* oper) { |
2008 | 3801 jvalue value; |
3802 BasicType type = oper->type()->basic_type(); | |
3803 switch (type) { | |
3804 case T_LONG: value.j = oper->constantL(); break; | |
3805 case T_FLOAT: value.f = oper->constantF(); break; | |
3806 case T_DOUBLE: value.d = oper->constantD(); break; | |
3807 case T_OBJECT: | |
3808 case T_ADDRESS: value.l = (jobject) oper->constant(); break; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3809 case T_METADATA: return add((Metadata*)oper->constant()); break; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6619
diff
changeset
|
3810 default: guarantee(false, err_msg_res("unhandled type: %s", type2name(type))); |
2008 | 3811 } |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3812 return add(n, type, value); |
2008 | 3813 } |
3814 | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3815 Compile::Constant Compile::ConstantTable::add_jump_table(MachConstantNode* n) { |
2008 | 3816 jvalue value; |
3817 // We can use the node pointer here to identify the right jump-table | |
3818 // as this method is called from Compile::Fill_buffer right before | |
3819 // the MachNodes are emitted and the jump-table is filled (means the | |
3820 // MachNode pointers do not change anymore). | |
3821 value.l = (jobject) n; | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3822 Constant con(T_VOID, value, next_jump_table_freq(), false); // Labels of a jump-table cannot be reused. |
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3823 add(con); |
2008 | 3824 return con; |
3825 } | |
3826 | |
3827 void Compile::ConstantTable::fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const { | |
3828 // If called from Compile::scratch_emit_size do nothing. | |
3829 if (Compile::current()->in_scratch_emit_size()) return; | |
3830 | |
3831 assert(labels.is_nonempty(), "must be"); | |
6268
6c5b7a6becc8
7187454: stack overflow in C2 compiler thread on Solaris x86
kvn
parents:
6179
diff
changeset
|
3832 assert((uint) labels.length() == n->outcnt(), err_msg_res("must be equal: %d == %d", labels.length(), n->outcnt())); |
2008 | 3833 |
3834 // Since MachConstantNode::constant_offset() also contains | |
3835 // table_base_offset() we need to subtract the table_base_offset() | |
3836 // to get the plain offset into the constant table. | |
3837 int offset = n->constant_offset() - table_base_offset(); | |
3838 | |
3839 MacroAssembler _masm(&cb); | |
3840 address* jump_table_base = (address*) (_masm.code()->consts()->start() + offset); | |
3841 | |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
4064
diff
changeset
|
3842 for (uint i = 0; i < n->outcnt(); i++) { |
2008 | 3843 address* constant_addr = &jump_table_base[i]; |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
3844 assert(*constant_addr == (((address) n) + i), err_msg_res("all jump-table entries must contain adjusted node pointer: " INTPTR_FORMAT " == " INTPTR_FORMAT, p2i(*constant_addr), p2i(((address) n) + i))); |
2008 | 3845 *constant_addr = cb.consts()->target(*labels.at(i), (address) constant_addr); |
3846 cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type); | |
3847 } | |
3848 } | |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
3849 |
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
3850 void Compile::dump_inlining() { |
12295 | 3851 if (print_inlining() || print_intrinsics()) { |
7473 | 3852 // Print inlining message for candidates that we couldn't inline |
3853 // for lack of space or non constant receiver | |
3854 for (int i = 0; i < _late_inlines.length(); i++) { | |
3855 CallGenerator* cg = _late_inlines.at(i); | |
3856 cg->print_inlining_late("live nodes > LiveNodeCountInliningCutoff"); | |
3857 } | |
3858 Unique_Node_List useful; | |
3859 useful.push(root()); | |
3860 for (uint next = 0; next < useful.size(); ++next) { | |
3861 Node* n = useful.at(next); | |
3862 if (n->is_Call() && n->as_Call()->generator() != NULL && n->as_Call()->generator()->call_node() == n) { | |
3863 CallNode* call = n->as_Call(); | |
3864 CallGenerator* cg = call->generator(); | |
3865 cg->print_inlining_late("receiver not constant"); | |
3866 } | |
3867 uint max = n->len(); | |
3868 for ( uint i = 0; i < max; ++i ) { | |
3869 Node *m = n->in(i); | |
3870 if ( m == NULL ) continue; | |
3871 useful.push(m); | |
3872 } | |
3873 } | |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
3874 for (int i = 0; i < _print_inlining_list->length(); i++) { |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17914
diff
changeset
|
3875 tty->print("%s", _print_inlining_list->adr_at(i)->ss()->as_string()); |
7421
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
3876 } |
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
3877 } |
ad5dd04754ee
8005031: Some cleanup in c2 to prepare for incremental inlining support
roland
parents:
7199
diff
changeset
|
3878 } |
8048
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3879 |
14232 | 3880 // Dump inlining replay data to the stream. |
3881 // Don't change thread state and acquire any locks. | |
3882 void Compile::dump_inline_data(outputStream* out) { | |
3883 InlineTree* inl_tree = ilt(); | |
3884 if (inl_tree != NULL) { | |
3885 out->print(" inline %d", inl_tree->count()); | |
3886 inl_tree->dump_replay_data(out); | |
3887 } | |
3888 } | |
3889 | |
8048
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3890 int Compile::cmp_expensive_nodes(Node* n1, Node* n2) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3891 if (n1->Opcode() < n2->Opcode()) return -1; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3892 else if (n1->Opcode() > n2->Opcode()) return 1; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3893 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3894 assert(n1->req() == n2->req(), err_msg_res("can't compare %s nodes: n1->req() = %d, n2->req() = %d", NodeClassNames[n1->Opcode()], n1->req(), n2->req())); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3895 for (uint i = 1; i < n1->req(); i++) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3896 if (n1->in(i) < n2->in(i)) return -1; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3897 else if (n1->in(i) > n2->in(i)) return 1; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3898 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3899 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3900 return 0; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3901 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3902 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3903 int Compile::cmp_expensive_nodes(Node** n1p, Node** n2p) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3904 Node* n1 = *n1p; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3905 Node* n2 = *n2p; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3906 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3907 return cmp_expensive_nodes(n1, n2); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3908 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3909 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3910 void Compile::sort_expensive_nodes() { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3911 if (!expensive_nodes_sorted()) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3912 _expensive_nodes->sort(cmp_expensive_nodes); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3913 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3914 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3915 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3916 bool Compile::expensive_nodes_sorted() const { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3917 for (int i = 1; i < _expensive_nodes->length(); i++) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3918 if (cmp_expensive_nodes(_expensive_nodes->adr_at(i), _expensive_nodes->adr_at(i-1)) < 0) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3919 return false; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3920 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3921 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3922 return true; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3923 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3924 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3925 bool Compile::should_optimize_expensive_nodes(PhaseIterGVN &igvn) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3926 if (_expensive_nodes->length() == 0) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3927 return false; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3928 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3929 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3930 assert(OptimizeExpensiveOps, "optimization off?"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3931 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3932 // Take this opportunity to remove dead nodes from the list |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3933 int j = 0; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3934 for (int i = 0; i < _expensive_nodes->length(); i++) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3935 Node* n = _expensive_nodes->at(i); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3936 if (!n->is_unreachable(igvn)) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3937 assert(n->is_expensive(), "should be expensive"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3938 _expensive_nodes->at_put(j, n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3939 j++; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3940 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3941 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3942 _expensive_nodes->trunc_to(j); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3943 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3944 // Then sort the list so that similar nodes are next to each other |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3945 // and check for at least two nodes of identical kind with same data |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3946 // inputs. |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3947 sort_expensive_nodes(); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3948 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3949 for (int i = 0; i < _expensive_nodes->length()-1; i++) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3950 if (cmp_expensive_nodes(_expensive_nodes->adr_at(i), _expensive_nodes->adr_at(i+1)) == 0) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3951 return true; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3952 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3953 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3954 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3955 return false; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3956 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3957 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3958 void Compile::cleanup_expensive_nodes(PhaseIterGVN &igvn) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3959 if (_expensive_nodes->length() == 0) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3960 return; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3961 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3962 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3963 assert(OptimizeExpensiveOps, "optimization off?"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3964 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3965 // Sort to bring similar nodes next to each other and clear the |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3966 // control input of nodes for which there's only a single copy. |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3967 sort_expensive_nodes(); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3968 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3969 int j = 0; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3970 int identical = 0; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3971 int i = 0; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3972 for (; i < _expensive_nodes->length()-1; i++) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3973 assert(j <= i, "can't write beyond current index"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3974 if (_expensive_nodes->at(i)->Opcode() == _expensive_nodes->at(i+1)->Opcode()) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3975 identical++; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3976 _expensive_nodes->at_put(j++, _expensive_nodes->at(i)); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3977 continue; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3978 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3979 if (identical > 0) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3980 _expensive_nodes->at_put(j++, _expensive_nodes->at(i)); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3981 identical = 0; |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3982 } else { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3983 Node* n = _expensive_nodes->at(i); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3984 igvn.hash_delete(n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3985 n->set_req(0, NULL); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3986 igvn.hash_insert(n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3987 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3988 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3989 if (identical > 0) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3990 _expensive_nodes->at_put(j++, _expensive_nodes->at(i)); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3991 } else if (_expensive_nodes->length() >= 1) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3992 Node* n = _expensive_nodes->at(i); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3993 igvn.hash_delete(n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3994 n->set_req(0, NULL); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3995 igvn.hash_insert(n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3996 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3997 _expensive_nodes->trunc_to(j); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3998 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
3999 |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4000 void Compile::add_expensive_node(Node * n) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4001 assert(!_expensive_nodes->contains(n), "duplicate entry in expensive list"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4002 assert(n->is_expensive(), "expensive nodes with non-null control here only"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4003 assert(!n->is_CFG() && !n->is_Mem(), "no cfg or memory nodes here"); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4004 if (OptimizeExpensiveOps) { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4005 _expensive_nodes->append(n); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4006 } else { |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4007 // Clear control input and let IGVN optimize expensive nodes if |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4008 // OptimizeExpensiveOps is off. |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4009 n->set_req(0, NULL); |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4010 } |
8b3da8d14c93
7197327: 40% regression on 8 b41 comp 8 b40 on specjvm2008.mpegaudio on oob
roland
parents:
7605
diff
changeset
|
4011 } |
8691
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4012 |
12966 | 4013 /** |
4014 * Remove the speculative part of types and clean up the graph | |
4015 */ | |
4016 void Compile::remove_speculative_types(PhaseIterGVN &igvn) { | |
4017 if (UseTypeSpeculation) { | |
4018 Unique_Node_List worklist; | |
4019 worklist.push(root()); | |
4020 int modified = 0; | |
4021 // Go over all type nodes that carry a speculative type, drop the | |
4022 // speculative part of the type and enqueue the node for an igvn | |
4023 // which may optimize it out. | |
4024 for (uint next = 0; next < worklist.size(); ++next) { | |
4025 Node *n = worklist.at(next); | |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4026 if (n->is_Type()) { |
12966 | 4027 TypeNode* tn = n->as_Type(); |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4028 const Type* t = tn->type(); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4029 const Type* t_no_spec = t->remove_speculative(); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4030 if (t_no_spec != t) { |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4031 bool in_hash = igvn.hash_delete(n); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4032 assert(in_hash, "node should be in igvn hash table"); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4033 tn->set_type(t_no_spec); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4034 igvn.hash_insert(n); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4035 igvn._worklist.push(n); // give it a chance to go away |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4036 modified++; |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4037 } |
12966 | 4038 } |
4039 uint max = n->len(); | |
4040 for( uint i = 0; i < max; ++i ) { | |
4041 Node *m = n->in(i); | |
4042 if (not_a_node(m)) continue; | |
4043 worklist.push(m); | |
4044 } | |
4045 } | |
4046 // Drop the speculative part of all types in the igvn's type table | |
4047 igvn.remove_speculative_types(); | |
4048 if (modified > 0) { | |
4049 igvn.optimize(); | |
4050 } | |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4051 #ifdef ASSERT |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4052 // Verify that after the IGVN is over no speculative type has resurfaced |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4053 worklist.clear(); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4054 worklist.push(root()); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4055 for (uint next = 0; next < worklist.size(); ++next) { |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4056 Node *n = worklist.at(next); |
17895
31e28ee4c9b4
8038921: assert(t != NULL) failed: must set before get
anoll
parents:
17810
diff
changeset
|
4057 const Type* t = igvn.type_or_null(n); |
31e28ee4c9b4
8038921: assert(t != NULL) failed: must set before get
anoll
parents:
17810
diff
changeset
|
4058 assert((t == NULL) || (t == t->remove_speculative()), "no more speculative types"); |
14383
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4059 if (n->is_Type()) { |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4060 t = n->as_Type()->type(); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4061 assert(t == t->remove_speculative(), "no more speculative types"); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4062 } |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4063 uint max = n->len(); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4064 for( uint i = 0; i < max; ++i ) { |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4065 Node *m = n->in(i); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4066 if (not_a_node(m)) continue; |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4067 worklist.push(m); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4068 } |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4069 } |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4070 igvn.check_no_speculative_types(); |
5ec7dace41a6
8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents:
14232
diff
changeset
|
4071 #endif |
12966 | 4072 } |
4073 } | |
4074 | |
23872
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4075 // Convert integer value to a narrowed long type dependent on ctrl (for example, a range check) |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4076 Node* Compile::constrained_convI2L(PhaseGVN* phase, Node* value, const TypeInt* itype, Node* ctrl) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4077 if (ctrl != NULL) { |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4078 // Express control dependency by a CastII node with a narrow type. |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4079 value = new (phase->C) CastIINode(value, itype, false, true /* range check dependency */); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4080 // Make the CastII node dependent on the control input to prevent the narrowed ConvI2L |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4081 // node from floating above the range check during loop optimizations. Otherwise, the |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4082 // ConvI2L node may be eliminated independently of the range check, causing the data path |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4083 // to become TOP while the control path is still there (although it's unreachable). |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4084 value->set_req(0, ctrl); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4085 // Save CastII node to remove it after loop optimizations. |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4086 phase->C->add_range_check_cast(value); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4087 value = phase->transform(value); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4088 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4089 const TypeLong* ltype = TypeLong::make(itype->_lo, itype->_hi, itype->_widen); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4090 return phase->transform(new (phase->C) ConvI2LNode(value, ltype)); |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4091 } |
94ec11846b18
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents:
23421
diff
changeset
|
4092 |
8691
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4093 // Auxiliary method to support randomized stressing/fuzzing. |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4094 // |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4095 // This method can be called the arbitrary number of times, with current count |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4096 // as the argument. The logic allows selecting a single candidate from the |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4097 // running list of candidates as follows: |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4098 // int count = 0; |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4099 // Cand* selected = null; |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4100 // while(cand = cand->next()) { |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4101 // if (randomized_select(++count)) { |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4102 // selected = cand; |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4103 // } |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4104 // } |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4105 // |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4106 // Including count equalizes the chances any candidate is "selected". |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4107 // This is useful when we don't have the complete list of candidates to choose |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4108 // from uniformly. In this case, we need to adjust the randomicity of the |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4109 // selection, or else we will end up biasing the selection towards the latter |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4110 // candidates. |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4111 // |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4112 // Quick back-envelope calculation shows that for the list of n candidates |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4113 // the equal probability for the candidate to persist as "best" can be |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4114 // achieved by replacing it with "next" k-th candidate with the probability |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4115 // of 1/k. It can be easily shown that by the end of the run, the |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4116 // probability for any candidate is converged to 1/n, thus giving the |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4117 // uniform distribution among all the candidates. |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4118 // |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4119 // We don't care about the domain size as long as (RANDOMIZED_DOMAIN / count) is large. |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4120 #define RANDOMIZED_DOMAIN_POW 29 |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4121 #define RANDOMIZED_DOMAIN (1 << RANDOMIZED_DOMAIN_POW) |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4122 #define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1) |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4123 bool Compile::randomized_select(int count) { |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4124 assert(count > 0, "only positive"); |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4125 return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count); |
571076d3c79d
8009120: Fuzz instruction scheduling in HotSpot compilers
shade
parents:
8048
diff
changeset
|
4126 } |