Sun, 11 Oct 2009 16:19:25 -0700
6888953: some calls to function-like macros are missing semicolons
Reviewed-by: pbk, kvn
1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 // This file contains the platform-independent parts
26 // of the template interpreter and the template interpreter generator.
28 #ifndef CC_INTERP
30 //------------------------------------------------------------------------------------------------------------------------
31 // A little wrapper class to group tosca-specific entry points into a unit.
32 // (tosca = Top-Of-Stack CAche)
34 class EntryPoint VALUE_OBJ_CLASS_SPEC {
35 private:
36 address _entry[number_of_states];
38 public:
39 // Construction
40 EntryPoint();
41 EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry);
43 // Attributes
44 address entry(TosState state) const; // return target address for a given tosca state
45 void set_entry(TosState state, address entry); // set target address for a given tosca state
46 void print();
48 // Comparison
49 bool operator == (const EntryPoint& y); // for debugging only
50 };
53 //------------------------------------------------------------------------------------------------------------------------
54 // A little wrapper class to group tosca-specific dispatch tables into a unit.
56 class DispatchTable VALUE_OBJ_CLASS_SPEC {
57 public:
58 enum { length = 1 << BitsPerByte }; // an entry point for each byte value (also for undefined bytecodes)
60 private:
61 address _table[number_of_states][length]; // dispatch tables, indexed by tosca and bytecode
63 public:
64 // Attributes
65 EntryPoint entry(int i) const; // return entry point for a given bytecode i
66 void set_entry(int i, EntryPoint& entry); // set entry point for a given bytecode i
67 address* table_for(TosState state) { return _table[state]; }
68 address* table_for() { return table_for((TosState)0); }
69 int distance_from(address *table) { return table - table_for(); }
70 int distance_from(TosState state) { return distance_from(table_for(state)); }
72 // Comparison
73 bool operator == (DispatchTable& y); // for debugging only
74 };
76 class TemplateInterpreter: public AbstractInterpreter {
77 friend class VMStructs;
78 friend class InterpreterMacroAssembler;
79 friend class TemplateInterpreterGenerator;
80 friend class InterpreterGenerator;
81 friend class TemplateTable;
82 // friend class Interpreter;
83 public:
85 enum MoreConstants {
86 number_of_return_entries = number_of_states, // number of return entry points
87 number_of_deopt_entries = number_of_states, // number of deoptimization entry points
88 number_of_return_addrs = number_of_states // number of return addresses
89 };
91 protected:
93 static address _throw_ArrayIndexOutOfBoundsException_entry;
94 static address _throw_ArrayStoreException_entry;
95 static address _throw_ArithmeticException_entry;
96 static address _throw_ClassCastException_entry;
97 static address _throw_WrongMethodType_entry;
98 static address _throw_NullPointerException_entry;
99 static address _throw_exception_entry;
101 static address _throw_StackOverflowError_entry;
103 static address _remove_activation_entry; // continuation address if an exception is not handled by current frame
104 #ifdef HOTSWAP
105 static address _remove_activation_preserving_args_entry; // continuation address when current frame is being popped
106 #endif // HOTSWAP
108 #ifndef PRODUCT
109 static EntryPoint _trace_code;
110 #endif // !PRODUCT
111 static EntryPoint _return_entry[number_of_return_entries]; // entry points to return to from a call
112 static EntryPoint _earlyret_entry; // entry point to return early from a call
113 static EntryPoint _deopt_entry[number_of_deopt_entries]; // entry points to return to from a deoptimization
114 static EntryPoint _continuation_entry;
115 static EntryPoint _safept_entry;
117 static address _return_3_addrs_by_index[number_of_return_addrs]; // for invokevirtual return entries
118 static address _return_5_addrs_by_index[number_of_return_addrs]; // for invokeinterface return entries
120 static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch)
121 static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode)
122 static DispatchTable _safept_table; // the safepoint dispatch table (used to set the active table for safepoints)
123 static address _wentry_point[DispatchTable::length]; // wide instructions only (vtos tosca always)
126 public:
127 // Initialization/debugging
128 static void initialize();
129 // this only returns whether a pc is within generated code for the interpreter.
130 static bool contains(address pc) { return _code != NULL && _code->contains(pc); }
132 public:
134 static address remove_activation_early_entry(TosState state) { return _earlyret_entry.entry(state); }
135 #ifdef HOTSWAP
136 static address remove_activation_preserving_args_entry() { return _remove_activation_preserving_args_entry; }
137 #endif // HOTSWAP
139 static address remove_activation_entry() { return _remove_activation_entry; }
140 static address throw_exception_entry() { return _throw_exception_entry; }
141 static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; }
142 static address throw_WrongMethodType_entry() { return _throw_WrongMethodType_entry; }
143 static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; }
144 static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }
146 // Code generation
147 #ifndef PRODUCT
148 static address trace_code (TosState state) { return _trace_code.entry(state); }
149 #endif // !PRODUCT
150 static address continuation (TosState state) { return _continuation_entry.entry(state); }
151 static address* dispatch_table(TosState state) { return _active_table.table_for(state); }
152 static address* dispatch_table() { return _active_table.table_for(); }
153 static int distance_from_dispatch_table(TosState state){ return _active_table.distance_from(state); }
154 static address* normal_table(TosState state) { return _normal_table.table_for(state); }
155 static address* normal_table() { return _normal_table.table_for(); }
157 // Support for invokes
158 static address* return_3_addrs_by_index_table() { return _return_3_addrs_by_index; }
159 static address* return_5_addrs_by_index_table() { return _return_5_addrs_by_index; }
160 static int TosState_as_index(TosState state); // computes index into return_3_entry_by_index table
162 static address return_entry (TosState state, int length);
163 static address deopt_entry (TosState state, int length);
165 // Safepoint support
166 static void notice_safepoints(); // stops the thread when reaching a safepoint
167 static void ignore_safepoints(); // ignores safepoints
169 // Deoptimization support
170 // Compute the entry address for continuation after
171 static address deopt_continue_after_entry(methodOop method,
172 address bcp,
173 int callee_parameters,
174 bool is_top_frame);
175 // Deoptimization should reexecute this bytecode
176 static bool bytecode_should_reexecute(Bytecodes::Code code);
177 // Compute the address for reexecution
178 static address deopt_reexecute_entry(methodOop method, address bcp);
180 #include "incls/_templateInterpreter_pd.hpp.incl"
182 };
184 #endif // !CC_INTERP