Mercurial > hg > truffle
comparison src/share/vm/prims/jni.cpp @ 8506:c3657d00e343
-Merge with tip
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Thu, 21 Mar 2013 14:11:13 +0100 |
parents | 86b4965f0c9a b8f261ba79c6 |
children | b9a918201d47 |
comparison
equal
deleted
inserted
replaced
8505:dee7c8b578c7 | 8506:c3657d00e343 |
---|---|
30 #include "classfile/javaClasses.hpp" | 30 #include "classfile/javaClasses.hpp" |
31 #include "classfile/symbolTable.hpp" | 31 #include "classfile/symbolTable.hpp" |
32 #include "classfile/systemDictionary.hpp" | 32 #include "classfile/systemDictionary.hpp" |
33 #include "classfile/vmSymbols.hpp" | 33 #include "classfile/vmSymbols.hpp" |
34 #include "interpreter/linkResolver.hpp" | 34 #include "interpreter/linkResolver.hpp" |
35 #include "utilities/macros.hpp" | |
35 #ifdef GRAAL | 36 #ifdef GRAAL |
36 #include "graal/graalCompiler.hpp" | 37 #include "graal/graalCompiler.hpp" |
37 #endif | 38 #endif |
38 #ifndef SERIALGC | 39 #if INCLUDE_ALL_GCS |
39 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" | 40 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
40 #endif // SERIALGC | 41 #endif // INCLUDE_ALL_GCS |
41 #include "memory/allocation.hpp" | 42 #include "memory/allocation.hpp" |
42 #include "memory/allocation.inline.hpp" | 43 #include "memory/allocation.inline.hpp" |
43 #include "memory/gcLocker.inline.hpp" | 44 #include "memory/gcLocker.inline.hpp" |
44 #include "memory/oopFactory.hpp" | 45 #include "memory/oopFactory.hpp" |
45 #include "memory/universe.inline.hpp" | 46 #include "memory/universe.inline.hpp" |
1316 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); | 1317 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); |
1317 return info.selected_method(); | 1318 return info.selected_method(); |
1318 } | 1319 } |
1319 | 1320 |
1320 | 1321 |
1321 static bool first_time_InvokeMain = true; | |
1322 | 1322 |
1323 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | 1323 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { |
1324 methodHandle method(THREAD, Method::resolve_jmethod_id(method_id)); | 1324 methodHandle method(THREAD, Method::resolve_jmethod_id(method_id)); |
1325 | 1325 |
1326 // Create object to hold arguments for the JavaCall, and associate it with | 1326 // Create object to hold arguments for the JavaCall, and associate it with |
1327 // the jni parser | 1327 // the jni parser |
1328 ResourceMark rm(THREAD); | 1328 ResourceMark rm(THREAD); |
1329 int number_of_parameters = method->size_of_parameters(); | 1329 int number_of_parameters = method->size_of_parameters(); |
1330 | |
1331 // Invoke the method. Result is returned as oop. | |
1332 JavaCallArguments java_args(number_of_parameters); | 1330 JavaCallArguments java_args(number_of_parameters); |
1333 args->set_java_argument_object(&java_args); | 1331 args->set_java_argument_object(&java_args); |
1334 | 1332 |
1335 assert(method->is_static(), "method should be static"); | 1333 assert(method->is_static(), "method should be static"); |
1336 | 1334 |
1337 // Fill out JavaCallArguments object | 1335 // Fill out JavaCallArguments object |
1338 args->iterate( Fingerprinter(method).fingerprint() ); | 1336 args->iterate( Fingerprinter(method).fingerprint() ); |
1339 // Initialize result type (must be done after args->iterate()) | 1337 // Initialize result type |
1340 result->set_type(args->get_ret_type()); | 1338 result->set_type(args->get_ret_type()); |
1341 | 1339 |
1340 // Invoke the method. Result is returned as oop. | |
1342 JavaCalls::call(result, method, &java_args, CHECK); | 1341 JavaCalls::call(result, method, &java_args, CHECK); |
1343 | 1342 |
1344 // Convert result | 1343 // Convert result |
1345 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { | 1344 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { |
1346 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); | 1345 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); |
1347 } | 1346 } |
1348 | |
1349 #ifdef HIGH_LEVEL_INTERPRETER | |
1350 if (invoked_main_method) { | |
1351 assert(THREAD->is_Java_thread(), "other threads must not call into java"); | |
1352 JavaThread* thread = (JavaThread*)THREAD; | |
1353 thread->set_high_level_interpreter_in_vm(false); | |
1354 } | |
1355 #endif | |
1356 } | 1347 } |
1357 | 1348 |
1358 | 1349 |
1359 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { | 1350 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { |
1360 oop recv = JNIHandles::resolve(receiver); | 1351 oop recv = JNIHandles::resolve(receiver); |
2652 // jni_GetField_probe() assumes that is okay to create handles. | 2643 // jni_GetField_probe() assumes that is okay to create handles. |
2653 if (JvmtiExport::should_post_field_access()) { | 2644 if (JvmtiExport::should_post_field_access()) { |
2654 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); | 2645 o = JvmtiExport::jni_GetField_probe(thread, obj, o, k, fieldID, false); |
2655 } | 2646 } |
2656 jobject ret = JNIHandles::make_local(env, o->obj_field(offset)); | 2647 jobject ret = JNIHandles::make_local(env, o->obj_field(offset)); |
2657 #ifndef SERIALGC | 2648 #if INCLUDE_ALL_GCS |
2658 // If G1 is enabled and we are accessing the value of the referent | 2649 // If G1 is enabled and we are accessing the value of the referent |
2659 // field in a reference object then we need to register a non-null | 2650 // field in a reference object then we need to register a non-null |
2660 // referent with the SATB barrier. | 2651 // referent with the SATB barrier. |
2661 if (UseG1GC) { | 2652 if (UseG1GC) { |
2662 bool needs_barrier = false; | 2653 bool needs_barrier = false; |
2671 if (needs_barrier) { | 2662 if (needs_barrier) { |
2672 oop referent = JNIHandles::resolve(ret); | 2663 oop referent = JNIHandles::resolve(ret); |
2673 G1SATBCardTableModRefBS::enqueue(referent); | 2664 G1SATBCardTableModRefBS::enqueue(referent); |
2674 } | 2665 } |
2675 } | 2666 } |
2676 #endif // SERIALGC | 2667 #endif // INCLUDE_ALL_GCS |
2677 #ifndef USDT2 | 2668 #ifndef USDT2 |
2678 DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); | 2669 DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); |
2679 #else /* USDT2 */ | 2670 #else /* USDT2 */ |
2680 HOTSPOT_JNI_GETOBJECTFIELD_RETURN( | 2671 HOTSPOT_JNI_GETOBJECTFIELD_RETURN( |
2681 ret); | 2672 ret); |