author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 39712 | hotspot/src/share/vm/interpreter/bytecodeStream.cpp@dccb9af07ee1 |
child 49480 | d7df2dd501ce |
permissions | -rw-r--r-- |
1 | 1 |
/* |
39712 | 2 |
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1623
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "interpreter/bytecodeStream.hpp" |
|
27 |
#include "interpreter/bytecodes.hpp" |
|
1 | 28 |
|
29 |
Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) { |
|
30 |
assert(!is_last_bytecode(), "should have been checked"); |
|
31 |
// set next bytecode position |
|
1493
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
32 |
address bcp = RawBytecodeStream::bcp(); |
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
33 |
address end = method()->code_base() + end_bci(); |
39712 | 34 |
int len = Bytecodes::raw_special_length_at(bcp, end); |
35 |
// Very large tableswitch or lookupswitch size can cause _next_bci to overflow. |
|
36 |
if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) { |
|
1 | 37 |
code = Bytecodes::_illegal; |
38 |
} else { |
|
39712 | 39 |
_next_bci += len; |
1 | 40 |
// set attributes |
41 |
_is_wide = false; |
|
42 |
// check for special (uncommon) cases |
|
43 |
if (code == Bytecodes::_wide) { |
|
1493
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
44 |
if (bcp + 1 >= end) { |
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
45 |
code = Bytecodes::_illegal; |
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
46 |
} else { |
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
47 |
code = (Bytecodes::Code)bcp[1]; |
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
48 |
_is_wide = true; |
7d2dc5fbfa8c
6756528: Bytecodes::special_length_at reads past end of code buffer
kamg
parents:
1
diff
changeset
|
49 |
} |
1 | 50 |
} |
51 |
} |
|
5688 | 52 |
_raw_code = code; |
1 | 53 |
return code; |
54 |
} |
|
5688 | 55 |
|
56 |
#ifdef ASSERT |
|
57 |
void BaseBytecodeStream::assert_raw_index_size(int size) const { |
|
58 |
if (raw_code() == Bytecodes::_invokedynamic && is_raw()) { |
|
59 |
// in raw mode, pretend indy is "bJJ__" |
|
60 |
assert(size == 2, "raw invokedynamic instruction has 2-byte index only"); |
|
61 |
} else { |
|
7913 | 62 |
bytecode().assert_index_size(size, raw_code(), is_wide()); |
5688 | 63 |
} |
64 |
} |
|
65 |
||
66 |
void BaseBytecodeStream::assert_raw_stream(bool want_raw) const { |
|
67 |
if (want_raw) { |
|
68 |
assert( is_raw(), "this function only works on raw streams"); |
|
69 |
} else { |
|
70 |
assert(!is_raw(), "this function only works on non-raw streams"); |
|
71 |
} |
|
72 |
} |
|
73 |
#endif //ASSERT |