annotate src/share/vm/ci/bcEscapeAnalyzer.hpp @ 1941:79d04223b8a5

Added caching for resolved types and resolved fields. This is crucial, because the local load elimination will lead to wrong results, if field equality (of two RiField objects with the same object and the same RiType) is not given. The caching makes sure that the default equals implementation is sufficient.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 28 Dec 2010 18:33:26 +0100
parents 8099e71601df
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1123
diff changeset
2 * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1123
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1123
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: 1123
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // This class implements a fast, conservative analysis of effect of methods
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // on the escape state of their arguments. The analysis is at the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // level.
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class ciMethodBlocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class ciBlock;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class BCEscapeAnalyzer : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 private:
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
34 Arena* _arena; // ciEnv arena
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 bool _conservative; // If true, return maximally
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // conservative results.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ciMethod* _method;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 ciMethodData* _methodData;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int _arg_size;
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
41 VectorSet _arg_local;
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
42 VectorSet _arg_stack;
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
43 VectorSet _arg_returned;
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
44 VectorSet _dirty;
45
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
45 enum{ ARG_OFFSET_MAX = 31};
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
46 uint *_arg_modified;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 bool _return_local;
78
e1e86702e43e 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 45
diff changeset
49 bool _return_allocated;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
50 bool _allocated_escapes;
45
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
51 bool _unknown_modified;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
53 GrowableArray<ciObject *> _dependencies;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 ciMethodBlocks *_methodBlocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 BCEscapeAnalyzer* _parent;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int _level;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 196
diff changeset
60 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 class ArgumentMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 class StateInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
63
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 196
diff changeset
64 private:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // helper functions
a61af66fc99e Initial load
duke
parents:
diff changeset
66 bool is_argument(int i) { return i >= 0 && i < _arg_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void set_returned(ArgumentMap vars);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 bool is_argument(ArgumentMap vars);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bool is_arg_stack(ArgumentMap vars);
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
70 void clear_bits(ArgumentMap vars, VectorSet &bs);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void set_method_escape(ArgumentMap vars);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void set_global_escape(ArgumentMap vars);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 void set_dirty(ArgumentMap vars);
45
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
74 void set_modified(ArgumentMap vars, int offs, int size);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 bool is_recursive_call(ciMethod* callee);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 void add_dependence(ciKlass *klass, ciMethod *meth);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 void propagate_dependencies(ciMethod *meth);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 void iterate_blocks(Arena *);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // analysis
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 void clear_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void compute_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 vmIntrinsics::ID known_intrinsic();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool do_analysis();
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void read_escape_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 bool contains(uint arg_set1, uint arg_set2);
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
98 BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
101 ciMethod* method() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 ciMethodData* methodData() const { return _methodData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 BCEscapeAnalyzer* parent() const { return _parent; }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 int level() const { return _level; }
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
105 GrowableArray<ciObject *>* dependencies() { return &_dependencies; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
106 bool has_dependencies() const { return !_dependencies.is_empty(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // retrieval of interprocedural escape information
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // The given argument does not escape the callee.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 bool is_arg_local(int i) const {
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
112 return !_conservative && _arg_local.test(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // The given argument escapes the callee, but does not become globally
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // reachable.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bool is_arg_stack(int i) const {
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
118 return !_conservative && _arg_stack.test(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // The given argument does not escape globally, and may be returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 bool is_arg_returned(int i) const {
1648
8099e71601df 6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents: 1552
diff changeset
123 return !_conservative && _arg_returned.test(i); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // True iff only input arguments are returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 bool is_return_local() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return !_conservative && _return_local;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // True iff only newly allocated unescaped objects are returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 bool is_return_allocated() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return !_conservative && _return_allocated && !_allocated_escapes;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
45
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
135 // Tracking of argument modification
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
136
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
137 enum {OFFSET_ANY = -1};
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
138 bool is_arg_modified(int arg, int offset, int size_in_bytes);
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
139 void set_arg_modified(int arg, int offset, int size_in_bytes);
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
140 bool has_non_arg_side_affects() { return _unknown_modified; }
48a3fa21394b 6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents: 0
diff changeset
141
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Copy dependencies from this analysis into "deps"
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void copy_dependencies(Dependencies *deps);
78
e1e86702e43e 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 45
diff changeset
144
e1e86702e43e 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 45
diff changeset
145 #ifndef PRODUCT
e1e86702e43e 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 45
diff changeset
146 // dump escape information
e1e86702e43e 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 45
diff changeset
147 void dump();
e1e86702e43e 6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents: 45
diff changeset
148 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 };