comparison src/share/vm/prims/methodHandleWalk.hpp @ 3371:fabcf26ee72f

6998541: JSR 292 implement missing return-type conversion for OP_RETYPE_RAW Reviewed-by: jrose, kvn, never
author twisti
date Thu, 12 May 2011 14:04:48 -0700
parents e2a92dd0d3d2
children a80577f854f9
comparison
equal deleted inserted replaced
3370:2f17eb233d13 3371:fabcf26ee72f
111 enum TokenType { 111 enum TokenType {
112 tt_void, 112 tt_void,
113 tt_parameter, 113 tt_parameter,
114 tt_temporary, 114 tt_temporary,
115 tt_constant, 115 tt_constant,
116 tt_symbolic,
116 tt_illegal 117 tt_illegal
117 }; 118 };
118 119
119 // Argument token: 120 // Argument token:
120 class ArgToken { 121 class ArgToken {
162 private: 163 private:
163 MethodHandleChain _chain; 164 MethodHandleChain _chain;
164 bool _for_invokedynamic; 165 bool _for_invokedynamic;
165 int _local_index; 166 int _local_index;
166 167
168 // This array is kept in an unusual order, indexed by low-level "slot number".
169 // TOS is always _outgoing.at(0), so simple pushes and pops shift the whole _outgoing array.
170 // If there is a receiver in the current argument list, it is at _outgoing.at(_outgoing.length()-1).
171 // If a value at _outgoing.at(n) is T_LONG or T_DOUBLE, the value at _outgoing.at(n+1) is T_VOID.
167 GrowableArray<SlotState> _outgoing; // current outgoing parameter slots 172 GrowableArray<SlotState> _outgoing; // current outgoing parameter slots
168 int _outgoing_argc; // # non-empty outgoing slots 173 int _outgoing_argc; // # non-empty outgoing slots
169 174
170 // Replace a value of type old_type at slot (and maybe slot+1) with the new value. 175 // Replace a value of type old_type at slot (and maybe slot+1) with the new value.
171 // If old_type != T_VOID, remove the old argument at that point. 176 // If old_type != T_VOID, remove the old argument at that point.
172 // If new_type != T_VOID, insert the new argument at that point. 177 // If new_type != T_VOID, insert the new argument at that point.
173 // Insert or delete a second empty slot as needed. 178 // Insert or delete a second empty slot as needed.
174 void change_argument(BasicType old_type, int slot, BasicType new_type, const ArgToken& new_arg); 179 void change_argument(BasicType old_type, int slot, BasicType new_type, const ArgToken& new_arg);
180
181 // Raw retype conversions for OP_RAW_RETYPE.
182 void retype_raw_conversion(BasicType src, BasicType dst, bool for_return, int slot, TRAPS);
183 void retype_raw_argument_type(BasicType src, BasicType dst, int slot, TRAPS) { retype_raw_conversion(src, dst, false, slot, CHECK); }
184 void retype_raw_return_type( BasicType src, BasicType dst, TRAPS) { retype_raw_conversion(src, dst, true, -1, CHECK); }
175 185
176 SlotState* slot_state(int slot) { 186 SlotState* slot_state(int slot) {
177 if (slot < 0 || slot >= _outgoing.length()) 187 if (slot < 0 || slot >= _outgoing.length())
178 return NULL; 188 return NULL;
179 return _outgoing.adr_at(slot); 189 return _outgoing.adr_at(slot);
219 } 229 }
220 230
221 int max_locals() const { return _local_index; } 231 int max_locals() const { return _local_index; }
222 232
223 // plug-in abstract interpretation steps: 233 // plug-in abstract interpretation steps:
224 virtual ArgToken make_parameter( BasicType type, klassOop tk, int argnum, TRAPS ) = 0; 234 virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) = 0;
225 virtual ArgToken make_prim_constant( BasicType type, jvalue* con, TRAPS ) = 0; 235 virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) = 0;
226 virtual ArgToken make_oop_constant( oop con, TRAPS ) = 0; 236 virtual ArgToken make_oop_constant(oop con, TRAPS) = 0;
227 virtual ArgToken make_conversion( BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS ) = 0; 237 virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS) = 0;
228 virtual ArgToken make_fetch( BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS ) = 0; 238 virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS) = 0;
229 virtual ArgToken make_invoke( methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS ) = 0; 239 virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS) = 0;
230 240
231 // For make_invoke, the methodOop can be NULL if the intrinsic ID 241 // For make_invoke, the methodOop can be NULL if the intrinsic ID
232 // is something other than vmIntrinsics::_none. 242 // is something other than vmIntrinsics::_none.
233 243
234 // and in case anyone cares to related the previous actions to the chain: 244 // and in case anyone cares to related the previous actions to the chain:
251 KlassHandle _rklass; // Return type for casting. 261 KlassHandle _rklass; // Return type for casting.
252 BasicType _rtype; 262 BasicType _rtype;
253 KlassHandle _target_klass; 263 KlassHandle _target_klass;
254 Thread* _thread; 264 Thread* _thread;
255 265
266 // Values used by the compiler.
267 static jvalue zero_jvalue;
268 static jvalue one_jvalue;
269
256 // Fake constant pool entry. 270 // Fake constant pool entry.
257 class ConstantValue { 271 class ConstantValue {
258 private: 272 private:
259 int _tag; // Constant pool tag type. 273 int _tag; // Constant pool tag type.
260 JavaValue _value; 274 JavaValue _value;
415 429
416 // Get a real methodOop. 430 // Get a real methodOop.
417 methodHandle get_method_oop(TRAPS) const; 431 methodHandle get_method_oop(TRAPS) const;
418 432
419 public: 433 public:
420 MethodHandleCompiler(Handle root, methodHandle call_method, int invoke_count, bool for_invokedynamic, TRAPS); 434 MethodHandleCompiler(Handle root, methodHandle callee, int invoke_count, bool for_invokedynamic, TRAPS);
421 435
422 // Compile the given MH chain into bytecode. 436 // Compile the given MH chain into bytecode.
423 methodHandle compile(TRAPS); 437 methodHandle compile(TRAPS);
424 438
425 // Tests if the given class is a MH adapter holder. 439 // Tests if the given class is a MH adapter holder.