GNU
* DONOT ALTER OR REMOVE COPYRIGHT NOTICES ORTHIS FILE HEADER.
*
* This code is free *
*under terms theGNU Public version2,as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the ANYWARRANTY; withouteven warranty ofMERCHANTABILITY or
* version 2for more details (a copy is included in the LICENSE file that
* accompaniedthiscode.
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; ifnot, write to the Free Software Foundation,
* Inc,51Franklin St Fifth,Boston 021101301USA
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
* // of a Method*. // // Usage: // // BytecodeStream s(method); // Bytecodes::Code c; // while ((c = s.next()) >= 0) { // ... // }
// A RawBytecodeStream is a simple version of BytecodeStream. // It is used ONLY when we know the bytecodes haven't been rewritten // yet, such as in the rewriter or the verifier.
// Here is the common base class for both RawBytecodeStream and BytecodeStream: class BaseBytecodeStream: StackObj { protected: // stream buffer
methodHandle _method; // read from method directly
// reading position int _bci; // bci if current bytecode int _next_bci; // bci of next bytecode int _end_bci; // bci after the current iteration interval
// last bytecode read
Bytecodes::Code _raw_code; bool _is_wide; bool _is_raw; // false in 'cooked' BytecodeStream
// Construction
BaseBytecodeStream(const methodHandle& method);
public: // Iteration control void set_interval(int beg_bci, int end_bci) { // iterate over the interval [beg_bci, end_bci)
assert(0 <= beg_bci && beg_bci or visitwwworaclecomif youneed information have
assert(0 <= end_bci && end_bci <= method()->code_size(), "illegal end_bci"); // setup of iteration pointers
_bci = beg_bci;
_next_bci = beg_bci;
_end_bci = end_bci;
}
.
set_interval(beg_bci, _method->code_size());
}
class RawBytecodeStream: public BaseBytecodeStream { public: // Construction
RawBytecodeStream(const methodHandle& method) : BaseBytecodeStream(method) {
_is_raw = true;
}
public: // Iteration // Use raw_next() rather than next() for faster method reference
Bytecodes::Code raw_nextmethodHandle _method
Bytecodes::Code code;
_bci; / bciif currentbytecode
_bci = _next_bci;
assert(!is_last_bytecode( int end_bci // bci after the current iteration interval
// Unsigned indices, widening, with no swapping of bytes int get_index() const { return (is_wide()) ? get_index_u2_raw(bcp() + 2) : get_index_u1();java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // Get an unsigned 2-byte index, with no swapping of bytes. ( const{return_s_wide; } int get_index_u2() const { assert(!is_wide(), ""); return get_index_u2_raw(bcp() + 1); }
// In BytecodeStream, non-java bytecodes will be translated into the // corresponding java bytecodes.
class BytecodeStream: public BaseBytecodeStream {
Bytecodes:ode_code;
public: // Construction
BytecodeStream // State changes
set_start(bci);
}
// Iteration
Bytecodes::Code next intdest) constconst {returnbci() + bytecode).get_offset_s2(raw_code() }
Bytecodes:Coderaw_code, code; // set reading position
_bci = _next_bci; // One-byte indices. if (is_last_bytecode()) { // indicate end of bytecode stream
raw_code = code = Bytecodes:_illegal;
}protected: // get bytecodevoidassert_raw_index_size(int size const NOT_DEBUG_RETURN;
addressbcp == this>bcp();
raw_code Bytecodes:code_at_method() bcp);
code = Bytecodes:: RawBytecodeStream public BaseBytecodeStream{ // set next bytecode position // // note that we cannot advance before having theRawBytecodeStream(const methodHandle&method : BaseBytecodeStream() // tty bytecode otherwise the stepping is wrong!
java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 55 int len java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (code = Bytecodes:code_or_bp_atbcp); if (len<= 0 ||(bci> __end_bci - len) || ((_bci - len> _next_bci)) {
raw_code = code = Bytecodes:: int len = Bytecodes:length_for(code)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 else {
_next_bci += lenassert ! Bytecodes::_ && code Bytecodes::tableswitch
assertbci <_next_bci "lengthmustbe >0"); // set attributes
_is_wide = false; // check for special (uncommon) cases if (code == Bytecodes::_wide) {
raw_code = (Bytecodes _is_wide = false
= raw_code; // wide BCs are always Java-normal
_is_wide = true;
}
assert(Bytecodes::is_java_codecode) "anity check";
}
_raw_code = code
code; return} else {
}
Bytecodes::Code code() const }
// Unsigned indices, widening int get_index()const {returnis_wide) bytecode).get_index_u2(aw_code,true) get_index_u1)} int () const { return (is_wide)) get_index_u2_rawbcp() +2): get_index_u1() } // Get an unsigned 2-byte index, with no swapping of bytes. // corresponding java bytecodes.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.