/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, 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 GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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.
*
*/
#ifndef SHARE_VM_CI_CISTREAMS_HPP
#define SHARE_VM_CI_CISTREAMS_HPP
#include "ci/ciClassList.hpp"
#include "ci/ciExceptionHandler.hpp"
#include "ci/ciInstanceKlass.hpp"
#include "ci/ciMethod.hpp"
#include "interpreter/bytecode.hpp"
// ciBytecodeStream
//
// The class is used to iterate over the bytecodes of a method.
// providing accessors for constant pool items. It returns only pure
// Java bytecodes; VM-internal _fast bytecodes are translated back to
// their original form during iteration.
private:
// Handling for the weird bytecodes
return c;
}
return c;
}
}
if (require_wide)
}
public:
// End-Of-Bytecodes
}
reset_to_method(m);
}
ciBytecodeStream() {
}
_method = m;
if (m == NULL) {
} else {
}
}
void reset_to_bci( int bci );
// Force the iterator to report a certain bci.
}
// Return current ByteCode and increment PC to next bytecode, skipping all
// intermediate constants. Returns EOBC at end.
// Expected usage:
// ciBytecodeStream iter(m);
// while (iter.next() != ciBytecodeStream::EOBC()) { ... }
// Fetch Java bytecode
// All rewritten bytecodes maintain the size of original bytecode.
if (csize == 0) {
}
return check_java(_bc);
}
// Does this instruction contain an index which refes into the CP cache?
int get_index_u1() const {
}
int get_index_u1_cpcache() const {
}
// Get a byte index following this bytecode.
// If prefixed with a wide bytecode, get a wide index.
int get_index() const {
? get_index_u2(true) // yes, return wide index
: get_index_u1(); // no, return narrow index
}
// Get 2-byte index (byte swapping depending on which bytecode)
}
// Get 2-byte index in native byte order. (Rewriter::rewrite makes these.)
int get_index_u2_cpcache() const {
}
// Get 4-byte index, for invokedynamic.
int get_index_u4() const {
}
bool has_index_u4() const {
}
// Get dimensions byte (multinewarray)
int get_constant_u1() const { return bytecode().get_constant_u1(instruction_size()-1, cur_bc_raw()); }
int get_constant_u2(bool is_wide = false) const { return bytecode().get_constant_u2(instruction_size()-2, cur_bc_raw(), is_wide); }
// Get a byte signed constant for "iinc". Invalid for other bytecodes.
// If prefixed with a wide bytecode, get a wide constant
int get_iinc_con() const {return (_pc==_was_wide) ? (jshort) get_constant_u2(true) : (jbyte) get_constant_u1();}
// 2-byte branch offset from current pc
int get_dest() const {
}
// 2-byte branch offset from next pc
int next_get_dest() const {
}
// 4-byte branch offset from current pc
int get_far_dest() const {
}
// For a lookup or switch table, return target destination
int get_int_table( int index ) const {
// For tableswitch - get length of offset part
int get_dest_table( int index ) const {
// --- Constant pool access ---
int get_constant_raw_index() const;
int get_constant_pool_index() const;
int get_constant_cache_index() const;
int get_field_index();
int get_method_index();
// If this bytecode is a new, newarray, multianewarray, instanceof,
// or checkcast, get the referenced klass.
int get_klass_index() const;
// If this bytecode is one of the ldc variants, get the referenced
// constant. Do not attempt to resolve it, since that would require
// execution of Java code. If it is not resolved, return an unloaded
// object (ciConstant.as_object()->is_loaded() == false).
// True if the klass-using bytecode points to an unresolved klass
bool is_unresolved_klass() const {
return tag.is_unresolved_klass();
}
// If this bytecode is one of get_field, get_static, put_field,
// or put_static, get the referenced field.
int get_field_holder_index();
int get_field_signature_index();
bool has_appendix();
ciObject* get_appendix();
bool has_method_type();
int get_method_holder_index();
int get_method_signature_index();
ciCPCache* get_cpcache() const;
};
// ciSignatureStream
//
// The class is used to iterate over the elements of a method signature.
class ciSignatureStream : public StackObj {
private:
int _pos;
public:
_pos = 0;
}
void next() {
_pos++;
}
}
if (at_return_type()) {
return _sig->return_type();
} else {
}
}
};
// ciExceptionHandlerStream
//
// The class is used to iterate over the exception handlers of
// a method.
private:
// The method whose handlers we are traversing
// Our current position in the list of handlers
int _pos;
int _end;
int _bci;
bool _is_exact;
public:
// Force loading of method code and handlers.
_pos = 0;
_bci = -1;
_is_exact = false;
}
bool is_exact = false) {
// Force loading of method code and handlers.
_pos = -1;
: NULL);
next();
}
// These methods are currently implemented in an odd way.
// Count the number of handlers the iterator has ever produced
// or will ever produce. Do not include the final rethrow handler.
// That is, a trivial exception handler stream will have a count
// of zero and produce just the rethrow handler.
int count();
// Count the number of handlers this stream will produce from now on.
// Include the current handler, and the final rethrow handler.
// The remaining count will be zero iff is_done() is true,
int count_remaining();
bool is_done() {
}
void next() {
_pos++;
if (_bci != -1) {
// We are not iterating over all handlers...
while (!is_done()) {
if (handler->is_catch_all()) {
// Found final active catch block.
return;
// We cannot do any type analysis here. Must conservatively assume
// catch block is reachable.
return;
// This catch clause will definitely catch the exception.
// Final candidate.
return;
} else if (!_is_exact &&
// This catch block may be reachable.
return;
}
}
// The catch block was not pertinent. Go on.
_pos++;
}
} else {
// This is an iteration over all handlers.
return;
}
}
}
};
// Implementation for declarations in bytecode.hpp
Bytecode::Bytecode(const ciBytecodeStream* stream, address bcp): _bcp(bcp != NULL ? bcp : stream->cur_bcp()), _code(Bytecodes::code_at(NULL, addr_at(0))) {}
Bytecode_lookupswitch::Bytecode_lookupswitch(const ciBytecodeStream* stream): Bytecode(stream) { verify(); }
Bytecode_tableswitch::Bytecode_tableswitch(const ciBytecodeStream* stream): Bytecode(stream) { verify(); }
#endif // SHARE_VM_CI_CISTREAMS_HPP