comparison src/share/vm/prims/jni.cpp @ 5747:120820e30baa

added basic high-level interpreter support to HotSpot
author Christian Haeubl <haeubl@ssw.jku.at>
date Tue, 03 Jul 2012 16:56:40 +0200
parents 33df1aeaebbf
children 957c266d8bc5
comparison
equal deleted inserted replaced
5746:17d2c3b72762 5747:120820e30baa
29 #include "classfile/systemDictionary.hpp" 29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/vmSymbols.hpp" 30 #include "classfile/vmSymbols.hpp"
31 #include "interpreter/linkResolver.hpp" 31 #include "interpreter/linkResolver.hpp"
32 #ifdef GRAAL 32 #ifdef GRAAL
33 #include "graal/graalCompiler.hpp" 33 #include "graal/graalCompiler.hpp"
34 #endif
35 #ifdef HIGH_LEVEL_INTERPRETER
36 #include "graal/graalVMToInterpreter.hpp"
34 #endif 37 #endif
35 #ifndef SERIALGC 38 #ifndef SERIALGC
36 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" 39 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
37 #endif // SERIALGC 40 #endif // SERIALGC
38 #include "memory/allocation.inline.hpp" 41 #include "memory/allocation.inline.hpp"
1315 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); 1318 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle()));
1316 return info.selected_method(); 1319 return info.selected_method();
1317 } 1320 }
1318 1321
1319 1322
1323 static bool first_time_InvokeMain = true;
1320 1324
1321 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { 1325 static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) {
1322 methodHandle method(THREAD, JNIHandles::resolve_jmethod_id(method_id)); 1326 methodHandle method(THREAD, JNIHandles::resolve_jmethod_id(method_id));
1323 1327
1324 // Create object to hold arguments for the JavaCall, and associate it with 1328 // Create object to hold arguments for the JavaCall, and associate it with
1325 // the jni parser 1329 // the jni parser
1326 ResourceMark rm(THREAD); 1330 ResourceMark rm(THREAD);
1327 int number_of_parameters = method->size_of_parameters(); 1331 int number_of_parameters = method->size_of_parameters();
1332
1333 // Invoke the method. Result is returned as oop.
1328 JavaCallArguments java_args(number_of_parameters); 1334 JavaCallArguments java_args(number_of_parameters);
1329 args->set_java_argument_object(&java_args); 1335 args->set_java_argument_object(&java_args);
1330 1336
1331 assert(method->is_static(), "method should be static"); 1337 assert(method->is_static(), "method should be static");
1332 1338
1333 // Fill out JavaCallArguments object 1339 // Fill out JavaCallArguments object
1334 args->iterate( Fingerprinter(method).fingerprint() ); 1340 args->iterate( Fingerprinter(method).fingerprint() );
1335 // Initialize result type 1341 // Initialize result type (must be done after args->iterate())
1336 result->set_type(args->get_ret_type()); 1342 result->set_type(args->get_ret_type());
1337 1343
1338 // Invoke the method. Result is returned as oop. 1344 #ifdef HIGH_LEVEL_INTERPRETER
1345 // TODO (chaeubl): this is quite a hack. The launcher should take care about that instead.
1346 bool invoked_main_method = false;
1347 if (HighLevelInterpreterClass != NULL && first_time_InvokeMain && method->name() == vmSymbols::main_name() && method->result_type() == T_VOID) {
1348 assert(THREAD->is_Java_thread(), "other threads must not call into java");
1349 JavaThread* thread = (JavaThread*)THREAD;
1350 first_time_InvokeMain = false;
1351 invoked_main_method = true;
1352 thread->set_high_level_interpreter_in_vm(true);
1353 }
1354 #endif
1355
1339 JavaCalls::call(result, method, &java_args, CHECK); 1356 JavaCalls::call(result, method, &java_args, CHECK);
1340 1357
1341 // Convert result 1358 // Convert result
1342 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) { 1359 if (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY) {
1343 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject())); 1360 result->set_jobject(JNIHandles::make_local(env, (oop) result->get_jobject()));
1344 } 1361 }
1362
1363 #ifdef HIGH_LEVEL_INTERPRETER
1364 if (invoked_main_method) {
1365 assert(THREAD->is_Java_thread(), "other threads must not call into java");
1366 JavaThread* thread = (JavaThread*)THREAD;
1367 thread->set_high_level_interpreter_in_vm(false);
1368 }
1369 #endif
1345 } 1370 }
1346 1371
1347 1372
1348 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { 1373 static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) {
1349 oop recv = JNIHandles::resolve(receiver); 1374 oop recv = JNIHandles::resolve(receiver);
5142 GraalCompiler* compiler = GraalCompiler::instance(); 5167 GraalCompiler* compiler = GraalCompiler::instance();
5143 ciObjectFactory::initialize(); 5168 ciObjectFactory::initialize();
5144 compiler->initialize(); 5169 compiler->initialize();
5145 #endif 5170 #endif
5146 5171
5172 #ifdef HIGH_LEVEL_INTERPRETER
5173 if (HighLevelInterpreterClass != NULL) {
5174 bool result = VMToInterpreter::allocate_interpreter(HighLevelInterpreterClass, HighLevelInterpreterArguments, thread);
5175 if (!result) {
5176 vm_abort(false);
5177 return JNI_ERR;
5178 }
5179 }
5180 #endif
5181
5147 // Tracks the time application was running before GC 5182 // Tracks the time application was running before GC
5148 RuntimeService::record_application_start(); 5183 RuntimeService::record_application_start();
5149 5184
5150 // Notify JVMTI 5185 // Notify JVMTI
5151 if (JvmtiExport::should_post_thread_life()) { 5186 if (JvmtiExport::should_post_thread_life()) {