# HG changeset patch # User Thomas Wuerthinger # Date 1314980956 -7200 # Node ID da1b32a58d7e9af99714647840ab2d29a9a452ca # Parent 76a7f1732bb086ae029364abeb9e20b04da41e3b# Parent 409ef3a68dc837430777341b6476b9dd142c0a16 Merge. diff -r 76a7f1732bb0 -r da1b32a58d7e hotspot/.cproject --- a/hotspot/.cproject Fri Sep 02 18:28:45 2011 +0200 +++ b/hotspot/.cproject Fri Sep 02 18:29:16 2011 +0200 @@ -37,6 +37,9 @@ + @@ -72,591 +75,590 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff -r 76a7f1732bb0 -r da1b32a58d7e src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Fri Sep 02 18:29:16 2011 +0200 @@ -526,7 +526,8 @@ LocationValue* loc = (LocationValue*)value; int monitor_offset = loc->location().stack_offset(); LocationValue* obj = new LocationValue(Location::new_stk_loc(Location::oop, monitor_offset + BasicObjectLock::obj_offset_in_bytes())); - monitors->append(new MonitorValue(obj, Location::new_stk_loc(Location::normal, monitor_offset + BasicObjectLock::lock_offset_in_bytes()))); + bool eliminated = value->is_object(); + monitors->append(new MonitorValue(obj, Location::new_stk_loc(Location::normal, monitor_offset + BasicObjectLock::lock_offset_in_bytes()), eliminated)); } if (second != NULL) { i++; diff -r 76a7f1732bb0 -r da1b32a58d7e src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Fri Sep 02 18:29:16 2011 +0200 @@ -127,18 +127,30 @@ 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) { + if (klass->oop_is_instance_slow()) { + assert(instanceKlass::cast(klass())->is_initialized(), "unexpected unresolved klass"); + } else if (klass->oop_is_javaArray_slow()){ + } else { + klass()->print(); + assert(false, "unexpected 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 76a7f1732bb0 -r da1b32a58d7e src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/graal/graalCompiler.hpp Fri Sep 02 18:29:16 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 76a7f1732bb0 -r da1b32a58d7e src/share/vm/graal/graalVMEntries.cpp --- a/src/share/vm/graal/graalVMEntries.cpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/graal/graalVMEntries.cpp Fri Sep 02 18:29:16 2011 +0200 @@ -214,64 +214,114 @@ // 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 counter_life; + int method_life = method_data->method()->interpreter_invocation_count(); + int current_mileage = methodDataOopDesc::mileage_of(method_data->method()); + int creation_mileage = method_data->creation_mileage(); + counter_life = current_mileage - creation_mileage; + + // counter_life due to backedge_counter could be > method_life + if (counter_life > method_life) + counter_life = method_life; + if (0 < counter_life && counter_life <= method_life) { + count = (int)((double)count * method_life / counter_life + 0.5); + 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"); + methodHandle method = getMethodFromHotSpotMethod(hotspot_method); + if (strstr(method->name_and_sig_as_C_string(), "factor") != NULL) { +// tty->print_cr("here"); + } + if (bci == 123) { +// tty->print_cr("here2"); + } + 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; + uint 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); + } - RiTypeProfile::set_count(obj, cimethod->scale_count(profile.count(), 1)); - RiTypeProfile::set_morphism(obj, profile.morphism()); + instanceKlass::cast(RiTypeProfile::klass())->initialize(CHECK_NULL); + obj = instanceKlass::cast(RiTypeProfile::klass())->allocate_instance(CHECK_NULL); + assert(obj() != NULL, "must succeed in allocating instance"); - 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; icount()); + RiTypeProfile::set_count(obj, scale_count(method_data(), count)); + RiTypeProfile::set_morphism(obj, morphism); + + if (morphism > 0) { + 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; - probabilities->float_at_put(i, prob); - types->obj_at_put(i, type); - } + float prob = recv->receiver_count(i) / (float) total_count; + oop type = GraalCompiler::get_RiType(receiver, KlassHandle(), CHECK_NULL); + + probabilities->float_at_put(pos, prob); + types->obj_at_put(pos, type); - RiTypeProfile::set_probabilities(obj, probabilities()); - RiTypeProfile::set_types(obj, types()); + pos++; + } + RiTypeProfile::set_probabilities(obj, probabilities()); + RiTypeProfile::set_types(obj, types()); + } else { + RiTypeProfile::set_probabilities(obj, NULL); + RiTypeProfile::set_types(obj, NULL); + } + } } return JNIHandles::make_local(obj()); diff -r 76a7f1732bb0 -r da1b32a58d7e src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/runtime/arguments.cpp Fri Sep 02 18:29:16 2011 +0200 @@ -2018,7 +2018,7 @@ if (UseGraal) { if (PrintVMOptions) { - tty->print("Running Graal VM... "); + tty->print_cr("Running Graal VM... "); } const int BUFFER_SIZE = 1024; char maxine_dir[BUFFER_SIZE]; @@ -2026,7 +2026,7 @@ if (!os::getenv("MAXINE", maxine_dir, sizeof(maxine_dir))) { fatal("Must set MAXINE environment variable to a Maxine project directory."); } - if (PrintVMOptions) tty->print("MAXINE=%s", maxine_dir); + if (PrintVMOptions) tty->print_cr("MAXINE=%s", maxine_dir); SysClassPath scp_compiler(Arguments::get_sysclasspath()); sprintf(temp, "%s/com.oracle.max.cri/bin", maxine_dir); scp_compiler.add_prefix(temp); diff -r 76a7f1732bb0 -r da1b32a58d7e src/share/vm/runtime/compilationPolicy.cpp --- a/src/share/vm/runtime/compilationPolicy.cpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/runtime/compilationPolicy.cpp Fri Sep 02 18:29:16 2011 +0200 @@ -60,11 +60,11 @@ break; case 1: -#ifdef COMPILER2 +//#ifdef COMPILER2 CompilationPolicy::set_policy(new StackWalkCompPolicy()); -#else - Unimplemented(); -#endif +//#else +// Unimplemented(); +//#endif break; case 2: #ifdef TIERED @@ -422,7 +422,7 @@ } // StackWalkCompPolicy - walk up stack to find a suitable method to compile -#ifdef COMPILER2 +//#ifdef COMPILER2 const char* StackWalkCompPolicy::_msg = NULL; @@ -649,4 +649,4 @@ -#endif // COMPILER2 +//#endif // COMPILER2 diff -r 76a7f1732bb0 -r da1b32a58d7e src/share/vm/runtime/compilationPolicy.hpp --- a/src/share/vm/runtime/compilationPolicy.hpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/runtime/compilationPolicy.hpp Fri Sep 02 18:29:16 2011 +0200 @@ -114,7 +114,7 @@ // StackWalkCompPolicy - existing C2 policy -#ifdef COMPILER2 +//#ifdef COMPILER2 class StackWalkCompPolicy : public NonTieredCompPolicy { public: virtual void method_invocation_event(methodHandle m, TRAPS); @@ -134,6 +134,6 @@ // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg }; -#endif +//#endif #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP diff -r 76a7f1732bb0 -r da1b32a58d7e src/share/vm/runtime/rframe.cpp --- a/src/share/vm/runtime/rframe.cpp Fri Sep 02 18:28:45 2011 +0200 +++ b/src/share/vm/runtime/rframe.cpp Fri Sep 02 18:29:16 2011 +0200 @@ -152,11 +152,11 @@ void RFrame::print(const char* kind) { #ifndef PRODUCT -#ifdef COMPILER2 +//#ifdef COMPILER2 int cnt = top_method()->interpreter_invocation_count(); -#else - int cnt = top_method()->invocation_count(); -#endif +//#else +// int cnt = top_method()->invocation_count(); +//#endif tty->print("%3d %s ", _num, is_interpreted() ? "I" : "C"); top_method()->print_short_name(tty); tty->print_cr(": inv=%5d(%d) cst=%4d", _invocations, cnt, cost());