hotspot/test/stress/gc/TestGCOld.java
author lfoltan
Fri, 23 Jan 2015 09:54:33 -0500
changeset 28731 f7339cba0a6a
parent 28380 4b0c67526510
permissions -rw-r--r--
8067480: Crash in klassItable::initialize_itable_for_interface when running vm.runtime.defmeth.StaticMethodsTest. Summary: A static method should be skipped in entirety by find_instance_method(), searching should continue to find an overpass method of the same name and signature if present. Reviewed-by: acorn, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28380
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     1
/*
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     2
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     4
*
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     5
* This code is free software; you can redistribute it and/or modify it
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     6
* under the terms of the GNU General Public License version 2 only, as
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     7
* published by the Free Software Foundation.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     8
*
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
     9
* This code is distributed in the hope that it will be useful, but WITHOUT
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    12
* version 2 for more details (a copy is included in the LICENSE file that
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    13
* accompanied this code).
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    14
*
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    15
* You should have received a copy of the GNU General Public License version
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    16
* 2 along with this work; if not, write to the Free Software Foundation,
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    18
*
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    20
* or visit www.oracle.com if you need additional information or have any
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    21
* questions.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    22
*/
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    23
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    24
/*
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    25
 * @test TestGCOld
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    26
 * @key gc
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    27
 * @key stress
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    28
 * @requires vm.gc=="null"
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    29
 * @summary Stress the GC by trying to make old objects more likely to be garbage than young objects.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    30
 * @run main/othervm -Xmx384M -XX:+UseSerialGC TestGCOld 50 1 20 10 10000
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    31
 * @run main/othervm -Xmx384M -XX:+UseParallelGC TestGCOld 50 1 20 10 10000
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    32
 * @run main/othervm -Xmx384M -XX:+UseParallelGC -XX:-UseParallelOldGC TestGCOld 50 1 20 10 10000
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    33
 * @run main/othervm -Xmx384M -XX:+UseConcMarkSweepGC TestGCOld 50 1 20 10 10000
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    34
 * @run main/othervm -Xmx384M -XX:+UseG1GC TestGCOld 50 1 20 10 10000
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    35
 */
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    36
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    37
import java.text.*;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    38
import java.util.Random;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    39
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    40
class TreeNode {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    41
    public TreeNode left, right;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    42
    public int val;                // will always be the height of the tree
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    43
}
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    44
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    45
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    46
/* Args:
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    47
   live-data-size: in megabytes (approximate, will be rounded down).
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    48
   work: units of mutator non-allocation work per byte allocated,
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    49
     (in unspecified units.  This will affect the promotion rate
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    50
      printed at the end of the run: more mutator work per step implies
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    51
      fewer steps per second implies fewer bytes promoted per second.)
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    52
   short/long ratio: ratio of short-lived bytes allocated to long-lived
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    53
      bytes allocated.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    54
   pointer mutation rate: number of pointer mutations per step.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    55
   steps: number of steps to do.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    56
*/
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    57
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    58
public class TestGCOld {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    59
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    60
  // Command-line parameters.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    61
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    62
  private static int size, workUnits, promoteRate, ptrMutRate, steps;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    63
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    64
  // Constants.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    65
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    66
  private static final int MEG = 1000000;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    67
  private static final int INSIGNIFICANT = 999; // this many bytes don't matter
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    68
  private static final int BYTES_PER_WORD = 4;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    69
  private static final int BYTES_PER_NODE = 20; // bytes per TreeNode
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    70
  private static final int WORDS_DEAD = 100;    // size of young garbage object
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    71
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    72
  private final static int treeHeight = 14;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    73
  private final static long treeSize = heightToBytes(treeHeight);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    74
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    75
  private static final String msg1
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    76
    = "Usage: java TestGCOld <size> <work> <ratio> <mutation> <steps>";
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    77
  private static final String msg2
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    78
    = "  where <size> is the live storage in megabytes";
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    79
  private static final String msg3
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    80
    = "        <work> is the mutator work per step (arbitrary units)";
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    81
  private static final String msg4
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    82
    = "        <ratio> is the ratio of short-lived to long-lived allocation";
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    83
  private static final String msg5
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    84
    = "        <mutation> is the mutations per step";
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    85
  private static final String msg6
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    86
    = "        <steps> is the number of steps";
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    87
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    88
  // Counters (and global variables that discourage optimization)
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    89
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    90
  private static long youngBytes = 0;    // total young bytes allocated
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    91
  private static long nodes = 0;         // total tree nodes allocated
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    92
  private static long actuallyMut = 0;   // pointer mutations in old trees
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    93
  private static long mutatorSum = 0;    // checksum to discourage optimization
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    94
  public static int[] aexport;           // exported array to discourage opt
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    95
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    96
  // Global variables.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    97
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    98
  private static TreeNode[] trees;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
    99
  private static int where = 0;               // roving index into trees
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   100
  private static Random rnd = new Random();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   101
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   102
  // Returns the height of the given tree.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   103
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   104
  private static int height (TreeNode t) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   105
    if (t == null) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   106
      return 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   107
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   108
    else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   109
      return 1 + Math.max (height (t.left), height (t.right));
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   110
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   111
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   112
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   113
  // Returns the length of the shortest path in the given tree.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   114
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   115
  private static int shortestPath (TreeNode t) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   116
    if (t == null) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   117
      return 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   118
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   119
    else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   120
      return 1 + Math.min (shortestPath (t.left), shortestPath (t.right));
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   121
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   122
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   123
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   124
  // Returns the number of nodes in a balanced tree of the given height.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   125
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   126
  private static long heightToNodes (int h) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   127
    if (h == 0) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   128
      return 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   129
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   130
    else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   131
      long n = 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   132
      while (h > 1) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   133
        n = n + n;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   134
        h = h - 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   135
      }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   136
      return n + n - 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   137
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   138
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   139
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   140
  // Returns the number of bytes in a balanced tree of the given height.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   141
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   142
  private static long heightToBytes (int h) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   143
    return BYTES_PER_NODE * heightToNodes (h);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   144
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   145
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   146
  // Returns the height of the largest balanced tree
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   147
  // that has no more than the given number of nodes.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   148
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   149
  private static int nodesToHeight (long nodes) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   150
    int h = 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   151
    long n = 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   152
    while (n + n - 1 <= nodes) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   153
      n = n + n;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   154
      h = h + 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   155
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   156
    return h - 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   157
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   158
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   159
  // Returns the height of the largest balanced tree
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   160
  // that occupies no more than the given number of bytes.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   161
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   162
  private static int bytesToHeight (long bytes) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   163
    return nodesToHeight (bytes / BYTES_PER_NODE);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   164
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   165
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   166
  // Returns a newly allocated balanced binary tree of height h.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   167
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   168
  private static TreeNode makeTree(int h) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   169
    if (h == 0) return null;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   170
    else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   171
      TreeNode res = new TreeNode();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   172
      nodes++;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   173
      res.left = makeTree(h-1);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   174
      res.right = makeTree(h-1);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   175
      res.val = h;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   176
      return res;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   177
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   178
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   179
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   180
  // Allocates approximately size megabytes of trees and stores
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   181
  // them into a global array.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   182
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   183
  private static void init() {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   184
    int ntrees = (int) ((size * MEG) / treeSize);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   185
    trees = new TreeNode[ntrees];
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   186
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   187
    System.err.println("Allocating " + ntrees + " trees.");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   188
    System.err.println("  (" + (ntrees * treeSize) + " bytes)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   189
    for (int i = 0; i < ntrees; i++) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   190
      trees[i] = makeTree(treeHeight);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   191
      // doYoungGenAlloc(promoteRate*ntrees*treeSize, WORDS_DEAD);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   192
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   193
    System.err.println("  (" + nodes + " nodes)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   194
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   195
    /* Allow any in-progress GC to catch up... */
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   196
    // try { Thread.sleep(20000); } catch (InterruptedException x) {}
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   197
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   198
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   199
  // Confirms that all trees are balanced and have the correct height.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   200
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   201
  private static void checkTrees() {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   202
    int ntrees = trees.length;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   203
    for (int i = 0; i < ntrees; i++) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   204
      TreeNode t = trees[i];
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   205
      int h1 = height(t);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   206
      int h2 = shortestPath(t);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   207
      if ((h1 != treeHeight) || (h2 != treeHeight)) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   208
        System.err.println("*****BUG: " + h1 + " " + h2);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   209
      }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   210
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   211
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   212
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   213
  // Called only by replaceTree (below) and by itself.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   214
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   215
  private static void replaceTreeWork(TreeNode full, TreeNode partial, boolean dir) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   216
    boolean canGoLeft = full.left != null && full.left.val > partial.val;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   217
    boolean canGoRight = full.right != null && full.right.val > partial.val;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   218
    if (canGoLeft && canGoRight) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   219
      if (dir)
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   220
        replaceTreeWork(full.left, partial, !dir);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   221
      else
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   222
        replaceTreeWork(full.right, partial, !dir);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   223
    } else if (!canGoLeft && !canGoRight) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   224
      if (dir)
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   225
        full.left = partial;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   226
      else
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   227
        full.right = partial;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   228
    } else if (!canGoLeft) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   229
      full.left = partial;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   230
    } else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   231
      full.right = partial;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   232
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   233
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   234
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   235
  // Given a balanced tree full and a smaller balanced tree partial,
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   236
  // replaces an appropriate subtree of full by partial, taking care
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   237
  // to preserve the shape of the full tree.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   238
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   239
  private static void replaceTree(TreeNode full, TreeNode partial) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   240
    boolean dir = (partial.val % 2) == 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   241
    actuallyMut++;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   242
    replaceTreeWork(full, partial, dir);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   243
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   244
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   245
  // Allocates approximately n bytes of long-lived storage,
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   246
  // replacing oldest existing long-lived storage.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   247
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   248
  private static void oldGenAlloc(long n) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   249
    int full = (int) (n / treeSize);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   250
    long partial = n % treeSize;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   251
    // System.out.println("In oldGenAlloc, doing " + full + " full trees "
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   252
    // + "and one partial tree of size " + partial);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   253
    for (int i = 0; i < full; i++) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   254
      trees[where++] = makeTree(treeHeight);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   255
      if (where == trees.length) where = 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   256
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   257
    while (partial > INSIGNIFICANT) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   258
      int h = bytesToHeight(partial);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   259
      TreeNode newTree = makeTree(h);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   260
      replaceTree(trees[where++], newTree);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   261
      if (where == trees.length) where = 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   262
      partial = partial - heightToBytes(h);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   263
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   264
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   265
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   266
  // Interchanges two randomly selected subtrees (of same size and depth).
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   267
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   268
  private static void oldGenSwapSubtrees() {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   269
    // Randomly pick:
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   270
    //   * two tree indices
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   271
    //   * A depth
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   272
    //   * A path to that depth.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   273
    int index1 = rnd.nextInt(trees.length);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   274
    int index2 = rnd.nextInt(trees.length);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   275
    int depth = rnd.nextInt(treeHeight);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   276
    int path = rnd.nextInt();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   277
    TreeNode tn1 = trees[index1];
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   278
    TreeNode tn2 = trees[index2];
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   279
    for (int i = 0; i < depth; i++) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   280
      if ((path & 1) == 0) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   281
        tn1 = tn1.left;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   282
        tn2 = tn2.left;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   283
      } else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   284
        tn1 = tn1.right;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   285
        tn2 = tn2.right;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   286
      }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   287
      path >>= 1;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   288
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   289
    TreeNode tmp;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   290
    if ((path & 1) == 0) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   291
      tmp = tn1.left;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   292
      tn1.left = tn2.left;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   293
      tn2.left = tmp;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   294
    } else {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   295
      tmp = tn1.right;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   296
      tn1.right = tn2.right;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   297
      tn2.right = tmp;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   298
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   299
    actuallyMut += 2;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   300
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   301
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   302
  // Update "n" old-generation pointers.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   303
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   304
  private static void oldGenMut(long n) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   305
    for (int i = 0; i < n/2; i++) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   306
      oldGenSwapSubtrees();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   307
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   308
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   309
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   310
  // Does the amount of mutator work appropriate for n bytes of young-gen
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   311
  // garbage allocation.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   312
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   313
  private static void doMutWork(long n) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   314
    int sum = 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   315
    long limit = workUnits*n/10;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   316
    for (long k = 0; k < limit; k++) sum++;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   317
    // We don't want dead code elimination to eliminate the loop above.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   318
    mutatorSum = mutatorSum + sum;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   319
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   320
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   321
  // Allocate n bytes of young-gen garbage, in units of "nwords"
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   322
  // words.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   323
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   324
  private static void doYoungGenAlloc(long n, int nwords) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   325
    final int nbytes = nwords*BYTES_PER_WORD;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   326
    int allocated = 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   327
    while (allocated < n) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   328
      aexport = new int[nwords];
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   329
      /* System.err.println("Step"); */
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   330
      allocated += nbytes;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   331
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   332
    youngBytes = youngBytes + allocated;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   333
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   334
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   335
  // Allocate "n" bytes of young-gen data; and do the
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   336
  // corresponding amount of old-gen allocation and pointer
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   337
  // mutation.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   338
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   339
  // oldGenAlloc may perform some mutations, so this code
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   340
  // takes those mutations into account.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   341
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   342
  private static void doStep(long n) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   343
    long mutations = actuallyMut;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   344
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   345
    doYoungGenAlloc(n, WORDS_DEAD);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   346
    doMutWork(n);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   347
    oldGenAlloc(n / promoteRate);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   348
    oldGenMut(Math.max(0L, (mutations + ptrMutRate) - actuallyMut));
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   349
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   350
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   351
  public static void main(String[] args) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   352
    if (args.length != 5) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   353
      System.err.println(msg1);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   354
      System.err.println(msg2);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   355
      System.err.println(msg3);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   356
      System.err.println(msg4);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   357
      System.err.println(msg5);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   358
      System.err.println(msg6);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   359
      return;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   360
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   361
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   362
    size = Integer.parseInt(args[0]);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   363
    workUnits = Integer.parseInt(args[1]);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   364
    promoteRate = Integer.parseInt(args[2]);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   365
    ptrMutRate = Integer.parseInt(args[3]);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   366
    steps = Integer.parseInt(args[4]);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   367
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   368
    System.out.println(size + " megabytes of live storage");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   369
    System.out.println(workUnits + " work units per step");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   370
    System.out.println("promotion ratio is 1:" + promoteRate);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   371
    System.out.println("pointer mutation rate is " + ptrMutRate);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   372
    System.out.println(steps + " steps");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   373
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   374
    init();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   375
//  checkTrees();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   376
    youngBytes = 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   377
    nodes = 0;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   378
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   379
    System.err.println("Initialization complete...");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   380
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   381
    long start = System.currentTimeMillis();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   382
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   383
    for (int step = 0; step < steps; step++) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   384
      doStep(MEG);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   385
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   386
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   387
    long end = System.currentTimeMillis();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   388
    float secs = ((float)(end-start))/1000.0F;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   389
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   390
//  checkTrees();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   391
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   392
    NumberFormat nf = NumberFormat.getInstance();
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   393
    nf.setMaximumFractionDigits(1);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   394
    System.out.println("\nTook " + nf.format(secs) + " sec in steady state.");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   395
    nf.setMaximumFractionDigits(2);
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   396
    System.out.println("Allocated " + steps + " Mb of young gen garbage"
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   397
                       + " (= " + nf.format(((float)steps)/secs) +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   398
                       " Mb/sec)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   399
    System.out.println("    (actually allocated " +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   400
                       nf.format(((float) youngBytes)/MEG) + " megabytes)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   401
    float promoted = ((float)steps) / (float)promoteRate;
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   402
    System.out.println("Promoted " + promoted +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   403
                       " Mb (= " + nf.format(promoted/secs) + " Mb/sec)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   404
    System.out.println("    (actually promoted " +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   405
                       nf.format(((float) (nodes * BYTES_PER_NODE))/MEG) +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   406
                       " megabytes)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   407
    if (ptrMutRate != 0) {
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   408
      System.out.println("Mutated " + actuallyMut +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   409
                         " pointers (= " +
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   410
                         nf.format(actuallyMut/secs) + " ptrs/sec)");
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   411
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   412
    }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   413
    // This output serves mainly to discourage optimization.
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   414
    System.out.println("Checksum = " + (mutatorSum + aexport.length));
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   415
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   416
  }
4b0c67526510 8067868: Add GCOld as a JTreg test
brutisso
parents:
diff changeset
   417
}