# HG changeset patch # User Tom Rodriguez # Date 1442517088 25200 # Node ID be44a5efeaffaaeb5668b190b268e46f7e4e7f6a # Parent c3b49e9d0f4827c4421d4fbb2eb4eed81c89f2ff HotSpotMethodData must handle profile data when TypeProfileLevel is non-zero diff -r c3b49e9d0f48 -r be44a5efeaff jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Thu Sep 17 12:10:17 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Thu Sep 17 12:11:28 2015 -0700 @@ -563,4 +563,12 @@ * @return null or the resolved method for this location */ native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed); + + /** + * @param metaspaceMethodData + * @param position + * @return Return the size of the ProfileData item pointed at by {@code current}. Throws + * {@link IllegalArgumentException} if an invalid position is given. + */ + native int methodDataProfileDataSize(long metaspaceMethodData, int position); } diff -r c3b49e9d0f48 -r be44a5efeaff jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java Thu Sep 17 12:10:17 2015 -0700 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMethodData.java Thu Sep 17 12:11:28 2015 -0700 @@ -61,10 +61,10 @@ new BranchData(), new MultiBranchData(), new ArgInfoData(), - null, // call_type_data_tag - null, // virtual_call_type_data_tag - null, // parameters_type_data_tag - null, // speculative_trap_data_tag + new UnknownProfileData(Tag.CallTypeData), + new VirtualCallTypeData(), + new UnknownProfileData(Tag.ParametersTypeData), + new UnknownProfileData(Tag.SpeculativeTrapData), }; // @formatter:on @@ -132,7 +132,8 @@ } HotSpotMethodDataAccessor result = getData(position); - assert result != null : "NO_DATA tag is not allowed"; + final Tag tag = AbstractMethodData.readTag(this, position); + assert result != null : "NO_DATA tag is not allowed " + tag; return result; } @@ -274,7 +275,7 @@ private static final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag; private final Tag tag; - private final int staticSize; + protected final int staticSize; protected AbstractMethodData(Tag tag, int staticSize) { this.tag = tag; @@ -296,8 +297,12 @@ } @Override - public int getSize(HotSpotMethodData data, int position) { - return staticSize + getDynamicSize(data, position); + public final int getSize(HotSpotMethodData data, int position) { + int size = staticSize + getDynamicSize(data, position); + // Sanity check against VM + int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); + assert size == vmSize : size + " != " + vmSize; + return size; } @Override @@ -609,6 +614,10 @@ super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); } + protected VirtualCallData(Tag tag, int staticSize) { + super(tag, staticSize); + } + @Override public int getExecutionCount(HotSpotMethodData data, int position) { final int typeProfileWidth = config.typeProfileWidth; @@ -701,6 +710,19 @@ } } + private static class VirtualCallTypeData extends VirtualCallData { + + public VirtualCallTypeData() { + super(Tag.VirtualCallTypeData, 0); + } + + @Override + protected int getDynamicSize(HotSpotMethodData data, int position) { + assert staticSize == 0; + return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); + } + } + private static class RetData extends CounterData { private static final int RET_DATA_ROW_SIZE = cellsToBytes(3); @@ -863,6 +885,24 @@ } } + private static class UnknownProfileData extends AbstractMethodData { + public UnknownProfileData(Tag tag) { + super(tag, 0); + } + + @Override + protected int getDynamicSize(HotSpotMethodData data, int position) { + assert staticSize == 0; + return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); + } + + @Override + public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { + // TODO Auto-generated method stub + return null; + } + } + public void setCompiledIRSize(int size) { UNSAFE.putInt(metaspaceMethodData + config.methodDataIRSizeOffset, size); } diff -r c3b49e9d0f48 -r be44a5efeaff src/cpu/x86/vm/globals_x86.hpp --- a/src/cpu/x86/vm/globals_x86.hpp Thu Sep 17 12:10:17 2015 -0700 +++ b/src/cpu/x86/vm/globals_x86.hpp Thu Sep 17 12:11:28 2015 -0700 @@ -80,8 +80,12 @@ // GC Ergo Flags define_pd_global(uintx, CMSYoungGenPerWorker, 64*M); // default max size of CMS young gen, per GC worker thread -// Disabled in JVMCI until HotSpotMethodData is updated to be aware of the new profiling tags -define_pd_global(uintx, TypeProfileLevel, JVMCI_ONLY(0) NOT_JVMCI(111)); +#ifdef COMPILER_JVMCI +// Don't bother enabling type profiling since JVMCI doesn't currently expose it +define_pd_global(uintx, TypeProfileLevel, 0); +#else +define_pd_global(uintx, TypeProfileLevel, 111); +#endif #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct) \ \ diff -r c3b49e9d0f48 -r be44a5efeaff src/share/vm/jvmci/jvmciCompilerToVM.cpp --- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Thu Sep 17 12:10:17 2015 -0700 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Thu Sep 17 12:11:28 2015 -0700 @@ -1122,6 +1122,26 @@ tty->flush(); C2V_END +C2V_VMENTRY(int, methodDataProfileDataSize, (JNIEnv*, jobject, jlong metaspace_method_data, jint position)) + ResourceMark rm; + MethodData* mdo = CompilerToVM::asMethodData(metaspace_method_data); + ProfileData* profile_data = mdo->data_at(position); + if (mdo->is_valid(profile_data)) { + return profile_data->size_in_bytes(); + } + DataLayout* data = mdo->extra_data_base(); + DataLayout* end = mdo->extra_data_limit(); + for (;; data = mdo->next_extra(data)) { + assert(data < end, "moved past end of extra data"); + profile_data = data->data_in(); + if (mdo->dp_to_di(profile_data->dp()) == position) { + return profile_data->size_in_bytes(); + } + } + mdo->print(); + THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Invalid profile data position %d", position)); +C2V_END + #define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) @@ -1200,6 +1220,7 @@ {CC"shouldDebugNonSafepoints", CC"()Z", FN_PTR(shouldDebugNonSafepoints)}, {CC"writeDebugOutput", CC"([BII)V", FN_PTR(writeDebugOutput)}, {CC"flushDebugOutput", CC"()V", FN_PTR(flushDebugOutput)}, + {CC"methodDataProfileDataSize", CC"(JI)I", FN_PTR(methodDataProfileDataSize)}, }; int CompilerToVM::methods_count() { diff -r c3b49e9d0f48 -r be44a5efeaff src/share/vm/oops/methodData.cpp --- a/src/share/vm/oops/methodData.cpp Thu Sep 17 12:10:17 2015 -0700 +++ b/src/share/vm/oops/methodData.cpp Thu Sep 17 12:11:28 2015 -0700 @@ -1124,7 +1124,9 @@ return new VirtualCallTypeData(this); case DataLayout::parameters_type_data_tag: return new ParametersTypeData(this); - }; + case DataLayout::speculative_trap_data_tag: + return new SpeculativeTrapData(this); + } } // Iteration over data. diff -r c3b49e9d0f48 -r be44a5efeaff src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Thu Sep 17 12:10:17 2015 -0700 +++ b/src/share/vm/runtime/arguments.cpp Thu Sep 17 12:11:28 2015 -0700 @@ -2442,10 +2442,6 @@ warning("forcing ScavengeRootsInCode non-zero because JVMCI is enabled"); ScavengeRootsInCode = 1; } - if (TypeProfileLevel != 0) { - warning("forcing TypeProfileLevel to 0 as HotSpotMethodData can not yet handle the new type profile info"); - TypeProfileLevel = 0; - } #endif // Need to limit the extent of the padding to reasonable size.