# HG changeset patch # User Thomas Wuerthinger # Date 1321391162 -3600 # Node ID c7d4198a9bce04a7cdf08d8de5673c6093828f51 # Parent cb1181db8bec0551cc4130d0f56d5d1e73633449 Use GraalEnv for installing code. diff -r cb1181db8bec -r c7d4198a9bce src/share/vm/ci/ciEnv.cpp --- a/src/share/vm/ci/ciEnv.cpp Tue Nov 15 21:15:26 2011 +0100 +++ b/src/share/vm/ci/ciEnv.cpp Tue Nov 15 22:06:02 2011 +0100 @@ -204,7 +204,7 @@ _factory->cleanup(); JavaThread* current_thread = JavaThread::current(); _factory->remove_symbols(); - current_thread->set_env(NULL); + //current_thread->set_env(NULL); } // ------------------------------------------------------------------ diff -r cb1181db8bec -r c7d4198a9bce src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Tue Nov 15 21:15:26 2011 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Tue Nov 15 22:06:02 2011 +0100 @@ -27,6 +27,7 @@ #include "graal/graalJavaAccess.hpp" #include "graal/graalVMEntries.hpp" #include "graal/graalVmIds.hpp" +#include "graal/graalEnv.hpp" #include "c1/c1_Runtime1.hpp" #include "classfile/vmSymbols.hpp" #include "vmreg_x86.inline.hpp" @@ -232,10 +233,9 @@ // constructor used to create a method CodeInstaller::CodeInstaller(Handle target_method, nmethod*& nm, bool install_code) { _env = CURRENT_ENV; - ciMethod *ciMethodObject = NULL; + methodOop method = NULL; { - methodOop method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method)); - ciMethodObject = (ciMethod *) _env->get_object(method); + method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method)); _parameter_count = method->size_of_parameters(); No_Safepoint_Verifier no_safepoint; @@ -255,8 +255,8 @@ int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer ThreadToNativeFromVM t((JavaThread*) Thread::current()); - nm = _env->register_method(ciMethodObject, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, - &_implicit_exception_table, GraalCompiler::instance(), _env->comp_level(), false, false, install_code); + nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, + &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, false, false, install_code); } // constructor used to create a stub diff -r cb1181db8bec -r c7d4198a9bce src/share/vm/graal/graalEnv.cpp --- a/src/share/vm/graal/graalEnv.cpp Tue Nov 15 21:15:26 2011 +0100 +++ b/src/share/vm/graal/graalEnv.cpp Tue Nov 15 22:06:02 2011 +0100 @@ -73,7 +73,6 @@ constantPoolHandle cpool, Symbol* sym, bool require_local) { - ASSERT_IN_VM; EXCEPTION_CONTEXT; // Now we need to check the SystemDictionary @@ -243,7 +242,7 @@ int index) { EXCEPTION_CONTEXT; - assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool"); + assert(klass->is_linked(), "must be linked before using its constan-pool"); constantPoolHandle cpool(thread, klass->constants()); @@ -416,24 +415,14 @@ //DEBUG_ONLY(test_deps = true); //if (!test_deps) return; - bool print_failures = false; - DEBUG_ONLY(print_failures = !counter_changed); - - bool keep_going = (print_failures || xtty != NULL); - - int violated = 0; - for (Dependencies::DepStream deps(dependencies); deps.next(); ) { klassOop witness = deps.check_dependency(); if (witness != NULL) { - ++violated; - if (print_failures) deps.print_dependency(witness, /*verbose=*/ true); - // If there's no log and we're not sanity-checking, we're done. - if (!keep_going) break; + return false; } } - return violated == 0; + return true; } // ------------------------------------------------------------------ diff -r cb1181db8bec -r c7d4198a9bce src/share/vm/graal/graalVMEntries.cpp --- a/src/share/vm/graal/graalVMEntries.cpp Tue Nov 15 21:15:26 2011 +0100 +++ b/src/share/vm/graal/graalVMEntries.cpp Tue Nov 15 22:06:02 2011 +0100 @@ -973,15 +973,13 @@ JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod, jboolean install_code) { VM_ENTRY_MARK; nmethod* nm = NULL; - if (CURRENT_ENV == NULL) { - Arena arena; - ciEnv env(&arena); - ResourceMark rm; - CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0); - } else { - ResourceMark rm; - CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0); - } + ciEnv* current_env = JavaThread::current()->env(); + JavaThread::current()->set_env(NULL); + Arena arena; + ciEnv env(&arena); + ResourceMark rm; + CodeInstaller installer(JNIHandles::resolve(targetMethod), nm, install_code != 0); + JavaThread::current()->set_env(current_env); return (jlong) nm; } @@ -989,15 +987,13 @@ JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installStub(JNIEnv *jniEnv, jobject, jobject targetMethod) { VM_ENTRY_MARK; jlong id; - if (CURRENT_ENV == NULL) { - Arena arena; - ciEnv env(&arena); - ResourceMark rm; - CodeInstaller installer(JNIHandles::resolve(targetMethod), id); - } else { - ResourceMark rm; - CodeInstaller installer(JNIHandles::resolve(targetMethod), id); - } + ciEnv* current_env = JavaThread::current()->env(); + JavaThread::current()->set_env(NULL); + Arena arena; + ciEnv env(&arena); + ResourceMark rm; + CodeInstaller installer(JNIHandles::resolve(targetMethod), id); + JavaThread::current()->set_env(current_env); return id; } diff -r cb1181db8bec -r c7d4198a9bce src/share/vm/graal/graalVMExits.cpp --- a/src/share/vm/graal/graalVMExits.cpp Tue Nov 15 21:15:26 2011 +0100 +++ b/src/share/vm/graal/graalVMExits.cpp Tue Nov 15 22:06:02 2011 +0100 @@ -272,14 +272,6 @@ oop VMExits::createCiConstantObject(Handle object, TRAPS) { JavaValue result(T_OBJECT); JavaCallArguments args; - /* - args.push_oop(instance()); - args.push_oop(object); - JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantObject_signature(), &args, THREAD); - check_pending_exception("Error while calling createCiConstantObject"); - */ - - KlassHandle klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_cri_ci_CiConstant(), SystemDictionary::java_system_loader(), NULL, Thread::current()); JavaCalls::call_static(&result, klass(), vmSymbols::forObject_name(), vmSymbols::createCiConstantObject_signature(), object, THREAD); check_pending_exception("Error while calling CiConstant.forObject");