Path: blob/master/src/hotspot/share/interpreter/interpreter.hpp
40949 views
/*1* Copyright (c) 1997, 2020, 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#ifndef SHARE_INTERPRETER_INTERPRETER_HPP25#define SHARE_INTERPRETER_INTERPRETER_HPP2627#include "code/stubs.hpp"28#include "interpreter/interp_masm.hpp"29#include "interpreter/templateInterpreter.hpp"30#include "interpreter/zero/zeroInterpreter.hpp"31#include "memory/resourceArea.hpp"32#include "utilities/align.hpp"3334// This file contains the platform-independent parts35// of the interpreter and the interpreter generator.3637class InterpreterMacroAssembler;3839//------------------------------------------------------------------------------------------------------------------------40// An InterpreterCodelet is a piece of interpreter code. All41// interpreter code is generated into little codelets which42// contain extra information for debugging and printing purposes.4344class InterpreterCodelet: public Stub {45friend class VMStructs;46friend class CodeCacheDumper; // possible extension [do not remove]47private:48int _size; // the size in bytes49const char* _description; // a description of the codelet, for debugging & printing50Bytecodes::Code _bytecode; // associated bytecode if any51NOT_PRODUCT(CodeStrings _strings;) // Comments for annotating assembler output.5253public:54// Initialization/finalization55void initialize(int size,56CodeStrings& strings) { _size = size;57NOT_PRODUCT(_strings = CodeStrings();)58NOT_PRODUCT(_strings.copy(strings);) }59void finalize() { ShouldNotCallThis(); }6061// General info/converters62int size() const { return _size; }63static int code_size_to_size(int code_size) { return align_up((int)sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; }6465// Code info66address code_begin() const { return (address)this + align_up(sizeof(InterpreterCodelet), CodeEntryAlignment); }67address code_end() const { return (address)this + size(); }6869// Debugging70void verify();71void print_on(outputStream* st) const;72void print() const;7374// Interpreter-specific initialization75void initialize(const char* description, Bytecodes::Code bytecode);7677// Interpreter-specific attributes78int code_size() const { return code_end() - code_begin(); }79const char* description() const { return _description; }80Bytecodes::Code bytecode() const { return _bytecode; }81};8283// Define a prototype interface84DEF_STUB_INTERFACE(InterpreterCodelet);858687//------------------------------------------------------------------------------------------------------------------------88// A CodeletMark serves as an automatic creator/initializer for Codelets89// (As a subclass of ResourceMark it automatically GC's the allocated90// code buffer and assemblers).9192class CodeletMark: ResourceMark {93private:94InterpreterCodelet* _clet;95InterpreterMacroAssembler** _masm;96CodeBuffer _cb;9798int codelet_size() {99// Request the whole code buffer (minus a little for alignment).100// The commit call below trims it back for each codelet.101int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;102103// Guarantee there's a little bit of code space left.104guarantee(codelet_size > 0 && (size_t)codelet_size > 2*K,105"not enough space for interpreter generation");106107return codelet_size;108}109110public:111CodeletMark(InterpreterMacroAssembler*& masm,112const char* description,113Bytecodes::Code bytecode = Bytecodes::_illegal);114~CodeletMark();115};116117// Wrapper typedef to use the name Interpreter to mean either118// the Zero interpreter or the template interpreter.119120typedef ZERO_ONLY(ZeroInterpreter) NOT_ZERO(TemplateInterpreter) Interpreter;121122#endif // SHARE_INTERPRETER_INTERPRETER_HPP123124125