src/share/vm/ci/bcEscapeAnalyzer.hpp

Wed, 06 Jan 2010 14:22:39 -0800

author
never
date
Wed, 06 Jan 2010 14:22:39 -0800
changeset 1577
4ce7240d622c
parent 631
d1605aabd0a1
child 1558
167c2986d91b
permissions
-rw-r--r--

6914300: ciEnv should export all well known classes
Reviewed-by: kvn, twisti

duke@435 1 /*
xdono@631 2 * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 define_array(ciObjectArray, ciObject*);
duke@435 26 define_stack(ciObjectList, ciObjectArray);
duke@435 27
duke@435 28 // This class implements a fast, conservative analysis of effect of methods
duke@435 29 // on the escape state of their arguments. The analysis is at the bytecode
duke@435 30 // level.
duke@435 31
duke@435 32 class ciMethodBlocks;
duke@435 33 class ciBlock;
duke@435 34
duke@435 35 class BCEscapeAnalyzer : public ResourceObj {
duke@435 36 private:
duke@435 37 bool _conservative; // If true, return maximally
duke@435 38 // conservative results.
duke@435 39 ciMethod* _method;
duke@435 40 ciMethodData* _methodData;
duke@435 41 int _arg_size;
duke@435 42
duke@435 43 intStack _stack;
duke@435 44
duke@435 45 BitMap _arg_local;
duke@435 46 BitMap _arg_stack;
duke@435 47 BitMap _arg_returned;
duke@435 48 BitMap _dirty;
kvn@480 49 enum{ ARG_OFFSET_MAX = 31};
kvn@480 50 uint *_arg_modified;
duke@435 51
duke@435 52 bool _return_local;
kvn@513 53 bool _return_allocated;
duke@435 54 bool _allocated_escapes;
kvn@480 55 bool _unknown_modified;
duke@435 56
duke@435 57 ciObjectList _dependencies;
duke@435 58
duke@435 59 ciMethodBlocks *_methodBlocks;
duke@435 60
duke@435 61 BCEscapeAnalyzer* _parent;
duke@435 62 int _level;
duke@435 63
duke@435 64 class ArgumentMap;
duke@435 65 class StateInfo;
duke@435 66
duke@435 67 // helper functions
duke@435 68 bool is_argument(int i) { return i >= 0 && i < _arg_size; }
duke@435 69
duke@435 70 void raw_push(int i) { _stack.push(i); }
duke@435 71 int raw_pop() { return _stack.is_empty() ? -1 : _stack.pop(); }
duke@435 72 void apush(int i) { raw_push(i); }
duke@435 73 void spush() { raw_push(-1); }
duke@435 74 void lpush() { spush(); spush(); }
duke@435 75 int apop() { return raw_pop(); }
duke@435 76 void spop() { assert(_stack.is_empty() || _stack.top() == -1, ""); raw_pop(); }
duke@435 77 void lpop() { spop(); spop(); }
duke@435 78
duke@435 79 void set_returned(ArgumentMap vars);
duke@435 80 bool is_argument(ArgumentMap vars);
duke@435 81 bool is_arg_stack(ArgumentMap vars);
duke@435 82 void clear_bits(ArgumentMap vars, BitMap &bs);
duke@435 83 void set_method_escape(ArgumentMap vars);
duke@435 84 void set_global_escape(ArgumentMap vars);
duke@435 85 void set_dirty(ArgumentMap vars);
kvn@480 86 void set_modified(ArgumentMap vars, int offs, int size);
duke@435 87
duke@435 88 bool is_recursive_call(ciMethod* callee);
duke@435 89 void add_dependence(ciKlass *klass, ciMethod *meth);
duke@435 90 void propagate_dependencies(ciMethod *meth);
duke@435 91 void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
duke@435 92
duke@435 93 void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
duke@435 94 void iterate_blocks(Arena *);
duke@435 95 void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
duke@435 96
duke@435 97 // analysis
duke@435 98 void initialize();
duke@435 99 void clear_escape_info();
duke@435 100 void compute_escape_info();
duke@435 101 vmIntrinsics::ID known_intrinsic();
duke@435 102 bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
duke@435 103 bool do_analysis();
duke@435 104
duke@435 105 void read_escape_info();
duke@435 106
duke@435 107 bool contains(uint arg_set1, uint arg_set2);
duke@435 108
duke@435 109 public:
duke@435 110 BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
duke@435 111
duke@435 112 // accessors
duke@435 113 ciMethod* method() const { return _method; }
duke@435 114 ciMethodData* methodData() const { return _methodData; }
duke@435 115 BCEscapeAnalyzer* parent() const { return _parent; }
duke@435 116 int level() const { return _level; }
duke@435 117 ciObjectList* dependencies() { return &_dependencies; }
duke@435 118 bool has_dependencies() const { return !_dependencies.is_empty(); }
duke@435 119
duke@435 120 // retrieval of interprocedural escape information
duke@435 121
duke@435 122 // The given argument does not escape the callee.
duke@435 123 bool is_arg_local(int i) const {
duke@435 124 return !_conservative && _arg_local.at(i);
duke@435 125 }
duke@435 126
duke@435 127 // The given argument escapes the callee, but does not become globally
duke@435 128 // reachable.
duke@435 129 bool is_arg_stack(int i) const {
duke@435 130 return !_conservative && _arg_stack.at(i);
duke@435 131 }
duke@435 132
duke@435 133 // The given argument does not escape globally, and may be returned.
duke@435 134 bool is_arg_returned(int i) const {
duke@435 135 return !_conservative && _arg_returned.at(i); }
duke@435 136
duke@435 137 // True iff only input arguments are returned.
duke@435 138 bool is_return_local() const {
duke@435 139 return !_conservative && _return_local;
duke@435 140 }
duke@435 141
duke@435 142 // True iff only newly allocated unescaped objects are returned.
duke@435 143 bool is_return_allocated() const {
duke@435 144 return !_conservative && _return_allocated && !_allocated_escapes;
duke@435 145 }
duke@435 146
kvn@480 147 // Tracking of argument modification
kvn@480 148
kvn@480 149 enum {OFFSET_ANY = -1};
kvn@480 150 bool is_arg_modified(int arg, int offset, int size_in_bytes);
kvn@480 151 void set_arg_modified(int arg, int offset, int size_in_bytes);
kvn@480 152 bool has_non_arg_side_affects() { return _unknown_modified; }
kvn@480 153
duke@435 154 // Copy dependencies from this analysis into "deps"
duke@435 155 void copy_dependencies(Dependencies *deps);
kvn@513 156
kvn@513 157 #ifndef PRODUCT
kvn@513 158 // dump escape information
kvn@513 159 void dump();
kvn@513 160 #endif
duke@435 161 };

mercurial