# HG changeset patch # User Doug Simon # Date 1369344183 -7200 # Node ID d552919fbb05a8f080abde767df1837170907cab # Parent 21b8cd853b2be576387643b8aa4077a4898c0e6b Graal's code annotations are installed into codeBlobs and are thus included in disassembler output (in a non-PRODUCT build) diff -r 21b8cd853b2b -r d552919fbb05 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Thu May 23 18:14:59 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Thu May 23 23:23:03 2013 +0200 @@ -492,6 +492,9 @@ * @return the code annotations or {@code null} if there are none */ public List getAnnotations() { + if (annotations == null) { + return Collections.emptyList(); + } return annotations; } diff -r 21b8cd853b2b -r d552919fbb05 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu May 23 18:14:59 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu May 23 23:23:03 2013 +0200 @@ -213,6 +213,8 @@ if (Debug.isDumpEnabled()) { Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); } + // TTY.println(String.valueOf(graph)); + // TTY.println(graalRuntime.getRuntime().disassemble(installedCode)); } }); diff -r 21b8cd853b2b -r d552919fbb05 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java Thu May 23 18:14:59 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java Thu May 23 23:23:03 2013 +0200 @@ -25,9 +25,9 @@ import java.util.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.ExceptionHandler; -import com.oracle.graal.api.code.CompilationResult.Mark; -import com.oracle.graal.api.code.CompilationResult.Site; +import com.oracle.graal.api.code.CompilationResult.CodeComment; +import com.oracle.graal.api.code.CompilationResult.JumpTable; +import com.oracle.graal.api.code.CompilationResult.*; /** * A {@link CompilationResult} with additional HotSpot-specific information required for installing @@ -40,6 +40,18 @@ public final Site[] sites; public final ExceptionHandler[] exceptionHandlers; + public final Comment[] comments; + + public static class Comment { + + public final String text; + public final int pcOffset; + + public Comment(int pcOffset, String text) { + this.text = text; + this.pcOffset = pcOffset; + } + } public HotSpotCompiledCode(CompilationResult compResult) { this.comp = compResult; @@ -49,6 +61,24 @@ } else { exceptionHandlers = compResult.getExceptionHandlers().toArray(new ExceptionHandler[compResult.getExceptionHandlers().size()]); } + List annotations = compResult.getAnnotations(); + comments = new Comment[annotations.size()]; + if (!annotations.isEmpty()) { + for (int i = 0; i < comments.length; i++) { + CodeAnnotation annotation = annotations.get(i); + String text; + if (annotation instanceof CodeComment) { + CodeComment codeComment = (CodeComment) annotation; + text = codeComment.value; + } else if (annotation instanceof JumpTable) { + JumpTable jumpTable = (JumpTable) annotation; + text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]"; + } else { + text = annotation.toString(); + } + comments[i] = new Comment(annotation.position, text); + } + } } static class SiteComparator implements Comparator { diff -r 21b8cd853b2b -r d552919fbb05 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Thu May 23 18:14:59 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Thu May 23 23:23:03 2013 +0200 @@ -129,8 +129,9 @@ @Override public native long getMaxCallTargetOffset(long address); + // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage @Override - public native String disassembleCodeBlob(long codeBlob); + public synchronized native String disassembleCodeBlob(long codeBlob); @Override public native byte[] getCode(long codeBlob); diff -r 21b8cd853b2b -r d552919fbb05 src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Thu May 23 18:14:59 2013 +0200 +++ b/src/share/vm/classfile/systemDictionary.hpp Thu May 23 23:23:03 2013 +0200 @@ -186,6 +186,7 @@ do_klass(BitSet_klass, java_util_BitSet, Opt) \ /* graal.hotspot */ \ do_klass(HotSpotCompiledCode_klass, com_oracle_graal_hotspot_HotSpotCompiledCode, Opt) \ + do_klass(HotSpotCompiledCode_Comment_klass, com_oracle_graal_hotspot_HotSpotCompiledCode_Comment, Opt) \ do_klass(HotSpotCompiledNmethod_klass, com_oracle_graal_hotspot_HotSpotCompiledNmethod, Opt) \ do_klass(HotSpotCompiledRuntimeStub_klass, com_oracle_graal_hotspot_HotSpotCompiledRuntimeStub, Opt) \ do_klass(HotSpotForeignCallLinkage_klass, com_oracle_graal_hotspot_HotSpotForeignCallLinkage, Opt) \ diff -r 21b8cd853b2b -r d552919fbb05 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Thu May 23 18:14:59 2013 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Thu May 23 23:23:03 2013 +0200 @@ -297,6 +297,7 @@ template(com_oracle_graal_hotspot_HotSpotKlassOop, "com/oracle/graal/hotspot/HotSpotKlassOop") \ template(com_oracle_graal_hotspot_HotSpotOptions, "com/oracle/graal/hotspot/HotSpotOptions") \ template(com_oracle_graal_hotspot_HotSpotCompiledCode, "com/oracle/graal/hotspot/HotSpotCompiledCode") \ + template(com_oracle_graal_hotspot_HotSpotCompiledCode_Comment, "com/oracle/graal/hotspot/HotSpotCompiledCode$Comment") \ template(com_oracle_graal_hotspot_HotSpotCompiledNmethod, "com/oracle/graal/hotspot/HotSpotCompiledNmethod") \ template(com_oracle_graal_hotspot_HotSpotCompiledRuntimeStub, "com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub") \ template(com_oracle_graal_hotspot_HotSpotForeignCallLinkage, "com/oracle/graal/hotspot/HotSpotForeignCallLinkage") \ diff -r 21b8cd853b2b -r d552919fbb05 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Thu May 23 18:14:59 2013 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Thu May 23 23:23:03 2013 +0200 @@ -410,6 +410,9 @@ // (very) conservative estimate: each site needs a constant section entry _constants_size = _sites->length() * (BytesPerLong*2); +#ifndef PRODUCT + _comments = (arrayOop) HotSpotCompiledCode::comments(compiled_code); +#endif _next_call_type = MARK_INVOKE_INVALID; } @@ -463,6 +466,19 @@ fatal("unexpected Site subclass"); } } + +#ifndef PRODUCT + if (_comments != NULL) { + oop* comments = (oop*) _comments->base(T_OBJECT); + for (int i = 0; i < _comments->length(); i++) { + oop comment = comments[i]; + assert(comment->is_a(HotSpotCompiledCode_Comment::klass()), "cce"); + jint offset = HotSpotCompiledCode_Comment::pcOffset(comment); + char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); + buffer.block_comment(offset, text); + } + } +#endif } void CodeInstaller::assumption_MethodContents(Handle assumption) { diff -r 21b8cd853b2b -r d552919fbb05 src/share/vm/graal/graalCodeInstaller.hpp --- a/src/share/vm/graal/graalCodeInstaller.hpp Thu May 23 18:14:59 2013 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.hpp Thu May 23 23:23:03 2013 +0200 @@ -60,6 +60,9 @@ jint _custom_stack_area_offset; jint _parameter_count; jint _constants_size; +#ifndef PRODUCT + arrayOop _comments; +#endif MarkId _next_call_type; address _invoke_mark_pc; diff -r 21b8cd853b2b -r d552919fbb05 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Thu May 23 18:14:59 2013 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Thu May 23 23:23:03 2013 +0200 @@ -87,6 +87,11 @@ oop_field(HotSpotCompiledCode, comp, "Lcom/oracle/graal/api/code/CompilationResult;") \ oop_field(HotSpotCompiledCode, sites, "[Lcom/oracle/graal/api/code/CompilationResult$Site;") \ oop_field(HotSpotCompiledCode, exceptionHandlers, "[Lcom/oracle/graal/api/code/CompilationResult$ExceptionHandler;") \ + oop_field(HotSpotCompiledCode, comments, "[Lcom/oracle/graal/hotspot/HotSpotCompiledCode$Comment;") \ + end_class \ + start_class(HotSpotCompiledCode_Comment) \ + oop_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;") \ + int_field(HotSpotCompiledCode_Comment, pcOffset) \ end_class \ start_class(HotSpotCompiledNmethod) \ oop_field(HotSpotCompiledNmethod, method, "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;") \ @@ -95,8 +100,8 @@ start_class(HotSpotCompiledRuntimeStub) \ oop_field(HotSpotCompiledRuntimeStub, stubName, "Ljava/lang/String;") \ end_class \ - start_class(HotSpotForeignCallLinkage) \ - long_field(HotSpotForeignCallLinkage, address) \ + start_class(HotSpotForeignCallLinkage) \ + long_field(HotSpotForeignCallLinkage, address) \ end_class \ start_class(ExceptionHandler) \ int_field(ExceptionHandler, startBCI) \ @@ -139,7 +144,7 @@ int_field(CompilationResult_Site, pcOffset) \ end_class \ start_class(CompilationResult_Call) \ - oop_field(CompilationResult_Call, target, "Lcom/oracle/graal/api/meta/InvokeTarget;") \ + oop_field(CompilationResult_Call, target, "Lcom/oracle/graal/api/meta/InvokeTarget;") \ oop_field(CompilationResult_Call, debugInfo, "Lcom/oracle/graal/api/code/DebugInfo;") \ end_class \ start_class(CompilationResult_DataPatch) \ @@ -228,10 +233,10 @@ oop_field(VirtualObject, type, "Lcom/oracle/graal/api/meta/ResolvedJavaType;") \ oop_field(VirtualObject, values, "[Lcom/oracle/graal/api/meta/Value;") \ end_class \ - start_class(HotSpotMonitorValue) \ - oop_field(HotSpotMonitorValue, owner, "Lcom/oracle/graal/api/meta/Value;") \ - oop_field(HotSpotMonitorValue, slot, "Lcom/oracle/graal/api/code/StackSlot;") \ - boolean_field(HotSpotMonitorValue, eliminated) \ + start_class(HotSpotMonitorValue) \ + oop_field(HotSpotMonitorValue, owner, "Lcom/oracle/graal/api/meta/Value;") \ + oop_field(HotSpotMonitorValue, slot, "Lcom/oracle/graal/api/code/StackSlot;") \ + boolean_field(HotSpotMonitorValue, eliminated) \ end_class \ /* end*/