1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/interpreter/templateTable.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,329 @@ 1.4 +/* 1.5 + * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef CC_INTERP 1.29 +// All the necessary definitions used for (bytecode) template generation. Instead of 1.30 +// spreading the implementation functionality for each bytecode in the interpreter 1.31 +// and the snippet generator, a template is assigned to each bytecode which can be 1.32 +// used to generate the bytecode's implementation if needed. 1.33 + 1.34 + 1.35 +// A Template describes the properties of a code template for a given bytecode 1.36 +// and provides a generator to generate the code template. 1.37 + 1.38 +class Template VALUE_OBJ_CLASS_SPEC { 1.39 + private: 1.40 + enum Flags { 1.41 + uses_bcp_bit, // set if template needs the bcp pointing to bytecode 1.42 + does_dispatch_bit, // set if template dispatches on its own 1.43 + calls_vm_bit, // set if template calls the vm 1.44 + wide_bit // set if template belongs to a wide instruction 1.45 + }; 1.46 + 1.47 + typedef void (*generator)(int arg); 1.48 + 1.49 + int _flags; // describes interpreter template properties (bcp unknown) 1.50 + TosState _tos_in; // tos cache state before template execution 1.51 + TosState _tos_out; // tos cache state after template execution 1.52 + generator _gen; // template code generator 1.53 + int _arg; // argument for template code generator 1.54 + 1.55 + void initialize(int flags, TosState tos_in, TosState tos_out, generator gen, int arg); 1.56 + 1.57 + friend class TemplateTable; 1.58 + 1.59 + public: 1.60 + Bytecodes::Code bytecode() const; 1.61 + bool is_valid() const { return _gen != NULL; } 1.62 + bool uses_bcp() const { return (_flags & (1 << uses_bcp_bit )) != 0; } 1.63 + bool does_dispatch() const { return (_flags & (1 << does_dispatch_bit)) != 0; } 1.64 + bool calls_vm() const { return (_flags & (1 << calls_vm_bit )) != 0; } 1.65 + bool is_wide() const { return (_flags & (1 << wide_bit )) != 0; } 1.66 + TosState tos_in() const { return _tos_in; } 1.67 + TosState tos_out() const { return _tos_out; } 1.68 + void generate(InterpreterMacroAssembler* masm); 1.69 +}; 1.70 + 1.71 + 1.72 +// The TemplateTable defines all Templates and provides accessor functions 1.73 +// to get the template for a given bytecode. 1.74 + 1.75 +class TemplateTable: AllStatic { 1.76 + public: 1.77 + enum Operation { add, sub, mul, div, rem, _and, _or, _xor, shl, shr, ushr }; 1.78 + enum Condition { equal, not_equal, less, less_equal, greater, greater_equal }; 1.79 + 1.80 + private: 1.81 + static bool _is_initialized; // true if TemplateTable has been initialized 1.82 + static Template _template_table [Bytecodes::number_of_codes]; 1.83 + static Template _template_table_wide[Bytecodes::number_of_codes]; 1.84 + 1.85 + static Template* _desc; // the current template to be generated 1.86 + static Bytecodes::Code bytecode() { return _desc->bytecode(); } 1.87 + 1.88 + public: 1.89 + //%note templates_1 1.90 + static InterpreterMacroAssembler* _masm; // the assembler used when generating templates 1.91 + 1.92 + private: 1.93 + 1.94 + // special registers 1.95 + static inline Address at_bcp(int offset); 1.96 + 1.97 + // helpers 1.98 + static void unimplemented_bc(); 1.99 + static void patch_bytecode(Bytecodes::Code bc, Register scratch1, 1.100 + Register scratch2, bool load_bc_in_scratch = true); 1.101 + 1.102 + // C calls 1.103 + static void call_VM(Register oop_result, address entry_point); 1.104 + static void call_VM(Register oop_result, address entry_point, Register arg_1); 1.105 + static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2); 1.106 + static void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3); 1.107 + 1.108 + // these overloadings are not presently used on SPARC: 1.109 + static void call_VM(Register oop_result, Register last_java_sp, address entry_point); 1.110 + static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1); 1.111 + static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2); 1.112 + static void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3); 1.113 + 1.114 + // bytecodes 1.115 + static void nop(); 1.116 + 1.117 + static void aconst_null(); 1.118 + static void iconst(int value); 1.119 + static void lconst(int value); 1.120 + static void fconst(int value); 1.121 + static void dconst(int value); 1.122 + 1.123 + static void bipush(); 1.124 + static void sipush(); 1.125 + static void ldc(bool wide); 1.126 + static void ldc2_w(); 1.127 + 1.128 + static void locals_index(Register reg, int offset = 1); 1.129 + static void iload(); 1.130 + static void fast_iload(); 1.131 + static void fast_iload2(); 1.132 + static void fast_icaload(); 1.133 + static void lload(); 1.134 + static void fload(); 1.135 + static void dload(); 1.136 + static void aload(); 1.137 + 1.138 + static void locals_index_wide(Register reg); 1.139 + static void wide_iload(); 1.140 + static void wide_lload(); 1.141 + static void wide_fload(); 1.142 + static void wide_dload(); 1.143 + static void wide_aload(); 1.144 + 1.145 + static void iaload(); 1.146 + static void laload(); 1.147 + static void faload(); 1.148 + static void daload(); 1.149 + static void aaload(); 1.150 + static void baload(); 1.151 + static void caload(); 1.152 + static void saload(); 1.153 + 1.154 + static void iload(int n); 1.155 + static void lload(int n); 1.156 + static void fload(int n); 1.157 + static void dload(int n); 1.158 + static void aload(int n); 1.159 + static void aload_0(); 1.160 + 1.161 + static void istore(); 1.162 + static void lstore(); 1.163 + static void fstore(); 1.164 + static void dstore(); 1.165 + static void astore(); 1.166 + 1.167 + static void wide_istore(); 1.168 + static void wide_lstore(); 1.169 + static void wide_fstore(); 1.170 + static void wide_dstore(); 1.171 + static void wide_astore(); 1.172 + 1.173 + static void iastore(); 1.174 + static void lastore(); 1.175 + static void fastore(); 1.176 + static void dastore(); 1.177 + static void aastore(); 1.178 + static void bastore(); 1.179 + static void castore(); 1.180 + static void sastore(); 1.181 + 1.182 + static void istore(int n); 1.183 + static void lstore(int n); 1.184 + static void fstore(int n); 1.185 + static void dstore(int n); 1.186 + static void astore(int n); 1.187 + 1.188 + static void pop(); 1.189 + static void pop2(); 1.190 + static void dup(); 1.191 + static void dup_x1(); 1.192 + static void dup_x2(); 1.193 + static void dup2(); 1.194 + static void dup2_x1(); 1.195 + static void dup2_x2(); 1.196 + static void swap(); 1.197 + 1.198 + static void iop2(Operation op); 1.199 + static void lop2(Operation op); 1.200 + static void fop2(Operation op); 1.201 + static void dop2(Operation op); 1.202 + 1.203 + static void idiv(); 1.204 + static void irem(); 1.205 + 1.206 + static void lmul(); 1.207 + static void ldiv(); 1.208 + static void lrem(); 1.209 + static void lshl(); 1.210 + static void lshr(); 1.211 + static void lushr(); 1.212 + 1.213 + static void ineg(); 1.214 + static void lneg(); 1.215 + static void fneg(); 1.216 + static void dneg(); 1.217 + 1.218 + static void iinc(); 1.219 + static void wide_iinc(); 1.220 + static void convert(); 1.221 + static void lcmp(); 1.222 + 1.223 + static void float_cmp (bool is_float, int unordered_result); 1.224 + static void float_cmp (int unordered_result); 1.225 + static void double_cmp(int unordered_result); 1.226 + 1.227 + static void count_calls(Register method, Register temp); 1.228 + static void branch(bool is_jsr, bool is_wide); 1.229 + static void if_0cmp (Condition cc); 1.230 + static void if_icmp (Condition cc); 1.231 + static void if_nullcmp(Condition cc); 1.232 + static void if_acmp (Condition cc); 1.233 + 1.234 + static void _goto(); 1.235 + static void jsr(); 1.236 + static void ret(); 1.237 + static void wide_ret(); 1.238 + 1.239 + static void goto_w(); 1.240 + static void jsr_w(); 1.241 + 1.242 + static void tableswitch(); 1.243 + static void lookupswitch(); 1.244 + static void fast_linearswitch(); 1.245 + static void fast_binaryswitch(); 1.246 + 1.247 + static void _return(TosState state); 1.248 + 1.249 + static void resolve_cache_and_index(int byte_no, Register cache, Register index); 1.250 + static void load_invoke_cp_cache_entry(int byte_no, 1.251 + Register method, 1.252 + Register itable_index, 1.253 + Register flags, 1.254 + bool is_invokevirtual = false, 1.255 + bool is_virtual_final = false); 1.256 + static void load_field_cp_cache_entry(Register obj, 1.257 + Register cache, 1.258 + Register index, 1.259 + Register offset, 1.260 + Register flags, 1.261 + bool is_static); 1.262 + static void invokevirtual(int byte_no); 1.263 + static void invokespecial(int byte_no); 1.264 + static void invokestatic(int byte_no); 1.265 + static void invokeinterface(int byte_no); 1.266 + static void fast_invokevfinal(int byte_no); 1.267 + 1.268 + static void getfield_or_static(int byte_no, bool is_static); 1.269 + static void putfield_or_static(int byte_no, bool is_static); 1.270 + static void getfield(int byte_no); 1.271 + static void putfield(int byte_no); 1.272 + static void getstatic(int byte_no); 1.273 + static void putstatic(int byte_no); 1.274 + static void pop_and_check_object(Register obj); 1.275 + 1.276 + static void _new(); 1.277 + static void newarray(); 1.278 + static void anewarray(); 1.279 + static void arraylength(); 1.280 + static void checkcast(); 1.281 + static void instanceof(); 1.282 + 1.283 + static void athrow(); 1.284 + 1.285 + static void monitorenter(); 1.286 + static void monitorexit(); 1.287 + 1.288 + static void wide(); 1.289 + static void multianewarray(); 1.290 + 1.291 + static void fast_xaccess(TosState state); 1.292 + static void fast_accessfield(TosState state); 1.293 + static void fast_storefield(TosState state); 1.294 + 1.295 + static void _breakpoint(); 1.296 + 1.297 + static void shouldnotreachhere(); 1.298 + 1.299 + // jvmti support 1.300 + static void jvmti_post_field_access(Register cache, Register index, bool is_static, bool has_tos); 1.301 + static void jvmti_post_field_mod(Register cache, Register index, bool is_static); 1.302 + static void jvmti_post_fast_field_mod(); 1.303 + 1.304 + // debugging of TemplateGenerator 1.305 + static void transition(TosState tos_in, TosState tos_out);// checks if in/out states expected by template generator correspond to table entries 1.306 + 1.307 + // initialization helpers 1.308 + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)( ), char filler ); 1.309 + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(int arg ), int arg ); 1.310 + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(bool arg ), bool arg ); 1.311 + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(TosState tos), TosState tos); 1.312 + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Operation op), Operation op); 1.313 + static void def(Bytecodes::Code code, int flags, TosState in, TosState out, void (*gen)(Condition cc), Condition cc); 1.314 + 1.315 + friend class Template; 1.316 + 1.317 + // InterpreterMacroAssembler::is_a(), etc., need TemplateTable::call_VM(). 1.318 + friend class InterpreterMacroAssembler; 1.319 + 1.320 + public: 1.321 + // Initialization 1.322 + static void initialize(); 1.323 + static void pd_initialize(); 1.324 + 1.325 + // Templates 1.326 + static Template* template_for (Bytecodes::Code code) { Bytecodes::check (code); return &_template_table [code]; } 1.327 + static Template* template_for_wide(Bytecodes::Code code) { Bytecodes::wide_check(code); return &_template_table_wide[code]; } 1.328 + 1.329 + // Platform specifics 1.330 + #include "incls/_templateTable_pd.hpp.incl" 1.331 +}; 1.332 +#endif /* !CC_INTERP */