Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/interpreter/templateTable.hpp
32285 views
/*1* Copyright (c) 1997, 2015, 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_VM_INTERPRETER_TEMPLATETABLE_HPP25#define SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP2627#include "interpreter/bytecodes.hpp"28#include "memory/allocation.hpp"29#include "runtime/frame.hpp"30#if defined INTERP_MASM_MD_HPP31# include INTERP_MASM_MD_HPP32#elif defined TARGET_ARCH_x8633# include "interp_masm_x86.hpp"34#elif defined TARGET_ARCH_MODEL_aarch3235# include "interp_masm_aarch32.hpp"36#elif defined TARGET_ARCH_MODEL_aarch6437# include "interp_masm_aarch64.hpp"38#elif defined TARGET_ARCH_MODEL_sparc39# include "interp_masm_sparc.hpp"40#elif defined TARGET_ARCH_MODEL_zero41# include "interp_masm_zero.hpp"42#elif defined TARGET_ARCH_MODEL_ppc_6443# include "interp_masm_ppc_64.hpp"44#endif4546#ifndef CC_INTERP47// All the necessary definitions used for (bytecode) template generation. Instead of48// spreading the implementation functionality for each bytecode in the interpreter49// and the snippet generator, a template is assigned to each bytecode which can be50// used to generate the bytecode's implementation if needed.515253// A Template describes the properties of a code template for a given bytecode54// and provides a generator to generate the code template.5556class Template VALUE_OBJ_CLASS_SPEC {57private:58enum Flags {59uses_bcp_bit, // set if template needs the bcp pointing to bytecode60does_dispatch_bit, // set if template dispatches on its own61calls_vm_bit, // set if template calls the vm62wide_bit // set if template belongs to a wide instruction63};6465typedef void (*generator)(int arg);6667int _flags; // describes interpreter template properties (bcp unknown)68TosState _tos_in; // tos cache state before template execution69TosState _tos_out; // tos cache state after template execution70generator _gen; // template code generator71int _arg; // argument for template code generator7273void initialize(int flags, TosState tos_in, TosState tos_out, generator gen, int arg);7475friend class TemplateTable;7677public:78Bytecodes::Code bytecode() const;79bool is_valid() const { return _gen != NULL; }80bool uses_bcp() const { return (_flags & (1 << uses_bcp_bit )) != 0; }81bool does_dispatch() const { return (_flags & (1 << does_dispatch_bit)) != 0; }82bool calls_vm() const { return (_flags & (1 << calls_vm_bit )) != 0; }83bool is_wide() const { return (_flags & (1 << wide_bit )) != 0; }84TosState tos_in() const { return _tos_in; }85TosState tos_out() const { return _tos_out; }86void generate(InterpreterMacroAssembler* masm);87};888990// The TemplateTable defines all Templates and provides accessor functions91// to get the template for a given bytecode.9293class TemplateTable: AllStatic {94public:95enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr };96enum Condition { equal, not_equal, less, less_equal, greater, greater_equal };97enum CacheByte { f1_byte = 1, f2_byte = 2 }; // byte_no codes9899private:100static bool _is_initialized; // true if TemplateTable has been initialized101static Template _template_table [Bytecodes::number_of_codes];102static Template _template_table_wide[Bytecodes::number_of_codes];103104static Template* _desc; // the current template to be generated105static Bytecodes::Code bytecode() { return _desc->bytecode(); }106107static BarrierSet* _bs; // Cache the barrier set.108public:109//%note templates_1110static InterpreterMacroAssembler* _masm; // the assembler used when generating templates111112private:113114// special registers115static inline Address at_bcp(int offset);116117// helpers118static void unimplemented_bc();119static void patch_bytecode(Bytecodes::Code bc, Register bc_reg,120Register temp_reg, bool load_bc_into_bc_reg = true, int byte_no = -1);121122// C calls123static void call_VM(Register oop_result, address entry_point);124static void call_VM(Register oop_result, address entry_point, Register arg_1);125static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2);126static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3);127128// these overloadings are not presently used on SPARC:129static void call_VM(Register oop_result, Register last_java_sp, address entry_point);130static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1);131static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2);132static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3);133134// bytecodes135static void nop();136137static void aconst_null();138static void iconst(int value);139static void lconst(int value);140static void fconst(int value);141static void dconst(int value);142143static void bipush();144static void sipush();145static void ldc(bool wide);146static void ldc2_w();147static void fast_aldc(bool wide);148149static void locals_index(Register reg, int offset = 1);150static void iload();151static void fast_iload();152static void fast_iload2();153static void fast_icaload();154static void lload();155static void fload();156static void dload();157static void aload();158159static void locals_index_wide(Register reg);160static void wide_iload();161static void wide_lload();162static void wide_fload();163static void wide_dload();164static void wide_aload();165166static void iaload();167static void laload();168static void faload();169static void daload();170static void aaload();171static void baload();172static void caload();173static void saload();174175static void iload(int n);176static void lload(int n);177static void fload(int n);178static void dload(int n);179static void aload(int n);180static void aload_0();181182static void istore();183static void lstore();184static void fstore();185static void dstore();186static void astore();187188static void wide_istore();189static void wide_lstore();190static void wide_fstore();191static void wide_dstore();192static void wide_astore();193194static void iastore();195static void lastore();196static void fastore();197static void dastore();198static void aastore();199static void bastore();200static void castore();201static void sastore();202203static void istore(int n);204static void lstore(int n);205static void fstore(int n);206static void dstore(int n);207static void astore(int n);208209static void pop();210static void pop2();211static void dup();212static void dup_x1();213static void dup_x2();214static void dup2();215static void dup2_x1();216static void dup2_x2();217static void swap();218219static void iop2(Operation op);220static void lop2(Operation op);221static void fop2(Operation op);222static void dop2(Operation op);223224static void idiv();225static void irem();226227static void lmul();228static void ldiv();229static void lrem();230static void lshl();231static void lshr();232static void lushr();233234static void ineg();235static void lneg();236static void fneg();237static void dneg();238239static void iinc();240static void wide_iinc();241static void convert();242static void lcmp();243244static void float_cmp (bool is_float, int unordered_result);245static void float_cmp (int unordered_result);246static void double_cmp(int unordered_result);247248static void count_calls(Register method, Register temp);249static void branch(bool is_jsr, bool is_wide);250static void if_0cmp (Condition cc);251static void if_icmp (Condition cc);252static void if_nullcmp(Condition cc);253static void if_acmp (Condition cc);254255static void _goto();256static void jsr();257static void ret();258static void wide_ret();259260static void goto_w();261static void jsr_w();262263static void tableswitch();264static void lookupswitch();265static void fast_linearswitch();266static void fast_binaryswitch();267268static void _return(TosState state);269270static void resolve_cache_and_index(int byte_no, // one of 1,2,11271Register cache, // output for CP cache272Register index, // output for CP index273size_t index_size); // one of 1,2,4274static void load_invoke_cp_cache_entry(int byte_no,275Register method,276Register itable_index,277Register flags,278bool is_invokevirtual,279bool is_virtual_final,280bool is_invokedynamic);281static void load_field_cp_cache_entry(Register obj,282Register cache,283Register index,284Register offset,285Register flags,286bool is_static);287static void invokevirtual(int byte_no);288static void invokespecial(int byte_no);289static void invokestatic(int byte_no);290static void invokeinterface(int byte_no);291static void invokedynamic(int byte_no);292static void invokehandle(int byte_no);293static void fast_invokevfinal(int byte_no);294295static void getfield_or_static(int byte_no, bool is_static);296static void putfield_or_static(int byte_no, bool is_static);297static void getfield(int byte_no);298static void putfield(int byte_no);299static void getstatic(int byte_no);300static void putstatic(int byte_no);301static void pop_and_check_object(Register obj);302303static void _new();304static void newarray();305static void anewarray();306static void arraylength();307static void checkcast();308static void instanceof();309310static void athrow();311312static void monitorenter();313static void monitorexit();314315static void wide();316static void multianewarray();317318static void fast_xaccess(TosState state);319static void fast_accessfield(TosState state);320static void fast_storefield(TosState state);321322static void _breakpoint();323324static void shouldnotreachhere();325326// jvmti support327static void jvmti_post_field_access(Register cache, Register index, bool is_static, bool has_tos);328static void jvmti_post_field_mod(Register cache, Register index, bool is_static);329static void jvmti_post_fast_field_mod();330331// debugging of TemplateGenerator332static void transition(TosState tos_in, TosState tos_out);// checks if in/out states expected by template generator correspond to table entries333334// initialization helpers335static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler );336static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg );337static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg );338static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos);339static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op);340static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc);341342friend class Template;343344// InterpreterMacroAssembler::is_a(), etc., need TemplateTable::call_VM().345friend class InterpreterMacroAssembler;346347public:348// Initialization349static void initialize();350static void pd_initialize();351352// Templates353static Template* template_for (Bytecodes::Code code) { Bytecodes::check (code); return &_template_table [code]; }354static Template* template_for_wide(Bytecodes::Code code) { Bytecodes::wide_check(code); return &_template_table_wide[code]; }355356// Platform specifics357#if defined TEMPLATETABLE_MD_HPP358# include TEMPLATETABLE_MD_HPP359#elif defined TARGET_ARCH_MODEL_x86_32360# include "templateTable_x86_32.hpp"361#elif defined TARGET_ARCH_MODEL_x86_64362# include "templateTable_x86_64.hpp"363#elif defined TARGET_ARCH_MODEL_aarch32364# include "templateTable_aarch32.hpp"365#elif defined TARGET_ARCH_MODEL_aarch64366# include "templateTable_aarch64.hpp"367#elif defined TARGET_ARCH_MODEL_sparc368# include "templateTable_sparc.hpp"369#elif defined TARGET_ARCH_MODEL_zero370# include "templateTable_zero.hpp"371#elif defined TARGET_ARCH_MODEL_ppc_64372# include "templateTable_ppc_64.hpp"373#endif374375};376#endif /* !CC_INTERP */377378#endif // SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP379380381