hotspot/src/share/vm/interpreter/bytecodes.cpp
Print this page
rev 611 : Merge
*** 1,10 ****
#ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)bytecodes.cpp 1.97 07/06/20 14:52:27 JVM"
#endif
/*
! * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,10 ----
#ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)bytecodes.cpp 1.97 07/06/20 14:52:27 JVM"
#endif
/*
! * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 55,71 ****
Bytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) {
if (method == NULL) method = methodOopDesc::method_from_bcp(bcp);
return method->orig_bytecode_at(method->bci_from(bcp));
}
! int Bytecodes::special_length_at(address bcp) {
Code code = code_at(bcp);
switch (code) {
case _wide:
return wide_length_for(cast(*(bcp + 1)));
case _tableswitch:
{ address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize;
// only return len if it can be represented as a positive int;
// return -1 otherwise
--- 55,77 ----
Bytecodes::Code Bytecodes::non_breakpoint_code_at(address bcp, methodOop method) {
if (method == NULL) method = methodOopDesc::method_from_bcp(bcp);
return method->orig_bytecode_at(method->bci_from(bcp));
}
! int Bytecodes::special_length_at(address bcp, address end) {
Code code = code_at(bcp);
switch (code) {
case _wide:
+ if (end != NULL && bcp + 1 >= end) {
+ return -1; // don't read past end of code buffer
+ }
return wide_length_for(cast(*(bcp + 1)));
case _tableswitch:
{ address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
+ if (end != NULL && aligned_bcp + 3*jintSize >= end) {
+ return -1; // don't read past end of code buffer
+ }
jlong lo = (jint)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
jlong hi = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
jlong len = (aligned_bcp - bcp) + (3 + hi - lo + 1)*jintSize;
// only return len if it can be represented as a positive int;
// return -1 otherwise
*** 74,83 ****
--- 80,92 ----
case _lookupswitch: // fall through
case _fast_binaryswitch: // fall through
case _fast_linearswitch:
{ address aligned_bcp = (address)round_to((intptr_t)bcp + 1, jintSize);
+ if (end != NULL && aligned_bcp + 2*jintSize >= end) {
+ return -1; // don't read past end of code buffer
+ }
jlong npairs = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
jlong len = (aligned_bcp - bcp) + (2 + 2*npairs)*jintSize;
// only return len if it can be represented as a positive int;
// return -1 otherwise
return (len > 0 && len == (int)len) ? len : -1;
*** 91,108 ****
// the RawByteCodeStream, which wants to see the actual bytecode
// values (including breakpoint). RawByteCodeStream is used by the
// verifier when reading in bytecode to verify. Other mechanisms that
// run at runtime (such as generateOopMaps) need to iterate over the code
// and don't expect to see breakpoints: they want to see the instruction
! // which was replaces so that they can get the correct length and find
// the next bytecode.
! int Bytecodes::raw_special_length_at(address bcp) {
Code code = code_or_bp_at(bcp);
if (code == _breakpoint) {
return 1;
} else {
! return special_length_at(bcp);
}
}
--- 100,120 ----
// the RawByteCodeStream, which wants to see the actual bytecode
// values (including breakpoint). RawByteCodeStream is used by the
// verifier when reading in bytecode to verify. Other mechanisms that
// run at runtime (such as generateOopMaps) need to iterate over the code
// and don't expect to see breakpoints: they want to see the instruction
! // which was replaced so that they can get the correct length and find
// the next bytecode.
! //
! // 'end' indicates the end of the code buffer, which we should not try to read
! // past.
! int Bytecodes::raw_special_length_at(address bcp, address end) {
Code code = code_or_bp_at(bcp);
if (code == _breakpoint) {
return 1;
} else {
! return special_length_at(bcp, end);
}
}