From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libjava/gnu/gcj/tools/gc_analyze/BlockMap.java | 218 +++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 libjava/gnu/gcj/tools/gc_analyze/BlockMap.java (limited to 'libjava/gnu/gcj/tools/gc_analyze/BlockMap.java') diff --git a/libjava/gnu/gcj/tools/gc_analyze/BlockMap.java b/libjava/gnu/gcj/tools/gc_analyze/BlockMap.java new file mode 100644 index 000000000..6e7adae20 --- /dev/null +++ b/libjava/gnu/gcj/tools/gc_analyze/BlockMap.java @@ -0,0 +1,218 @@ +/* BlockMap.java -- Container for information on GC maintained memory blocks. + Copyright (C) 2007 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.tools.gc_analyze; + +import java.io.BufferedReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; +import java.util.TreeMap; + +class BlockMap +{ + static final int HBLKSIZE = 4096; + + class SizeKind implements Comparable + { + int size; + int kind; + + public SizeKind(int size, int kind) + { + this.size = size; + this.kind = kind; + } + + public int compareTo(SizeKind b) + { + if (this.size != b.size) + return this.size - b.size; + return this.kind - b.kind; + } + } + + class PtrMarks + { + long ptr; + int marks; + + public PtrMarks(long ptr, int marks) + { + this.ptr = ptr; + this.marks = marks; + } + } + + private TreeMap> map = + new TreeMap>(); + + public BlockMap(BufferedReader reader) throws IOException + { + for (;;) + { + String s = reader.readLine(); + if (s == null) + break; + if (s.charAt(0) == '#') + continue; + if (s.indexOf("Begin block map") >= 0) + { + for (;;) + { + s = reader.readLine(); + if (s.charAt(0) == '#') + continue; + if (s.indexOf("End block map") >= 0) + return; + String[] items = s.split(","); + long ptr = 0; + int kind = 0, size = 0, marks = 0; + for (int i=0; i m = map.get(sk); + if (m == null) + { + m = new ArrayList(); + map.put(sk, m); + } + PtrMarks pm = new PtrMarks(ptr, marks); + m.add(pm); + } // inner loop + } // started inner loop + } // outer loop - finding begin + } // memoryMap + + public void dump() + { + System.out.println(); + System.out.println(); + System.out.println("*** Used Blocks ***\n"); + System.out.println(); + System.out.println(" Size Kind Blocks Used Free Wasted"); + System.out.println("------- ------------- ------- ---------- ---------- -------"); + + int total_blocks = 0, total_used = 0, total_free = 0, total_wasted = 0; + + for (Map.Entry> me : map.entrySet()) + { + SizeKind sk = me.getKey(); + + System.out.println(MemoryAnalyze.format(sk.size, 7) + " " + + MemoryAnalyze.kindToName(sk.kind)); + + int sub_blocks = 0, sub_used = 0, sub_free = 0, sub_wasted = 0; + int sub_count = 0; + + ArrayList v = me.getValue(); + + for (PtrMarks pm : v) + { + int bytes = sk.size; + int blocks = (sk.size + HBLKSIZE - 1) / HBLKSIZE; + int used; + int free; + int wasted; + + if (bytes < HBLKSIZE) + { + used = bytes * pm.marks; + free = bytes * (HBLKSIZE / bytes - pm.marks); + wasted = HBLKSIZE - HBLKSIZE / bytes * bytes; + } + else + { + if (pm.marks != 0) + { + used = bytes; + free = 0; + wasted = (bytes + HBLKSIZE - 1) + / HBLKSIZE * HBLKSIZE - used; + } + else + { + used = 0; + free = bytes; + wasted = 0; + } + } + + StringBuilder sb = new StringBuilder(); + sb.append(" "); + sb.append(MemoryAnalyze.format(blocks, 5)); + sb.append(" "); + sb.append(MemoryAnalyze.format(used, 9)); + sb.append(" "); + sb.append(MemoryAnalyze.format(free, 9)); + sb.append(" "); + sb.append(MemoryAnalyze.format(wasted, 9)); + System.out.println(sb); + + sub_blocks += blocks; + sub_used += used; + sub_free += free; + sub_wasted += wasted; + sub_count++; + + total_blocks += blocks; + total_used += used; + total_free += free; + total_wasted += wasted; + } // blocks with size/kind + if (sub_count > 1) + { + System.out.println( + " ------- ---------- ---------- -------"); + StringBuilder sb = new StringBuilder(); + sb.append(" "); + sb.append(MemoryAnalyze.format(sub_blocks, 5)); + sb.append(" "); + sb.append(MemoryAnalyze.format(sub_used, 9)); + sb.append(" "); + sb.append(MemoryAnalyze.format(sub_free, 9)); + sb.append(" "); + sb.append(MemoryAnalyze.format(sub_wasted, 9)); + System.out.println(sb); + } + } // size/kind + + System.out.println("------- ------------- ------- ---------- ---------- -------"); + StringBuilder sb = new StringBuilder(); + sb.append(" "); + sb.append(MemoryAnalyze.format(total_blocks, 5)); + sb.append(" "); + sb.append(MemoryAnalyze.format(total_used, 9)); + sb.append(" "); + sb.append(MemoryAnalyze.format(total_free, 9)); + sb.append(" "); + sb.append(MemoryAnalyze.format(total_wasted, 9)); + System.out.println(sb); + System.out.println("Total bytes = " + + MemoryAnalyze.format(total_blocks * HBLKSIZE, 10)); + } +} -- cgit v1.2.3