src/share/vm/ci/bcEscapeAnalyzer.hpp

Wed, 23 Oct 2013 12:40:23 +0200

author
roland
date
Wed, 23 Oct 2013 12:40:23 +0200
changeset 5991
b2ee5dc63353
parent 5436
c90c698831d7
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8024070: C2 needs some form of type speculation
Summary: record unused type profile information with type system, propagate and use it.
Reviewed-by: kvn, twisti

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CI_BCESCAPEANALYZER_HPP
stefank@2314 26 #define SHARE_VM_CI_BCESCAPEANALYZER_HPP
stefank@2314 27
stefank@2314 28 #ifdef COMPILER2
coleenp@4037 29 #include "ci/ciObject.hpp"
stefank@2314 30 #include "ci/ciMethod.hpp"
stefank@2314 31 #include "ci/ciMethodData.hpp"
stefank@2314 32 #include "code/dependencies.hpp"
stefank@2314 33 #include "libadt/vectset.hpp"
stefank@2314 34 #include "memory/allocation.hpp"
stefank@2314 35 #include "utilities/growableArray.hpp"
stefank@2314 36 #endif
stefank@2314 37
duke@435 38 // This class implements a fast, conservative analysis of effect of methods
duke@435 39 // on the escape state of their arguments. The analysis is at the bytecode
duke@435 40 // level.
duke@435 41
duke@435 42 class ciMethodBlocks;
duke@435 43 class ciBlock;
duke@435 44
duke@435 45 class BCEscapeAnalyzer : public ResourceObj {
duke@435 46 private:
kvn@2003 47 Arena* _arena; // ciEnv arena
kvn@2003 48
duke@435 49 bool _conservative; // If true, return maximally
duke@435 50 // conservative results.
duke@435 51 ciMethod* _method;
duke@435 52 ciMethodData* _methodData;
duke@435 53 int _arg_size;
kvn@2003 54 VectorSet _arg_local;
kvn@2003 55 VectorSet _arg_stack;
kvn@2003 56 VectorSet _arg_returned;
kvn@2003 57 VectorSet _dirty;
kvn@480 58 enum{ ARG_OFFSET_MAX = 31};
kvn@480 59 uint *_arg_modified;
duke@435 60
duke@435 61 bool _return_local;
kvn@513 62 bool _return_allocated;
duke@435 63 bool _allocated_escapes;
kvn@480 64 bool _unknown_modified;
duke@435 65
coleenp@4037 66 GrowableArray<ciMetadata *> _dependencies;
duke@435 67
duke@435 68 ciMethodBlocks *_methodBlocks;
duke@435 69
duke@435 70 BCEscapeAnalyzer* _parent;
duke@435 71 int _level;
duke@435 72
phh@1558 73 public:
duke@435 74 class ArgumentMap;
duke@435 75 class StateInfo;
duke@435 76
phh@1558 77 private:
duke@435 78 // helper functions
duke@435 79 bool is_argument(int i) { return i >= 0 && i < _arg_size; }
duke@435 80 void set_returned(ArgumentMap vars);
duke@435 81 bool is_argument(ArgumentMap vars);
duke@435 82 bool is_arg_stack(ArgumentMap vars);
kvn@5436 83 bool returns_all(ArgumentMap vars);
kvn@2003 84 void clear_bits(ArgumentMap vars, VectorSet &bs);
duke@435 85 void set_method_escape(ArgumentMap vars);
kvn@3318 86 void set_global_escape(ArgumentMap vars, bool merge = false);
duke@435 87 void set_dirty(ArgumentMap vars);
kvn@480 88 void set_modified(ArgumentMap vars, int offs, int size);
duke@435 89
duke@435 90 bool is_recursive_call(ciMethod* callee);
duke@435 91 void add_dependence(ciKlass *klass, ciMethod *meth);
duke@435 92 void propagate_dependencies(ciMethod *meth);
duke@435 93 void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
duke@435 94
duke@435 95 void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
duke@435 96 void iterate_blocks(Arena *);
duke@435 97 void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
duke@435 98
duke@435 99 // analysis
duke@435 100 void initialize();
duke@435 101 void clear_escape_info();
duke@435 102 void compute_escape_info();
duke@435 103 vmIntrinsics::ID known_intrinsic();
duke@435 104 bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
duke@435 105 bool do_analysis();
duke@435 106
duke@435 107 void read_escape_info();
duke@435 108
duke@435 109 bool contains(uint arg_set1, uint arg_set2);
duke@435 110
duke@435 111 public:
duke@435 112 BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
duke@435 113
duke@435 114 // accessors
duke@435 115 ciMethod* method() const { return _method; }
duke@435 116 ciMethodData* methodData() const { return _methodData; }
duke@435 117 BCEscapeAnalyzer* parent() const { return _parent; }
duke@435 118 int level() const { return _level; }
coleenp@4037 119 GrowableArray<ciMetadata *>* dependencies() { return &_dependencies; }
duke@435 120 bool has_dependencies() const { return !_dependencies.is_empty(); }
duke@435 121
duke@435 122 // retrieval of interprocedural escape information
duke@435 123
duke@435 124 // The given argument does not escape the callee.
duke@435 125 bool is_arg_local(int i) const {
kvn@2003 126 return !_conservative && _arg_local.test(i);
duke@435 127 }
duke@435 128
duke@435 129 // The given argument escapes the callee, but does not become globally
duke@435 130 // reachable.
duke@435 131 bool is_arg_stack(int i) const {
kvn@2003 132 return !_conservative && _arg_stack.test(i);
duke@435 133 }
duke@435 134
duke@435 135 // The given argument does not escape globally, and may be returned.
duke@435 136 bool is_arg_returned(int i) const {
kvn@2003 137 return !_conservative && _arg_returned.test(i); }
duke@435 138
duke@435 139 // True iff only input arguments are returned.
duke@435 140 bool is_return_local() const {
duke@435 141 return !_conservative && _return_local;
duke@435 142 }
duke@435 143
duke@435 144 // True iff only newly allocated unescaped objects are returned.
duke@435 145 bool is_return_allocated() const {
duke@435 146 return !_conservative && _return_allocated && !_allocated_escapes;
duke@435 147 }
duke@435 148
kvn@480 149 // Tracking of argument modification
kvn@480 150
kvn@480 151 enum {OFFSET_ANY = -1};
kvn@480 152 bool is_arg_modified(int arg, int offset, int size_in_bytes);
kvn@480 153 void set_arg_modified(int arg, int offset, int size_in_bytes);
kvn@480 154 bool has_non_arg_side_affects() { return _unknown_modified; }
kvn@480 155
duke@435 156 // Copy dependencies from this analysis into "deps"
duke@435 157 void copy_dependencies(Dependencies *deps);
kvn@513 158
kvn@513 159 #ifndef PRODUCT
kvn@513 160 // dump escape information
kvn@513 161 void dump();
kvn@513 162 #endif
duke@435 163 };
stefank@2314 164
stefank@2314 165 #endif // SHARE_VM_CI_BCESCAPEANALYZER_HPP

mercurial