src/share/vm/ci/bcEscapeAnalyzer.hpp

Wed, 17 Sep 2008 12:59:52 -0700

author
never
date
Wed, 17 Sep 2008 12:59:52 -0700
changeset 802
194b8e3a2fc4
parent 631
d1605aabd0a1
child 1558
167c2986d91b
permissions
-rw-r--r--

6384206: Phis which are later unneeded are impairing our ability to inline based on static types
Reviewed-by: rasbold, jrose

     1 /*
     2  * Copyright 2005-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 define_array(ciObjectArray, ciObject*);
    26 define_stack(ciObjectList, ciObjectArray);
    28 // This class implements a fast, conservative analysis of effect of methods
    29 // on the escape state of their arguments.  The analysis is at the bytecode
    30 // level.
    32 class  ciMethodBlocks;
    33 class  ciBlock;
    35 class BCEscapeAnalyzer : public ResourceObj {
    36  private:
    37   bool              _conservative; // If true, return maximally
    38                                    // conservative results.
    39   ciMethod*         _method;
    40   ciMethodData*     _methodData;
    41   int               _arg_size;
    43   intStack          _stack;
    45   BitMap            _arg_local;
    46   BitMap            _arg_stack;
    47   BitMap            _arg_returned;
    48   BitMap            _dirty;
    49   enum{ ARG_OFFSET_MAX = 31};
    50   uint              *_arg_modified;
    52   bool              _return_local;
    53   bool              _return_allocated;
    54   bool              _allocated_escapes;
    55   bool              _unknown_modified;
    57   ciObjectList     _dependencies;
    59   ciMethodBlocks   *_methodBlocks;
    61   BCEscapeAnalyzer* _parent;
    62   int               _level;
    64   class  ArgumentMap;
    65   class  StateInfo;
    67   // helper functions
    68   bool is_argument(int i)    { return i >= 0 && i < _arg_size; }
    70   void raw_push(int i)       { _stack.push(i); }
    71   int  raw_pop()             { return _stack.is_empty() ? -1 : _stack.pop(); }
    72   void apush(int i)          { raw_push(i); }
    73   void spush()               { raw_push(-1); }
    74   void lpush()               { spush(); spush(); }
    75   int  apop()                { return raw_pop(); }
    76   void spop()                { assert(_stack.is_empty() || _stack.top() == -1, ""); raw_pop(); }
    77   void lpop()                { spop(); spop(); }
    79   void set_returned(ArgumentMap vars);
    80   bool is_argument(ArgumentMap vars);
    81   bool is_arg_stack(ArgumentMap vars);
    82   void clear_bits(ArgumentMap vars, BitMap &bs);
    83   void set_method_escape(ArgumentMap vars);
    84   void set_global_escape(ArgumentMap vars);
    85   void set_dirty(ArgumentMap vars);
    86   void set_modified(ArgumentMap vars, int offs, int size);
    88   bool is_recursive_call(ciMethod* callee);
    89   void add_dependence(ciKlass *klass, ciMethod *meth);
    90   void propagate_dependencies(ciMethod *meth);
    91   void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
    93   void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
    94   void iterate_blocks(Arena *);
    95   void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
    97   // analysis
    98   void initialize();
    99   void clear_escape_info();
   100   void compute_escape_info();
   101   vmIntrinsics::ID known_intrinsic();
   102   bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
   103   bool do_analysis();
   105   void read_escape_info();
   107   bool contains(uint arg_set1, uint arg_set2);
   109  public:
   110   BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
   112   // accessors
   113   ciMethod*         method() const               { return _method; }
   114   ciMethodData*     methodData() const           { return _methodData; }
   115   BCEscapeAnalyzer* parent() const               { return _parent; }
   116   int               level() const                { return _level; }
   117   ciObjectList*     dependencies()               { return &_dependencies; }
   118   bool              has_dependencies() const     { return !_dependencies.is_empty(); }
   120   // retrieval of interprocedural escape information
   122   // The given argument does not escape the callee.
   123   bool is_arg_local(int i) const {
   124     return !_conservative && _arg_local.at(i);
   125   }
   127   // The given argument escapes the callee, but does not become globally
   128   // reachable.
   129   bool is_arg_stack(int i) const {
   130     return !_conservative && _arg_stack.at(i);
   131   }
   133   // The given argument does not escape globally, and may be returned.
   134   bool is_arg_returned(int i) const {
   135     return !_conservative && _arg_returned.at(i); }
   137   // True iff only input arguments are returned.
   138   bool is_return_local() const {
   139     return !_conservative && _return_local;
   140   }
   142   // True iff only newly allocated unescaped objects are returned.
   143   bool is_return_allocated() const {
   144     return !_conservative && _return_allocated && !_allocated_escapes;
   145   }
   147   // Tracking of argument modification
   149   enum {OFFSET_ANY = -1};
   150   bool is_arg_modified(int arg, int offset, int size_in_bytes);
   151   void set_arg_modified(int arg, int offset, int size_in_bytes);
   152   bool has_non_arg_side_affects()    { return _unknown_modified; }
   154   // Copy dependencies from this analysis into "deps"
   155   void copy_dependencies(Dependencies *deps);
   157 #ifndef PRODUCT
   158   // dump escape information
   159   void dump();
   160 #endif
   161 };

mercurial