Path: blob/master/src/hotspot/share/interpreter/bytecodeStream.cpp
40949 views
/*1* Copyright (c) 1997, 2018, 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"27#include "runtime/handles.inline.hpp"2829Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) {30assert(!is_last_bytecode(), "should have been checked");31// set next bytecode position32address bcp = RawBytecodeStream::bcp();33address end = method()->code_base() + end_bci();34int len = Bytecodes::raw_special_length_at(bcp, end);35// Very large tableswitch or lookupswitch size can cause _next_bci to overflow.36if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {37code = Bytecodes::_illegal;38} else {39_next_bci += len;40// set attributes41_is_wide = false;42// check for special (uncommon) cases43if (code == Bytecodes::_wide) {44if (bcp + 1 >= end) {45code = Bytecodes::_illegal;46} else {47code = (Bytecodes::Code)bcp[1];48_is_wide = true;49}50}51}52_raw_code = code;53return code;54}5556BaseBytecodeStream::BaseBytecodeStream(const methodHandle& method) : _method(method) {57set_interval(0, _method->code_size());58_is_raw = false;59}6061#ifdef ASSERT62void BaseBytecodeStream::assert_raw_index_size(int size) const {63if (raw_code() == Bytecodes::_invokedynamic && is_raw()) {64// in raw mode, pretend indy is "bJJ__"65assert(size == 2, "raw invokedynamic instruction has 2-byte index only");66} else {67bytecode().assert_index_size(size, raw_code(), is_wide());68}69}7071void BaseBytecodeStream::assert_raw_stream(bool want_raw) const {72if (want_raw) {73assert( is_raw(), "this function only works on raw streams");74} else {75assert(!is_raw(), "this function only works on non-raw streams");76}77}78#endif //ASSERT798081