Path: blob/master/src/hotspot/share/ci/ciMethodBlocks.hpp
40930 views
/*1* Copyright (c) 2006, 2019, 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_CI_CIMETHODBLOCKS_HPP25#define SHARE_CI_CIMETHODBLOCKS_HPP2627#include "ci/ciMethod.hpp"28#include "memory/resourceArea.hpp"29#include "utilities/growableArray.hpp"303132class ciBlock;3334class ciMethodBlocks : public ResourceObj {35private:36ciMethod *_method;37Arena *_arena;38GrowableArray<ciBlock *> *_blocks;39ciBlock **_bci_to_block;40int _num_blocks;41int _code_size;4243void do_analysis();44public:45ciMethodBlocks(Arena *arena, ciMethod *meth);4647ciBlock *block_containing(int bci);48ciBlock *block(int index) { return _blocks->at(index); }49ciBlock *make_block_at(int bci);50ciBlock *split_block_at(int bci);51bool is_block_start(int bci);52int num_blocks() { return _num_blocks;}53void clear_processed();5455ciBlock *make_dummy_block(); // a block not associated with a bci5657#ifndef PRODUCT58void dump();59#endif60};6162class ciBlock : public ResourceObj {63private:64int _idx;65int _start_bci;66int _limit_bci;67int _control_bci;68uint _flags;69int _ex_start_bci;70int _ex_limit_bci;71#ifndef PRODUCT72ciMethod *_method;73#endif74enum {75Processed = (1 << 0),76Handler = (1 << 1),77MayThrow = (1 << 2),78DoesJsr = (1 << 3),79DoesRet = (1 << 4),80RetTarget = (1 << 5),81HasHandler = (1 << 6)82};838485public:86enum {87fall_through_bci = -188};8990ciBlock(ciMethod *method, int index, int start_bci);91int start_bci() const { return _start_bci; }92int limit_bci() const { return _limit_bci; }93int control_bci() const { return _control_bci; }94int index() const { return _idx; }95void set_start_bci(int bci) { _start_bci = bci; }96void set_limit_bci(int bci) { _limit_bci = bci; }97void set_control_bci(int bci) { _control_bci = bci;}98void set_exception_range(int start_bci, int limit_bci);99int ex_start_bci() const { return _ex_start_bci; }100int ex_limit_bci() const { return _ex_limit_bci; }101bool contains(int bci) const { return start_bci() <= bci && bci < limit_bci(); }102103// flag handling104bool processed() const { return (_flags & Processed) != 0; }105bool is_handler() const { return (_flags & Handler) != 0; }106bool may_throw() const { return (_flags & MayThrow) != 0; }107bool does_jsr() const { return (_flags & DoesJsr) != 0; }108bool does_ret() const { return (_flags & DoesRet) != 0; }109bool has_handler() const { return (_flags & HasHandler) != 0; }110bool is_ret_target() const { return (_flags & RetTarget) != 0; }111void set_processed() { _flags |= Processed; }112void clear_processed() { _flags &= ~Processed; }113void set_handler() { _flags |= Handler; }114void set_may_throw() { _flags |= MayThrow; }115void set_does_jsr() { _flags |= DoesJsr; }116void clear_does_jsr() { _flags &= ~DoesJsr; }117void set_does_ret() { _flags |= DoesRet; }118void clear_does_ret() { _flags &= ~DoesRet; }119void set_is_ret_target() { _flags |= RetTarget; }120void set_has_handler() { _flags |= HasHandler; }121void clear_exception_handler() { _flags &= ~Handler; _ex_start_bci = -1; _ex_limit_bci = -1; }122#ifndef PRODUCT123ciMethod *method() const { return _method; }124void dump();125void print_on(outputStream* st) const PRODUCT_RETURN;126#endif127};128129#endif // SHARE_CI_CIMETHODBLOCKS_HPP130131132