annotate src/share/tools/MakeDeps/MakeDeps.java @ 1716:be3f9c242c9d

6948538: CMS: BOT walkers can fall into object allocation and initialization cracks Summary: GC workers now recognize an intermediate transient state of blocks which are allocated but have not yet completed initialization. blk_start() calls do not attempt to determine the size of a block in the transient state, rather waiting for the block to become initialized so that it is safe to query its size. Audited and ensured the order of initialization of object fields (klass, free bit and size) to respect block state transition protocol. Also included some new assertion checking code enabled in debug mode. Reviewed-by: chrisphi, johnc, poonam
author ysr
date Mon, 16 Aug 2010 15:58:42 -0700
parents c18cbe5936b8
children 2d26b0046e0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // This program reads an include file database.
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // The database should cover each self .c and .h file,
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // but not files in /usr/include
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // The database consists of pairs of nonblank words, where the first word is
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // the filename that needs to include the file named by the second word.
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // For each .c file, this program generates a fooIncludes.h file that
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // the .c file may include to include all the needed files in the right order.
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // It also generates a foo.dep file to include in the makefile.
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Finally it detects cycles, and can work with two files, an old and a new one.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // To incrementally write out only needed files after a small change.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Based on a suggestion by Roland Conybeare, algorithm suggested by Craig
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Chambers, written by David Ungar, 3/1/89.
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Added PREFIX, {DEP/INC}_DIR, smaller dep output 10/92 -Urs
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Add something for precompiled headers
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // To handle different platforms, I am introducing a platform file.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // The platform file contains lines like:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // os = svr4
a61af66fc99e Initial load
duke
parents:
diff changeset
45 //
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Then, when processing the includeDB file, a token such as <os>
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // gets replaced by svr4. -- dmu 3/25/97
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Modified to centralize Dependencies to speed up make -- dmu 5/97
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public class MakeDeps {
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public static void usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 System.out.println("usage:");
a61af66fc99e Initial load
duke
parents:
diff changeset
55 System.out.println("\tmakeDeps platform-name platform-file database-file [MakeDeps args] [platform args]");
a61af66fc99e Initial load
duke
parents:
diff changeset
56 System.out.println("\tmakeDeps diffs platform-name old-platform-file old-database-file new-platform-file new-database-file [MakeDeps args] [platform args]");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 System.out.println("where platform-name is the name of a platform MakeDeps supports");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 System.out.println("(currently \"WinGammaPlatform\" or \"UnixPlatform\")");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 System.out.println("MakeDeps options:");
a61af66fc99e Initial load
duke
parents:
diff changeset
60 System.out.println(" -firstFile [filename]: Specify the first file in link order (i.e.,");
a61af66fc99e Initial load
duke
parents:
diff changeset
61 System.out.println(" to have a well-known function at the start of the output file)");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 System.out.println(" -lastFile [filename]: Specify the last file in link order (i.e.,");
a61af66fc99e Initial load
duke
parents:
diff changeset
63 System.out.println(" to have a well-known function at the end of the output file)");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 System.err.println("WinGammaPlatform platform-specific options:");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 System.err.println(" -sourceBase <path to directory (workspace) " +
a61af66fc99e Initial load
duke
parents:
diff changeset
66 "containing source files; no trailing slash>");
a61af66fc99e Initial load
duke
parents:
diff changeset
67 System.err.println(" -dspFileName <full pathname to which .dsp file " +
a61af66fc99e Initial load
duke
parents:
diff changeset
68 "will be written; all parent directories must " +
a61af66fc99e Initial load
duke
parents:
diff changeset
69 "already exist>");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 System.err.println(" -envVar <environment variable to be inserted " +
a61af66fc99e Initial load
duke
parents:
diff changeset
71 "into .dsp file, substituting for path given in " +
a61af66fc99e Initial load
duke
parents:
diff changeset
72 "-sourceBase. Example: HotSpotWorkSpace>");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 System.err.println(" -dllLoc <path to directory in which to put " +
a61af66fc99e Initial load
duke
parents:
diff changeset
74 "jvm.dll and jvm_g.dll; no trailing slash>");
a61af66fc99e Initial load
duke
parents:
diff changeset
75 System.err.println(" If any of the above are specified, "+
a61af66fc99e Initial load
duke
parents:
diff changeset
76 "they must all be.");
a61af66fc99e Initial load
duke
parents:
diff changeset
77 System.err.println(" Additional, optional arguments, which can be " +
a61af66fc99e Initial load
duke
parents:
diff changeset
78 "specified multiple times:");
a61af66fc99e Initial load
duke
parents:
diff changeset
79 System.err.println(" -absoluteInclude <string containing absolute " +
a61af66fc99e Initial load
duke
parents:
diff changeset
80 "path to include directory>");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 System.err.println(" -relativeInclude <string containing include " +
a61af66fc99e Initial load
duke
parents:
diff changeset
82 "directory relative to -envVar>");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 System.err.println(" -define <preprocessor flag to be #defined " +
a61af66fc99e Initial load
duke
parents:
diff changeset
84 "(note: doesn't yet support " +
a61af66fc99e Initial load
duke
parents:
diff changeset
85 "#define (flag) (value))>");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 System.err.println(" -perFileLine <file> <line>");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 System.err.println(" -conditionalPerFileLine <file> <line for " +
a61af66fc99e Initial load
duke
parents:
diff changeset
88 "release build> <line for debug build>");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 System.err.println(" (NOTE: To work around a bug in nmake, where " +
a61af66fc99e Initial load
duke
parents:
diff changeset
90 "you can't have a '#' character in a quoted " +
a61af66fc99e Initial load
duke
parents:
diff changeset
91 "string, all of the lines outputted have \"#\"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
92 "prepended)");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 System.err.println(" -startAt <subdir of sourceBase>");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 System.err.println(" -ignoreFile <file which won't be able to be " +
a61af66fc99e Initial load
duke
parents:
diff changeset
95 "found in the sourceBase because it's generated " +
a61af66fc99e Initial load
duke
parents:
diff changeset
96 "later>");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 System.err.println(" -additionalFile <file not in database but " +
a61af66fc99e Initial load
duke
parents:
diff changeset
98 "which should show up in .dsp file, like " +
a61af66fc99e Initial load
duke
parents:
diff changeset
99 "includeDB_core>");
a61af66fc99e Initial load
duke
parents:
diff changeset
100 System.err.println(" -additionalGeneratedFile <environment variable of " +
a61af66fc99e Initial load
duke
parents:
diff changeset
101 "generated file's location> <relative path to " +
a61af66fc99e Initial load
duke
parents:
diff changeset
102 "directory containing file; no trailing slash> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
103 "<name of file generated later in the build process>");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 System.err.println(" -prelink <build> <desc> <cmds>:");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 System.err.println(" Generate a set of prelink commands for the given BUILD");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 System.err.println(" (\"Debug\" or \"Release\"). The prelink description and commands");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 System.err.println(" are both quoted strings.");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 System.err.println(" Default includes: \".\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 System.err.println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (args.length < 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 System.exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 int argc = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 boolean diffMode = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (args[argc].equals("diffs")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 diffMode = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 ++argc;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 String platformName = args[argc++];
a61af66fc99e Initial load
duke
parents:
diff changeset
127 Class platformClass = Class.forName(platformName);
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 String plat1 = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 String db1 = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 String plat2 = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 String db2 = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 String firstFile = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 String lastFile = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 int numOptionalArgs =
a61af66fc99e Initial load
duke
parents:
diff changeset
138 (diffMode ? (args.length - 6) : (args.length - 3));
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (numOptionalArgs < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 System.exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 plat1 = args[argc++];
a61af66fc99e Initial load
duke
parents:
diff changeset
145 db1 = args[argc++];
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (diffMode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 plat2 = args[argc++];
a61af66fc99e Initial load
duke
parents:
diff changeset
149 db2 = args[argc++];
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // argc now points at start of optional arguments, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 boolean gotOne = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 while (gotOne && (argc < args.length - 1)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 gotOne = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 String arg = args[argc];
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if (arg.equals("-firstFile")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 firstFile = args[argc + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
161 argc += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 gotOne = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } else if (arg.equals("-lastFile")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 lastFile = args[argc + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
165 argc += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 gotOne = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 System.exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Platform platform = (Platform) platformClass.newInstance();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 platform.setupFileTemplates();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 long t = platform.defaultGrandIncludeThreshold();
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 String[] platformArgs = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 int numPlatformArgs = args.length - argc;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (numPlatformArgs > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 platformArgs = new String[numPlatformArgs];
a61af66fc99e Initial load
duke
parents:
diff changeset
184 int offset = argc;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 while (argc < args.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 platformArgs[argc - offset] = args[argc];
a61af66fc99e Initial load
duke
parents:
diff changeset
187 ++argc;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // If you want to change the threshold, change the default
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // "grand include" threshold in Platform.java, or override
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // it in the platform-specific file like UnixPlatform.java
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 Database previous = new Database(platform, t);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 Database current = new Database(platform, t);
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 previous.canBeMissing();
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if (firstFile != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 previous.setFirstFile(firstFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 current.setFirstFile(firstFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (lastFile != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 previous.setLastFile(lastFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 current.setLastFile(lastFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (diffMode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 System.out.println("Old database:");
a61af66fc99e Initial load
duke
parents:
diff changeset
211 previous.get(plat1, db1);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 previous.compute();
a61af66fc99e Initial load
duke
parents:
diff changeset
213 System.out.println("New database:");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 current.get(plat2, db2);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 current.compute();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 System.out.println("Deltas:");
a61af66fc99e Initial load
duke
parents:
diff changeset
217 current.putDiffs(previous);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 System.out.println("New database:");
a61af66fc99e Initial load
duke
parents:
diff changeset
220 current.get(plat1, db1);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 current.compute();
a61af66fc99e Initial load
duke
parents:
diff changeset
222 current.put();
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 if (platformArgs != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Allow the platform to write platform-specific files
a61af66fc99e Initial load
duke
parents:
diff changeset
227 platform.writePlatformSpecificFiles(previous, current,
a61af66fc99e Initial load
duke
parents:
diff changeset
228 platformArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 System.exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }