jdk
79 строк · 2.7 Кб
1/*
2* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
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*
19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20* or visit www.oracle.com if you need additional information or have any
21* questions.
22*
23*/
24
25#include "precompiled.hpp"26#include "interpreter/bytecodeStream.hpp"27#include "interpreter/bytecodes.hpp"28#include "runtime/handles.inline.hpp"29
30Bytecodes::Code RawBytecodeStream::raw_next_special(Bytecodes::Code code) {31assert(!is_last_bytecode(), "should have been checked");32// set next bytecode position33address bcp = RawBytecodeStream::bcp();34address end = method()->code_base() + end_bci();35int len = Bytecodes::raw_special_length_at(bcp, end);36// Very large tableswitch or lookupswitch size can cause _next_bci to overflow.37if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {38code = Bytecodes::_illegal;39} else {40_next_bci += len;41// set attributes42_is_wide = false;43// check for special (uncommon) cases44if (code == Bytecodes::_wide) {45if (bcp + 1 >= end) {46code = Bytecodes::_illegal;47} else {48code = (Bytecodes::Code)bcp[1];49_is_wide = true;50}51}52}53_raw_code = code;54return code;55}
56
57BaseBytecodeStream::BaseBytecodeStream(const methodHandle& method) : _method(method) {58set_interval(0, _method->code_size());59_is_raw = false;60}
61
62#ifdef ASSERT63void BaseBytecodeStream::assert_raw_index_size(int size) const {64if (raw_code() == Bytecodes::_invokedynamic && is_raw()) {65// in raw mode, pretend indy is "bJJ__"66assert(size == 2, "raw invokedynamic instruction has 2-byte index only");67} else {68bytecode().assert_index_size(size, raw_code(), is_wide());69}70}
71
72void BaseBytecodeStream::assert_raw_stream(bool want_raw) const {73if (want_raw) {74assert( is_raw(), "this function only works on raw streams");75} else {76assert(!is_raw(), "this function only works on non-raw streams");77}78}
79#endif //ASSERT80