Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/methodHandleWalk.hpp @ 3388:a80577f854f9
7045513: JSR 292 inlining causes crashes in methodHandleWalk.cpp
Reviewed-by: jrose
author | never |
---|---|
date | Tue, 17 May 2011 19:11:51 -0700 |
parents | fabcf26ee72f |
children | 88559690c95a |
comparison
equal
deleted
inserted
replaced
3385:33ae33516634 | 3388:a80577f854f9 |
---|---|
124 BasicType _bt; | 124 BasicType _bt; |
125 jvalue _value; | 125 jvalue _value; |
126 Handle _handle; | 126 Handle _handle; |
127 | 127 |
128 public: | 128 public: |
129 ArgToken(TokenType tt = tt_illegal) : _tt(tt) {} | 129 ArgToken(TokenType tt = tt_illegal) : _tt(tt) { |
130 ArgToken(TokenType tt, BasicType bt, jvalue value) : _tt(tt), _bt(bt), _value(value) {} | 130 assert(tt == tt_illegal || tt == tt_void, "invalid token type"); |
131 } | |
131 | 132 |
132 ArgToken(TokenType tt, BasicType bt, int index) : _tt(tt), _bt(bt) { | 133 ArgToken(TokenType tt, BasicType bt, int index) : _tt(tt), _bt(bt) { |
134 assert(_tt == tt_parameter || _tt == tt_temporary, "must have index"); | |
133 _value.i = index; | 135 _value.i = index; |
134 } | 136 } |
135 | 137 |
136 ArgToken(TokenType tt, BasicType bt, Handle value) : _tt(tt), _bt(bt) { | 138 ArgToken(BasicType bt, jvalue value) : _tt(tt_constant), _bt(bt), _value(value) {} |
137 _handle = value; | 139 ArgToken(BasicType bt, Handle value) : _tt(tt_constant), _bt(bt), _handle(value) {} |
140 | |
141 | |
142 ArgToken(const char* str) : _tt(tt_symbolic), _bt(T_LONG) { | |
143 _value.j = (intptr_t)str; | |
138 } | 144 } |
139 | 145 |
140 TokenType token_type() const { return _tt; } | 146 TokenType token_type() const { return _tt; } |
141 BasicType basic_type() const { return _bt; } | 147 BasicType basic_type() const { return _bt; } |
142 int index() const { return _value.i; } | 148 bool has_index() const { return _tt == tt_parameter || _tt == tt_temporary; } |
143 Handle object() const { return _handle; } | 149 int index() const { assert(has_index(), "must have index");; return _value.i; } |
144 | 150 Handle object() const { assert(_tt == tt_constant, "value type"); return _handle; } |
145 jint get_jint() const { return _value.i; } | 151 const char* str() const { assert(_tt == tt_symbolic, "string type"); return (const char*)_value.j; } |
146 jlong get_jlong() const { return _value.j; } | 152 |
147 jfloat get_jfloat() const { return _value.f; } | 153 jint get_jint() const { assert(_tt == tt_constant, "value types"); return _value.i; } |
148 jdouble get_jdouble() const { return _value.d; } | 154 jlong get_jlong() const { assert(_tt == tt_constant, "value types"); return _value.j; } |
155 jfloat get_jfloat() const { assert(_tt == tt_constant, "value types"); return _value.f; } | |
156 jdouble get_jdouble() const { assert(_tt == tt_constant, "value types"); return _value.d; } | |
149 }; | 157 }; |
150 | 158 |
151 // Abstract interpretation state: | 159 // Abstract interpretation state: |
152 struct SlotState { | 160 struct SlotState { |
153 BasicType _type; | 161 BasicType _type; |
254 // An abstract interpreter for method handle chains. | 262 // An abstract interpreter for method handle chains. |
255 // Produces an account of the semantics of a chain, in terms of a static IR. | 263 // Produces an account of the semantics of a chain, in terms of a static IR. |
256 // The IR happens to be JVM bytecodes. | 264 // The IR happens to be JVM bytecodes. |
257 class MethodHandleCompiler : public MethodHandleWalker { | 265 class MethodHandleCompiler : public MethodHandleWalker { |
258 private: | 266 private: |
259 methodHandle _callee; | |
260 int _invoke_count; // count the original call site has been executed | 267 int _invoke_count; // count the original call site has been executed |
261 KlassHandle _rklass; // Return type for casting. | 268 KlassHandle _rklass; // Return type for casting. |
262 BasicType _rtype; | 269 BasicType _rtype; |
263 KlassHandle _target_klass; | 270 KlassHandle _target_klass; |
264 Thread* _thread; | 271 Thread* _thread; |
402 } | 409 } |
403 int cpool_name_and_type_put(int name_index, int signature_index) { | 410 int cpool_name_and_type_put(int name_index, int signature_index) { |
404 return cpool_oop_reference_put(JVM_CONSTANT_NameAndType, name_index, signature_index); | 411 return cpool_oop_reference_put(JVM_CONSTANT_NameAndType, name_index, signature_index); |
405 } | 412 } |
406 | 413 |
407 void emit_bc(Bytecodes::Code op, int index = 0); | 414 void emit_bc(Bytecodes::Code op, int index = 0, int args_size = -1); |
408 void emit_load(BasicType bt, int index); | 415 void emit_load(BasicType bt, int index); |
409 void emit_store(BasicType bt, int index); | 416 void emit_store(BasicType bt, int index); |
410 void emit_load_constant(ArgToken arg); | 417 void emit_load_constant(ArgToken arg); |
411 | 418 |
412 virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) { | 419 virtual ArgToken make_parameter(BasicType type, klassOop tk, int argnum, TRAPS) { |
413 return ArgToken(tt_parameter, type, argnum); | 420 return ArgToken(tt_parameter, type, argnum); |
414 } | 421 } |
415 virtual ArgToken make_oop_constant(oop con, TRAPS) { | 422 virtual ArgToken make_oop_constant(oop con, TRAPS) { |
416 Handle h(THREAD, con); | 423 Handle h(THREAD, con); |
417 return ArgToken(tt_constant, T_OBJECT, h); | 424 return ArgToken(T_OBJECT, h); |
418 } | 425 } |
419 virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) { | 426 virtual ArgToken make_prim_constant(BasicType type, jvalue* con, TRAPS) { |
420 return ArgToken(tt_constant, type, *con); | 427 return ArgToken(type, *con); |
421 } | 428 } |
422 | 429 |
423 virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS); | 430 virtual ArgToken make_conversion(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& src, TRAPS); |
424 virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS); | 431 virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS); |
425 virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS); | 432 virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS); |
429 | 436 |
430 // Get a real methodOop. | 437 // Get a real methodOop. |
431 methodHandle get_method_oop(TRAPS) const; | 438 methodHandle get_method_oop(TRAPS) const; |
432 | 439 |
433 public: | 440 public: |
434 MethodHandleCompiler(Handle root, methodHandle callee, int invoke_count, bool for_invokedynamic, TRAPS); | 441 MethodHandleCompiler(Handle root, Symbol* name, Symbol* signature, int invoke_count, bool for_invokedynamic, TRAPS); |
435 | 442 |
436 // Compile the given MH chain into bytecode. | 443 // Compile the given MH chain into bytecode. |
437 methodHandle compile(TRAPS); | 444 methodHandle compile(TRAPS); |
438 | 445 |
439 // Tests if the given class is a MH adapter holder. | 446 // Tests if the given class is a MH adapter holder. |