1 /*
2 * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "compiler/compileBroker.hpp"
28 #include "interpreter/interpreter.hpp"
29 #include "interpreter/oopMapCache.hpp"
30 #include "memory/allocation.inline.hpp"
31 #include "memory/oopFactory.hpp"
32 #include "prims/methodHandles.hpp"
33 #include "runtime/compilationPolicy.hpp"
34 #include "runtime/javaCalls.hpp"
35 #include "runtime/reflection.hpp"
36 #include "runtime/signature.hpp"
37 #include "runtime/stubRoutines.hpp"
38 #include "utilities/exceptions.hpp"
39
40
41 /*
42 * JSR 292 reference implementation: method handles
43 * The JDK 7 reference implementation represented method handle
44 * combinations as chains. Each link in the chain had a "vmentry"
45 * field which pointed at a bit of assembly code which performed
46 * one transformation before dispatching to the next link in the chain.
1228 }
1229
1230 if (name != NULL && sig != NULL && results.not_null()) {
1231 // try a direct resolve
1232 // %%% TO DO
1233 }
1234
1235 int res = MethodHandles::find_MemberNames(k, name, sig, mflags,
1236 caller, skip, results);
1237 // TO DO: expand at least some of the MemberNames, to avoid massive callbacks
1238 return res;
1239 }
1240 JVM_END
1241
1242 JVM_ENTRY(void, MHN_setCallSiteTargetNormal(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
1243 Handle call_site(THREAD, JNIHandles::resolve_non_null(call_site_jh));
1244 Handle target (THREAD, JNIHandles::resolve(target_jh));
1245 {
1246 // Walk all nmethods depending on this call site.
1247 MutexLocker mu(Compile_lock, thread);
1248 Universe::flush_dependents_on(call_site, target);
1249 java_lang_invoke_CallSite::set_target(call_site(), target());
1250 }
1251 }
1252 JVM_END
1253
1254 JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
1255 Handle call_site(THREAD, JNIHandles::resolve_non_null(call_site_jh));
1256 Handle target (THREAD, JNIHandles::resolve(target_jh));
1257 {
1258 // Walk all nmethods depending on this call site.
1259 MutexLocker mu(Compile_lock, thread);
1260 Universe::flush_dependents_on(call_site, target);
1261 java_lang_invoke_CallSite::set_target_volatile(call_site(), target());
1262 }
1263 }
1264 JVM_END
1265
1266 /**
1267 * Throws a java/lang/UnsupportedOperationException unconditionally.
1268 * This is required by the specification of MethodHandle.invoke if
1269 * invoked directly.
1270 */
1271 JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
1272 THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively");
1273 return NULL;
1274 }
1275 JVM_END
1276
1277 /**
1278 * Throws a java/lang/UnsupportedOperationException unconditionally.
1279 * This is required by the specification of MethodHandle.invokeExact if
1280 * invoked directly.
|
1 /*
2 * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "code/codeCache.hpp"
28 #include "compiler/compileBroker.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "interpreter/oopMapCache.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "memory/oopFactory.hpp"
33 #include "prims/methodHandles.hpp"
34 #include "runtime/compilationPolicy.hpp"
35 #include "runtime/javaCalls.hpp"
36 #include "runtime/reflection.hpp"
37 #include "runtime/signature.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #include "utilities/exceptions.hpp"
40
41
42 /*
43 * JSR 292 reference implementation: method handles
44 * The JDK 7 reference implementation represented method handle
45 * combinations as chains. Each link in the chain had a "vmentry"
46 * field which pointed at a bit of assembly code which performed
47 * one transformation before dispatching to the next link in the chain.
1229 }
1230
1231 if (name != NULL && sig != NULL && results.not_null()) {
1232 // try a direct resolve
1233 // %%% TO DO
1234 }
1235
1236 int res = MethodHandles::find_MemberNames(k, name, sig, mflags,
1237 caller, skip, results);
1238 // TO DO: expand at least some of the MemberNames, to avoid massive callbacks
1239 return res;
1240 }
1241 JVM_END
1242
1243 JVM_ENTRY(void, MHN_setCallSiteTargetNormal(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
1244 Handle call_site(THREAD, JNIHandles::resolve_non_null(call_site_jh));
1245 Handle target (THREAD, JNIHandles::resolve(target_jh));
1246 {
1247 // Walk all nmethods depending on this call site.
1248 MutexLocker mu(Compile_lock, thread);
1249 CodeCache::flush_dependents_on(call_site, target);
1250 java_lang_invoke_CallSite::set_target(call_site(), target());
1251 }
1252 }
1253 JVM_END
1254
1255 JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
1256 Handle call_site(THREAD, JNIHandles::resolve_non_null(call_site_jh));
1257 Handle target (THREAD, JNIHandles::resolve(target_jh));
1258 {
1259 // Walk all nmethods depending on this call site.
1260 MutexLocker mu(Compile_lock, thread);
1261 CodeCache::flush_dependents_on(call_site, target);
1262 java_lang_invoke_CallSite::set_target_volatile(call_site(), target());
1263 }
1264 }
1265 JVM_END
1266
1267 /**
1268 * Throws a java/lang/UnsupportedOperationException unconditionally.
1269 * This is required by the specification of MethodHandle.invoke if
1270 * invoked directly.
1271 */
1272 JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
1273 THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively");
1274 return NULL;
1275 }
1276 JVM_END
1277
1278 /**
1279 * Throws a java/lang/UnsupportedOperationException unconditionally.
1280 * This is required by the specification of MethodHandle.invokeExact if
1281 * invoked directly.
|