8152479: Coded byte streams
Reviewed-by: acorn, mschoene, asmotrak
This commit is contained in:
parent
86e696a816
commit
99c24f5f1c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,12 +31,12 @@ Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) {
|
|||||||
// set next bytecode position
|
// set next bytecode position
|
||||||
address bcp = RawBytecodeStream::bcp();
|
address bcp = RawBytecodeStream::bcp();
|
||||||
address end = method()->code_base() + end_bci();
|
address end = method()->code_base() + end_bci();
|
||||||
int l = Bytecodes::raw_special_length_at(bcp, end);
|
int len = Bytecodes::raw_special_length_at(bcp, end);
|
||||||
if (l <= 0 || (_bci + l) > _end_bci) {
|
// Very large tableswitch or lookupswitch size can cause _next_bci to overflow.
|
||||||
|
if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {
|
||||||
code = Bytecodes::_illegal;
|
code = Bytecodes::_illegal;
|
||||||
} else {
|
} else {
|
||||||
_next_bci += l;
|
_next_bci += len;
|
||||||
assert(_bci < _next_bci, "length must be > 0");
|
|
||||||
// set attributes
|
// set attributes
|
||||||
_is_wide = false;
|
_is_wide = false;
|
||||||
// check for special (uncommon) cases
|
// check for special (uncommon) cases
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -135,12 +135,15 @@ class RawBytecodeStream: public BaseBytecodeStream {
|
|||||||
code = Bytecodes::code_or_bp_at(bcp);
|
code = Bytecodes::code_or_bp_at(bcp);
|
||||||
|
|
||||||
// set next bytecode position
|
// set next bytecode position
|
||||||
int l = Bytecodes::length_for(code);
|
int len = Bytecodes::length_for(code);
|
||||||
if (l > 0 && (_bci + l) <= _end_bci) {
|
if (len > 0 && (_bci <= _end_bci - len)) {
|
||||||
assert(code != Bytecodes::_wide && code != Bytecodes::_tableswitch
|
assert(code != Bytecodes::_wide && code != Bytecodes::_tableswitch
|
||||||
&& code != Bytecodes::_lookupswitch, "can't be special bytecode");
|
&& code != Bytecodes::_lookupswitch, "can't be special bytecode");
|
||||||
_is_wide = false;
|
_is_wide = false;
|
||||||
_next_bci += l;
|
_next_bci += len;
|
||||||
|
if (_next_bci <= _bci) { // Check for integer overflow
|
||||||
|
code = Bytecodes::_illegal;
|
||||||
|
}
|
||||||
_raw_code = code;
|
_raw_code = code;
|
||||||
return code;
|
return code;
|
||||||
} else {
|
} else {
|
||||||
@ -189,19 +192,23 @@ class BytecodeStream: public BaseBytecodeStream {
|
|||||||
// note that we cannot advance before having the
|
// note that we cannot advance before having the
|
||||||
// tty bytecode otherwise the stepping is wrong!
|
// tty bytecode otherwise the stepping is wrong!
|
||||||
// (carefull: length_for(...) must be used first!)
|
// (carefull: length_for(...) must be used first!)
|
||||||
int l = Bytecodes::length_for(code);
|
int len = Bytecodes::length_for(code);
|
||||||
if (l == 0) l = Bytecodes::length_at(_method(), bcp);
|
if (len == 0) len = Bytecodes::length_at(_method(), bcp);
|
||||||
_next_bci += l;
|
if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {
|
||||||
assert(_bci < _next_bci, "length must be > 0");
|
raw_code = code = Bytecodes::_illegal;
|
||||||
// set attributes
|
} else {
|
||||||
_is_wide = false;
|
_next_bci += len;
|
||||||
// check for special (uncommon) cases
|
assert(_bci < _next_bci, "length must be > 0");
|
||||||
if (code == Bytecodes::_wide) {
|
// set attributes
|
||||||
raw_code = (Bytecodes::Code)bcp[1];
|
_is_wide = false;
|
||||||
code = raw_code; // wide BCs are always Java-normal
|
// check for special (uncommon) cases
|
||||||
_is_wide = true;
|
if (code == Bytecodes::_wide) {
|
||||||
|
raw_code = (Bytecodes::Code)bcp[1];
|
||||||
|
code = raw_code; // wide BCs are always Java-normal
|
||||||
|
_is_wide = true;
|
||||||
|
}
|
||||||
|
assert(Bytecodes::is_java_code(code), "sanity check");
|
||||||
}
|
}
|
||||||
assert(Bytecodes::is_java_code(code), "sanity check");
|
|
||||||
}
|
}
|
||||||
_raw_code = raw_code;
|
_raw_code = raw_code;
|
||||||
_code = code;
|
_code = code;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user