Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/ci/bcEscapeAnalyzer.hpp
32285 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_CI_BCESCAPEANALYZER_HPP25#define SHARE_VM_CI_BCESCAPEANALYZER_HPP2627#ifdef COMPILER228#include "ci/ciObject.hpp"29#include "ci/ciMethod.hpp"30#include "ci/ciMethodData.hpp"31#include "code/dependencies.hpp"32#include "libadt/vectset.hpp"33#include "memory/allocation.hpp"34#include "utilities/growableArray.hpp"35#endif3637// This class implements a fast, conservative analysis of effect of methods38// on the escape state of their arguments. The analysis is at the bytecode39// level.4041class ciMethodBlocks;42class ciBlock;4344class BCEscapeAnalyzer : public ResourceObj {45private:46Arena* _arena; // ciEnv arena4748bool _conservative; // If true, return maximally49// conservative results.50ciMethod* _method;51ciMethodData* _methodData;52int _arg_size;53VectorSet _arg_local;54VectorSet _arg_stack;55VectorSet _arg_returned;56VectorSet _dirty;57enum{ ARG_OFFSET_MAX = 31};58uint *_arg_modified;5960bool _return_local;61bool _return_allocated;62bool _allocated_escapes;63bool _unknown_modified;6465GrowableArray<ciMetadata *> _dependencies;6667ciMethodBlocks *_methodBlocks;6869BCEscapeAnalyzer* _parent;70int _level;7172public:73class ArgumentMap;74class StateInfo;7576private:77// helper functions78bool is_argument(int i) { return i >= 0 && i < _arg_size; }79void set_returned(ArgumentMap vars);80bool is_argument(ArgumentMap vars);81bool is_arg_stack(ArgumentMap vars);82bool returns_all(ArgumentMap vars);83void clear_bits(ArgumentMap vars, VectorSet &bs);84void set_method_escape(ArgumentMap vars);85void set_global_escape(ArgumentMap vars, bool merge = false);86void set_dirty(ArgumentMap vars);87void set_modified(ArgumentMap vars, int offs, int size);8889bool is_recursive_call(ciMethod* callee);90void add_dependence(ciKlass *klass, ciMethod *meth);91void propagate_dependencies(ciMethod *meth);92void invoke(StateInfo &state, Bytecodes::Code code, ciMethod* target, ciKlass* holder);9394void iterate_one_block(ciBlock *blk, StateInfo &state, GrowableArray<ciBlock *> &successors);95void iterate_blocks(Arena *);96void merge_block_states(StateInfo *blockstates, ciBlock *dest, StateInfo *s_state);9798// analysis99void initialize();100void clear_escape_info();101void compute_escape_info();102vmIntrinsics::ID known_intrinsic();103void compute_escape_for_intrinsic(vmIntrinsics::ID iid);104void do_analysis();105106void read_escape_info();107108bool contains(uint arg_set1, uint arg_set2);109110public:111BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL);112113// accessors114ciMethod* method() const { return _method; }115ciMethodData* methodData() const { return _methodData; }116BCEscapeAnalyzer* parent() const { return _parent; }117int level() const { return _level; }118GrowableArray<ciMetadata *>* dependencies() { return &_dependencies; }119bool has_dependencies() const { return !_dependencies.is_empty(); }120121// retrieval of interprocedural escape information122123// The given argument does not escape the callee.124bool is_arg_local(int i) const {125return !_conservative && _arg_local.test(i);126}127128// The given argument escapes the callee, but does not become globally129// reachable.130bool is_arg_stack(int i) const {131return !_conservative && _arg_stack.test(i);132}133134// The given argument does not escape globally, and may be returned.135bool is_arg_returned(int i) const {136return !_conservative && _arg_returned.test(i); }137138// True iff only input arguments are returned.139bool is_return_local() const {140return !_conservative && _return_local;141}142143// True iff only newly allocated unescaped objects are returned.144bool is_return_allocated() const {145return !_conservative && _return_allocated && !_allocated_escapes;146}147148// Tracking of argument modification149150enum {OFFSET_ANY = -1};151bool is_arg_modified(int arg, int offset, int size_in_bytes);152void set_arg_modified(int arg, int offset, int size_in_bytes);153bool has_non_arg_side_affects() { return _unknown_modified; }154155// Copy dependencies from this analysis into "deps"156void copy_dependencies(Dependencies *deps);157158#ifndef PRODUCT159// dump escape information160void dump();161#endif162};163164#endif // SHARE_VM_CI_BCESCAPEANALYZER_HPP165166167