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