# HG changeset patch # User Thomas Wuerthinger # Date 1321629821 -3600 # Node ID 415aa4a73b959aacccd81bc131afd5275cb8ad49 # Parent f198b24093f35fe2efdeb4a9ffa540b2d12150d5# Parent bb3337727ab6145c32b31baa8e0788a77e0c98e1 Merge. diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciEnv.cpp --- a/src/share/vm/ci/ciEnv.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciEnv.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -201,10 +201,8 @@ } ciEnv::~ciEnv() { - _factory->cleanup(); - JavaThread* current_thread = JavaThread::current(); _factory->remove_symbols(); - //current_thread->set_env(NULL); + JavaThread::current()->set_env(NULL); } // ------------------------------------------------------------------ diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciInstanceKlass.cpp --- a/src/share/vm/ci/ciInstanceKlass.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciInstanceKlass.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -64,7 +64,7 @@ } Thread *thread = Thread::current(); - if (ciObjectFactory::is_initialized() && !UseGraal) { + if (ciObjectFactory::is_initialized()) { _loader = JNIHandles::make_local(thread, ik->class_loader()); _protection_domain = JNIHandles::make_local(thread, ik->protection_domain()); _is_shared = false; diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciInstanceKlass.hpp --- a/src/share/vm/ci/ciInstanceKlass.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciInstanceKlass.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -71,19 +71,6 @@ GrowableArray* _non_static_fields; -public: - virtual void cleanup() { - ciObject::cleanup(); - if (!_is_shared) { - if (JNIHandles::is_global_handle(_loader)) { - JNIHandles::destroy_global(_loader); - } - if (JNIHandles::is_global_handle(_protection_domain)) { - JNIHandles::destroy_global(_protection_domain); - } - } - } - protected: ciInstanceKlass(KlassHandle h_k); ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain); diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciObject.cpp --- a/src/share/vm/ci/ciObject.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciObject.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -52,19 +52,13 @@ ciObject::ciObject(oop o) { ASSERT_IN_VM; if (ciObjectFactory::is_initialized()) { - if (UseGraal) { - _handle = JNIHandles::make_global(o); - _temp_global = true; - } else { - _handle = JNIHandles::make_local(o); - } + _handle = JNIHandles::make_local(o); } else { _handle = JNIHandles::make_global(o); } _klass = NULL; _ident = 0; init_flags_from(o); - _temp_global = false; } // ------------------------------------------------------------------ @@ -80,7 +74,6 @@ _klass = NULL; _ident = 0; init_flags_from(h()); - _temp_global = false; } // ------------------------------------------------------------------ @@ -94,7 +87,6 @@ _handle = NULL; _klass = klass; _ident = 0; - _temp_global = false; } // ------------------------------------------------------------------ @@ -106,7 +98,6 @@ _handle = NULL; _klass = NULL; _ident = 0; - _temp_global = false; } // ------------------------------------------------------------------ diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciObject.hpp --- a/src/share/vm/ci/ciObject.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciObject.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -58,7 +58,6 @@ jobject _handle; ciKlass* _klass; uint _ident; - bool _temp_global; enum { FLAG_BITS = 2 }; enum { @@ -72,11 +71,6 @@ ciObject(ciKlass* klass); public: - virtual void cleanup() { - if (_temp_global && _handle != NULL && JNIHandles::is_global_handle(_handle)) { - JNIHandles::destroy_global(_handle); - } - } jobject handle() const { return _handle; } // Get the VM oop that this object holds. oop get_oop() const { diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciObjectFactory.cpp --- a/src/share/vm/ci/ciObjectFactory.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciObjectFactory.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -88,9 +88,9 @@ // If the shared ci objects exist append them to this factory's objects - if (_shared_ci_objects != NULL) { + /*if (_shared_ci_objects != NULL) { _ci_objects->appendAll(_shared_ci_objects); - } + }*/ _unloaded_methods = new (arena) GrowableArray(arena, 4, 0, NULL); _unloaded_klasses = new (arena) GrowableArray(arena, 8, 0, NULL); @@ -101,14 +101,6 @@ _symbols = new (arena) GrowableArray(arena, 100, 0, NULL); } -void ciObjectFactory::cleanup() { - int start = 0; - if (_shared_ci_objects != NULL) start = _shared_ci_objects->length(); - for (int i = start; i < _ci_objects->length(); ++i) { - _ci_objects->at(i)->cleanup(); - } -} - // ------------------------------------------------------------------ // ciObjectFactory::ciObjectFactory void ciObjectFactory::initialize() { @@ -227,15 +219,15 @@ ciSymbol* ciObjectFactory::get_symbol(Symbol* key) { - vmSymbols::SID sid = vmSymbols::find_sid(key); + /*vmSymbols::SID sid = vmSymbols::find_sid(key); if (sid != vmSymbols::NO_SID) { // do not pollute the main cache with it ciSymbol* result = vm_symbol_at(sid); assert(result != NULL, ""); return result; - } + }*/ - assert(vmSymbols::find_sid(key) == vmSymbols::NO_SID, ""); + //assert(vmSymbols::find_sid(key) == vmSymbols::NO_SID, ""); ciSymbol* s = new (arena()) ciSymbol(key, vmSymbols::NO_SID); _symbols->push(s); return s; diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciObjectFactory.hpp --- a/src/share/vm/ci/ciObjectFactory.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciObjectFactory.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -94,8 +94,6 @@ ciObjectFactory(Arena* arena, int expected_size); - void cleanup(); - // Get the ciObject corresponding to some oop. ciObject* get(oop key); diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/ci/ciSymbol.hpp --- a/src/share/vm/ci/ciSymbol.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/ci/ciSymbol.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -48,7 +48,7 @@ private: const vmSymbols::SID _sid; - DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbol()) == _sid; } ) + DEBUG_ONLY( bool sid_ok() { return true;/*vmSymbols::find_sid(get_symbol()) == _sid;*/ } ) ciSymbol(Symbol* s); // normal case, for symbols not mentioned in vmSymbols ciSymbol(Symbol* s, vmSymbols::SID sid); // for use with vmSymbols diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -177,7 +177,7 @@ if (obj == NULL) { return new ConstantOopWriteValue(NULL); } else { - return new ConstantOopWriteValue(JNIHandles::make_global(obj)); + return new ConstantOopWriteValue(JNIHandles::make_local(obj)); } } else if (type == T_ADDRESS) { return new ConstantLongValue(prim); @@ -186,8 +186,7 @@ } else if (value->is_a(CiVirtualObject::klass())) { oop type = CiVirtualObject::type(value); int id = CiVirtualObject::id(value); - ciKlass* klass = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type))); - assert(klass->is_instance_klass() || klass->is_array_klass(), "Not supported allocation."); + instanceKlass* klass = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type))); for (jint i = 0; i < objects->length(); i++) { ObjectValue* obj = (ObjectValue*) objects->at(i); @@ -196,7 +195,7 @@ } } - ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(klass->constant_encoding())); + ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), klass->as_klassOop()))); arrayOop values = (arrayOop) CiVirtualObject::values(value); for (jint i = 0; i < values->length(); i++) { @@ -230,26 +229,23 @@ return NULL; } -// constructor used to create a method -CodeInstaller::CodeInstaller(Handle target_method, nmethod*& nm, bool install_code) { - _env = CURRENT_ENV; - GraalCompiler::initialize_buffer_blob(); - CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); - +void CodeInstaller::initialize_assumptions(oop target_method) { _oop_recorder = new OopRecorder(_env->arena()); _env->set_oop_recorder(_oop_recorder); _env->set_dependencies(_dependencies); _dependencies = new Dependencies(_env); Handle assumptions_handle = CiTargetMethod::assumptions(HotSpotTargetMethod::targetMethod(target_method)); if (!assumptions_handle.is_null()) { - objArrayHandle assumptions = (objArrayOop)CiAssumptions::list(assumptions_handle()); - for (int i = 0; i < assumptions->length(); ++i) { - Handle assumption = assumptions->obj_at(i); - if (!assumption.is_null()) { - if (assumption->is_a(CiAssumptions_ConcreteSubtype::klass())) { - assumption_ConcreteSubtype(assumption); - } else if (assumption->is_a(CiAssumptions_ConcreteMethod::klass())) { - assumption_ConcreteMethod(assumption); + objArrayHandle assumptions(Thread::current(), (objArrayOop)CiAssumptions::list(assumptions_handle())); + int length = assumptions->length(); + jobject assumptions_handle = JNIHandles::make_local(assumptions()); + for (int i = 0; i < length; ++i) { + oop assumption = assumptions->obj_at(i); + if (assumption != NULL) { + if (assumption->klass() == CiAssumptions_ConcreteSubtype::klass()) { + assumption_ConcreteSubtype(JNIHandles::make_local(assumption)); + } else if (assumption->klass() == CiAssumptions_ConcreteMethod::klass()) { + assumption_ConcreteMethod(JNIHandles::make_local(assumption)); } else { assumption->print(); fatal("unexpected Assumption subclass"); @@ -257,16 +253,25 @@ } } } +} + +// constructor used to create a method +CodeInstaller::CodeInstaller(Handle& target_method, nmethod*& nm, bool install_code) { + _env = CURRENT_ENV; + GraalCompiler::initialize_buffer_blob(); + CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); + jobject target_method_obj = JNIHandles::make_local(target_method()); + initialize_assumptions(JNIHandles::resolve(target_method_obj)); { No_Safepoint_Verifier no_safepoint; - initialize_fields(target_method); + initialize_fields(JNIHandles::resolve(target_method_obj)); initialize_buffer(buffer); process_exception_handlers(); } int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer - methodHandle method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method)); + methodHandle method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(JNIHandles::resolve(target_method_obj))); { 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); @@ -275,13 +280,13 @@ } // constructor used to create a stub -CodeInstaller::CodeInstaller(Handle target_method, jlong& id) { +CodeInstaller::CodeInstaller(Handle& target_method, jlong& id) { No_Safepoint_Verifier no_safepoint; _env = CURRENT_ENV; _oop_recorder = new OopRecorder(_env->arena()); _env->set_oop_recorder(_oop_recorder); - initialize_fields(target_method); + initialize_fields(target_method()); assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); // (very) conservative estimate: each site needs a relocation @@ -295,7 +300,7 @@ id = VmIds::addStub(blob->code_begin()); } -void CodeInstaller::initialize_fields(Handle target_method) { +void CodeInstaller::initialize_fields(oop target_method) { _citarget_method = HotSpotTargetMethod::targetMethod(target_method); _hotspot_method = HotSpotTargetMethod::method(target_method); if (_hotspot_method != NULL) { @@ -362,30 +367,46 @@ } } -void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) { - Handle context_handle = CiAssumptions_ConcreteSubtype::context(assumption); - Handle type_handle = CiAssumptions_ConcreteSubtype::subtype(assumption); +void CodeInstaller::assumption_ConcreteSubtype(jobject assumption) { + Handle context_handle = CiAssumptions_ConcreteSubtype::context(JNIHandles::resolve(assumption)); + ciKlass* context = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(context_handle))); - ciKlass* context = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(context_handle))); + Handle type_handle = CiAssumptions_ConcreteSubtype::subtype(JNIHandles::resolve(assumption)); ciKlass* type = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type_handle))); _dependencies->assert_leaf_type(type); - if (context != type) { + if (context != type) { + // Once you removed the transition to native here + // and have realized what a terrible mistake that was, + // please increment the following counter as a warning + // to the next guy: + // + // total_hours_wasted_here = 8 + ThreadToNativeFromVM trans(JavaThread::current()); assert(context->is_abstract(), ""); _dependencies->assert_abstract_with_unique_concrete_subtype(context, type); } } -void CodeInstaller::assumption_ConcreteMethod(Handle assumption) { - Handle context_handle = CiAssumptions_ConcreteMethod::context(assumption); - Handle method_handle = CiAssumptions_ConcreteMethod::method(assumption); +void CodeInstaller::assumption_ConcreteMethod(jobject assumption) { + Handle method_handle = CiAssumptions_ConcreteMethod::method(JNIHandles::resolve(assumption)); methodHandle method = getMethodFromHotSpotMethod(method_handle()); + ciMethod* m = (ciMethod*) CURRENT_ENV->get_object(method()); + + Handle context_handle = CiAssumptions_ConcreteMethod::context(JNIHandles::resolve(assumption)); methodHandle context = getMethodFromHotSpotMethod(context_handle()); - - ciMethod* m = (ciMethod*) CURRENT_ENV->get_object(method()); ciMethod* c = (ciMethod*) CURRENT_ENV->get_object(context()); ciKlass* context_klass = c->holder(); - _dependencies->assert_unique_concrete_method(context_klass, m); + { + // Once you removed the transition to native here + // and have realized what a terrible mistake that was, + // please increment the following counter as a warning + // to the next guy: + // + // total_hours_wasted_here = 8 + ThreadToNativeFromVM trans(JavaThread::current()); + _dependencies->assert_unique_concrete_method(context_klass, m); + } } void CodeInstaller::process_exception_handlers() { diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/graal/graalCodeInstaller.hpp --- a/src/share/vm/graal/graalCodeInstaller.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -82,22 +82,23 @@ public: // constructor used to create a method - CodeInstaller(Handle target_method, nmethod*& nm, bool install_code); + CodeInstaller(Handle& target_method, nmethod*& nm, bool install_code); // constructor used to create a stub - CodeInstaller(Handle target_method, jlong& id); + CodeInstaller(Handle& target_method, jlong& id); static address runtime_call_target_address(oop runtime_call); private: // extract the fields of the CiTargetMethod - void initialize_fields(Handle target_method); + void initialize_fields(oop target_method); + void initialize_assumptions(oop target_method); // perform data and call relocation on the CodeBuffer void initialize_buffer(CodeBuffer& buffer); - void assumption_ConcreteSubtype(Handle assumption); - void assumption_ConcreteMethod(Handle assumption); + void assumption_ConcreteSubtype(jobject assumption); + void assumption_ConcreteMethod(jobject assumption); void site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site); void site_Call(CodeBuffer& buffer, jint pc_offset, oop site); diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/graal/graalEnv.cpp --- a/src/share/vm/graal/graalEnv.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/graal/graalEnv.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -49,7 +49,7 @@ // // Note: the logic of this method should mirror the logic of // constantPoolOopDesc::verify_constant_pool_resolve. -bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { +bool GraalEnv::check_klass_accessibility(KlassHandle& accessing_klass, KlassHandle& resolved_klass) { if (accessing_klass->oop_is_objArray()) { accessing_klass = objArrayKlass::cast(accessing_klass())->bottom_klass(); } @@ -69,8 +69,8 @@ // ------------------------------------------------------------------ // ciEnv::get_klass_by_name_impl -KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle accessing_klass, - constantPoolHandle cpool, +KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle& accessing_klass, + constantPoolHandle& cpool, Symbol* sym, bool require_local) { EXCEPTION_CONTEXT; @@ -149,7 +149,7 @@ // ------------------------------------------------------------------ // ciEnv::get_klass_by_name -KlassHandle GraalEnv::get_klass_by_name(KlassHandle accessing_klass, +KlassHandle GraalEnv::get_klass_by_name(KlassHandle& accessing_klass, Symbol* klass_name, bool require_local) { ResourceMark rm; @@ -163,10 +163,10 @@ // ciEnv::get_klass_by_index_impl // // Implementation of get_klass_by_index. -KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle cpool, +KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool, int index, bool& is_accessible, - KlassHandle accessor) { + KlassHandle& accessor) { EXCEPTION_CONTEXT; KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); Symbol* klass_name = NULL; @@ -207,7 +207,7 @@ is_accessible = false; } else { // Linked locally, and we must also check public/private, etc. - is_accessible = check_klass_accessibility(accessor(), k()); + is_accessible = check_klass_accessibility(accessor, k); } return k; } @@ -221,10 +221,10 @@ // ciEnv::get_klass_by_index // // Get a klass from the constant pool. -KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle cpool, +KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle& cpool, int index, bool& is_accessible, - KlassHandle accessor) { + KlassHandle& accessor) { ResourceMark rm; return get_klass_by_index_impl(cpool, index, is_accessible, accessor); } @@ -236,7 +236,7 @@ // // Implementation note: the results of field lookups are cached // in the accessor klass. -void GraalEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescriptor& field_desc, +void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc, int index) { EXCEPTION_CONTEXT; @@ -282,7 +282,7 @@ // ciEnv::get_field_by_index // // Get a field by index from a klass's constant pool. -void GraalEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor& fd, +void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) { ResourceMark rm; return get_field_by_index_impl(accessor, fd, index); @@ -293,8 +293,8 @@ // // Perform an appropriate method lookup based on accessor, holder, // name, signature, and bytecode. -methodHandle GraalEnv::lookup_method(instanceKlassHandle h_accessor, - instanceKlassHandle h_holder, +methodHandle GraalEnv::lookup_method(instanceKlassHandle& h_accessor, + instanceKlassHandle& h_holder, Symbol* name, Symbol* sig, Bytecodes::Code bc) { @@ -329,9 +329,9 @@ // ------------------------------------------------------------------ // ciEnv::get_method_by_index_impl -methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle cpool, +methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle& cpool, int index, Bytecodes::Code bc, - instanceKlassHandle accessor) { + instanceKlassHandle& accessor) { int holder_index = cpool->klass_ref_index_at(index); bool holder_is_accessible; KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); @@ -364,7 +364,7 @@ // ------------------------------------------------------------------ // ciEnv::get_instance_klass_for_declared_method_holder -instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle method_holder) { +instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) { // For the case of .clone(), the method holder can be a ciArrayKlass // instead of a ciInstanceKlass. For that case simply pretend that the // declared holder is Object.clone since that's where the call will bottom out. @@ -386,9 +386,9 @@ // ------------------------------------------------------------------ // ciEnv::get_method_by_index -methodHandle GraalEnv::get_method_by_index(constantPoolHandle cpool, +methodHandle GraalEnv::get_method_by_index(constantPoolHandle& cpool, int index, Bytecodes::Code bc, - instanceKlassHandle accessor) { + instanceKlassHandle& accessor) { ResourceMark rm; assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported"); return get_method_by_index_impl(cpool, index, bc, accessor); diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/graal/graalEnv.hpp --- a/src/share/vm/graal/graalEnv.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/graal/graalEnv.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -58,42 +58,42 @@ // The CI treats a klass as loaded if it is consistently defined in // another loader, even if it hasn't yet been loaded in all loaders // that could potentially see it via delegation. - static KlassHandle get_klass_by_name(KlassHandle accessing_klass, + static KlassHandle get_klass_by_name(KlassHandle& accessing_klass, Symbol* klass_name, bool require_local); // Constant pool access. - static KlassHandle get_klass_by_index(constantPoolHandle cpool, + static KlassHandle get_klass_by_index(constantPoolHandle& cpool, int klass_index, bool& is_accessible, - KlassHandle loading_klass); - static void get_field_by_index(instanceKlassHandle loading_klass, fieldDescriptor& fd, + KlassHandle& loading_klass); + static void get_field_by_index(instanceKlassHandle& loading_klass, fieldDescriptor& fd, int field_index); - static methodHandle get_method_by_index(constantPoolHandle cpool, + static methodHandle get_method_by_index(constantPoolHandle& cpool, int method_index, Bytecodes::Code bc, - instanceKlassHandle loading_klass); + instanceKlassHandle& loading_klass); private: // Implementation methods for loading and constant pool access. - static KlassHandle get_klass_by_name_impl(KlassHandle accessing_klass, - constantPoolHandle cpool, + static KlassHandle get_klass_by_name_impl(KlassHandle& accessing_klass, + constantPoolHandle& cpool, Symbol* klass_name, bool require_local); - static KlassHandle get_klass_by_index_impl(constantPoolHandle cpool, + static KlassHandle get_klass_by_index_impl(constantPoolHandle& cpool, int klass_index, bool& is_accessible, - KlassHandle loading_klass); - static void get_field_by_index_impl(instanceKlassHandle loading_klass, fieldDescriptor& fd, + KlassHandle& loading_klass); + static void get_field_by_index_impl(instanceKlassHandle& loading_klass, fieldDescriptor& fd, int field_index); - static methodHandle get_method_by_index_impl(constantPoolHandle cpool, + static methodHandle get_method_by_index_impl(constantPoolHandle& cpool, int method_index, Bytecodes::Code bc, - instanceKlassHandle loading_klass); + instanceKlassHandle& loading_klass); // Helper methods - static bool check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klassOop); - static methodHandle lookup_method(instanceKlassHandle accessor, - instanceKlassHandle holder, + static bool check_klass_accessibility(KlassHandle& accessing_klass, KlassHandle& resolved_klassOop); + static methodHandle lookup_method(instanceKlassHandle& accessor, + instanceKlassHandle& holder, Symbol* name, Symbol* sig, Bytecodes::Code bc); @@ -135,7 +135,7 @@ // ciInstanceKlass*. This is needed since the holder of a method in // the bytecodes could be an array type. Basically this converts // array types into java/lang/Object and other types stay as they are. - static instanceKlassHandle get_instance_klass_for_declared_method_holder(KlassHandle klass); + static instanceKlassHandle get_instance_klass_for_declared_method_holder(KlassHandle& klass); }; #endif // SHARE_VM_GRAAL_GRAALENV_HPP diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/graal/graalVMEntries.cpp --- a/src/share/vm/graal/graalVMEntries.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/graal/graalVMEntries.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -467,9 +467,10 @@ VM_ENTRY_MARK; index = GraalCompiler::to_cp_index_u2(index); constantPoolHandle cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)))->constants(); + instanceKlassHandle pool_holder(cp->pool_holder()); Bytecodes::Code bc = (Bytecodes::Code) (((int) byteCode) & 0xFF); - methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, cp->pool_holder()); + methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, pool_holder); if (!method.is_null()) { Handle ret = GraalCompiler::createHotSpotMethodResolved(method, CHECK_NULL); return JNIHandles::make_local(THREAD, ret()); @@ -925,28 +926,26 @@ // public long installMethod(HotSpotTargetMethod targetMethod, boolean installCode); JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod, jboolean install_code) { VM_ENTRY_MARK; + ResourceMark rm; + HandleMark hm; + Handle targetMethodHandle = JNIHandles::resolve(targetMethod); nmethod* nm = NULL; - 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); + CodeInstaller installer(targetMethodHandle, nm, install_code != 0); return (jlong) nm; } // public HotSpotProxy installStub(HotSpotTargetMethod targetMethod, String name); JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installStub(JNIEnv *jniEnv, jobject, jobject targetMethod) { VM_ENTRY_MARK; + ResourceMark rm; + HandleMark hm; + Handle targetMethodHandle = JNIHandles::resolve(targetMethod); jlong 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); + CodeInstaller installer(targetMethodHandle, id); return id; } diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/oops/instanceKlass.cpp Fri Nov 18 16:23:41 2011 +0100 @@ -2280,7 +2280,7 @@ } // ----------------------------------------------------------------------------------------------------- -#ifndef PRODUCT + // Printing @@ -2350,7 +2350,7 @@ } } -#endif //PRODUCT + void instanceKlass::oop_print_value_on(oop obj, outputStream* st) { st->print("a "); diff -r bb3337727ab6 -r 415aa4a73b95 src/share/vm/oops/instanceKlass.hpp --- a/src/share/vm/oops/instanceKlass.hpp Fri Nov 18 16:00:09 2011 +0100 +++ b/src/share/vm/oops/instanceKlass.hpp Fri Nov 18 16:23:41 2011 +0100 @@ -98,7 +98,7 @@ virtual void do_field(fieldDescriptor* fd) = 0; }; -#ifndef PRODUCT +//#ifndef PRODUCT // Print fields. // If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields. class FieldPrinter: public FieldClosure { @@ -108,7 +108,7 @@ FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {} void do_field(fieldDescriptor* fd); }; -#endif // !PRODUCT +//#endif // !PRODUCT // ValueObjs embedded in klass. Describes where oops are located in instances of // this klass. @@ -832,12 +832,11 @@ public: // Printing void oop_print_value_on(oop obj, outputStream* st); -#ifndef PRODUCT + void oop_print_on (oop obj, outputStream* st); void print_dependent_nmethods(bool verbose = false); bool is_dependent_nmethod(nmethod* nm); -#endif // Verification const char* internal_name() const;