author | kvn |
Wed, 14 Jul 2010 14:47:34 -0700 | |
changeset 5928 | f6e69b46e9e3 |
parent 5547 | f4b087cbb361 |
child 7397 | 5b173b4ca846 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
2 |
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
// This class implements a fast, conservative analysis of effect of methods |
|
26 |
// on the escape state of their arguments. The analysis is at the bytecode |
|
27 |
// level. |
|
28 |
||
29 |
class ciMethodBlocks; |
|
30 |
class ciBlock; |
|
31 |
||
32 |
class BCEscapeAnalyzer : public ResourceObj { |
|
33 |
private: |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
34 |
Arena* _arena; // ciEnv arena |
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
35 |
|
1 | 36 |
bool _conservative; // If true, return maximally |
37 |
// conservative results. |
|
38 |
ciMethod* _method; |
|
39 |
ciMethodData* _methodData; |
|
40 |
int _arg_size; |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
41 |
VectorSet _arg_local; |
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
42 |
VectorSet _arg_stack; |
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
43 |
VectorSet _arg_returned; |
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
44 |
VectorSet _dirty; |
218
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
45 |
enum{ ARG_OFFSET_MAX = 31}; |
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
46 |
uint *_arg_modified; |
1 | 47 |
|
48 |
bool _return_local; |
|
251
cb2e73f71205
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
218
diff
changeset
|
49 |
bool _return_allocated; |
1 | 50 |
bool _allocated_escapes; |
218
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
51 |
bool _unknown_modified; |
1 | 52 |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
53 |
GrowableArray<ciObject *> _dependencies; |
1 | 54 |
|
55 |
ciMethodBlocks *_methodBlocks; |
|
56 |
||
57 |
BCEscapeAnalyzer* _parent; |
|
58 |
int _level; |
|
59 |
||
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
670
diff
changeset
|
60 |
public: |
1 | 61 |
class ArgumentMap; |
62 |
class StateInfo; |
|
63 |
||
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
670
diff
changeset
|
64 |
private: |
1 | 65 |
// helper functions |
66 |
bool is_argument(int i) { return i >= 0 && i < _arg_size; } |
|
67 |
void set_returned(ArgumentMap vars); |
|
68 |
bool is_argument(ArgumentMap vars); |
|
69 |
bool is_arg_stack(ArgumentMap vars); |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
70 |
void clear_bits(ArgumentMap vars, VectorSet &bs); |
1 | 71 |
void set_method_escape(ArgumentMap vars); |
72 |
void set_global_escape(ArgumentMap vars); |
|
73 |
void set_dirty(ArgumentMap vars); |
|
218
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
74 |
void set_modified(ArgumentMap vars, int offs, int size); |
1 | 75 |
|
76 |
bool is_recursive_call(ciMethod* callee); |
|
77 |
void add_dependence(ciKlass *klass, ciMethod *meth); |
|
78 |
void propagate_dependencies(ciMethod *meth); |
|
79 |
void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder); |
|
80 |
||
81 |
void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors); |
|
82 |
void iterate_blocks(Arena *); |
|
83 |
void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state); |
|
84 |
||
85 |
// analysis |
|
86 |
void initialize(); |
|
87 |
void clear_escape_info(); |
|
88 |
void compute_escape_info(); |
|
89 |
vmIntrinsics::ID known_intrinsic(); |
|
90 |
bool compute_escape_for_intrinsic(vmIntrinsics::ID iid); |
|
91 |
bool do_analysis(); |
|
92 |
||
93 |
void read_escape_info(); |
|
94 |
||
95 |
bool contains(uint arg_set1, uint arg_set2); |
|
96 |
||
97 |
public: |
|
98 |
BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL); |
|
99 |
||
100 |
// accessors |
|
101 |
ciMethod* method() const { return _method; } |
|
102 |
ciMethodData* methodData() const { return _methodData; } |
|
103 |
BCEscapeAnalyzer* parent() const { return _parent; } |
|
104 |
int level() const { return _level; } |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
105 |
GrowableArray<ciObject *>* dependencies() { return &_dependencies; } |
1 | 106 |
bool has_dependencies() const { return !_dependencies.is_empty(); } |
107 |
||
108 |
// retrieval of interprocedural escape information |
|
109 |
||
110 |
// The given argument does not escape the callee. |
|
111 |
bool is_arg_local(int i) const { |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
112 |
return !_conservative && _arg_local.test(i); |
1 | 113 |
} |
114 |
||
115 |
// The given argument escapes the callee, but does not become globally |
|
116 |
// reachable. |
|
117 |
bool is_arg_stack(int i) const { |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
118 |
return !_conservative && _arg_stack.test(i); |
1 | 119 |
} |
120 |
||
121 |
// The given argument does not escape globally, and may be returned. |
|
122 |
bool is_arg_returned(int i) const { |
|
5928
f6e69b46e9e3
6968368: SIGSEGV in the BCEscapeAnalyzer::copy_dependencies
kvn
parents:
5547
diff
changeset
|
123 |
return !_conservative && _arg_returned.test(i); } |
1 | 124 |
|
125 |
// True iff only input arguments are returned. |
|
126 |
bool is_return_local() const { |
|
127 |
return !_conservative && _return_local; |
|
128 |
} |
|
129 |
||
130 |
// True iff only newly allocated unescaped objects are returned. |
|
131 |
bool is_return_allocated() const { |
|
132 |
return !_conservative && _return_allocated && !_allocated_escapes; |
|
133 |
} |
|
134 |
||
218
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
135 |
// Tracking of argument modification |
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
136 |
|
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
137 |
enum {OFFSET_ANY = -1}; |
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
138 |
bool is_arg_modified(int arg, int offset, int size_in_bytes); |
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
139 |
void set_arg_modified(int arg, int offset, int size_in_bytes); |
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
140 |
bool has_non_arg_side_affects() { return _unknown_modified; } |
a0e996680b05
6667615: (Escape Analysis) extend MDO to cache arguments escape state
kvn
parents:
1
diff
changeset
|
141 |
|
1 | 142 |
// Copy dependencies from this analysis into "deps" |
143 |
void copy_dependencies(Dependencies *deps); |
|
251
cb2e73f71205
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
218
diff
changeset
|
144 |
|
cb2e73f71205
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
218
diff
changeset
|
145 |
#ifndef PRODUCT |
cb2e73f71205
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
218
diff
changeset
|
146 |
// dump escape information |
cb2e73f71205
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
218
diff
changeset
|
147 |
void dump(); |
cb2e73f71205
6680665: bytecode Escape Analyzer produces incorrect escape information for methods without oop arguments
kvn
parents:
218
diff
changeset
|
148 |
#endif |
1 | 149 |
}; |