0N/A/*
2273N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP
1879N/A#define SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP
1879N/A
1879N/A#include "interpreter/bytecodes.hpp"
1879N/A#include "memory/allocation.hpp"
1879N/A#include "runtime/frame.hpp"
1879N/A#ifdef TARGET_ARCH_MODEL_x86_32
1879N/A# include "interp_masm_x86_32.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_x86_64
1879N/A# include "interp_masm_x86_64.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_sparc
1879N/A# include "interp_masm_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_zero
1879N/A# include "interp_masm_zero.hpp"
1879N/A#endif
2073N/A#ifdef TARGET_ARCH_MODEL_arm
2073N/A# include "interp_masm_arm.hpp"
2073N/A#endif
2073N/A#ifdef TARGET_ARCH_MODEL_ppc
2073N/A# include "interp_masm_ppc.hpp"
2073N/A#endif
1879N/A
0N/A#ifndef CC_INTERP
0N/A// All the necessary definitions used for (bytecode) template generation. Instead of
0N/A// spreading the implementation functionality for each bytecode in the interpreter
0N/A// and the snippet generator, a template is assigned to each bytecode which can be
0N/A// used to generate the bytecode's implementation if needed.
0N/A
0N/A
0N/A// A Template describes the properties of a code template for a given bytecode
0N/A// and provides a generator to generate the code template.
0N/A
0N/Aclass Template VALUE_OBJ_CLASS_SPEC {
0N/A private:
0N/A enum Flags {
0N/A uses_bcp_bit, // set if template needs the bcp pointing to bytecode
0N/A does_dispatch_bit, // set if template dispatches on its own
0N/A calls_vm_bit, // set if template calls the vm
0N/A wide_bit // set if template belongs to a wide instruction
0N/A };
0N/A
0N/A typedef void (*generator)(int arg);
0N/A
0N/A int _flags; // describes interpreter template properties (bcp unknown)
0N/A TosState _tos_in; // tos cache state before template execution
0N/A TosState _tos_out; // tos cache state after template execution
0N/A generator _gen; // template code generator
0N/A int _arg; // argument for template code generator
0N/A
0N/A void initialize(int flags, TosState tos_in, TosState tos_out, generator gen, int arg);
0N/A
0N/A friend class TemplateTable;
0N/A
0N/A public:
0N/A Bytecodes::Code bytecode() const;
0N/A bool is_valid() const { return _gen != NULL; }
0N/A bool uses_bcp() const { return (_flags & (1 << uses_bcp_bit )) != 0; }
0N/A bool does_dispatch() const { return (_flags & (1 << does_dispatch_bit)) != 0; }
0N/A bool calls_vm() const { return (_flags & (1 << calls_vm_bit )) != 0; }
0N/A bool is_wide() const { return (_flags & (1 << wide_bit )) != 0; }
0N/A TosState tos_in() const { return _tos_in; }
0N/A TosState tos_out() const { return _tos_out; }
0N/A void generate(InterpreterMacroAssembler* masm);
0N/A};
0N/A
0N/A
0N/A// The TemplateTable defines all Templates and provides accessor functions
0N/A// to get the template for a given bytecode.
0N/A
0N/Aclass TemplateTable: AllStatic {
0N/A public:
0N/A enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr };
0N/A enum Condition { equal, not_equal, less, less_equal, greater, greater_equal };
3932N/A enum CacheByte { f1_byte = 1, f2_byte = 2, f12_oop = 0x12 }; // byte_no codes
0N/A
0N/A private:
0N/A static bool _is_initialized; // true if TemplateTable has been initialized
0N/A static Template _template_table [Bytecodes::number_of_codes];
0N/A static Template _template_table_wide[Bytecodes::number_of_codes];
0N/A
0N/A static Template* _desc; // the current template to be generated
0N/A static Bytecodes::Code bytecode() { return _desc->bytecode(); }
0N/A
342N/A static BarrierSet* _bs; // Cache the barrier set.
0N/A public:
0N/A //%note templates_1
0N/A static InterpreterMacroAssembler* _masm; // the assembler used when generating templates
0N/A
0N/A private:
0N/A
0N/A // special registers
0N/A static inline Address at_bcp(int offset);
0N/A
0N/A // helpers
0N/A static void unimplemented_bc();
2677N/A static void patch_bytecode(Bytecodes::Code bc, Register bc_reg,
2677N/A Register temp_reg, bool load_bc_into_bc_reg = true, int byte_no = -1);
0N/A
0N/A // C calls
0N/A static void call_VM(Register oop_result, address entry_point);
0N/A static void call_VM(Register oop_result, address entry_point, Register arg_1);
0N/A static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2);
0N/A static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3);
0N/A
0N/A // these overloadings are not presently used on SPARC:
0N/A static void call_VM(Register oop_result, Register last_java_sp, address entry_point);
0N/A static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1);
0N/A static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2);
0N/A static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3);
0N/A
0N/A // bytecodes
0N/A static void nop();
0N/A
0N/A static void aconst_null();
0N/A static void iconst(int value);
0N/A static void lconst(int value);
0N/A static void fconst(int value);
0N/A static void dconst(int value);
0N/A
0N/A static void bipush();
0N/A static void sipush();
0N/A static void ldc(bool wide);
0N/A static void ldc2_w();
1522N/A static void fast_aldc(bool wide);
0N/A
0N/A static void locals_index(Register reg, int offset = 1);
0N/A static void iload();
0N/A static void fast_iload();
0N/A static void fast_iload2();
0N/A static void fast_icaload();
0N/A static void lload();
0N/A static void fload();
0N/A static void dload();
0N/A static void aload();
0N/A
0N/A static void locals_index_wide(Register reg);
0N/A static void wide_iload();
0N/A static void wide_lload();
0N/A static void wide_fload();
0N/A static void wide_dload();
0N/A static void wide_aload();
0N/A
0N/A static void iaload();
0N/A static void laload();
0N/A static void faload();
0N/A static void daload();
0N/A static void aaload();
0N/A static void baload();
0N/A static void caload();
0N/A static void saload();
0N/A
0N/A static void iload(int n);
0N/A static void lload(int n);
0N/A static void fload(int n);
0N/A static void dload(int n);
0N/A static void aload(int n);
0N/A static void aload_0();
0N/A
0N/A static void istore();
0N/A static void lstore();
0N/A static void fstore();
0N/A static void dstore();
0N/A static void astore();
0N/A
0N/A static void wide_istore();
0N/A static void wide_lstore();
0N/A static void wide_fstore();
0N/A static void wide_dstore();
0N/A static void wide_astore();
0N/A
0N/A static void iastore();
0N/A static void lastore();
0N/A static void fastore();
0N/A static void dastore();
0N/A static void aastore();
0N/A static void bastore();
0N/A static void castore();
0N/A static void sastore();
0N/A
0N/A static void istore(int n);
0N/A static void lstore(int n);
0N/A static void fstore(int n);
0N/A static void dstore(int n);
0N/A static void astore(int n);
0N/A
0N/A static void pop();
0N/A static void pop2();
0N/A static void dup();
0N/A static void dup_x1();
0N/A static void dup_x2();
0N/A static void dup2();
0N/A static void dup2_x1();
0N/A static void dup2_x2();
0N/A static void swap();
0N/A
0N/A static void iop2(Operation op);
0N/A static void lop2(Operation op);
0N/A static void fop2(Operation op);
0N/A static void dop2(Operation op);
0N/A
0N/A static void idiv();
0N/A static void irem();
0N/A
0N/A static void lmul();
0N/A static void ldiv();
0N/A static void lrem();
0N/A static void lshl();
0N/A static void lshr();
0N/A static void lushr();
0N/A
0N/A static void ineg();
0N/A static void lneg();
0N/A static void fneg();
0N/A static void dneg();
0N/A
0N/A static void iinc();
0N/A static void wide_iinc();
0N/A static void convert();
0N/A static void lcmp();
0N/A
0N/A static void float_cmp (bool is_float, int unordered_result);
0N/A static void float_cmp (int unordered_result);
0N/A static void double_cmp(int unordered_result);
0N/A
0N/A static void count_calls(Register method, Register temp);
0N/A static void branch(bool is_jsr, bool is_wide);
0N/A static void if_0cmp (Condition cc);
0N/A static void if_icmp (Condition cc);
0N/A static void if_nullcmp(Condition cc);
0N/A static void if_acmp (Condition cc);
0N/A
0N/A static void _goto();
0N/A static void jsr();
0N/A static void ret();
0N/A static void wide_ret();
0N/A
0N/A static void goto_w();
0N/A static void jsr_w();
0N/A
0N/A static void tableswitch();
0N/A static void lookupswitch();
0N/A static void fast_linearswitch();
0N/A static void fast_binaryswitch();
0N/A
0N/A static void _return(TosState state);
0N/A
1485N/A static void resolve_cache_and_index(int byte_no, // one of 1,2,11
1485N/A Register result , // either noreg or output for f1/f2
1485N/A Register cache, // output for CP cache
1485N/A Register index, // output for CP index
1485N/A size_t index_size); // one of 1,2,4
0N/A static void load_invoke_cp_cache_entry(int byte_no,
0N/A Register method,
0N/A Register itable_index,
0N/A Register flags,
1485N/A bool is_invokevirtual,
1485N/A bool is_virtual_final,
1485N/A bool is_invokedynamic);
0N/A static void load_field_cp_cache_entry(Register obj,
0N/A Register cache,
0N/A Register index,
0N/A Register offset,
0N/A Register flags,
0N/A bool is_static);
0N/A static void invokevirtual(int byte_no);
0N/A static void invokespecial(int byte_no);
0N/A static void invokestatic(int byte_no);
0N/A static void invokeinterface(int byte_no);
726N/A static void invokedynamic(int byte_no);
3932N/A static void invokehandle(int byte_no);
0N/A static void fast_invokevfinal(int byte_no);
0N/A
0N/A static void getfield_or_static(int byte_no, bool is_static);
0N/A static void putfield_or_static(int byte_no, bool is_static);
0N/A static void getfield(int byte_no);
0N/A static void putfield(int byte_no);
0N/A static void getstatic(int byte_no);
0N/A static void putstatic(int byte_no);
0N/A static void pop_and_check_object(Register obj);
0N/A
0N/A static void _new();
0N/A static void newarray();
0N/A static void anewarray();
0N/A static void arraylength();
0N/A static void checkcast();
0N/A static void instanceof();
0N/A
0N/A static void athrow();
0N/A
0N/A static void monitorenter();
0N/A static void monitorexit();
0N/A
0N/A static void wide();
0N/A static void multianewarray();
0N/A
0N/A static void fast_xaccess(TosState state);
0N/A static void fast_accessfield(TosState state);
0N/A static void fast_storefield(TosState state);
0N/A
0N/A static void _breakpoint();
0N/A
0N/A static void shouldnotreachhere();
0N/A
0N/A // jvmti support
0N/A static void jvmti_post_field_access(Register cache, Register index, bool is_static, bool has_tos);
0N/A static void jvmti_post_field_mod(Register cache, Register index, bool is_static);
0N/A static void jvmti_post_fast_field_mod();
0N/A
0N/A // debugging of TemplateGenerator
0N/A static void transition(TosState tos_in, TosState tos_out);// checks if in/out states expected by template generator correspond to table entries
0N/A
0N/A // initialization helpers
0N/A static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler );
0N/A static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg );
0N/A static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg );
0N/A static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos);
0N/A static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op);
0N/A static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc);
0N/A
0N/A friend class Template;
0N/A
0N/A // InterpreterMacroAssembler::is_a(), etc., need TemplateTable::call_VM().
0N/A friend class InterpreterMacroAssembler;
0N/A
0N/A public:
0N/A // Initialization
0N/A static void initialize();
0N/A static void pd_initialize();
0N/A
0N/A // Templates
0N/A static Template* template_for (Bytecodes::Code code) { Bytecodes::check (code); return &_template_table [code]; }
0N/A static Template* template_for_wide(Bytecodes::Code code) { Bytecodes::wide_check(code); return &_template_table_wide[code]; }
0N/A
0N/A // Platform specifics
1879N/A#ifdef TARGET_ARCH_MODEL_x86_32
1879N/A# include "templateTable_x86_32.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_x86_64
1879N/A# include "templateTable_x86_64.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_sparc
1879N/A# include "templateTable_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_MODEL_zero
1879N/A# include "templateTable_zero.hpp"
1879N/A#endif
2073N/A#ifdef TARGET_ARCH_MODEL_arm
2073N/A# include "templateTable_arm.hpp"
2073N/A#endif
2073N/A#ifdef TARGET_ARCH_MODEL_ppc
2073N/A# include "templateTable_ppc.hpp"
2073N/A#endif
1879N/A
0N/A};
0N/A#endif /* !CC_INTERP */
1879N/A
1879N/A#endif // SHARE_VM_INTERPRETER_TEMPLATETABLE_HPP