5252import java .util .function .Consumer ;
5353import java .util .stream .Collectors ;
5454
55- import com .oracle .graal .pointsto .reports .ReportUtils ;
56- import com .oracle .svm .util .ReflectionUtil ;
5755import org .graalvm .collections .EconomicMap ;
5856import org .graalvm .collections .Pair ;
5957import org .graalvm .compiler .debug .DebugOptions ;
6866import com .oracle .graal .pointsto .meta .AnalysisField ;
6967import com .oracle .graal .pointsto .meta .AnalysisMethod ;
7068import com .oracle .graal .pointsto .meta .AnalysisUniverse ;
69+ import com .oracle .graal .pointsto .reports .ReportUtils ;
7170import com .oracle .graal .pointsto .util .Timer ;
7271import com .oracle .graal .pointsto .util .TimerCollection ;
7372import com .oracle .svm .core .BuildArtifacts ;
101100import com .oracle .svm .hosted .reflect .ReflectionHostedSupport ;
102101import com .oracle .svm .hosted .util .VMErrorReporter ;
103102import com .oracle .svm .util .ImageBuildStatistics ;
103+ import com .oracle .svm .util .ReflectionUtil ;
104104
105105import jdk .vm .ci .meta .JavaConstant ;
106106
@@ -115,9 +115,6 @@ public class ProgressReporter {
115115 private static final double EXCESSIVE_GC_MIN_THRESHOLD_MILLIS = 15_000 ;
116116 private static final double EXCESSIVE_GC_RATIO = 0.5 ;
117117 private static final String BREAKDOWN_BYTE_ARRAY_PREFIX = "byte[] for " ;
118- private static final Field STRING_VALUE = ReflectionUtil .lookupField (String .class , "value" );
119- private static final double MILLIS_TO_SECONDS = 1000d ;
120- private static final double NANOS_TO_SECONDS = 1000d * 1000d * 1000d ;
121118
122119 private final NativeImageSystemIOWrappers builderIO ;
123120
@@ -596,8 +593,6 @@ private void printBreakdowns() {
596593 .jumpToMiddle ()
597594 .a (String .format ("Top %d object types in image heap:" , MAX_NUM_BREAKDOWN )).reset ().flushln ();
598595
599- int maxLength = ProgressReporter .CHARACTERS_PER_LINE / 2 - 10 ;
600-
601596 long printedCodeBytes = 0 ;
602597 long printedHeapBytes = 0 ;
603598 long printedCodeItems = 0 ;
@@ -606,7 +601,7 @@ private void printBreakdowns() {
606601 String codeSizePart = "" ;
607602 if (packagesBySize .hasNext ()) {
608603 Entry <String , Long > e = packagesBySize .next ();
609- String className = Utils .truncateClassOrPackageName (e .getKey (), maxLength );
604+ String className = Utils .truncateClassOrPackageName (e .getKey ());
610605 codeSizePart = String .format ("%9s %s" , ByteFormattingUtil .bytesToHuman (e .getValue ()), className );
611606 printedCodeBytes += e .getValue ();
612607 printedCodeItems ++;
@@ -618,7 +613,7 @@ private void printBreakdowns() {
618613 String className = e .getKey ();
619614 // Do not truncate special breakdown items, they can contain links.
620615 if (!className .startsWith (BREAKDOWN_BYTE_ARRAY_PREFIX )) {
621- className = Utils .truncateClassOrPackageName (className , maxLength );
616+ className = Utils .truncateClassOrPackageName (className );
622617 }
623618 heapSizePart = String .format ("%9s %s" , ByteFormattingUtil .bytesToHuman (e .getValue ()), className );
624619 printedHeapBytes += e .getValue ();
@@ -742,22 +737,6 @@ private static Path reportImageBuildStatistics(String imageName, BigBang bb) {
742737 }
743738 }
744739
745- private static Path reportBuildArtifacts (String imageName , Map <ArtifactType , List <Path >> buildArtifacts ) {
746- Path buildDir = NativeImageGenerator .generatedFiles (HostedOptionValues .singleton ());
747-
748- Consumer <PrintWriter > writerConsumer = writer -> buildArtifacts .forEach ((artifactType , paths ) -> {
749- writer .println ("[" + artifactType + "]" );
750- if (artifactType == BuildArtifacts .ArtifactType .JDK_LIB_SHIM ) {
751- writer .println ("# Note that shim JDK libraries depend on this" );
752- writer .println ("# particular native image (including its name)" );
753- writer .println ("# and therefore cannot be used with others." );
754- }
755- paths .stream ().map (Path ::toAbsolutePath ).map (buildDir ::relativize ).forEach (writer ::println );
756- writer .println ();
757- });
758- return com .oracle .graal .pointsto .reports .ReportUtils .report ("build artifacts" , buildDir .resolve (imageName + ".build_artifacts.txt" ), writerConsumer , false );
759- }
760-
761740 private void printResourceStatistics () {
762741 double totalProcessTimeSeconds = Utils .millisToSeconds (System .currentTimeMillis () - ManagementFactory .getRuntimeMXBean ().getStartTime ());
763742 GCStats gcStats = GCStats .getCurrent ();
@@ -810,34 +789,38 @@ private void recordJsonMetric(JsonMetric metric, Object value) {
810789 /*
811790 * HELPERS
812791 */
792+ private static class Utils {
793+ private static final double MILLIS_TO_SECONDS = 1000d ;
794+ private static final double NANOS_TO_SECONDS = 1000d * 1000d * 1000d ;
795+ private static final Field STRING_VALUE = ReflectionUtil .lookupField (String .class , "value" );
813796
814- private static Timer getTimer ( TimerCollection . Registry type ) {
815- return TimerCollection . singleton (). get ( type ) ;
816- }
797+ private static double millisToSeconds ( double millis ) {
798+ return millis / MILLIS_TO_SECONDS ;
799+ }
817800
818- private static void resetANSIMode ( ) {
819- NativeImageSystemIOWrappers . singleton (). getOut (). print ( ANSI . RESET ) ;
820- }
801+ private static double nanosToSeconds ( double nanos ) {
802+ return nanos / NANOS_TO_SECONDS ;
803+ }
821804
822- private static class Utils {
823- public static int getInternalByteArrayLength (String string ) {
805+ private static int getInternalByteArrayLength (String string ) {
824806 try {
825807 return ((byte []) STRING_VALUE .get (string )).length ;
826808 } catch (ReflectiveOperationException ex ) {
827809 throw VMError .shouldNotReachHere (ex );
828810 }
829811 }
830812
831- static double getUsedMemory () {
813+ private static double getUsedMemory () {
832814 return ByteFormattingUtil .bytesToGiB (Runtime .getRuntime ().totalMemory () - Runtime .getRuntime ().freeMemory ());
833815 }
834816
835- static String stringFilledWith (int size , String fill ) {
817+ private static String stringFilledWith (int size , String fill ) {
836818 return new String (new char [size ]).replace ("\0 " , fill );
837819 }
838820
839- static String truncateClassOrPackageName (String classOrPackageName , int maxLength ) {
821+ private static String truncateClassOrPackageName (String classOrPackageName ) {
840822 int classNameLength = classOrPackageName .length ();
823+ int maxLength = CHARACTERS_PER_LINE / 2 - 10 ;
841824 if (classNameLength <= maxLength ) {
842825 return classOrPackageName ;
843826 }
@@ -867,14 +850,14 @@ static String truncateClassOrPackageName(String classOrPackageName, int maxLengt
867850 }
868851 return sb .toString ();
869852 }
853+ }
870854
871- public static double millisToSeconds ( double millis ) {
872- return millis / MILLIS_TO_SECONDS ;
873- }
855+ private static Timer getTimer ( TimerCollection . Registry type ) {
856+ return TimerCollection . singleton (). get ( type ) ;
857+ }
874858
875- public static double nanosToSeconds (double nanos ) {
876- return nanos / NANOS_TO_SECONDS ;
877- }
859+ private static void resetANSIMode () {
860+ NativeImageSystemIOWrappers .singleton ().getOut ().print (ANSI .RESET );
878861 }
879862
880863 private static class GCStats {
0 commit comments