bcEscapeAnalyzer.hpp revision 1879
0N/A/*
0N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A *
0N/A */
0N/A
729N/A#ifndef SHARE_VM_CI_BCESCAPEANALYZER_HPP
0N/A#define SHARE_VM_CI_BCESCAPEANALYZER_HPP
0N/A
0N/A#ifdef COMPILER2
0N/A#include "ci/ciMethod.hpp"
0N/A#include "ci/ciMethodData.hpp"
0N/A#include "code/dependencies.hpp"
0N/A#include "libadt/vectset.hpp"
0N/A#include "memory/allocation.hpp"
233N/A#include "utilities/growableArray.hpp"
233N/A#endif
233N/A
233N/A// This class implements a fast, conservative analysis of effect of methods
233N/A// on the escape state of their arguments. The analysis is at the bytecode
233N/A// level.
233N/A
233N/Aclass ciMethodBlocks;
233N/Aclass ciBlock;
233N/A
233N/Aclass BCEscapeAnalyzer : public ResourceObj {
233N/A private:
712N/A Arena* _arena; // ciEnv arena
233N/A
233N/A bool _conservative; // If true, return maximally
564N/A // conservative results.
0N/A ciMethod* _method;
0N/A ciMethodData* _methodData;
0N/A int _arg_size;
0N/A VectorSet _arg_local;
712N/A VectorSet _arg_stack;
0N/A VectorSet _arg_returned;
0N/A VectorSet _dirty;
0N/A enum{ ARG_OFFSET_MAX = 31};
0N/A uint *_arg_modified;
0N/A
233N/A bool _return_local;
233N/A bool _return_allocated;
0N/A bool _allocated_escapes;
114N/A bool _unknown_modified;
114N/A
114N/A GrowableArray<ciObject *> _dependencies;
114N/A
114N/A ciMethodBlocks *_methodBlocks;
114N/A
0N/A BCEscapeAnalyzer* _parent;
0N/A int _level;
0N/A
0N/A public:
0N/A class ArgumentMap;
0N/A class StateInfo;
0N/A
567N/A private:
567N/A // helper functions
567N/A bool is_argument(int i) { return i >= 0 && i < _arg_size; }
567N/A void set_returned(ArgumentMap vars);
712N/A bool is_argument(ArgumentMap vars);
712N/A bool is_arg_stack(ArgumentMap vars);
712N/A void clear_bits(ArgumentMap vars, VectorSet &bs);
712N/A void set_method_escape(ArgumentMap vars);
712N/A void set_global_escape(ArgumentMap vars);
712N/A void set_dirty(ArgumentMap vars);
675N/A void set_modified(ArgumentMap vars, int offs, int size);
675N/A
712N/A bool is_recursive_call(ciMethod* callee);
675N/A void add_dependence(ciKlass *klass, ciMethod *meth);
567N/A void propagate_dependencies(ciMethod *meth);
0N/A void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);
422N/A
712N/A void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);
422N/A void iterate_blocks(Arena *);
0N/A void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);
422N/A
0N/A // analysis
422N/A void initialize();
0N/A void clear_escape_info();
0N/A void compute_escape_info();
0N/A vmIntrinsics::ID known_intrinsic();
0N/A bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
0N/A bool do_analysis();
0N/A
0N/A void read_escape_info();
0N/A
233N/A bool contains(uint arg_set1, uint arg_set2);
233N/A
233N/A public:
233N/A BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);
730N/A
730N/A // accessors
730N/A ciMethod* method() const { return _method; }
0N/A ciMethodData* methodData() const { return _methodData; }
729N/A BCEscapeAnalyzer* parent() const { return _parent; }
729N/A int level() const { return _level; }
729N/A GrowableArray<ciObject *>* dependencies() { return &_dependencies; }
0N/A bool has_dependencies() const { return !_dependencies.is_empty(); }
0N/A
0N/A // retrieval of interprocedural escape information
110N/A
110N/A // The given argument does not escape the callee.
121N/A bool is_arg_local(int i) const {
699N/A return !_conservative && _arg_local.test(i);
0N/A }
0N/A
0N/A // The given argument escapes the callee, but does not become globally
0N/A // reachable.
0N/A bool is_arg_stack(int i) const {
0N/A return !_conservative && _arg_stack.test(i);
0N/A }
0N/A
0N/A // The given argument does not escape globally, and may be returned.
0N/A bool is_arg_returned(int i) const {
0N/A return !_conservative && _arg_returned.test(i); }
735N/A
0N/A // True iff only input arguments are returned.
0N/A bool is_return_local() const {
0N/A return !_conservative && _return_local;
0N/A }
0N/A
0N/A // True iff only newly allocated unescaped objects are returned.
0N/A bool is_return_allocated() const {
511N/A return !_conservative && _return_allocated && !_allocated_escapes;
0N/A }
0N/A
0N/A // Tracking of argument modification
0N/A
0N/A enum {OFFSET_ANY = -1};
0N/A bool is_arg_modified(int arg, int offset, int size_in_bytes);
0N/A void set_arg_modified(int arg, int offset, int size_in_bytes);
0N/A bool has_non_arg_side_affects() { return _unknown_modified; }
0N/A
0N/A // Copy dependencies from this analysis into "deps"
0N/A void copy_dependencies(Dependencies *deps);
0N/A
0N/A#ifndef PRODUCT
0N/A // dump escape information
735N/A void dump();
0N/A#endif
0N/A};
0N/A
0N/A#endif // SHARE_VM_CI_BCESCAPEANALYZER_HPP
0N/A