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 #include "precompiled.hpp"
26 #include "classfile/javaClasses.inline.hpp"
27 #include "classfile/stringTable.hpp"
28 #include "code/codeCache.hpp"
29 #include "code/codeCacheExtensions.hpp"
30 #include "code/dependencyContext.hpp"
31 #include "compiler/compileBroker.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "interpreter/oopMapCache.hpp"
34 #include "interpreter/linkResolver.hpp"
35 #include "memory/allocation.inline.hpp"
36 #include "memory/oopFactory.hpp"
37 #include "oops/objArrayOop.inline.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "prims/methodHandles.hpp"
40 #include "prims/jvmtiRedefineClassesTrace.hpp"
41 #include "runtime/compilationPolicy.hpp"
42 #include "runtime/javaCalls.hpp"
43 #include "runtime/reflection.hpp"
44 #include "runtime/signature.hpp"
45 #include "runtime/stubRoutines.hpp"
46 #include "utilities/exceptions.hpp"
47
48
49 /*
50 * JSR 292 reference implementation: method handles
51 * The JDK 7 reference implementation represented method handle
52 * combinations as chains. Each link in the chain had a "vmentry"
53 * field which pointed at a bit of assembly code which performed
54 * one transformation before dispatching to the next link in the chain.
59 * handle's behavior. The LambdaForm is a normal Java object, managed
60 * by a runtime coded in Java.
61 */
62
63 bool MethodHandles::_enabled = false; // set true after successful native linkage
64 MethodHandlesAdapterBlob* MethodHandles::_adapter_code = NULL;
65
66
67 /**
68 * Generates method handle adapters. Returns 'false' if memory allocation
69 * failed and true otherwise.
70 */
71 bool MethodHandles::generate_adapters() {
72 if (SystemDictionary::MethodHandle_klass() == NULL) {
73 return true;
74 }
75
76 assert(_adapter_code == NULL, "generate only once");
77
78 ResourceMark rm;
79 TraceTime timer("MethodHandles adapters generation", TraceStartupTime);
80 _adapter_code = MethodHandlesAdapterBlob::create(adapter_code_size);
81 if (_adapter_code == NULL) {
82 return false;
83 }
84
85 CodeBuffer code(_adapter_code);
86 MethodHandlesAdapterGenerator g(&code);
87 g.generate();
88 code.log_section_sizes("MethodHandlesAdapterBlob");
89 return true;
90 }
91
92 //------------------------------------------------------------------------------
93 // MethodHandlesAdapterGenerator::generate
94 //
95 void MethodHandlesAdapterGenerator::generate() {
96 // Generate generic method handle adapters.
97 // Generate interpreter entries
98 for (Interpreter::MethodKind mk = Interpreter::method_handle_invoke_FIRST;
99 mk <= Interpreter::method_handle_invoke_LAST;
|
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 #include "precompiled.hpp"
26 #include "classfile/javaClasses.inline.hpp"
27 #include "classfile/stringTable.hpp"
28 #include "code/codeCache.hpp"
29 #include "code/codeCacheExtensions.hpp"
30 #include "code/dependencyContext.hpp"
31 #include "compiler/compileBroker.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "interpreter/oopMapCache.hpp"
34 #include "interpreter/linkResolver.hpp"
35 #include "logging/log.hpp"
36 #include "memory/allocation.inline.hpp"
37 #include "memory/oopFactory.hpp"
38 #include "oops/objArrayOop.inline.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "prims/methodHandles.hpp"
41 #include "prims/jvmtiRedefineClassesTrace.hpp"
42 #include "runtime/compilationPolicy.hpp"
43 #include "runtime/javaCalls.hpp"
44 #include "runtime/reflection.hpp"
45 #include "runtime/signature.hpp"
46 #include "runtime/stubRoutines.hpp"
47 #include "utilities/exceptions.hpp"
48
49
50 /*
51 * JSR 292 reference implementation: method handles
52 * The JDK 7 reference implementation represented method handle
53 * combinations as chains. Each link in the chain had a "vmentry"
54 * field which pointed at a bit of assembly code which performed
55 * one transformation before dispatching to the next link in the chain.
60 * handle's behavior. The LambdaForm is a normal Java object, managed
61 * by a runtime coded in Java.
62 */
63
64 bool MethodHandles::_enabled = false; // set true after successful native linkage
65 MethodHandlesAdapterBlob* MethodHandles::_adapter_code = NULL;
66
67
68 /**
69 * Generates method handle adapters. Returns 'false' if memory allocation
70 * failed and true otherwise.
71 */
72 bool MethodHandles::generate_adapters() {
73 if (SystemDictionary::MethodHandle_klass() == NULL) {
74 return true;
75 }
76
77 assert(_adapter_code == NULL, "generate only once");
78
79 ResourceMark rm;
80 TraceTime timer("MethodHandles adapters generation",
81 log_is_enabled(Info, startuptime),
82 LogTag::_startuptime);
83 _adapter_code = MethodHandlesAdapterBlob::create(adapter_code_size);
84 if (_adapter_code == NULL) {
85 return false;
86 }
87
88 CodeBuffer code(_adapter_code);
89 MethodHandlesAdapterGenerator g(&code);
90 g.generate();
91 code.log_section_sizes("MethodHandlesAdapterBlob");
92 return true;
93 }
94
95 //------------------------------------------------------------------------------
96 // MethodHandlesAdapterGenerator::generate
97 //
98 void MethodHandlesAdapterGenerator::generate() {
99 // Generate generic method handle adapters.
100 // Generate interpreter entries
101 for (Interpreter::MethodKind mk = Interpreter::method_handle_invoke_FIRST;
102 mk <= Interpreter::method_handle_invoke_LAST;
|