1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/ci/ciMethodBlocks.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,121 @@ 1.4 +/* 1.5 + * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 + 1.29 +class ciBlock; 1.30 + 1.31 +typedef short ciBlockIndex; 1.32 + 1.33 +class ciMethodBlocks : public ResourceObj { 1.34 +private: 1.35 + ciMethod *_method; 1.36 + Arena *_arena; 1.37 + GrowableArray<ciBlock *> *_blocks; 1.38 + ciBlock **_bci_to_block; 1.39 + int _num_blocks; 1.40 + int _code_size; 1.41 + 1.42 + void do_analysis(); 1.43 +public: 1.44 + ciMethodBlocks(Arena *arena, ciMethod *meth); 1.45 + 1.46 + ciBlock *block_containing(int bci); 1.47 + ciBlock *block(int index) { return _blocks->at(index); } 1.48 + ciBlock *make_block_at(int bci); 1.49 + ciBlock *split_block_at(int bci); 1.50 + bool is_block_start(int bci); 1.51 + int num_blocks() { return _num_blocks;} 1.52 + void clear_processed(); 1.53 + 1.54 +#ifndef PRODUCT 1.55 + void dump(); 1.56 +#endif 1.57 +}; 1.58 + 1.59 +class ciBlock : public ResourceObj { 1.60 +private: 1.61 + int _idx; 1.62 + int _start_bci; 1.63 + int _limit_bci; 1.64 + int _control_bci; 1.65 + uint _flags; 1.66 + int _ex_start_bci; 1.67 + int _ex_limit_bci; 1.68 +#ifndef PRODUCT 1.69 + ciMethod *_method; 1.70 +#endif 1.71 + enum { 1.72 + Processed = (1 << 0), 1.73 + Handler = (1 << 1), 1.74 + MayThrow = (1 << 2), 1.75 + DoesJsr = (1 << 3), 1.76 + DoesRet = (1 << 4), 1.77 + RetTarget = (1 << 5), 1.78 + HasHandler = (1 << 6) 1.79 + }; 1.80 + 1.81 + 1.82 +public: 1.83 + enum { 1.84 + fall_through_bci = -1 1.85 + }; 1.86 + 1.87 + ciBlock(ciMethod *method, int index, ciMethodBlocks *mb, int start_bci); 1.88 + int start_bci() const { return _start_bci; } 1.89 + int limit_bci() const { return _limit_bci; } 1.90 + int control_bci() const { return _control_bci; } 1.91 + int index() const { return _idx; } 1.92 + void set_start_bci(int bci) { _start_bci = bci; } 1.93 + void set_limit_bci(int bci) { _limit_bci = bci; } 1.94 + void set_control_bci(int bci) { _control_bci = bci;} 1.95 + void set_exception_range(int start_bci, int limit_bci); 1.96 + int ex_start_bci() const { return _ex_start_bci; } 1.97 + int ex_limit_bci() const { return _ex_limit_bci; } 1.98 + bool contains(int bci) const { return start_bci() <= bci && bci < limit_bci(); } 1.99 + 1.100 + 1.101 + // flag handling 1.102 + bool processed() const { return (_flags & Processed) != 0; } 1.103 + bool is_handler() const { return (_flags & Handler) != 0; } 1.104 + bool may_throw() const { return (_flags & MayThrow) != 0; } 1.105 + bool does_jsr() const { return (_flags & DoesJsr) != 0; } 1.106 + bool does_ret() const { return (_flags & DoesRet) != 0; } 1.107 + bool has_handler() const { return (_flags & HasHandler) != 0; } 1.108 + bool is_ret_target() const { return (_flags & RetTarget) != 0; } 1.109 + void set_processed() { _flags |= Processed; } 1.110 + void clear_processed() { _flags &= ~Processed; } 1.111 + void set_handler() { _flags |= Handler; } 1.112 + void set_may_throw() { _flags |= MayThrow; } 1.113 + void set_does_jsr() { _flags |= DoesJsr; } 1.114 + void clear_does_jsr() { _flags &= ~DoesJsr; } 1.115 + void set_does_ret() { _flags |= DoesRet; } 1.116 + void clear_does_ret() { _flags |= DoesRet; } 1.117 + void set_is_ret_target() { _flags |= RetTarget; } 1.118 + void set_has_handler() { _flags |= HasHandler; } 1.119 +#ifndef PRODUCT 1.120 + ciMethod *method() const { return _method; } 1.121 + void dump(); 1.122 + void print_on(outputStream* st) const PRODUCT_RETURN; 1.123 +#endif 1.124 +};