# HG changeset patch # User Lukas Stadler # Date 1314777515 -7200 # Node ID b3f0f8a01ca2c8e5eee628d499f138c0aed87e58 # Parent bea0186223240fa8ed93061dd0e28917e977e7df remove some ci-dependencies diff -r bea018622324 -r b3f0f8a01ca2 hotspot/.cproject --- a/hotspot/.cproject Thu Aug 25 16:58:25 2011 +0200 +++ b/hotspot/.cproject Wed Aug 31 09:58:35 2011 +0200 @@ -37,6 +37,9 @@ + @@ -72,591 +75,590 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff -r bea018622324 -r b3f0f8a01ca2 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Thu Aug 25 16:58:25 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Wed Aug 31 09:58:35 2011 +0200 @@ -127,18 +127,24 @@ TRACE_graal_1("GraalCompiler::print_timers"); } -oop GraalCompiler::get_RiType(ciType *type, KlassHandle accessor, TRAPS) { - if (type->is_loaded()) { - if (type->is_primitive_type()) { - return VMExits::createRiTypePrimitive((int) type->basic_type(), THREAD); +oop GraalCompiler::get_RiType(KlassHandle klass, KlassHandle accessor, TRAPS) { + assert(instanceKlass::cast(klass())->is_initialized(), "unexpected unresolved klass"); + Handle name = VmIds::toString(klass->name(), THREAD); + return createHotSpotTypeResolved(klass, name, CHECK_NULL); +} + + oop GraalCompiler::get_RiType(ciType *type, KlassHandle accessor, TRAPS) { + if (type->is_loaded()) { + if (type->is_primitive_type()) { + return VMExits::createRiTypePrimitive((int) type->basic_type(), THREAD); + } + KlassHandle klass = (klassOop) type->get_oop(); + Handle name = VmIds::toString(klass->name(), THREAD); + return createHotSpotTypeResolved(klass, name, CHECK_NULL); + } else { + Symbol* name = ((ciKlass *) type)->name()->get_symbol(); + return VMExits::createRiTypeUnresolved(VmIds::toString(name, THREAD), THREAD); } - KlassHandle klass = (klassOop) type->get_oop(); - Handle name = VmIds::toString(klass->name(), THREAD); - return createHotSpotTypeResolved(klass, name, CHECK_NULL); - } else { - Symbol* name = ((ciKlass *) type)->name()->get_symbol(); - return VMExits::createRiTypeUnresolved(VmIds::toString(name, THREAD), THREAD); - } } oop GraalCompiler::get_RiField(ciField *field, ciInstanceKlass* accessor_klass, KlassHandle accessor, Bytecodes::Code byteCode, TRAPS) { diff -r bea018622324 -r b3f0f8a01ca2 src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Thu Aug 25 16:58:25 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.hpp Wed Aug 31 09:58:35 2011 +0200 @@ -57,6 +57,7 @@ // Print compilation timers and statistics virtual void print_timers(); + static oop get_RiType(KlassHandle klass, KlassHandle accessor, TRAPS); static oop get_RiType(ciType *klass, KlassHandle accessor, TRAPS); static oop get_RiField(ciField *ciField, ciInstanceKlass* accessor_klass, KlassHandle accessor, Bytecodes::Code byteCode, TRAPS); diff -r bea018622324 -r b3f0f8a01ca2 src/share/vm/graal/graalVMEntries.cpp --- a/src/share/vm/graal/graalVMEntries.cpp Thu Aug 25 16:58:25 2011 +0200 +++ b/src/share/vm/graal/graalVMEntries.cpp Wed Aug 31 09:58:35 2011 +0200 @@ -214,64 +214,100 @@ // public native int RiMethod_exceptionProbability(long vmId, int bci); JNIEXPORT jint JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2exceptionProbability(JNIEnv *, jobject, jobject hotspot_method, jint bci) { TRACE_graal_3("VMEntries::RiMethod_exceptionProbability"); - ciMethod* cimethod; { VM_ENTRY_MARK; methodOop method = getMethodFromHotSpotMethod(hotspot_method); - cimethod = (ciMethod*)CURRENT_ENV->get_object(method); + methodDataOop method_data = method->method_data(); + if (method_data == NULL || !method_data->is_mature()) { + return -1; + } + ProfileData* data = method_data->bci_to_data(bci); + if (data == NULL) { + return 0; + } + uint trap = Deoptimization::trap_state_is_recompiled(data->trap_state())? 1: 0; + if (trap > 0) { + return 100; + } else { + return trap; + } } - ciMethodData* method_data = cimethod->method_data(); - - if (method_data == NULL || !method_data->is_mature()) return -1; +} - ciProfileData* profile = method_data->bci_to_data(bci); - if (profile == NULL) { - return 0; +// ------------------------------------------------------------------ +// Adjust a CounterData count to be commensurate with +// interpreter_invocation_count. If the MDO exists for +// only 25% of the time the method exists, then the +// counts in the MDO should be scaled by 4X, so that +// they can be usefully and stably compared against the +// invocation counts in methods. +int scale_count(methodDataOop method_data, int count) { + if (count > 0) { + int method_life = method_data->method()->invocation_count(); + int counter_life = method_life - method_data->creation_mileage(); + + if (method_life > 0 && counter_life > 0 && method_life > counter_life) { + double factor = method_life / (double) counter_life; + count = (int)(count * factor); + count = (count > 0) ? count : 1; + } } - uint trap = method_data->trap_recompiled_at(profile); - if (trap > 0) { - return 100; - } else { - return trap; - } + return count; } // public native RiTypeProfile RiMethod_typeProfile(long vmId, int bci); JNIEXPORT jobject JNICALL Java_com_oracle_graal_runtime_VMEntries_RiMethod_2typeProfile(JNIEnv *, jobject, jobject hotspot_method, jint bci) { TRACE_graal_3("VMEntries::RiMethod_typeProfile"); - ciMethod* cimethod; - { - VM_ENTRY_MARK; - methodOop method = getMethodFromHotSpotMethod(hotspot_method); - cimethod = (ciMethod*)CURRENT_ENV->get_object(method); - } - - ciCallProfile profile = cimethod->call_profile_at_bci(bci); - Handle obj; { + /* VM_ENTRY_MARK; - instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL); - obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL); - assert(obj() != NULL, "must succeed in allocating instance"); - - RiTypeProfile::set_count(obj, cimethod->scale_count(profile.count(), 1)); - RiTypeProfile::set_morphism(obj, profile.morphism()); + methodHandle method = getMethodFromHotSpotMethod(hotspot_method); + methodDataHandle method_data = method->method_data(); + if (method_data == NULL || !method_data->is_mature()) { + return NULL; + } + ProfileData* data = method_data->bci_to_data(bci); + if (data != NULL && data->is_ReceiverTypeData()) { + ReceiverTypeData* recv = data->as_ReceiverTypeData(); + // determine morphism + int morphism = 0; + int total_count = 0; + for (uint i = 0; i < recv->row_limit(); i++) { + klassOop receiver = recv->receiver(i); + if (receiver == NULL) continue; + morphism++; + total_count += recv->receiver_count(i); + } - typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, profile.limit(), CHECK_NULL); - objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), profile.limit(), CHECK_NULL); - for (int i=0; i 0) { + instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL); + obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL); + assert(obj() != NULL, "must succeed in allocating instance"); + + RiTypeProfile::set_count(obj, scale_count(method_data(), recv->count())); + RiTypeProfile::set_morphism(obj, morphism); - probabilities->float_at_put(i, prob); - types->obj_at_put(i, type); - } + typeArrayHandle probabilities = oopFactory::new_typeArray(T_FLOAT, morphism, CHECK_NULL); + objArrayHandle types = oopFactory::new_objArray(SystemDictionary::RiType_klass(), morphism, CHECK_NULL); + int pos = 0; + for (uint i = 0; i < recv->row_limit(); i++) { + KlassHandle receiver = recv->receiver(i); + if (receiver.is_null()) continue; + + float prob = recv->receiver_count(i) / (float) total_count; + oop type = GraalCompiler::get_RiType(receiver, KlassHandle(), CHECK_NULL); - RiTypeProfile::set_probabilities(obj, probabilities()); - RiTypeProfile::set_types(obj, types()); + probabilities->float_at_put(pos, prob); + types->obj_at_put(pos, type); + pos++; + } + + RiTypeProfile::set_probabilities(obj, probabilities()); + RiTypeProfile::set_types(obj, types()); + } + }*/ } return JNIHandles::make_local(obj());