Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/interpreter/bytecodeStream.cpp
32285 views
/*1* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "interpreter/bytecodeStream.hpp"26#include "interpreter/bytecodes.hpp"2728Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) {29assert(!is_last_bytecode(), "should have been checked");30// set next bytecode position31address bcp = RawBytecodeStream::bcp();32address end = method()->code_base() + end_bci();33int len = Bytecodes::raw_special_length_at(bcp, end);34// Very large tableswitch or lookupswitch size can cause _next_bci to overflow.35if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {36code = Bytecodes::_illegal;37} else {38_next_bci += len;39// set attributes40_is_wide = false;41// check for special (uncommon) cases42if (code == Bytecodes::_wide) {43if (bcp + 1 >= end) {44code = Bytecodes::_illegal;45} else {46code = (Bytecodes::Code)bcp[1];47_is_wide = true;48}49}50}51_raw_code = code;52return code;53}5455#ifdef ASSERT56void BaseBytecodeStream::assert_raw_index_size(int size) const {57if (raw_code() == Bytecodes::_invokedynamic && is_raw()) {58// in raw mode, pretend indy is "bJJ__"59assert(size == 2, "raw invokedynamic instruction has 2-byte index only");60} else {61bytecode().assert_index_size(size, raw_code(), is_wide());62}63}6465void BaseBytecodeStream::assert_raw_stream(bool want_raw) const {66if (want_raw) {67assert( is_raw(), "this function only works on raw streams");68} else {69assert(!is_raw(), "this function only works on non-raw streams");70}71}72#endif //ASSERT737475