Thu, 20 Nov 2008 16:56:09 -0800
6684579: SoftReference processing can be made more efficient
Summary: For current soft-ref clearing policies, we can decide at marking time if a soft-reference will definitely not be cleared, postponing the decision of whether it will definitely be cleared to the final reference processing phase. This can be especially beneficial in the case of concurrent collectors where the marking is usually concurrent but reference processing is usually not.
Reviewed-by: jmasa
1 #
2 # Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation.
8 #
9 # This code is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # version 2 for more details (a copy is included in the LICENSE file that
13 # accompanied this code).
14 #
15 # You should have received a copy of the GNU General Public License version
16 # 2 along with this work; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 #
19 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 # CA 95054 USA or visit www.sun.com if you need additional information or
21 # have any questions.
22 #
23 #
25 # Top level gnumake file for hotspot builds
26 #
27 # Default is to build the both product images and construct an export dir.
28 # The default export directory name is `pwd`/export-$(PLATFORM).
29 #
30 # Use: 'gnumake help' for more information.
31 #
32 # This makefile uses the default settings for where to find compilers and
33 # tools, and obeys the ALT_* variable settings used by the other JDK
34 # workspaces.
35 #
37 # Expected/optional make variables defined on make command line:
38 # LP64=1 or ARCH_DATA_MODEL=64 for 64bit build
39 #
40 # Expected/optional make variables or environment variables:
41 # ALT_SLASH_JAVA Location of /java or J:
42 # ALT_BOOTDIR Previous JDK home directory for javac compiler
43 # ALT_OUTPUTDIR Output directory to use for hotspot build
44 # ALT_EXPORT_PATH Directory to export hotspot build to
45 # ALT_JDK_IMPORT_PATH Current JDK build (only for create_jdk rules)
46 # ALT_BUILD_WIN_SA Building SA on Windows is disabled by default.
47 # Set ALT_BUILD_WIN_SA=1 to enable building SA on
48 # Windows.
49 # Version strings and numbers:
50 # JDK_VERSION Current JDK version (e.g. 1.6.0)
51 # PREVIOUS_JDK_VERSION Previous (bootdir) JDK version (e.g. 1.5.0)
52 # FULL_VERSION Full version string to use (e.g. "1.6.0-ea-b42")
53 #
54 # Version strings and numbers especially needed on Windows:
55 # COOKED_JDK_UPDATE_VERSION Just the update release number (e.g. 02)
56 # COOKED_BUILD_NUMBER Just the build number (e.g. 42)
57 # JDK_MKTG_VERSION Marketing JDK version (e.g. 6.0)
58 # JDK_MAJOR_VERSION Major number for version (e.g. 1) always 1?
59 # JDK_MINOR_VERSION Minor number for version (e.g. 6)
60 # JDK_MICRO_VERSION Micro number for version (e.g. 0)
61 #
63 # Default is build both product fastdebug and create export area
65 # Allow to build HotSpot in local directory from sources specified by GAMMADIR.
66 # After make/defs.make GAMMADIR is defined.
67 ifdef GAMMADIR
68 ifndef ALT_OUTPUTDIR
69 ALT_OUTPUTDIR := $(shell pwd)
70 endif
71 include $(GAMMADIR)/make/defs.make
72 else
73 include defs.make
74 endif
77 ifneq ($(ALT_OUTPUTDIR),)
78 ALT_OUT=ALT_OUTPUTDIR=$(ALT_OUTPUTDIR)
79 else
80 ALT_OUT=
81 endif
83 # Typical C1/C2 targets made available with this Makefile
84 C1_VM_TARGETS=product1 fastdebug1 optimized1 jvmg1
85 C2_VM_TARGETS=product fastdebug optimized jvmg
86 KERNEL_VM_TARGETS=productkernel fastdebugkernel optimizedkernel jvmgkernel
88 # JDK directory list
89 JDK_DIRS=bin include jre lib demo
91 all: all_product all_fastdebug
92 all_product: product product1 productkernel docs export_product
93 all_fastdebug: fastdebug fastdebug1 fastdebugkernel docs export_fastdebug
94 all_debug: jvmg jvmg1 jvmgkernel docs export_debug
95 all_optimized: optimized optimized1 optimizedkernel docs export_optimized
97 # Do everything
98 world: all create_jdk
100 # Build or export docs
101 docs:
102 ifeq ($(OSNAME),windows)
103 @$(ECHO) "No docs ($(VM_TARGET)) for windows"
104 else
105 $(CD) $(OUTPUTDIR); \
106 $(MAKE) -f $(ABS_OS_MAKEFILE) \
107 $(MAKE_ARGS) docs
108 endif
110 # Build variation of hotspot
111 $(C1_VM_TARGETS):
112 $(CD) $(GAMMADIR)/make; \
113 $(MAKE) VM_TARGET=$@ generic_build1 $(ALT_OUT)
115 $(C2_VM_TARGETS):
116 $(CD) $(GAMMADIR)/make; \
117 $(MAKE) VM_TARGET=$@ generic_build2 $(ALT_OUT)
119 $(KERNEL_VM_TARGETS):
120 $(CD) $(GAMMADIR)/make; \
121 $(MAKE) VM_TARGET=$@ generic_buildkernel $(ALT_OUT)
123 # Build compiler1 (client) rule, different for platforms
124 generic_build1:
125 $(MKDIR) -p $(OUTPUTDIR)
126 ifeq ($(OSNAME),windows)
127 ifeq ($(ARCH_DATA_MODEL), 32)
128 $(CD) $(OUTPUTDIR); \
129 $(NMAKE) -f $(ABS_OS_MAKEFILE) \
130 Variant=compiler1 \
131 WorkSpace=$(ABS_GAMMADIR) \
132 BootStrapDir=$(ABS_BOOTDIR) \
133 BuildUser=$(USERNAME) \
134 $(MAKE_ARGS) $(VM_TARGET:%1=%)
135 else
136 @$(ECHO) "No compiler1 ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
137 endif
138 else
139 ifeq ($(ARCH_DATA_MODEL), 32)
140 $(CD) $(OUTPUTDIR); \
141 $(MAKE) -f $(ABS_OS_MAKEFILE) \
142 $(MAKE_ARGS) $(VM_TARGET)
143 else
144 @$(ECHO) "No compiler1 ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
145 endif
146 endif
148 # Build compiler2 (server) rule, different for platforms
149 generic_build2:
150 $(MKDIR) -p $(OUTPUTDIR)
151 ifeq ($(OSNAME),windows)
152 $(CD) $(OUTPUTDIR); \
153 $(NMAKE) -f $(ABS_OS_MAKEFILE) \
154 Variant=compiler2 \
155 WorkSpace=$(ABS_GAMMADIR) \
156 BootStrapDir=$(ABS_BOOTDIR) \
157 BuildUser=$(USERNAME) \
158 $(MAKE_ARGS) $(VM_TARGET)
159 else
160 $(CD) $(OUTPUTDIR); \
161 $(MAKE) -f $(ABS_OS_MAKEFILE) \
162 $(MAKE_ARGS) $(VM_TARGET)
163 endif
165 generic_buildkernel:
166 $(MKDIR) -p $(OUTPUTDIR)
167 ifeq ($(OSNAME),windows)
168 ifeq ($(ARCH_DATA_MODEL), 32)
169 $(CD) $(OUTPUTDIR); \
170 $(NMAKE) -f $(ABS_OS_MAKEFILE) \
171 Variant=kernel \
172 WorkSpace=$(ABS_GAMMADIR) \
173 BootStrapDir=$(ABS_BOOTDIR) \
174 BuildUser=$(USERNAME) \
175 $(MAKE_ARGS) $(VM_TARGET:%kernel=%)
176 else
177 @$(ECHO) "No kernel ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)"
178 endif
179 else
180 @$(ECHO) "No kernel ($(VM_TARGET)) for OS_NAME=$(OSNAME)"
181 endif
183 # Export file rule
184 generic_export: $(EXPORT_LIST)
185 export_product:
186 $(MAKE) VM_SUBDIR=product generic_export
187 export_fastdebug:
188 $(MAKE) VM_SUBDIR=fastdebug EXPORT_SUBDIR=/fastdebug generic_export
189 export_debug:
190 $(MAKE) VM_SUBDIR=${VM_DEBUG} EXPORT_SUBDIR=/debug generic_export
191 export_optimized:
192 $(MAKE) VM_SUBDIR=optimized EXPORT_SUBDIR=/optimized generic_export
193 export_product_jdk:
194 $(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
195 VM_SUBDIR=product generic_export
196 export_optimized_jdk:
197 $(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
198 VM_SUBDIR=optimized generic_export
199 export_fastdebug_jdk:
200 $(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/fastdebug \
201 VM_SUBDIR=fastdebug generic_export
202 export_debug_jdk:
203 $(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/debug \
204 VM_SUBDIR=${VM_DEBUG} generic_export
207 # Export file copy rules
208 XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt
209 DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs
210 C1_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1
211 C2_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2
212 KERNEL_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_kernel
213 C1_DIR=$(C1_BASE_DIR)/$(VM_SUBDIR)
214 C2_DIR=$(C2_BASE_DIR)/$(VM_SUBDIR)
215 KERNEL_DIR=$(KERNEL_BASE_DIR)/$(VM_SUBDIR)
217 # Misc files and generated files need to come from C1 or C2 area
218 ifeq ($(ARCH_DATA_MODEL), 32)
219 MISC_DIR=$(C1_DIR)
220 GEN_DIR=$(C1_BASE_DIR)/generated
221 else
222 MISC_DIR=$(C2_DIR)
223 GEN_DIR=$(C2_BASE_DIR)/generated
224 endif
226 # Bin files (windows)
227 ifeq ($(OSNAME),windows)
229 # Get jvm.lib
230 $(EXPORT_LIB_DIR)/%.lib: $(MISC_DIR)/%.lib
231 $(install-file)
233 # Other libraries (like SA)
234 $(EXPORT_JRE_BIN_DIR)/%.dll: $(MISC_DIR)/%.dll
235 $(install-file)
236 $(EXPORT_JRE_BIN_DIR)/%.pdb: $(MISC_DIR)/%.pdb
237 $(install-file)
238 $(EXPORT_JRE_BIN_DIR)/%.map: $(MISC_DIR)/%.map
239 $(install-file)
241 # Client files always come from C1 area
242 $(EXPORT_CLIENT_DIR)/%.dll: $(C1_DIR)/%.dll
243 $(install-file)
244 $(EXPORT_CLIENT_DIR)/%.pdb: $(C1_DIR)/%.pdb
245 $(install-file)
246 $(EXPORT_CLIENT_DIR)/%.map: $(C1_DIR)/%.map
247 $(install-file)
249 # Server files always come from C2 area
250 $(EXPORT_SERVER_DIR)/%.dll: $(C2_DIR)/%.dll
251 $(install-file)
252 $(EXPORT_SERVER_DIR)/%.pdb: $(C2_DIR)/%.pdb
253 $(install-file)
254 $(EXPORT_SERVER_DIR)/%.map: $(C2_DIR)/%.map
255 $(install-file)
257 # Kernel files always come from kernel area
258 $(EXPORT_KERNEL_DIR)/%.dll: $(KERNEL_DIR)/%.dll
259 $(install-file)
260 $(EXPORT_KERNEL_DIR)/%.pdb: $(KERNEL_DIR)/%.pdb
261 $(install-file)
262 $(EXPORT_KERNEL_DIR)/%.map: $(KERNEL_DIR)/%.map
263 $(install-file)
264 endif
266 # Shared Library
267 ifneq ($(OSNAME),windows)
268 $(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(C2_DIR)/%.so
269 $(install-file)
270 $(EXPORT_CLIENT_DIR)/%.so: $(C1_DIR)/%.so
271 $(install-file)
272 $(EXPORT_CLIENT_DIR)/64/%.so: $(C1_DIR)/%.so
273 $(install-file)
274 $(EXPORT_SERVER_DIR)/%.so: $(C2_DIR)/%.so
275 $(install-file)
276 $(EXPORT_SERVER_DIR)/64/%.so: $(C2_DIR)/%.so
277 $(install-file)
278 endif
280 # Jar file (sa-jdi.jar)
281 $(EXPORT_LIB_DIR)/%.jar: $(GEN_DIR)/%.jar
282 $(install-file)
284 # Include files (jvmti.h, jni.h, $(JDK_INCLUDE_SUBDIR)/jni_md.h, jmm.h)
285 $(EXPORT_INCLUDE_DIR)/%: $(GEN_DIR)/jvmtifiles/%
286 $(install-file)
288 $(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/prims/%
289 $(install-file)
291 $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h: $(HS_SRC_DIR)/cpu/$(HS_ARCH)/vm/jni_$(HS_ARCH).h
292 $(install-file)
294 $(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/services/%
295 $(install-file)
297 # Doc files (jvmti.html)
298 $(EXPORT_DOCS_DIR)/platform/jvmti/%: $(DOCS_DIR)/%
299 $(install-file)
301 # Xusage file
302 $(EXPORT_SERVER_DIR)/Xusage.txt $(EXPORT_CLIENT_DIR)/Xusage.txt $(EXPORT_KERNEL_DIR)/Xusage.txt: $(XUSAGE)
303 $(prep-target)
304 $(RM) $@.temp
305 $(SED) 's/\(separated by \)[;:]/\1$(PATH_SEP)/g' $< > $@.temp
306 $(MV) $@.temp $@
308 #
309 # Clean rules
310 #
311 clobber clean: clean_build clean_export clean_jdk
312 clean_build:
313 $(RM) -r $(C1_DIR)
314 $(RM) -r $(C2_DIR)
315 $(RM) -r $(KERNEL_DIR)
316 clean_export:
317 $(RM) -r $(EXPORT_PATH)
318 clean_jdk:
319 $(RM) -r $(JDK_IMAGE_DIR)
321 #
322 # Create JDK and place this build into it
323 #
324 create_jdk: copy_jdk update_jdk
326 update_jdk: export_product_jdk export_fastdebug_jdk test_jdk
328 copy_jdk: $(JDK_IMAGE_DIR)/jre/lib/rt.jar
330 $(JDK_IMAGE_DIR)/jre/lib/rt.jar:
331 $(RM) -r $(JDK_IMAGE_DIR)
332 $(MKDIR) -p $(JDK_IMAGE_DIR)
333 ($(CD) $(JDK_IMPORT_PATH) && \
334 $(TAR) -cf - *) | \
335 ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -)
337 test_jdk:
338 ifeq ($(ARCH_DATA_MODEL), 32)
339 $(JDK_IMAGE_DIR)/bin/java -client -version
340 endif
341 $(JDK_IMAGE_DIR)/bin/java -server -version
343 copy_product_jdk:
344 $(RM) -r $(JDK_IMAGE_DIR)
345 $(MKDIR) -p $(JDK_IMAGE_DIR)
346 ($(CD) $(JDK_IMPORT_PATH) && \
347 $(TAR) -cf - $(JDK_DIRS)) | \
348 ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -)
350 copy_fastdebug_jdk:
351 $(RM) -r $(JDK_IMAGE_DIR)/fastdebug
352 $(MKDIR) -p $(JDK_IMAGE_DIR)/fastdebug
353 if [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \
354 ($(CD) $(JDK_IMPORT_PATH)/fastdebug && \
355 $(TAR) -cf - $(JDK_DIRS)) | \
356 ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \
357 else \
358 ($(CD) $(JDK_IMPORT_PATH) && \
359 $(TAR) -cf - $(JDK_DIRS)) | \
360 ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \
361 fi
363 copy_debug_jdk:
364 $(RM) -r $(JDK_IMAGE_DIR)/debug
365 $(MKDIR) -p $(JDK_IMAGE_DIR)/debug
366 if [ -d $(JDK_IMPORT_PATH)/debug ] ; then \
367 ($(CD) $(JDK_IMPORT_PATH)/debug && \
368 $(TAR) -cf - $(JDK_DIRS)) | \
369 ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
370 elif [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \
371 ($(CD) $(JDK_IMPORT_PATH)/fastdebug && \
372 $(TAR) -cf - $(JDK_DIRS)) | \
373 ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
374 else \
375 ($(CD) $(JDK_IMPORT_PATH) && \
376 $(TAR) -cf - $(JDK_DIRS)) | \
377 ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
378 fi
380 #
381 # Check target
382 #
383 check: variable_check
385 #
386 # Help target
387 #
388 help: intro_help target_help variable_help notes_help examples_help
390 # Intro help message
391 intro_help:
392 @$(ECHO) \
393 "Makefile for the Hotspot workspace."
394 @$(ECHO) \
395 "Default behavior is to build and create an export area for the j2se builds."
397 # Target help
398 target_help:
399 @$(ECHO) "help: This help message"
400 @$(ECHO) "all: Same as: all_product all_fastdebug"
401 @$(ECHO) "world: Same as: all create_jdk"
402 @$(ECHO) "all_product: Same as: product product1 export_product"
403 @$(ECHO) "all_fastdebug: Same as: fastdebug fastdebug1 export_fastdebug"
404 @$(ECHO) "all_debug: Same as: jvmg jvmg1 export_debug"
405 @$(ECHO) "all_optimized: Same as: optimized optimized1 export_optimized"
406 @$(ECHO) "clean: Clean all areas"
407 @$(ECHO) "export_product: Export product files to EXPORT_PATH"
408 @$(ECHO) "export_fastdebug: Export fastdebug files to EXPORT_PATH"
409 @$(ECHO) "export_debug: Export debug files to EXPORT_PATH"
410 @$(ECHO) "export_optimized: Export optimized files to EXPORT_PATH"
411 @$(ECHO) "create_jdk: Create JDK image, export all files into it"
412 @$(ECHO) "update_jdk: Update JDK image with fresh exported files"
413 @$(ECHO) " "
414 @$(ECHO) "Others targets are:"
415 @$(ECHO) " $(C1_VM_TARGETS)"
416 @$(ECHO) " $(C2_VM_TARGETS)"
417 @$(ECHO) " $(KERNEL_VM_TARGETS)"
419 # Variable help (only common ones used by this workspace)
420 variable_help: variable_help_intro variable_list variable_help_end
421 variable_help_intro:
422 @$(ECHO) "--- Common Variables ---"
423 variable_help_end:
424 @$(ECHO) " "
425 @$(ECHO) "--- Make Arguments ---"
426 @$(ECHO) "MAKE_ARGS=$(MAKE_ARGS)"
428 # One line descriptions for the variables
429 SLASH_JAVA.desc = Root of all build tools, e.g. /java or J:
430 OUTPUTDIR.desc = Output directory, default is build/<osname>
431 BOOTDIR.desc = JDK used to compile agent java source and test with
432 JDK_IMPORT_PATH.desc = Promoted JDK to copy for 'create_jdk'
433 EXPORT_PATH.desc = Directory to place files to export for JDK build
435 # Make variables to print out (description and value)
436 VARIABLE_PRINTVAL_LIST += \
437 SLASH_JAVA \
438 OUTPUTDIR \
439 BOOTDIR \
440 JDK_IMPORT_PATH \
441 EXPORT_PATH
443 # Make variables that should refer to directories that exist
444 VARIABLE_CHECKDIR_LIST += \
445 SLASH_JAVA \
446 BOOTDIR \
447 JDK_IMPORT_PATH
449 # For pattern rules below, so all are treated the same
450 DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval)
451 DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir)
453 # Complete variable check
454 variable_check: $(DO_CHECKDIR_LIST)
455 variable_list: $(DO_PRINTVAL_LIST) variable_check
457 # Pattern rule for printing out a variable
458 %.printval:
459 @$(ECHO) " ALT_$* - $($*.desc)"
460 @$(ECHO) " $*=$($*)"
462 # Pattern rule for checking to see if a variable with a directory exists
463 %.checkdir:
464 @if [ ! -d $($*) ] ; then \
465 $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
466 fi
468 # Pattern rule for checking to see if a variable with a file exists
469 %.checkfil:
470 @if [ ! -f $($*) ] ; then \
471 $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
472 fi
474 # Misc notes on help
475 notes_help:
476 @$(ECHO) \
477 "--- Notes --- "
478 @$(ECHO) \
479 "- JDK_IMPORT_PATH must refer to a compatible build, not all past promoted"
480 @$(ECHO) \
481 " builds or previous release JDK builds will work."
482 @$(ECHO) \
483 "- The fastest builds have been when the workspace and the BOOTDIR are on"
484 @$(ECHO) \
485 " local disk."
487 examples_help:
488 @$(ECHO) \
489 "--- Examples --- "
490 @$(ECHO) \
491 " $(MAKE) all"
492 @$(ECHO) \
493 " $(MAKE) world"
494 @$(ECHO) \
495 " $(MAKE) ALT_BOOTDIR=/opt/java/jdk$(PREVIOUS_JDK_VERSION)"
496 @$(ECHO) \
497 " $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk$(JDK_VERSION)"
499 # JPRT rule to build this workspace
500 include $(GAMMADIR)/make/jprt.gmk
502 .PHONY: all world clobber clean help $(C1_VM_TARGETS) $(C2_VM_TARGETS) \
503 $(KERNEL_VM_TARGETS) \
504 generic_build1 generic_build2 generic_buildkernel generic_export \
505 export_product export_fastdebug export_debug export_optimized \
506 export_jdk_product export_jdk_fastdebug export_jdk_debug \
507 create_jdk copy_jdk update_jdk test_jdk \
508 copy_product_jdk copy_fastdebug_jdk copy_debug_jdk