duke@435: /* never@2462: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "interpreter/bytecodeStream.hpp" stefank@2314: #include "interpreter/bytecodes.hpp" duke@435: duke@435: Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) { duke@435: assert(!is_last_bytecode(), "should have been checked"); duke@435: // set next bytecode position kamg@848: address bcp = RawBytecodeStream::bcp(); kamg@848: address end = method()->code_base() + end_bci(); kamg@848: int l = Bytecodes::raw_special_length_at(bcp, end); duke@435: if (l <= 0 || (_bci + l) > _end_bci) { duke@435: code = Bytecodes::_illegal; duke@435: } else { duke@435: _next_bci += l; duke@435: assert(_bci < _next_bci, "length must be > 0"); duke@435: // set attributes duke@435: _is_wide = false; duke@435: // check for special (uncommon) cases duke@435: if (code == Bytecodes::_wide) { kamg@848: if (bcp + 1 >= end) { kamg@848: code = Bytecodes::_illegal; kamg@848: } else { kamg@848: code = (Bytecodes::Code)bcp[1]; kamg@848: _is_wide = true; kamg@848: } duke@435: } duke@435: } jrose@1920: _raw_code = code; duke@435: return code; duke@435: } jrose@1920: jrose@1920: #ifdef ASSERT jrose@1920: void BaseBytecodeStream::assert_raw_index_size(int size) const { jrose@1920: if (raw_code() == Bytecodes::_invokedynamic && is_raw()) { jrose@1920: // in raw mode, pretend indy is "bJJ__" jrose@1920: assert(size == 2, "raw invokedynamic instruction has 2-byte index only"); jrose@1920: } else { never@2462: bytecode().assert_index_size(size, raw_code(), is_wide()); jrose@1920: } jrose@1920: } jrose@1920: jrose@1920: void BaseBytecodeStream::assert_raw_stream(bool want_raw) const { jrose@1920: if (want_raw) { jrose@1920: assert( is_raw(), "this function only works on raw streams"); jrose@1920: } else { jrose@1920: assert(!is_raw(), "this function only works on non-raw streams"); jrose@1920: } jrose@1920: } jrose@1920: #endif //ASSERT