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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 // Low-level parser for method handle chains. 26 class MethodHandleChain : StackObj { 27 public: 28 typedef MethodHandles::EntryKind EntryKind; 29 30 private: 31 Handle _root; // original target 32 Handle _method_handle; // current target 33 bool _is_last; // final guy in chain 34 bool _is_bound; // has a bound argument 35 BasicType _arg_type; // if is_bound, the bound argument type 36 int _arg_slot; // if is_bound or is_adapter, affected argument slot 37 jint _conversion; // conversion field of AMH or -1 38 methodHandle _last_method; // if is_last, which method we target 39 Bytecodes::Code _last_invoke; // if is_last, type of invoke 40 const char* _lose_message; // saved argument to lose() 41 42 void set_method_handle(Handle target, TRAPS); 43 void set_last_method(oop target, TRAPS); 44 static BasicType compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS); 394 virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS); 395 396 // Get a real constant pool. 397 constantPoolHandle get_constant_pool(TRAPS) const; 398 399 // Get a real methodOop. 400 methodHandle get_method_oop(TRAPS) const; 401 402 public: 403 MethodHandleCompiler(Handle root, methodHandle call_method, bool for_invokedynamic, TRAPS); 404 405 // Compile the given MH chain into bytecode. 406 methodHandle compile(TRAPS); 407 408 // Tests if the given class is a MH adapter holder. 409 static bool klass_is_method_handle_adapter_holder(klassOop klass) { 410 return (klass == SystemDictionary::MethodHandle_klass() || 411 klass == SystemDictionary::InvokeDynamic_klass()); 412 } 413 }; | 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_PRIMS_METHODHANDLEWALK_HPP 26 #define SHARE_VM_PRIMS_METHODHANDLEWALK_HPP 27 28 #include "prims/methodHandles.hpp" 29 30 // Low-level parser for method handle chains. 31 class MethodHandleChain : StackObj { 32 public: 33 typedef MethodHandles::EntryKind EntryKind; 34 35 private: 36 Handle _root; // original target 37 Handle _method_handle; // current target 38 bool _is_last; // final guy in chain 39 bool _is_bound; // has a bound argument 40 BasicType _arg_type; // if is_bound, the bound argument type 41 int _arg_slot; // if is_bound or is_adapter, affected argument slot 42 jint _conversion; // conversion field of AMH or -1 43 methodHandle _last_method; // if is_last, which method we target 44 Bytecodes::Code _last_invoke; // if is_last, type of invoke 45 const char* _lose_message; // saved argument to lose() 46 47 void set_method_handle(Handle target, TRAPS); 48 void set_last_method(oop target, TRAPS); 49 static BasicType compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS); 399 virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS); 400 401 // Get a real constant pool. 402 constantPoolHandle get_constant_pool(TRAPS) const; 403 404 // Get a real methodOop. 405 methodHandle get_method_oop(TRAPS) const; 406 407 public: 408 MethodHandleCompiler(Handle root, methodHandle call_method, bool for_invokedynamic, TRAPS); 409 410 // Compile the given MH chain into bytecode. 411 methodHandle compile(TRAPS); 412 413 // Tests if the given class is a MH adapter holder. 414 static bool klass_is_method_handle_adapter_holder(klassOop klass) { 415 return (klass == SystemDictionary::MethodHandle_klass() || 416 klass == SystemDictionary::InvokeDynamic_klass()); 417 } 418 }; 419 420 #endif // SHARE_VM_PRIMS_METHODHANDLEWALK_HPP |