Mon, 10 Jan 2011 00:56:39 -0800
7010180: JSR 292 InvokeDynamicPrintArgs fails with: assert(_adapter == NULL) failed: init'd to NULL
Reviewed-by: never
1.1 --- a/src/cpu/sparc/vm/methodHandles_sparc.cpp Fri Jan 07 11:53:24 2011 -0800 1.2 +++ b/src/cpu/sparc/vm/methodHandles_sparc.cpp Mon Jan 10 00:56:39 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -395,7 +395,7 @@ 1.11 // 1.12 // Generate an "entry" field for a method handle. 1.13 // This determines how the method handle will respond to calls. 1.14 -void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) { 1.15 +void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) { 1.16 // Here is the register state during an interpreted call, 1.17 // as set up by generate_method_handle_interpreter_entry(): 1.18 // - G5: garbage temp (was MethodHandle.invoke methodOop, unused) 1.19 @@ -447,8 +447,9 @@ 1.20 // exception. Since we use a C2I adapter to set up the 1.21 // interpreter state, arguments are expected in compiler 1.22 // argument registers. 1.23 - methodHandle mh(raise_exception_method()); 1.24 - address c2i_entry = methodOopDesc::make_adapters(mh, CATCH); 1.25 + assert(raise_exception_method(), "must be set"); 1.26 + address c2i_entry = raise_exception_method()->get_c2i_entry(); 1.27 + assert(c2i_entry, "method must be linked"); 1.28 1.29 __ mov(O5_savedSP, SP); // Cut the stack back to where the caller started. 1.30
2.1 --- a/src/cpu/x86/vm/methodHandles_x86.cpp Fri Jan 07 11:53:24 2011 -0800 2.2 +++ b/src/cpu/x86/vm/methodHandles_x86.cpp Mon Jan 10 00:56:39 2011 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -390,7 +390,7 @@ 2.11 // 2.12 // Generate an "entry" field for a method handle. 2.13 // This determines how the method handle will respond to calls. 2.14 -void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) { 2.15 +void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) { 2.16 // Here is the register state during an interpreted call, 2.17 // as set up by generate_method_handle_interpreter_entry(): 2.18 // - rbx: garbage temp (was MethodHandle.invoke methodOop, unused) 2.19 @@ -451,8 +451,9 @@ 2.20 // exception. Since we use a C2I adapter to set up the 2.21 // interpreter state, arguments are expected in compiler 2.22 // argument registers. 2.23 - methodHandle mh(raise_exception_method()); 2.24 - address c2i_entry = methodOopDesc::make_adapters(mh, CHECK); 2.25 + assert(raise_exception_method(), "must be set"); 2.26 + address c2i_entry = raise_exception_method()->get_c2i_entry(); 2.27 + assert(c2i_entry, "method must be linked"); 2.28 2.29 const Register rdi_pc = rax; 2.30 __ pop(rdi_pc); // caller PC
3.1 --- a/src/share/vm/prims/methodHandles.cpp Fri Jan 07 11:53:24 2011 -0800 3.2 +++ b/src/share/vm/prims/methodHandles.cpp Mon Jan 10 00:56:39 2011 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -111,7 +111,7 @@ 3.11 //------------------------------------------------------------------------------ 3.12 // MethodHandles::generate_adapters 3.13 // 3.14 -void MethodHandles::generate_adapters(TRAPS) { 3.15 +void MethodHandles::generate_adapters() { 3.16 if (!EnableMethodHandles || SystemDictionary::MethodHandle_klass() == NULL) return; 3.17 3.18 assert(_adapter_code == NULL, "generate only once"); 3.19 @@ -123,20 +123,20 @@ 3.20 vm_exit_out_of_memory(_adapter_code_size, "CodeCache: no room for MethodHandles adapters"); 3.21 CodeBuffer code(_adapter_code); 3.22 MethodHandlesAdapterGenerator g(&code); 3.23 - g.generate(CHECK); 3.24 + g.generate(); 3.25 } 3.26 3.27 3.28 //------------------------------------------------------------------------------ 3.29 // MethodHandlesAdapterGenerator::generate 3.30 // 3.31 -void MethodHandlesAdapterGenerator::generate(TRAPS) { 3.32 +void MethodHandlesAdapterGenerator::generate() { 3.33 // Generate generic method handle adapters. 3.34 for (MethodHandles::EntryKind ek = MethodHandles::_EK_FIRST; 3.35 ek < MethodHandles::_EK_LIMIT; 3.36 ek = MethodHandles::EntryKind(1 + (int)ek)) { 3.37 StubCodeMark mark(this, "MethodHandle", MethodHandles::entry_name(ek)); 3.38 - MethodHandles::generate_method_handle_stub(_masm, ek, CHECK); 3.39 + MethodHandles::generate_method_handle_stub(_masm, ek); 3.40 } 3.41 } 3.42 3.43 @@ -2621,10 +2621,20 @@ 3.44 warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); 3.45 enable_MH = false; 3.46 } 3.47 + } else { 3.48 + enable_MH = false; 3.49 } 3.50 } 3.51 3.52 if (enable_MH) { 3.53 + // We need to link the MethodHandleImpl klass before we generate 3.54 + // the method handle adapters as the _raise_exception adapter uses 3.55 + // one of its methods (and its c2i-adapter). 3.56 + KlassHandle k = SystemDictionaryHandles::MethodHandleImpl_klass(); 3.57 + instanceKlass* ik = instanceKlass::cast(k()); 3.58 + ik->link_class(CHECK); 3.59 + 3.60 + MethodHandles::generate_adapters(); 3.61 MethodHandles::set_enabled(true); 3.62 } 3.63 3.64 @@ -2645,10 +2655,5 @@ 3.65 MethodHandles::set_enabled(true); 3.66 } 3.67 } 3.68 - 3.69 - // Generate method handles adapters if enabled. 3.70 - if (MethodHandles::enabled()) { 3.71 - MethodHandles::generate_adapters(CHECK); 3.72 - } 3.73 } 3.74 JVM_END
4.1 --- a/src/share/vm/prims/methodHandles.hpp Fri Jan 07 11:53:24 2011 -0800 4.2 +++ b/src/share/vm/prims/methodHandles.hpp Mon Jan 10 00:56:39 2011 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -294,11 +294,11 @@ 4.11 enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 }; 4.12 4.13 // Generate MethodHandles adapters. 4.14 - static void generate_adapters(TRAPS); 4.15 + static void generate_adapters(); 4.16 4.17 // Called from InterpreterGenerator and MethodHandlesAdapterGenerator. 4.18 static address generate_method_handle_interpreter_entry(MacroAssembler* _masm); 4.19 - static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek, TRAPS); 4.20 + static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek); 4.21 4.22 // argument list parsing 4.23 static int argument_slot(oop method_type, int arg); 4.24 @@ -530,7 +530,7 @@ 4.25 public: 4.26 MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code) {} 4.27 4.28 - void generate(TRAPS); 4.29 + void generate(); 4.30 }; 4.31 4.32 #endif // SHARE_VM_PRIMS_METHODHANDLES_HPP