Mercurial > hg > truffle
annotate src/share/vm/ci/bcEscapeAnalyzer.hpp @ 6800:9191895df19d
7200001: failed C1 OSR compile doesn't get recompiled with C2
Reviewed-by: kvn
author | twisti |
---|---|
date | Mon, 24 Sep 2012 17:59:24 -0700 |
parents | da91efe96a93 |
children | c90c698831d7 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4122
diff
changeset
|
2 * Copyright (c) 2005, 2012, 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:
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CI_BCESCAPEANALYZER_HPP |
26 #define SHARE_VM_CI_BCESCAPEANALYZER_HPP | |
27 | |
28 #ifdef COMPILER2 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4122
diff
changeset
|
29 #include "ci/ciObject.hpp" |
1972 | 30 #include "ci/ciMethod.hpp" |
31 #include "ci/ciMethodData.hpp" | |
32 #include "code/dependencies.hpp" | |
33 #include "libadt/vectset.hpp" | |
34 #include "memory/allocation.hpp" | |
35 #include "utilities/growableArray.hpp" | |
36 #endif | |
37 | |
0 | 38 // This class implements a fast, conservative analysis of effect of methods |
39 // on the escape state of their arguments. The analysis is at the bytecode | |
40 // level. | |
41 | |
42 class ciMethodBlocks; | |
43 class ciBlock; | |
44 | |
45 class BCEscapeAnalyzer : public ResourceObj { | |
46 private: | |
1648
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
47 Arena* _arena; // ciEnv arena |
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
48 |
0 | 49 bool _conservative; // If true, return maximally |
50 // conservative results. | |
51 ciMethod* _method; | |
52 ciMethodData* _methodData; | |
53 int _arg_size; | |
1648
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
54 VectorSet _arg_local; |
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
55 VectorSet _arg_stack; |
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
56 VectorSet _arg_returned; |
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
57 VectorSet _dirty; |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
58 enum{ ARG_OFFSET_MAX = 31}; |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
59 uint *_arg_modified; |
0 | 60 |
61 bool _return_local; | |
78
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
62 bool _return_allocated; |
0 | 63 bool _allocated_escapes; |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
64 bool _unknown_modified; |
0 | 65 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4122
diff
changeset
|
66 GrowableArray<ciMetadata *> _dependencies; |
0 | 67 |
68 ciMethodBlocks *_methodBlocks; | |
69 | |
70 BCEscapeAnalyzer* _parent; | |
71 int _level; | |
72 | |
1123
167c2986d91b
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
196
diff
changeset
|
73 public: |
0 | 74 class ArgumentMap; |
75 class StateInfo; | |
76 | |
1123
167c2986d91b
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
196
diff
changeset
|
77 private: |
0 | 78 // helper functions |
79 bool is_argument(int i) { return i >= 0 && i < _arg_size; } | |
80 void set_returned(ArgumentMap vars); | |
81 bool is_argument(ArgumentMap vars); | |
82 bool is_arg_stack(ArgumentMap vars); | |
1648
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
83 void clear_bits(ArgumentMap vars, VectorSet &bs); |
0 | 84 void set_method_escape(ArgumentMap vars); |
4122
cc81b9c09bbb
7112478: after 7105605 JRuby bench_define_method_methods.rb fails with NPE
kvn
parents:
1972
diff
changeset
|
85 void set_global_escape(ArgumentMap vars, bool merge = false); |
0 | 86 void set_dirty(ArgumentMap vars); |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
87 void set_modified(ArgumentMap vars, int offs, int size); |
0 | 88 |
89 bool is_recursive_call(ciMethod* callee); | |
90 void add_dependence(ciKlass *klass, ciMethod *meth); | |
91 void propagate_dependencies(ciMethod *meth); | |
92 void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder); | |
93 | |
94 void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors); | |
95 void iterate_blocks(Arena *); | |
96 void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state); | |
97 | |
98 // analysis | |
99 void initialize(); | |
100 void clear_escape_info(); | |
101 void compute_escape_info(); | |
102 vmIntrinsics::ID known_intrinsic(); | |
103 bool compute_escape_for_intrinsic(vmIntrinsics::ID iid); | |
104 bool do_analysis(); | |
105 | |
106 void read_escape_info(); | |
107 | |
108 bool contains(uint arg_set1, uint arg_set2); | |
109 | |
110 public: | |
111 BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL); | |
112 | |
113 // accessors | |
114 ciMethod* method() const { return _method; } | |
115 ciMethodData* methodData() const { return _methodData; } | |
116 BCEscapeAnalyzer* parent() const { return _parent; } | |
117 int level() const { return _level; } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4122
diff
changeset
|
118 GrowableArray<ciMetadata *>* dependencies() { return &_dependencies; } |
0 | 119 bool has_dependencies() const { return !_dependencies.is_empty(); } |
120 | |
121 // retrieval of interprocedural escape information | |
122 | |
123 // The given argument does not escape the callee. | |
124 bool is_arg_local(int i) const { | |
1648
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
125 return !_conservative && _arg_local.test(i); |
0 | 126 } |
127 | |
128 // The given argument escapes the callee, but does not become globally | |
129 // reachable. | |
130 bool is_arg_stack(int i) const { | |
1648
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
131 return !_conservative && _arg_stack.test(i); |
0 | 132 } |
133 | |
134 // The given argument does not escape globally, and may be returned. | |
135 bool is_arg_returned(int i) const { | |
1648
8099e71601df
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
1552
diff
changeset
|
136 return !_conservative && _arg_returned.test(i); } |
0 | 137 |
138 // True iff only input arguments are returned. | |
139 bool is_return_local() const { | |
140 return !_conservative && _return_local; | |
141 } | |
142 | |
143 // True iff only newly allocated unescaped objects are returned. | |
144 bool is_return_allocated() const { | |
145 return !_conservative && _return_allocated && !_allocated_escapes; | |
146 } | |
147 | |
45
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
148 // Tracking of argument modification |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
149 |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
150 enum {OFFSET_ANY = -1}; |
48a3fa21394b
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
0
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 |
0 | 155 // Copy dependencies from this analysis into "deps" |
156 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
|
157 |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
158 #ifndef PRODUCT |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
159 // dump escape information |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
160 void dump(); |
e1e86702e43e
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
45
diff
changeset
|
161 #endif |
0 | 162 }; |
1972 | 163 |
164 #endif // SHARE_VM_CI_BCESCAPEANALYZER_HPP |