Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/ci/bcEscapeAnalyzer.hpp
40930 views
1
/*
2
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
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
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_CI_BCESCAPEANALYZER_HPP
26
#define SHARE_CI_BCESCAPEANALYZER_HPP
27
28
#ifdef COMPILER2
29
#include "ci/ciObject.hpp"
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
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:
47
Arena* _arena; // ciEnv arena
48
49
bool _conservative; // If true, return maximally
50
// conservative results.
51
ciMethod* _method;
52
ciMethodData* _methodData;
53
int _arg_size;
54
VectorSet _arg_local;
55
VectorSet _arg_stack;
56
VectorSet _arg_returned;
57
enum{ ARG_OFFSET_MAX = 31};
58
uint *_arg_modified;
59
60
bool _return_local;
61
bool _return_allocated;
62
bool _allocated_escapes;
63
bool _unknown_modified;
64
65
GrowableArray<ciMetadata*> _dependencies;
66
67
ciMethodBlocks *_methodBlocks;
68
69
BCEscapeAnalyzer* _parent;
70
int _level;
71
72
public:
73
class ArgumentMap;
74
class StateInfo;
75
76
private:
77
// helper functions
78
bool is_argument(int i) { return i >= 0 && i < _arg_size; }
79
void set_returned(ArgumentMap vars);
80
bool is_argument(ArgumentMap vars);
81
bool is_arg_stack(ArgumentMap vars);
82
bool returns_all(ArgumentMap vars);
83
void clear_bits(ArgumentMap vars, VectorSet &bs);
84
void set_method_escape(ArgumentMap vars);
85
void set_global_escape(ArgumentMap vars, bool merge = false);
86
void set_modified(ArgumentMap vars, int offs, int size);
87
88
bool is_recursive_call(ciMethod* callee);
89
void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
90
91
void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
92
void iterate_blocks(Arena *);
93
void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
94
95
// analysis
96
void initialize();
97
void clear_escape_info();
98
void compute_escape_info();
99
vmIntrinsicID known_intrinsic();
100
void compute_escape_for_intrinsic(vmIntrinsicID iid);
101
void do_analysis();
102
103
void read_escape_info();
104
105
bool contains(uint arg_set1, uint arg_set2);
106
107
public:
108
BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
109
110
// accessors
111
ciMethod* method() const { return _method; }
112
ciMethodData* methodData() const { return _methodData; }
113
BCEscapeAnalyzer* parent() const { return _parent; }
114
int level() const { return _level; }
115
GrowableArray<ciMetadata *>* dependencies() { return &_dependencies; }
116
bool has_dependencies() const { return !_dependencies.is_empty(); }
117
118
// retrieval of interprocedural escape information
119
120
// The given argument does not escape the callee.
121
bool is_arg_local(int i) const {
122
return !_conservative && _arg_local.test(i);
123
}
124
125
// The given argument escapes the callee, but does not become globally
126
// reachable.
127
bool is_arg_stack(int i) const {
128
return !_conservative && _arg_stack.test(i);
129
}
130
131
// The given argument does not escape globally, and may be returned.
132
bool is_arg_returned(int i) const {
133
return !_conservative && _arg_returned.test(i); }
134
135
// True iff only input arguments are returned.
136
bool is_return_local() const {
137
return !_conservative && _return_local;
138
}
139
140
// True iff only newly allocated non-escaped objects are returned.
141
bool is_return_allocated() const {
142
return !_conservative && _return_allocated && !_allocated_escapes;
143
}
144
145
// Tracking of argument modification
146
147
enum {OFFSET_ANY = -1};
148
bool is_arg_modified(int arg, int offset, int size_in_bytes);
149
void set_arg_modified(int arg, int offset, int size_in_bytes);
150
bool has_non_arg_side_affects() { return _unknown_modified; }
151
152
// Copy dependencies from this analysis into "deps"
153
void copy_dependencies(Dependencies *deps);
154
155
#ifndef PRODUCT
156
// dump escape information
157
void dump();
158
#endif
159
};
160
161
#endif // SHARE_CI_BCESCAPEANALYZER_HPP
162
163