src/share/vm/ci/bcEscapeAnalyzer.hpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 480
48a3fa21394b
permissions
-rw-r--r--

Initial load

     1 /*
     2  * Copyright 2005-2006 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;
    50   bool              _return_local;
    51   bool              _allocated_escapes;
    52   bool              _return_allocated;
    54   ciObjectList     _dependencies;
    56   ciMethodBlocks   *_methodBlocks;
    58   BCEscapeAnalyzer* _parent;
    59   int               _level;
    61   class  ArgumentMap;
    62   class  StateInfo;
    64   // helper functions
    65   bool is_argument(int i)    { return i >= 0 && i < _arg_size; }
    67   void raw_push(int i)       { _stack.push(i); }
    68   int  raw_pop()             { return _stack.is_empty() ? -1 : _stack.pop(); }
    69   void apush(int i)          { raw_push(i); }
    70   void spush()               { raw_push(-1); }
    71   void lpush()               { spush(); spush(); }
    72   int  apop()                { return raw_pop(); }
    73   void spop()                { assert(_stack.is_empty() || _stack.top() == -1, ""); raw_pop(); }
    74   void lpop()                { spop(); spop(); }
    76   void set_returned(ArgumentMap vars);
    77   bool is_argument(ArgumentMap vars);
    78   bool is_arg_stack(ArgumentMap vars);
    79   void clear_bits(ArgumentMap vars, BitMap &bs);
    80   void set_method_escape(ArgumentMap vars);
    81   void set_global_escape(ArgumentMap vars);
    82   void set_dirty(ArgumentMap vars);
    84   bool is_recursive_call(ciMethod* callee);
    85   void add_dependence(ciKlass *klass, ciMethod *meth);
    86   void propagate_dependencies(ciMethod *meth);
    87   void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
    89   void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
    90   void iterate_blocks(Arena *);
    91   void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
    93   // analysis
    94   void initialize();
    95   void clear_escape_info();
    96   void compute_escape_info();
    97   vmIntrinsics::ID known_intrinsic();
    98   bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
    99   bool do_analysis();
   101   void read_escape_info();
   103   bool contains(uint arg_set1, uint arg_set2);
   105  public:
   106   BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
   108   // accessors
   109   ciMethod*         method() const               { return _method; }
   110   ciMethodData*     methodData() const           { return _methodData; }
   111   BCEscapeAnalyzer* parent() const               { return _parent; }
   112   int               level() const                { return _level; }
   113   ciObjectList*     dependencies()               { return &_dependencies; }
   114   bool              has_dependencies() const     { return !_dependencies.is_empty(); }
   116   // retrieval of interprocedural escape information
   118   // The given argument does not escape the callee.
   119   bool is_arg_local(int i) const {
   120     return !_conservative && _arg_local.at(i);
   121   }
   123   // The given argument escapes the callee, but does not become globally
   124   // reachable.
   125   bool is_arg_stack(int i) const {
   126     return !_conservative && _arg_stack.at(i);
   127   }
   129   // The given argument does not escape globally, and may be returned.
   130   bool is_arg_returned(int i) const {
   131     return !_conservative && _arg_returned.at(i); }
   133   // True iff only input arguments are returned.
   134   bool is_return_local() const {
   135     return !_conservative && _return_local;
   136   }
   138   // True iff only newly allocated unescaped objects are returned.
   139   bool is_return_allocated() const {
   140     return !_conservative && _return_allocated && !_allocated_escapes;
   141   }
   143   // Copy dependencies from this analysis into "deps"
   144   void copy_dependencies(Dependencies *deps);
   145 };

mercurial