Merge

Thu, 16 May 2013 13:47:55 -0700

author
twisti
date
Thu, 16 May 2013 13:47:55 -0700
changeset 5115
e484fe2abebd
parent 5104
513a5298c1dd
parent 5114
cd6f6fccd287
child 5126
2f9ac66165e6

Merge

make/bsd/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/bsd/makefiles/vm.make file | annotate | diff | comparison | revisions
make/linux/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/solaris/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/windows/makefiles/launcher.make file | annotate | diff | comparison | revisions
src/os/posix/launcher/java_md.c file | annotate | diff | comparison | revisions
src/os/posix/launcher/java_md.h file | annotate | diff | comparison | revisions
src/os/posix/launcher/launcher.script file | annotate | diff | comparison | revisions
src/os/windows/launcher/java_md.c file | annotate | diff | comparison | revisions
src/os/windows/launcher/java_md.h file | annotate | diff | comparison | revisions
src/share/tools/launcher/java.c file | annotate | diff | comparison | revisions
src/share/tools/launcher/java.h file | annotate | diff | comparison | revisions
src/share/tools/launcher/jli_util.c file | annotate | diff | comparison | revisions
src/share/tools/launcher/jli_util.h file | annotate | diff | comparison | revisions
src/share/tools/launcher/wildcard.c file | annotate | diff | comparison | revisions
src/share/tools/launcher/wildcard.h file | annotate | diff | comparison | revisions
src/share/vm/classfile/classFileParser.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/method.cpp file | annotate | diff | comparison | revisions
src/share/vm/prims/methodHandles.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/vmStructs.cpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/quickSort.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/make/Makefile	Tue May 14 17:33:07 2013 +0000
     1.2 +++ b/make/Makefile	Thu May 16 13:47:55 2013 -0700
     1.3 @@ -151,32 +151,43 @@
     1.4  		      $(MAKE_ARGS) BUILD_FLAVOR=product docs
     1.5  endif
     1.6  
     1.7 +# Output directories
     1.8 +C1_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1
     1.9 +C2_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2
    1.10 +MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1
    1.11 +ZERO_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_zero
    1.12 +SHARK_DIR   =$(OUTPUTDIR)/$(VM_PLATFORM)_shark
    1.13 +
    1.14  # Build variation of hotspot
    1.15  $(C1_VM_TARGETS):
    1.16  	$(CD) $(GAMMADIR)/make; \
    1.17 -	$(MAKE) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
    1.18 +	$(MAKE) BUILD_DIR=$(C1_DIR) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
    1.19  
    1.20  $(C2_VM_TARGETS):
    1.21  	$(CD) $(GAMMADIR)/make; \
    1.22 -	$(MAKE) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
    1.23 +	$(MAKE) BUILD_DIR=$(C2_DIR) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
    1.24  
    1.25  $(ZERO_VM_TARGETS):
    1.26  	$(CD) $(GAMMADIR)/make; \
    1.27 -	$(MAKE) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ \
    1.28 -	  generic_buildzero $(ALT_OUT)
    1.29 +	$(MAKE) BUILD_DIR=$(ZERO_DIR) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ generic_buildzero $(ALT_OUT)
    1.30  
    1.31  $(SHARK_VM_TARGETS):
    1.32  	$(CD) $(GAMMADIR)/make; \
    1.33 -	$(MAKE) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ \
    1.34 -	  generic_buildshark $(ALT_OUT)
    1.35 +	$(MAKE) BUILD_DIR=$(SHARK_DIR) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ generic_buildshark $(ALT_OUT)
    1.36  
    1.37  $(MINIMAL1_VM_TARGETS):
    1.38  	$(CD) $(GAMMADIR)/make; \
    1.39 -	$(MAKE) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ \
    1.40 -	  generic_buildminimal1 $(ALT_OUT)
    1.41 +	$(MAKE) BUILD_DIR=$(MINIMAL1_DIR) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ generic_buildminimal1 $(ALT_OUT)
    1.42 +
    1.43 +# Install hotspot script in build directory
    1.44 +HOTSPOT_SCRIPT=$(BUILD_DIR)/$(BUILD_FLAVOR)/hotspot
    1.45 +$(HOTSPOT_SCRIPT): $(GAMMADIR)/make/hotspot.script
    1.46 +	$(QUIETLY) $(MKDIR) -p $(BUILD_DIR)/$(BUILD_FLAVOR)
    1.47 +	$(QUIETLY) cat $< | sed -e 's|@@LIBARCH@@|$(LIBARCH)|g' | sed -e 's|@@JDK_IMPORT_PATH@@|$(JDK_IMPORT_PATH)|g' > $@
    1.48 +	$(QUIETLY) chmod +x $@
    1.49  
    1.50  # Build compiler1 (client) rule, different for platforms
    1.51 -generic_build1:
    1.52 +generic_build1: $(HOTSPOT_SCRIPT)
    1.53  	$(MKDIR) -p $(OUTPUTDIR)
    1.54  ifeq ($(OSNAME),windows)
    1.55    ifeq ($(ARCH_DATA_MODEL), 32)
    1.56 @@ -201,7 +212,7 @@
    1.57  endif
    1.58  
    1.59  # Build compiler2 (server) rule, different for platforms
    1.60 -generic_build2:
    1.61 +generic_build2: $(HOTSPOT_SCRIPT)
    1.62  	$(MKDIR) -p $(OUTPUTDIR)
    1.63  ifeq ($(OSNAME),windows)
    1.64  	$(CD) $(OUTPUTDIR); \
    1.65 @@ -217,19 +228,19 @@
    1.66  		      $(MAKE_ARGS) $(VM_TARGET)
    1.67  endif
    1.68  
    1.69 -generic_buildzero:
    1.70 +generic_buildzero: $(HOTSPOT_SCRIPT)
    1.71  	$(MKDIR) -p $(OUTPUTDIR)
    1.72  	$(CD) $(OUTPUTDIR); \
    1.73  		$(MAKE) -f $(ABS_OS_MAKEFILE) \
    1.74  			$(MAKE_ARGS) $(VM_TARGET)
    1.75  
    1.76 -generic_buildshark:
    1.77 +generic_buildshark: $(HOTSPOT_SCRIPT)
    1.78  	$(MKDIR) -p $(OUTPUTDIR)
    1.79  	$(CD) $(OUTPUTDIR); \
    1.80  		$(MAKE) -f $(ABS_OS_MAKEFILE) \
    1.81  			$(MAKE_ARGS) $(VM_TARGET)
    1.82  
    1.83 -generic_buildminimal1:
    1.84 +generic_buildminimal1: $(HOTSPOT_SCRIPT)
    1.85  ifeq ($(JVM_VARIANT_MINIMAL1),true)
    1.86  	$(MKDIR) -p $(OUTPUTDIR)
    1.87    ifeq ($(ARCH_DATA_MODEL), 32)
    1.88 @@ -252,224 +263,210 @@
    1.89  
    1.90  # Export file rule
    1.91  generic_export: $(EXPORT_LIST)
    1.92 +
    1.93  export_product:
    1.94 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
    1.95 -          generic_export
    1.96 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) generic_export
    1.97  export_fastdebug:
    1.98 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
    1.99 -	  EXPORT_SUBDIR=/$(@:export_%=%) \
   1.100 -	  generic_export
   1.101 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
   1.102  export_debug:
   1.103 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
   1.104 -	  EXPORT_SUBDIR=/$(@:export_%=%) \
   1.105 -	  generic_export
   1.106 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
   1.107  export_optimized:
   1.108 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
   1.109 -	  EXPORT_SUBDIR=/$(@:export_%=%) \
   1.110 -	  generic_export
   1.111 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
   1.112 +
   1.113  export_product_jdk::
   1.114 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
   1.115 -	  VM_SUBDIR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
   1.116 -	  generic_export
   1.117 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
   1.118  export_optimized_jdk::
   1.119 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
   1.120 -	  VM_SUBDIR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
   1.121 -	  generic_export
   1.122 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
   1.123  export_fastdebug_jdk::
   1.124 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
   1.125 -	  VM_SUBDIR=$(@:export_%_jdk=%)  \
   1.126 -	  ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) \
   1.127 -	  generic_export
   1.128 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
   1.129  export_debug_jdk::
   1.130 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) VM_SUBDIR=$(@:export_%_jdk=%) \
   1.131 -	  ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) \
   1.132 -	  generic_export
   1.133 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
   1.134  
   1.135  # Export file copy rules
   1.136  XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt
   1.137 -DOCS_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_docs
   1.138 -C1_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1/$(VM_SUBDIR)
   1.139 -C2_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2/$(VM_SUBDIR)
   1.140 -MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1/$(VM_SUBDIR)
   1.141 -ZERO_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_zero/$(VM_SUBDIR)
   1.142 -SHARK_DIR   =$(OUTPUTDIR)/$(VM_PLATFORM)_shark/$(VM_SUBDIR)
   1.143 +DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs
   1.144 +C1_BUILD_DIR      =$(C1_DIR)/$(BUILD_FLAVOR)
   1.145 +C2_BUILD_DIR      =$(C2_DIR)/$(BUILD_FLAVOR)
   1.146 +MINIMAL1_BUILD_DIR=$(MINIMAL1_DIR)/$(BUILD_FLAVOR)
   1.147 +ZERO_BUILD_DIR    =$(ZERO_DIR)/$(BUILD_FLAVOR)
   1.148 +SHARK_BUILD_DIR   =$(SHARK_DIR)/$(BUILD_FLAVOR)
   1.149  
   1.150  # Server (C2)
   1.151  ifeq ($(JVM_VARIANT_SERVER), true)
   1.152  # Common
   1.153 -$(EXPORT_SERVER_DIR)/%.diz:       		$(C2_DIR)/%.diz
   1.154 +$(EXPORT_SERVER_DIR)/%.diz:       		$(C2_BUILD_DIR)/%.diz
   1.155  	$(install-file)
   1.156 -$(EXPORT_LIB_DIR)/%.jar:			$(C2_DIR)/../generated/%.jar
   1.157 +$(EXPORT_LIB_DIR)/%.jar:			$(C2_BUILD_DIR)/../generated/%.jar
   1.158  	$(install-file)
   1.159 -$(EXPORT_INCLUDE_DIR)/%:			$(C2_DIR)/../generated/jvmtifiles/%
   1.160 +$(EXPORT_INCLUDE_DIR)/%:			$(C2_BUILD_DIR)/../generated/jvmtifiles/%
   1.161  	$(install-file)
   1.162  # Windows
   1.163 -$(EXPORT_SERVER_DIR)/%.dll:			$(C2_DIR)/%.dll
   1.164 +$(EXPORT_SERVER_DIR)/%.dll:			$(C2_BUILD_DIR)/%.dll
   1.165  	$(install-file)
   1.166 -$(EXPORT_SERVER_DIR)/%.pdb:			$(C2_DIR)/%.pdb
   1.167 +$(EXPORT_SERVER_DIR)/%.pdb:			$(C2_BUILD_DIR)/%.pdb
   1.168  	$(install-file)
   1.169 -$(EXPORT_SERVER_DIR)/%.map:			$(C2_DIR)/%.map
   1.170 +$(EXPORT_SERVER_DIR)/%.map:			$(C2_BUILD_DIR)/%.map
   1.171  	$(install-file)
   1.172 -$(EXPORT_LIB_DIR)/%.lib:			$(C2_DIR)/%.lib
   1.173 +$(EXPORT_LIB_DIR)/%.lib:			$(C2_BUILD_DIR)/%.lib
   1.174  	$(install-file)
   1.175 -$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C2_DIR)/%.diz
   1.176 +$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C2_BUILD_DIR)/%.diz
   1.177  	$(install-file)
   1.178 -$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C2_DIR)/%.dll
   1.179 +$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C2_BUILD_DIR)/%.dll
   1.180  	$(install-file)
   1.181 -$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C2_DIR)/%.pdb
   1.182 +$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C2_BUILD_DIR)/%.pdb
   1.183  	$(install-file)
   1.184 -$(EXPORT_JRE_BIN_DIR)/%.map:			$(C2_DIR)/%.map
   1.185 +$(EXPORT_JRE_BIN_DIR)/%.map:			$(C2_BUILD_DIR)/%.map
   1.186  	$(install-file)
   1.187  # Unix
   1.188 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
   1.189 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.190  	$(install-file)
   1.191 -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_DIR)/%.$(LIBRARY_SUFFIX)
   1.192 +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.193  	$(install-file)
   1.194 -$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_DIR)/%.$(LIBRARY_SUFFIX)
   1.195 +$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.196  	$(install-file)
   1.197 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C2_DIR)/%.debuginfo
   1.198 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C2_BUILD_DIR)/%.debuginfo
   1.199  	$(install-file)
   1.200 -$(EXPORT_SERVER_DIR)/%.debuginfo:       	$(C2_DIR)/%.debuginfo
   1.201 +$(EXPORT_SERVER_DIR)/%.debuginfo:       	$(C2_BUILD_DIR)/%.debuginfo
   1.202  	$(install-file)
   1.203 -$(EXPORT_SERVER_DIR)/64/%.debuginfo:    	$(C2_DIR)/%.debuginfo
   1.204 +$(EXPORT_SERVER_DIR)/64/%.debuginfo:    	$(C2_BUILD_DIR)/%.debuginfo
   1.205  	$(install-file)
   1.206 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C2_DIR)/%.diz
   1.207 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C2_BUILD_DIR)/%.diz
   1.208  	$(install-file)
   1.209 -$(EXPORT_SERVER_DIR)/64/%.diz:    		$(C2_DIR)/%.diz
   1.210 +$(EXPORT_SERVER_DIR)/64/%.diz:    		$(C2_BUILD_DIR)/%.diz
   1.211  	$(install-file)
   1.212  endif
   1.213  
   1.214  # Client (C1)
   1.215  ifeq ($(JVM_VARIANT_CLIENT), true)
   1.216  # Common
   1.217 -$(EXPORT_CLIENT_DIR)/%.diz:       		$(C1_DIR)/%.diz
   1.218 +$(EXPORT_CLIENT_DIR)/%.diz:       		$(C1_BUILD_DIR)/%.diz
   1.219  	$(install-file)
   1.220 -$(EXPORT_LIB_DIR)/%.jar:			$(C1_DIR)/../generated/%.jar
   1.221 +$(EXPORT_LIB_DIR)/%.jar:			$(C1_BUILD_DIR)/../generated/%.jar
   1.222  	$(install-file)
   1.223 -$(EXPORT_INCLUDE_DIR)/%:			$(C1_DIR)/../generated/jvmtifiles/%
   1.224 +$(EXPORT_INCLUDE_DIR)/%:			$(C1_BUILD_DIR)/../generated/jvmtifiles/%
   1.225  	$(install-file)
   1.226  # Windows
   1.227 -$(EXPORT_CLIENT_DIR)/%.dll:			$(C1_DIR)/%.dll
   1.228 +$(EXPORT_CLIENT_DIR)/%.dll:			$(C1_BUILD_DIR)/%.dll
   1.229  	$(install-file)
   1.230 -$(EXPORT_CLIENT_DIR)/%.pdb:			$(C1_DIR)/%.pdb
   1.231 +$(EXPORT_CLIENT_DIR)/%.pdb:			$(C1_BUILD_DIR)/%.pdb
   1.232  	$(install-file)
   1.233 -$(EXPORT_CLIENT_DIR)/%.map:			$(C1_DIR)/%.map
   1.234 +$(EXPORT_CLIENT_DIR)/%.map:			$(C1_BUILD_DIR)/%.map
   1.235  	$(install-file)
   1.236 -$(EXPORT_LIB_DIR)/%.lib:			$(C1_DIR)/%.lib
   1.237 +$(EXPORT_LIB_DIR)/%.lib:			$(C1_BUILD_DIR)/%.lib
   1.238  	$(install-file)
   1.239 -$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C1_DIR)/%.diz
   1.240 +$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C1_BUILD_DIR)/%.diz
   1.241  	$(install-file)
   1.242 -$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C1_DIR)/%.dll
   1.243 +$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C1_BUILD_DIR)/%.dll
   1.244  	$(install-file)
   1.245 -$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C1_DIR)/%.pdb
   1.246 +$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C1_BUILD_DIR)/%.pdb
   1.247  	$(install-file)
   1.248 -$(EXPORT_JRE_BIN_DIR)/%.map:			$(C1_DIR)/%.map
   1.249 +$(EXPORT_JRE_BIN_DIR)/%.map:			$(C1_BUILD_DIR)/%.map
   1.250  	$(install-file)
   1.251  # Unix
   1.252 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
   1.253 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.254  	$(install-file)
   1.255 -$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_DIR)/%.$(LIBRARY_SUFFIX)
   1.256 +$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.257  	$(install-file)
   1.258 -$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_DIR)/%.$(LIBRARY_SUFFIX)
   1.259 +$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.260  	$(install-file)
   1.261 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C1_DIR)/%.debuginfo
   1.262 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C1_BUILD_DIR)/%.debuginfo
   1.263  	$(install-file)
   1.264 -$(EXPORT_CLIENT_DIR)/%.debuginfo:       	$(C1_DIR)/%.debuginfo
   1.265 +$(EXPORT_CLIENT_DIR)/%.debuginfo:       	$(C1_BUILD_DIR)/%.debuginfo
   1.266  	$(install-file)
   1.267 -$(EXPORT_CLIENT_DIR)/64/%.debuginfo:    	$(C1_DIR)/%.debuginfo
   1.268 +$(EXPORT_CLIENT_DIR)/64/%.debuginfo:    	$(C1_BUILD_DIR)/%.debuginfo
   1.269  	$(install-file)
   1.270 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C1_DIR)/%.diz
   1.271 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C1_BUILD_DIR)/%.diz
   1.272  	$(install-file)
   1.273 -$(EXPORT_CLIENT_DIR)/64/%.diz:    		$(C1_DIR)/%.diz
   1.274 +$(EXPORT_CLIENT_DIR)/64/%.diz:    		$(C1_BUILD_DIR)/%.diz
   1.275  	$(install-file)
   1.276  endif
   1.277  
   1.278  # Minimal1
   1.279  ifeq ($(JVM_VARIANT_MINIMAL1), true)
   1.280  # Common
   1.281 -$(EXPORT_MINIMAL_DIR)/%.diz:			$(MINIMAL1_DIR)/%.diz
   1.282 +$(EXPORT_MINIMAL_DIR)/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
   1.283  	$(install-file)
   1.284 -$(EXPORT_LIB_DIR)/%.jar:			$(MINIMAL1_DIR)/../generated/%.jar
   1.285 +$(EXPORT_LIB_DIR)/%.jar:			$(MINIMAL1_BUILD_DIR)/../generated/%.jar
   1.286  	$(install-file)
   1.287 -$(EXPORT_INCLUDE_DIR)/%:			$(MINIMAL1_DIR)/../generated/jvmtifiles/%
   1.288 +$(EXPORT_INCLUDE_DIR)/%:			$(MINIMAL1_BUILD_DIR)/../generated/jvmtifiles/%
   1.289  	$(install-file)
   1.290  # Windows
   1.291 -$(EXPORT_MINIMAL_DIR)/%.dll:			$(MINIMAL1_DIR)/%.dll
   1.292 +$(EXPORT_MINIMAL_DIR)/%.dll:			$(MINIMAL1_BUILD_DIR)/%.dll
   1.293  	$(install-file)
   1.294 -$(EXPORT_MINIMAL_DIR)/%.pdb:			$(MINIMAL1_DIR)/%.pdb
   1.295 +$(EXPORT_MINIMAL_DIR)/%.pdb:			$(MINIMAL1_BUILD_DIR)/%.pdb
   1.296  	$(install-file)
   1.297 -$(EXPORT_MINIMAL_DIR)/%.map:			$(MINIMAL1_DIR)/%.map
   1.298 +$(EXPORT_MINIMAL_DIR)/%.map:			$(MINIMAL1_BUILD_DIR)/%.map
   1.299  	$(install-file)
   1.300 -$(EXPORT_LIB_DIR)/%.lib:			$(MINIMAL1_DIR)/%.lib
   1.301 +$(EXPORT_LIB_DIR)/%.lib:			$(MINIMAL1_BUILD_DIR)/%.lib
   1.302  	$(install-file)
   1.303 -$(EXPORT_JRE_BIN_DIR)/%.diz:			$(MINIMAL1_DIR)/%.diz
   1.304 +$(EXPORT_JRE_BIN_DIR)/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
   1.305  	$(install-file)
   1.306 -$(EXPORT_JRE_BIN_DIR)/%.dll:			$(MINIMAL1_DIR)/%.dll
   1.307 +$(EXPORT_JRE_BIN_DIR)/%.dll:			$(MINIMAL1_BUILD_DIR)/%.dll
   1.308  	$(install-file)
   1.309 -$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(MINIMAL1_DIR)/%.pdb
   1.310 +$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(MINIMAL1_BUILD_DIR)/%.pdb
   1.311  	$(install-file)
   1.312 -$(EXPORT_JRE_BIN_DIR)/%.map:			$(MINIMAL1_DIR)/%.map
   1.313 +$(EXPORT_JRE_BIN_DIR)/%.map:			$(MINIMAL1_BUILD_DIR)/%.map
   1.314  	$(install-file)
   1.315  # Unix
   1.316 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
   1.317 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.318  	$(install-file)
   1.319 -$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
   1.320 +$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.321  	$(install-file)
   1.322 -$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
   1.323 +$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.324  	$(install-file)
   1.325 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(MINIMAL1_DIR)/%.debuginfo
   1.326 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
   1.327  	$(install-file)
   1.328 -$(EXPORT_MINIMAL_DIR)/%.debuginfo:		$(MINIMAL1_DIR)/%.debuginfo
   1.329 +$(EXPORT_MINIMAL_DIR)/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
   1.330  	$(install-file)
   1.331 -$(EXPORT_MINIMAL_DIR)/64/%.debuginfo:		$(MINIMAL1_DIR)/%.debuginfo
   1.332 +$(EXPORT_MINIMAL_DIR)/64/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
   1.333  	$(install-file)
   1.334 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(MINIMAL1_DIR)/%.diz
   1.335 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(MINIMAL1_BUILD_DIR)/%.diz
   1.336  	$(install-file)
   1.337 -$(EXPORT_MINIMAL_DIR)/64/%.diz:			$(MINIMAL1_DIR)/%.diz
   1.338 +$(EXPORT_MINIMAL_DIR)/64/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
   1.339  	$(install-file)
   1.340  endif
   1.341  
   1.342  # Zero
   1.343  ifeq ($(JVM_VARIANT_ZERO), true)
   1.344  # Common
   1.345 -$(EXPORT_LIB_DIR)/%.jar:			$(ZERO_DIR)/../generated/%.jar
   1.346 +$(EXPORT_LIB_DIR)/%.jar:			$(ZERO_BUILD_DIR)/../generated/%.jar
   1.347  	$(install-file)
   1.348 -$(EXPORT_INCLUDE_DIR)/%:			$(ZERO_DIR)/../generated/jvmtifiles/%
   1.349 +$(EXPORT_INCLUDE_DIR)/%:			$(ZERO_BUILD_DIR)/../generated/jvmtifiles/%
   1.350  	$(install-file)
   1.351  # Unix
   1.352 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
   1.353 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.354  	$(install-file)
   1.355 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(ZERO_DIR)/%.debuginfo
   1.356 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(ZERO_BUILD_DIR)/%.debuginfo
   1.357  	$(install-file)
   1.358 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(ZERO_DIR)/%.diz
   1.359 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(ZERO_BUILD_DIR)/%.diz
   1.360  	$(install-file)
   1.361 -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
   1.362 +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.363  	$(install-file)
   1.364 -$(EXPORT_SERVER_DIR)/%.debuginfo:		$(ZERO_DIR)/%.debuginfo
   1.365 +$(EXPORT_SERVER_DIR)/%.debuginfo:		$(ZERO_BUILD_DIR)/%.debuginfo
   1.366  	$(install-file)
   1.367 -$(EXPORT_SERVER_DIR)/%.diz:			$(ZERO_DIR)/%.diz
   1.368 +$(EXPORT_SERVER_DIR)/%.diz:			$(ZERO_BUILD_DIR)/%.diz
   1.369  	$(install-file)
   1.370  endif
   1.371  
   1.372  # Shark
   1.373  ifeq ($(JVM_VARIANT_ZEROSHARK), true)
   1.374  # Common
   1.375 -$(EXPORT_LIB_DIR)/%.jar:			$(SHARK_DIR)/../generated/%.jar
   1.376 +$(EXPORT_LIB_DIR)/%.jar:			$(SHARK_BUILD_DIR)/../generated/%.jar
   1.377  	$(install-file)
   1.378 -$(EXPORT_INCLUDE_DIR)/%:			$(SHARK_DIR)/../generated/jvmtifiles/%
   1.379 +$(EXPORT_INCLUDE_DIR)/%:			$(SHARK_BUILD_DIR)/../generated/jvmtifiles/%
   1.380  	$(install-file)
   1.381  # Unix
   1.382 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
   1.383 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.384  	$(install-file)
   1.385 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo):	$(SHARK_DIR)/%.debuginfo
   1.386 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo):	$(SHARK_BUILD_DIR)/%.debuginfo
   1.387  	$(install-file)
   1.388 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(SHARK_DIR)/%.diz
   1.389 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(SHARK_BUILD_DIR)/%.diz
   1.390  	$(install-file)
   1.391 -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
   1.392 +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.393  	$(install-file)
   1.394 -$(EXPORT_SERVER_DIR)/%.debuginfo:		$(SHARK_DIR)/%.debuginfo
   1.395 +$(EXPORT_SERVER_DIR)/%.debuginfo:		$(SHARK_BUILD_DIR)/%.debuginfo
   1.396  	$(install-file)
   1.397 -$(EXPORT_SERVER_DIR)/%.diz:			$(SHARK_DIR)/%.diz
   1.398 +$(EXPORT_SERVER_DIR)/%.diz:			$(SHARK_BUILD_DIR)/%.diz
   1.399  	$(install-file)
   1.400  endif
   1.401  
     2.1 --- a/make/bsd/makefiles/buildtree.make	Tue May 14 17:33:07 2013 +0000
     2.2 +++ b/make/bsd/makefiles/buildtree.make	Thu May 16 13:47:55 2013 -0700
     2.3 @@ -49,7 +49,6 @@
     2.4  # adlc.make	-
     2.5  # jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
     2.6  # sa.make	- generate SA jar file and natives
     2.7 -# env.[ck]sh	- environment settings
     2.8  #
     2.9  # The makefiles are split this way so that "make foo" will run faster by not
    2.10  # having to read the dependency files for the vm.
    2.11 @@ -129,9 +128,7 @@
    2.12  BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
    2.13  
    2.14  # dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
    2.15 -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make \
    2.16 -	jvmti.make sa.make dtrace.make \
    2.17 -        env.sh env.csh jdkpath.sh
    2.18 +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make dtrace.make
    2.19  
    2.20  BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
    2.21  	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
    2.22 @@ -354,33 +351,6 @@
    2.23  	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
    2.24  	) > $@
    2.25  
    2.26 -env.sh: $(BUILDTREE_MAKE)
    2.27 -	@echo Creating $@ ...
    2.28 -	$(QUIETLY) ( \
    2.29 -	$(BUILDTREE_COMMENT); \
    2.30 -	{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
    2.31 -	{ \
    2.32 -	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
    2.33 -	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
    2.34 -	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
    2.35 -	echo "export JAVA_HOME CLASSPATH HOTSPOT_BUILD_USER"; \
    2.36 -	) > $@
    2.37 -
    2.38 -env.csh: env.sh
    2.39 -	@echo Creating $@ ...
    2.40 -	$(QUIETLY) ( \
    2.41 -	$(BUILDTREE_COMMENT); \
    2.42 -	{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
    2.43 -	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
    2.44 -	) > $@
    2.45 -
    2.46 -jdkpath.sh: $(BUILDTREE_MAKE)
    2.47 -	@echo Creating $@ ...
    2.48 -	$(QUIETLY) ( \
    2.49 -	$(BUILDTREE_COMMENT); \
    2.50 -	echo "JDK=${JAVA_HOME}"; \
    2.51 -	) > $@
    2.52 -
    2.53  FORCE:
    2.54  
    2.55  .PHONY:  all FORCE
     3.1 --- a/make/bsd/makefiles/launcher.make	Tue May 14 17:33:07 2013 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,115 +0,0 @@
     3.4 -#
     3.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 -#
     3.8 -# This code is free software; you can redistribute it and/or modify it
     3.9 -# under the terms of the GNU General Public License version 2 only, as
    3.10 -# published by the Free Software Foundation.
    3.11 -#
    3.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 -# version 2 for more details (a copy is included in the LICENSE file that
    3.16 -# accompanied this code).
    3.17 -#
    3.18 -# You should have received a copy of the GNU General Public License version
    3.19 -# 2 along with this work; if not, write to the Free Software Foundation,
    3.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 -#
    3.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 -# or visit www.oracle.com if you need additional information or have any
    3.24 -# questions.
    3.25 -#
    3.26 -#
    3.27 -
    3.28 -# Rules to build gamma launcher, used by vm.make
    3.29 -
    3.30 -
    3.31 -LAUNCHER_SCRIPT = hotspot
    3.32 -LAUNCHER   = gamma
    3.33 -
    3.34 -LAUNCHERDIR   := $(GAMMADIR)/src/os/posix/launcher
    3.35 -LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
    3.36 -LAUNCHERFLAGS := $(ARCHFLAG) \
    3.37 -                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
    3.38 -                -I$(LAUNCHERDIR_SHARE) \
    3.39 -                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
    3.40 -                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
    3.41 -                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
    3.42 -                -DARCH=\"$(LIBARCH)\" \
    3.43 -                -DGAMMA \
    3.44 -                -DLAUNCHER_TYPE=\"gamma\" \
    3.45 -                -DLINK_INTO_$(LINK_INTO) \
    3.46 -                $(TARGET_DEFINES)
    3.47 -# Give the launcher task_for_pid() privileges so that it can be used to run JStack, JInfo, et al.
    3.48 -LFLAGS_LAUNCHER += -sectcreate __TEXT __info_plist $(GAMMADIR)/src/os/bsd/launcher/Info-privileged.plist
    3.49 -
    3.50 -ifeq ($(LINK_INTO),AOUT)
    3.51 -  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
    3.52 -  LAUNCHER_MAPFILE           = mapfile_reorder
    3.53 -  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
    3.54 -  LFLAGS_LAUNCHER           += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
    3.55 -  LIBS_LAUNCHER             += $(STATIC_STDCXX) $(LIBS)
    3.56 -else
    3.57 -  LAUNCHER.o                 = launcher.o
    3.58 -  LFLAGS_LAUNCHER           += -L`pwd`
    3.59 -
    3.60 -  # The gamma launcher runs the JDK from $JAVA_HOME, overriding the JVM with a
    3.61 -  # freshly built JVM at ./libjvm.{so|dylib}.  This is accomplished by setting
    3.62 -  # the library searchpath using ({DY}LD_LIBRARY_PATH) to find the local JVM
    3.63 -  # first.  Gamma dlopen()s libjava from $JAVA_HOME/jre/lib{/$arch}, which is
    3.64 -  # statically linked with CoreFoundation framework libs. Unfortunately, gamma's
    3.65 -  # unique searchpath results in some unresolved symbols in the framework
    3.66 -  # libraries, because JDK libraries are inadvertently discovered first on the
    3.67 -  # searchpath, e.g. libjpeg.  On Mac OS X, filenames are case *insensitive*.
    3.68 -  # So, the actual filename collision is libjpeg.dylib and libJPEG.dylib.
    3.69 -  # To resolve this, gamma needs to also statically link with the CoreFoundation
    3.70 -  # framework libraries.
    3.71 -
    3.72 -  ifeq ($(OS_VENDOR),Darwin)
    3.73 -    LFLAGS_LAUNCHER         += -framework CoreFoundation
    3.74 -  endif
    3.75 -
    3.76 -  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
    3.77 -endif
    3.78 -
    3.79 -LINK_LAUNCHER = $(LINK.CC)
    3.80 -
    3.81 -LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
    3.82 -LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
    3.83 -
    3.84 -LAUNCHER_OUT = launcher
    3.85 -
    3.86 -SUFFIXES += .d
    3.87 -
    3.88 -SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
    3.89 -SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
    3.90 -
    3.91 -OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
    3.92 -
    3.93 -DEPFILES := $(patsubst %.o,%.d,$(OBJS))
    3.94 --include $(DEPFILES)
    3.95 -
    3.96 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
    3.97 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
    3.98 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
    3.99 -
   3.100 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
   3.101 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
   3.102 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
   3.103 -
   3.104 -$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
   3.105 -	$(QUIETLY) echo Linking launcher...
   3.106 -	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
   3.107 -	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
   3.108 -	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
   3.109 -	# Sign the launcher with the development certificate (if present) so that it can be used
   3.110 -	# to run JStack, JInfo, et al.
   3.111 -	$(QUIETLY) -codesign -s openjdk_codesign $@
   3.112 -
   3.113 -$(LAUNCHER): $(LAUNCHER_SCRIPT)
   3.114 -
   3.115 -$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
   3.116 -	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
   3.117 -	$(QUIETLY) chmod +x $@
   3.118 -
     4.1 --- a/make/bsd/makefiles/vm.make	Tue May 14 17:33:07 2013 +0000
     4.2 +++ b/make/bsd/makefiles/vm.make	Thu May 16 13:47:55 2013 -0700
     4.3 @@ -331,9 +331,6 @@
     4.4  #----------------------------------------------------------------------
     4.5  # Other files
     4.6  
     4.7 -# Gamma launcher
     4.8 -include $(MAKEFILES_DIR)/launcher.make
     4.9 -
    4.10  # Signal interposition library
    4.11  include $(MAKEFILES_DIR)/jsig.make
    4.12  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/make/hotspot.script	Thu May 16 13:47:55 2013 -0700
     5.3 @@ -0,0 +1,218 @@
     5.4 +#!/bin/sh
     5.5 +
     5.6 +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
     5.7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8 +#
     5.9 +# This code is free software; you can redistribute it and/or modify it
    5.10 +# under the terms of the GNU General Public License version 2 only, as
    5.11 +# published by the Free Software Foundation.
    5.12 +#
    5.13 +# This code is distributed in the hope that it will be useful, but WITHOUT
    5.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.15 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.16 +# version 2 for more details (a copy is included in the LICENSE file that
    5.17 +# accompanied this code).
    5.18 +#
    5.19 +# You should have received a copy of the GNU General Public License version
    5.20 +# 2 along with this work; if not, write to the Free Software Foundation,
    5.21 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.22 +#
    5.23 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.24 +# or visit www.oracle.com if you need additional information or have any
    5.25 +# questions.
    5.26 +
    5.27 +
    5.28 +# This script launches HotSpot.
    5.29 +#
    5.30 +# If the first parameter is either "-gdb" or "-gud", HotSpot will be
    5.31 +# launched inside gdb. "-gud" means "open an Emacs window and run gdb
    5.32 +# inside Emacs".
    5.33 +#
    5.34 +# If the first parameter is "-dbx", HotSpot will be launched inside dbx.
    5.35 +#
    5.36 +# If the first parameter is "-valgrind", HotSpot will be launched
    5.37 +# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
    5.38 +# and with memory leak detection enabled.  This currently (2005jan19)
    5.39 +# requires at least Valgrind 2.3.0.  -Xmx16m will also be passed as
    5.40 +# the first parameter to HotSpot, since lowering HotSpot's memory
    5.41 +# consumption makes execution inside of Valgrind *a lot* faster.
    5.42 +#
    5.43 +
    5.44 +
    5.45 +#
    5.46 +# User changeable parameters ------------------------------------------------
    5.47 +#
    5.48 +
    5.49 +# This is the name of the gdb binary to use
    5.50 +if [ ! "$GDB" ]
    5.51 +then
    5.52 +    GDB=gdb
    5.53 +fi
    5.54 +
    5.55 +# This is the name of the gdb binary to use
    5.56 +if [ ! "$DBX" ]
    5.57 +then
    5.58 +    DBX=dbx
    5.59 +fi
    5.60 +
    5.61 +# This is the name of the Valgrind binary to use
    5.62 +if [ ! "$VALGRIND" ]
    5.63 +then
    5.64 +    VALGRIND=valgrind
    5.65 +fi
    5.66 +
    5.67 +# This is the name of Emacs for running GUD
    5.68 +EMACS=emacs
    5.69 +
    5.70 +#
    5.71 +# End of user changeable parameters -----------------------------------------
    5.72 +#
    5.73 +
    5.74 +# Make sure the paths are fully specified, i.e. they must begin with /.
    5.75 +REL_MYDIR=`dirname $0`
    5.76 +MYDIR=`cd $REL_MYDIR && pwd`
    5.77 +
    5.78 +#
    5.79 +# Look whether the user wants to run inside gdb
    5.80 +case "$1" in
    5.81 +    -gdb)
    5.82 +        MODE=gdb
    5.83 +        shift
    5.84 +        ;;
    5.85 +    -gud)
    5.86 +        MODE=gud
    5.87 +        shift
    5.88 +        ;;
    5.89 +    -dbx)
    5.90 +        MODE=dbx
    5.91 +        shift
    5.92 +        ;;
    5.93 +    -valgrind)
    5.94 +        MODE=valgrind
    5.95 +        shift
    5.96 +        ;;
    5.97 +    *)
    5.98 +        MODE=run
    5.99 +        ;;
   5.100 +esac
   5.101 +
   5.102 +if [ "${ALT_JAVA_HOME}" != "" ]; then
   5.103 +    JDK=${ALT_JAVA_HOME%%/jre}
   5.104 +else
   5.105 +    JDK=@@JDK_IMPORT_PATH@@
   5.106 +fi
   5.107 +
   5.108 +if [ "${JDK}" = "" ]; then
   5.109 +    echo "Failed to find JDK.  Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
   5.110 +fi
   5.111 +
   5.112 +# We will set the LD_LIBRARY_PATH as follows:
   5.113 +#     o		$JVMPATH (directory portion only)
   5.114 +#     o		$JRE/lib/$ARCH
   5.115 +# followed by the user's previous effective LD_LIBRARY_PATH, if
   5.116 +# any.
   5.117 +JRE=$JDK/jre
   5.118 +JAVA_HOME=$JDK
   5.119 +export JAVA_HOME
   5.120 +
   5.121 +ARCH=@@LIBARCH@@
   5.122 +SBP=${MYDIR}:${JRE}/lib/${ARCH}
   5.123 +
   5.124 +
   5.125 +# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
   5.126 +OS=`uname -s`
   5.127 +if [ "${OS}" = "Darwin" ]
   5.128 +then
   5.129 +    if [ -z "$DYLD_LIBRARY_PATH" ]
   5.130 +    then
   5.131 +        DYLD_LIBRARY_PATH="$SBP"
   5.132 +    else
   5.133 +        DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
   5.134 +    fi
   5.135 +    export DYLD_LIBRARY_PATH
   5.136 +else
   5.137 +    # not 'Darwin'
   5.138 +    if [ -z "$LD_LIBRARY_PATH" ]
   5.139 +    then
   5.140 +        LD_LIBRARY_PATH="$SBP"
   5.141 +    else
   5.142 +        LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
   5.143 +    fi
   5.144 +    export LD_LIBRARY_PATH
   5.145 +fi
   5.146 +
   5.147 +JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS";
   5.148 +
   5.149 +# Locate the java launcher
   5.150 +LAUNCHER=$JDK/bin/java
   5.151 +if [ ! -x $LAUNCHER ] ; then
   5.152 +    echo Error: Cannot find the java launcher \"$LAUNCHER\"
   5.153 +    exit 1
   5.154 +fi
   5.155 +
   5.156 +GDBSRCDIR=$MYDIR
   5.157 +BASEDIR=`cd $MYDIR/../../.. && pwd`
   5.158 +
   5.159 +init_gdb() {
   5.160 +# Create a gdb script in case we should run inside gdb
   5.161 +    GDBSCR=/tmp/hsl.$$
   5.162 +    rm -f $GDBSCR
   5.163 +    cat >>$GDBSCR <<EOF
   5.164 +cd `pwd`
   5.165 +handle SIGUSR1 nostop noprint
   5.166 +handle SIGUSR2 nostop noprint
   5.167 +set args $JPARMS
   5.168 +file $LAUNCHER
   5.169 +directory $GDBSRCDIR
   5.170 +# Get us to a point where we can set breakpoints in libjvm.so
   5.171 +set breakpoint pending on
   5.172 +break JNI_CreateJavaVM
   5.173 +run
   5.174 +# Stop in JNI_CreateJavaVM
   5.175 +delete 1
   5.176 +# We can now set breakpoints wherever we like
   5.177 +EOF
   5.178 +}
   5.179 +
   5.180 +
   5.181 +case "$MODE" in
   5.182 +    gdb)
   5.183 +	init_gdb
   5.184 +        $GDB -x $GDBSCR
   5.185 +	rm -f $GDBSCR
   5.186 +        ;;
   5.187 +    gud)
   5.188 +	init_gdb
   5.189 +# First find out what emacs version we're using, so that we can
   5.190 +# use the new pretty GDB mode if emacs -version >= 22.1
   5.191 +	case `$EMACS -version 2> /dev/null` in
   5.192 +	    *GNU\ Emacs\ 2[23]*)
   5.193 +	    emacs_gud_cmd="gdba"
   5.194 +	    emacs_gud_args="--annotate=3"
   5.195 +	    ;;
   5.196 +	    *)
   5.197 +		emacs_gud_cmd="gdb"
   5.198 +		emacs_gud_args=
   5.199 +		;;
   5.200 +	esac
   5.201 +        $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
   5.202 +	rm -f $GDBSCR
   5.203 +        ;;
   5.204 +    dbx)
   5.205 +        $DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER
   5.206 +        ;;
   5.207 +    valgrind)
   5.208 +        echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
   5.209 +        echo
   5.210 +        $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
   5.211 +        ;;
   5.212 +    run)
   5.213 +        LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
   5.214 +        ;;
   5.215 +    *)
   5.216 +        echo Error: Internal error, unknown launch mode \"$MODE\"
   5.217 +        exit 1
   5.218 +        ;;
   5.219 +esac
   5.220 +RETVAL=$?
   5.221 +exit $RETVAL
     6.1 --- a/make/jprt.properties	Tue May 14 17:33:07 2013 +0000
     6.2 +++ b/make/jprt.properties	Thu May 16 13:47:55 2013 -0700
     6.3 @@ -134,14 +134,14 @@
     6.4  
     6.5  jprt.build.targets.standard= \
     6.6      ${jprt.my.solaris.sparc}-{product|fastdebug}, \
     6.7 -    ${jprt.my.solaris.sparcv9}-{product|fastdebug}, \
     6.8 +    ${jprt.my.solaris.sparcv9}-{product|fastdebug|optimized}, \
     6.9      ${jprt.my.solaris.i586}-{product|fastdebug}, \
    6.10      ${jprt.my.solaris.x64}-{product|fastdebug}, \
    6.11      ${jprt.my.linux.i586}-{product|fastdebug}, \
    6.12 -    ${jprt.my.linux.x64}-{product|fastdebug}, \
    6.13 +    ${jprt.my.linux.x64}-{product|fastdebug|optimized}, \
    6.14      ${jprt.my.macosx.x64}-{product|fastdebug}, \
    6.15      ${jprt.my.windows.i586}-{product|fastdebug}, \
    6.16 -    ${jprt.my.windows.x64}-{product|fastdebug}, \
    6.17 +    ${jprt.my.windows.x64}-{product|fastdebug|optimized}, \
    6.18      ${jprt.my.linux.armvh}-{product|fastdebug}
    6.19  
    6.20  jprt.build.targets.open= \
     7.1 --- a/make/linux/makefiles/buildtree.make	Tue May 14 17:33:07 2013 +0000
     7.2 +++ b/make/linux/makefiles/buildtree.make	Thu May 16 13:47:55 2013 -0700
     7.3 @@ -49,7 +49,6 @@
     7.4  # adlc.make	-
     7.5  # jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
     7.6  # sa.make	- generate SA jar file and natives
     7.7 -# env.[ck]sh	- environment settings
     7.8  #
     7.9  # The makefiles are split this way so that "make foo" will run faster by not
    7.10  # having to read the dependency files for the vm.
    7.11 @@ -123,8 +122,7 @@
    7.12  # For dependencies and recursive makes.
    7.13  BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
    7.14  
    7.15 -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
    7.16 -        env.sh env.csh jdkpath.sh
    7.17 +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make
    7.18  
    7.19  BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
    7.20  	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
    7.21 @@ -349,33 +347,6 @@
    7.22  	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
    7.23  	) > $@
    7.24  
    7.25 -env.sh: $(BUILDTREE_MAKE)
    7.26 -	@echo Creating $@ ...
    7.27 -	$(QUIETLY) ( \
    7.28 -	$(BUILDTREE_COMMENT); \
    7.29 -	{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
    7.30 -	{ \
    7.31 -	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
    7.32 -	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
    7.33 -	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
    7.34 -	echo "export JAVA_HOME CLASSPATH HOTSPOT_BUILD_USER"; \
    7.35 -	) > $@
    7.36 -
    7.37 -env.csh: env.sh
    7.38 -	@echo Creating $@ ...
    7.39 -	$(QUIETLY) ( \
    7.40 -	$(BUILDTREE_COMMENT); \
    7.41 -	{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
    7.42 -	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
    7.43 -	) > $@
    7.44 -
    7.45 -jdkpath.sh: $(BUILDTREE_MAKE)
    7.46 -	@echo Creating $@ ...
    7.47 -	$(QUIETLY) ( \
    7.48 -	$(BUILDTREE_COMMENT); \
    7.49 -	echo "JDK=${JAVA_HOME}"; \
    7.50 -	) > $@
    7.51 -
    7.52  FORCE:
    7.53  
    7.54  .PHONY:  all FORCE
     8.1 --- a/make/linux/makefiles/launcher.make	Tue May 14 17:33:07 2013 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,93 +0,0 @@
     8.4 -#
     8.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     8.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 -#
     8.8 -# This code is free software; you can redistribute it and/or modify it
     8.9 -# under the terms of the GNU General Public License version 2 only, as
    8.10 -# published by the Free Software Foundation.
    8.11 -#
    8.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
    8.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.15 -# version 2 for more details (a copy is included in the LICENSE file that
    8.16 -# accompanied this code).
    8.17 -#
    8.18 -# You should have received a copy of the GNU General Public License version
    8.19 -# 2 along with this work; if not, write to the Free Software Foundation,
    8.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.21 -#
    8.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.23 -# or visit www.oracle.com if you need additional information or have any
    8.24 -# questions.
    8.25 -#  
    8.26 -#
    8.27 -
    8.28 -# Rules to build gamma launcher, used by vm.make
    8.29 -
    8.30 -
    8.31 -LAUNCHER_SCRIPT = hotspot
    8.32 -LAUNCHER   = gamma
    8.33 -
    8.34 -LAUNCHERDIR   := $(GAMMADIR)/src/os/posix/launcher
    8.35 -LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
    8.36 -LAUNCHERFLAGS := $(ARCHFLAG) \
    8.37 -                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
    8.38 -                -I$(LAUNCHERDIR_SHARE) \
    8.39 -                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
    8.40 -                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
    8.41 -                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
    8.42 -                -DARCH=\"$(LIBARCH)\" \
    8.43 -                -DGAMMA \
    8.44 -                -DLAUNCHER_TYPE=\"gamma\" \
    8.45 -                -DLINK_INTO_$(LINK_INTO) \
    8.46 -                $(TARGET_DEFINES)
    8.47 -
    8.48 -ifeq ($(LINK_INTO),AOUT)
    8.49 -  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
    8.50 -  LAUNCHER_MAPFILE           = mapfile_reorder
    8.51 -  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
    8.52 -  LFLAGS_LAUNCHER           += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
    8.53 -  LIBS_LAUNCHER             += $(STATIC_STDCXX) $(LIBS)
    8.54 -else
    8.55 -  LAUNCHER.o                 = launcher.o
    8.56 -  LFLAGS_LAUNCHER           += -L `pwd`
    8.57 -  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
    8.58 -endif
    8.59 -
    8.60 -LINK_LAUNCHER = $(LINK.CC)
    8.61 -
    8.62 -LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
    8.63 -LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
    8.64 -
    8.65 -LAUNCHER_OUT = launcher
    8.66 -
    8.67 -SUFFIXES += .d
    8.68 -
    8.69 -SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
    8.70 -SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
    8.71 -
    8.72 -OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
    8.73 -
    8.74 -DEPFILES := $(patsubst %.o,%.d,$(OBJS))
    8.75 --include $(DEPFILES)
    8.76 -
    8.77 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
    8.78 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
    8.79 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
    8.80 -
    8.81 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
    8.82 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
    8.83 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
    8.84 -
    8.85 -$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
    8.86 -	$(QUIETLY) echo Linking launcher...
    8.87 -	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
    8.88 -	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
    8.89 -	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
    8.90 -
    8.91 -$(LAUNCHER): $(LAUNCHER_SCRIPT)
    8.92 -
    8.93 -$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
    8.94 -	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
    8.95 -	$(QUIETLY) chmod +x $@
    8.96 -
     9.1 --- a/make/linux/makefiles/vm.make	Tue May 14 17:33:07 2013 +0000
     9.2 +++ b/make/linux/makefiles/vm.make	Thu May 16 13:47:55 2013 -0700
     9.3 @@ -372,9 +372,6 @@
     9.4  #----------------------------------------------------------------------
     9.5  # Other files
     9.6  
     9.7 -# Gamma launcher
     9.8 -include $(MAKEFILES_DIR)/launcher.make
     9.9 -
    9.10  # Signal interposition library
    9.11  include $(MAKEFILES_DIR)/jsig.make
    9.12  
    10.1 --- a/make/solaris/makefiles/buildtree.make	Tue May 14 17:33:07 2013 +0000
    10.2 +++ b/make/solaris/makefiles/buildtree.make	Thu May 16 13:47:55 2013 -0700
    10.3 @@ -49,7 +49,6 @@
    10.4  # adlc.make	-
    10.5  # jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
    10.6  # sa.make	- generate SA jar file and natives
    10.7 -# env.[ck]sh	- environment settings
    10.8  #
    10.9  # The makefiles are split this way so that "make foo" will run faster by not
   10.10  # having to read the dependency files for the vm.
   10.11 @@ -116,8 +115,7 @@
   10.12  # For dependencies and recursive makes.
   10.13  BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
   10.14  
   10.15 -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
   10.16 -        env.sh env.csh jdkpath.sh
   10.17 +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make
   10.18  
   10.19  BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
   10.20  	ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
   10.21 @@ -339,33 +337,6 @@
   10.22  	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
   10.23  	) > $@
   10.24  
   10.25 -env.sh: $(BUILDTREE_MAKE)
   10.26 -	@echo Creating $@ ...
   10.27 -	$(QUIETLY) ( \
   10.28 -	$(BUILDTREE_COMMENT); \
   10.29 -	{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
   10.30 -	{ \
   10.31 -	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
   10.32 -	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
   10.33 -	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
   10.34 -	echo "export JAVA_HOME LD_LIBRARY_PATH CLASSPATH HOTSPOT_BUILD_USER"; \
   10.35 -	) > $@
   10.36 -
   10.37 -env.csh: env.sh
   10.38 -	@echo Creating $@ ...
   10.39 -	$(QUIETLY) ( \
   10.40 -	$(BUILDTREE_COMMENT); \
   10.41 -	{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
   10.42 -	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
   10.43 -	) > $@
   10.44 -
   10.45 -jdkpath.sh: $(BUILDTREE_MAKE)
   10.46 -	@echo Creating $@ ...
   10.47 -	$(QUIETLY) ( \
   10.48 -	$(BUILDTREE_COMMENT); \
   10.49 -	echo "JDK=${JAVA_HOME}"; \
   10.50 -	) > $@
   10.51 -
   10.52  FORCE:
   10.53  
   10.54  .PHONY:  all FORCE
    11.1 --- a/make/solaris/makefiles/launcher.make	Tue May 14 17:33:07 2013 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,108 +0,0 @@
    11.4 -#
    11.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    11.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 -#
    11.8 -# This code is free software; you can redistribute it and/or modify it
    11.9 -# under the terms of the GNU General Public License version 2 only, as
   11.10 -# published by the Free Software Foundation.
   11.11 -#
   11.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 -# version 2 for more details (a copy is included in the LICENSE file that
   11.16 -# accompanied this code).
   11.17 -#
   11.18 -# You should have received a copy of the GNU General Public License version
   11.19 -# 2 along with this work; if not, write to the Free Software Foundation,
   11.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 -#
   11.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 -# or visit www.oracle.com if you need additional information or have any
   11.24 -# questions.
   11.25 -#  
   11.26 -#
   11.27 -
   11.28 -# Rules to build gamma launcher, used by vm.make
   11.29 -
   11.30 -LAUNCHER_SCRIPT = hotspot
   11.31 -LAUNCHER   = gamma
   11.32 -
   11.33 -LAUNCHERDIR   = $(GAMMADIR)/src/os/posix/launcher
   11.34 -LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
   11.35 -LAUNCHERFLAGS = $(ARCHFLAG) \
   11.36 -                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
   11.37 -                -I$(LAUNCHERDIR_SHARE) \
   11.38 -                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
   11.39 -                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
   11.40 -                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
   11.41 -                -DARCH=\"$(LIBARCH)\" \
   11.42 -                -DGAMMA \
   11.43 -                -DLAUNCHER_TYPE=\"gamma\" \
   11.44 -                -DLINK_INTO_$(LINK_INTO) \
   11.45 -                $(TARGET_DEFINES)
   11.46 -
   11.47 -ifeq ($(LINK_INTO),AOUT)
   11.48 -  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
   11.49 -  LAUNCHER_MAPFILE           = mapfile_extended
   11.50 -  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
   11.51 -  LIBS_LAUNCHER             += $(LIBS)
   11.52 -else
   11.53 -  LAUNCHER.o                 = launcher.o
   11.54 -  LFLAGS_LAUNCHER           += -L `pwd`
   11.55 -  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
   11.56 -endif
   11.57 -
   11.58 -LINK_LAUNCHER = $(LINK.CXX)
   11.59 -
   11.60 -LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
   11.61 -LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
   11.62 -
   11.63 -ifeq ("${Platform_compiler}", "sparcWorks")
   11.64 -# Enable the following LAUNCHERFLAGS addition if you need to compare the
   11.65 -# built ELF objects.
   11.66 -#
   11.67 -# The -g option makes static data global and the "-W0,-noglobal"
   11.68 -# option tells the compiler to not globalize static data using a unique
   11.69 -# globalization prefix. Instead force the use of a static globalization
   11.70 -# prefix based on the source filepath so the objects from two identical
   11.71 -# compilations are the same.
   11.72 -#
   11.73 -# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
   11.74 -#       seem to work. I got "-W0,-noglobal" from Kelly and that works.
   11.75 -#LAUNCHERFLAGS += -W0,-noglobal
   11.76 -endif # Platform_compiler == sparcWorks
   11.77 -
   11.78 -LAUNCHER_OUT = launcher
   11.79 -
   11.80 -SUFFIXES += .d
   11.81 -
   11.82 -SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
   11.83 -SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
   11.84 -
   11.85 -OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
   11.86 -
   11.87 -DEPFILES := $(patsubst %.o,%.d,$(OBJS))
   11.88 --include $(DEPFILES)
   11.89 -
   11.90 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
   11.91 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
   11.92 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
   11.93 -
   11.94 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
   11.95 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
   11.96 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
   11.97 -
   11.98 -$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
   11.99 -ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
  11.100 -	$(QUIETLY) echo Linking launcher...
  11.101 -	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
  11.102 -	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
  11.103 -	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
  11.104 -endif # filter -sbfast -xsbfast
  11.105 -
  11.106 -$(LAUNCHER): $(LAUNCHER_SCRIPT)
  11.107 -
  11.108 -$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
  11.109 -	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
  11.110 -	$(QUIETLY) chmod +x $@
  11.111 -
    12.1 --- a/make/solaris/makefiles/vm.make	Tue May 14 17:33:07 2013 +0000
    12.2 +++ b/make/solaris/makefiles/vm.make	Thu May 16 13:47:55 2013 -0700
    12.3 @@ -338,9 +338,6 @@
    12.4  #----------------------------------------------------------------------
    12.5  # Other files
    12.6  
    12.7 -# Gamma launcher
    12.8 -include $(MAKEFILES_DIR)/launcher.make
    12.9 -
   12.10  # Signal interposition library
   12.11  include $(MAKEFILES_DIR)/jsig.make
   12.12  
    13.1 --- a/make/windows/makefiles/debug.make	Tue May 14 17:33:07 2013 +0000
    13.2 +++ b/make/windows/makefiles/debug.make	Thu May 16 13:47:55 2013 -0700
    13.3 @@ -33,7 +33,7 @@
    13.4  BUILD_PCH_FILE=_build_pch_file.obj
    13.5  !endif
    13.6  
    13.7 -default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
    13.8 +default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
    13.9  
   13.10  !include ../local.make
   13.11  !include compile.make
   13.12 @@ -71,4 +71,3 @@
   13.13  
   13.14  !include $(WorkSpace)/make/windows/makefiles/shared.make
   13.15  !include $(WorkSpace)/make/windows/makefiles/sa.make
   13.16 -!include $(WorkSpace)/make/windows/makefiles/launcher.make
    14.1 --- a/make/windows/makefiles/fastdebug.make	Tue May 14 17:33:07 2013 +0000
    14.2 +++ b/make/windows/makefiles/fastdebug.make	Thu May 16 13:47:55 2013 -0700
    14.3 @@ -33,7 +33,7 @@
    14.4  BUILD_PCH_FILE=_build_pch_file.obj
    14.5  !endif
    14.6  
    14.7 -default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
    14.8 +default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
    14.9  
   14.10  !include ../local.make
   14.11  !include compile.make
   14.12 @@ -70,4 +70,3 @@
   14.13  
   14.14  !include $(WorkSpace)/make/windows/makefiles/shared.make
   14.15  !include $(WorkSpace)/make/windows/makefiles/sa.make
   14.16 -!include $(WorkSpace)/make/windows/makefiles/launcher.make
    15.1 --- a/make/windows/makefiles/launcher.make	Tue May 14 17:33:07 2013 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,73 +0,0 @@
    15.4 -#
    15.5 -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    15.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 -#
    15.8 -# This code is free software; you can redistribute it and/or modify it
    15.9 -# under the terms of the GNU General Public License version 2 only, as
   15.10 -# published by the Free Software Foundation.
   15.11 -#
   15.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 -# version 2 for more details (a copy is included in the LICENSE file that
   15.16 -# accompanied this code).
   15.17 -#
   15.18 -# You should have received a copy of the GNU General Public License version
   15.19 -# 2 along with this work; if not, write to the Free Software Foundation,
   15.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 -#
   15.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 -# or visit www.oracle.com if you need additional information or have any
   15.24 -# questions.
   15.25 -#  
   15.26 -#
   15.27 -
   15.28 -
   15.29 -LAUNCHER_FLAGS=$(CXX_FLAGS) $(ARCHFLAG) \
   15.30 -	/D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
   15.31 -	/D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
   15.32 -	/D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
   15.33 -	/D GAMMA \
   15.34 -	/D LAUNCHER_TYPE=\"gamma\" \
   15.35 -	/D _CRT_SECURE_NO_WARNINGS \
   15.36 -	/D _CRT_SECURE_NO_DEPRECATE \
   15.37 -	/D LINK_INTO_LIBJVM \
   15.38 -	/I $(WorkSpace)\src\os\windows\launcher \
   15.39 -	/I $(WorkSpace)\src\share\tools\launcher \
   15.40 -	/I $(WorkSpace)\src\share\vm\prims \
   15.41 -	/I $(WorkSpace)\src\share\vm \
   15.42 -	/I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \
   15.43 -	/I $(WorkSpace)\src\os\windows\vm
   15.44 -
   15.45 -LD_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console 
   15.46 -
   15.47 -!if "$(COMPILER_NAME)" == "VS2005"
   15.48 -# This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib
   15.49 -#    on the link command line, otherwise we get missing __security_check_cookie
   15.50 -#    externals at link time. Even with /GS-, you need bufferoverflowU.lib.
   15.51 -BUFFEROVERFLOWLIB = bufferoverflowU.lib
   15.52 -LD_FLAGS = $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
   15.53 -!endif
   15.54 -
   15.55 -!if "$(COMPILER_NAME)" == "VS2010" && "$(BUILDARCH)" == "i486"
   15.56 -LD_FLAGS = /SAFESEH $(LD_FLAGS)
   15.57 -!endif
   15.58 -
   15.59 -LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher
   15.60 -LAUNCHERDIR_SHARE = $(WorkSpace)/src/share/tools/launcher
   15.61 -
   15.62 -OUTDIR = launcher
   15.63 -
   15.64 -{$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj:
   15.65 -	-mkdir $(OUTDIR) 2>NUL >NUL
   15.66 -        $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
   15.67 -
   15.68 -{$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj:
   15.69 -	-mkdir $(OUTDIR) 2>NUL >NUL
   15.70 -        $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
   15.71 -
   15.72 -$(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h
   15.73 -
   15.74 -launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj
   15.75 -	echo $(JAVA_HOME) > jdkpath.txt  
   15.76 -	$(LD) $(LD_FLAGS) /out:hotspot.exe $**
    16.1 --- a/make/windows/makefiles/product.make	Tue May 14 17:33:07 2013 +0000
    16.2 +++ b/make/windows/makefiles/product.make	Thu May 16 13:47:55 2013 -0700
    16.3 @@ -32,7 +32,7 @@
    16.4  BUILD_PCH_FILE=_build_pch_file.obj
    16.5  !endif
    16.6  
    16.7 -default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
    16.8 +default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
    16.9  
   16.10  !include ../local.make
   16.11  !include compile.make
   16.12 @@ -73,4 +73,3 @@
   16.13  
   16.14  !include $(WorkSpace)/make/windows/makefiles/shared.make
   16.15  !include $(WorkSpace)/make/windows/makefiles/sa.make
   16.16 -!include $(WorkSpace)/make/windows/makefiles/launcher.make
    17.1 --- a/make/windows/makefiles/projectcreator.make	Tue May 14 17:33:07 2013 +0000
    17.2 +++ b/make/windows/makefiles/projectcreator.make	Thu May 16 13:47:55 2013 -0700
    17.3 @@ -59,7 +59,6 @@
    17.4          -relativeSrcInclude src \
    17.5          -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \
    17.6          -ignorePath $(HOTSPOTBUILDSPACE) \
    17.7 -        -ignorePath launcher \
    17.8          -ignorePath share\vm\adlc \
    17.9          -ignorePath share\vm\shark \
   17.10          -ignorePath share\tools \
   17.11 @@ -105,7 +104,6 @@
   17.12          -define ALIGN_STACK_FRAMES \
   17.13          -define VM_LITTLE_ENDIAN \
   17.14          -prelink  "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	set JAVA_HOME=$(HOTSPOTJDKDIST)	$(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \
   17.15 -        -postbuild "" "Building hotspot.exe..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	nmake -f $(HOTSPOTWORKSPACE)\make\windows\projectfiles\common\Makefile LOCAL_MAKE=$(HOTSPOTBUILDSPACE)\%f\local.make JAVA_HOME=$(HOTSPOTJDKDIST) launcher" \
   17.16          -ignoreFile jsig.c \
   17.17          -ignoreFile jvmtiEnvRecommended.cpp \
   17.18          -ignoreFile jvmtiEnvStub.cpp \
    18.1 --- a/make/windows/projectfiles/common/Makefile	Tue May 14 17:33:07 2013 +0000
    18.2 +++ b/make/windows/projectfiles/common/Makefile	Thu May 16 13:47:55 2013 -0700
    18.3 @@ -65,7 +65,6 @@
    18.4  !endif
    18.5  
    18.6  HS_INTERNAL_NAME=jvm
    18.7 -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/launcher.make
    18.8  
    18.9  default:: $(AdditionalTargets) $(JvmtiGeneratedFiles)
   18.10  
    19.1 --- a/src/os/posix/launcher/java_md.c	Tue May 14 17:33:07 2013 +0000
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,1936 +0,0 @@
    19.4 -/*
    19.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 - *
    19.8 - * This code is free software; you can redistribute it and/or modify it
    19.9 - * under the terms of the GNU General Public License version 2 only, as
   19.10 - * published by the Free Software Foundation.
   19.11 - *
   19.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 - * version 2 for more details (a copy is included in the LICENSE file that
   19.16 - * accompanied this code).
   19.17 - *
   19.18 - * You should have received a copy of the GNU General Public License version
   19.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 - *
   19.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 - * or visit www.oracle.com if you need additional information or have any
   19.24 - * questions.
   19.25 - *
   19.26 - */
   19.27 -
   19.28 -
   19.29 -#include "java.h"
   19.30 -#include <dirent.h>
   19.31 -#include <dlfcn.h>
   19.32 -#include <fcntl.h>
   19.33 -#include <inttypes.h>
   19.34 -#include <stdio.h>
   19.35 -#include <string.h>
   19.36 -#include <stdlib.h>
   19.37 -#include <limits.h>
   19.38 -#include <sys/stat.h>
   19.39 -#include <unistd.h>
   19.40 -#include <sys/types.h>
   19.41 -
   19.42 -#ifndef GAMMA
   19.43 -#include "manifest_info.h"
   19.44 -#include "version_comp.h"
   19.45 -#endif
   19.46 -
   19.47 -#if defined(__linux__) || defined(_ALLBSD_SOURCE)
   19.48 -#include <pthread.h>
   19.49 -#else
   19.50 -#include <thread.h>
   19.51 -#endif
   19.52 -
   19.53 -#ifdef __APPLE__
   19.54 -#define JVM_DLL "libjvm.dylib"
   19.55 -#define JAVA_DLL "libjava.dylib"
   19.56 -#define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
   19.57 -#else
   19.58 -#define JVM_DLL "libjvm.so"
   19.59 -#define JAVA_DLL "libjava.so"
   19.60 -#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
   19.61 -#endif
   19.62 -
   19.63 -#ifndef GAMMA   /* launcher.make defines ARCH */
   19.64 -/*
   19.65 - * If a processor / os combination has the ability to run binaries of
   19.66 - * two data models and cohabitation of jre/jdk bits with both data
   19.67 - * models is supported, then DUAL_MODE is defined.  When DUAL_MODE is
   19.68 - * defined, the architecture names for the narrow and wide version of
   19.69 - * the architecture are defined in LIBARCH64NAME and LIBARCH32NAME.  Currently
   19.70 - * only Solaris on sparc/sparcv9 and i586/amd64 is DUAL_MODE; linux
   19.71 - * i586/amd64 could be defined as DUAL_MODE but that is not the
   19.72 - * current policy.
   19.73 - */
   19.74 -
   19.75 -#ifndef LIBARCHNAME
   19.76 -#  error "The macro LIBARCHNAME was not defined on the compile line"
   19.77 -#endif
   19.78 -
   19.79 -#ifdef __sun
   19.80 -#  define DUAL_MODE
   19.81 -#  ifndef LIBARCH32NAME
   19.82 -#    error "The macro LIBARCH32NAME was not defined on the compile line"
   19.83 -#  endif
   19.84 -#  ifndef LIBARCH64NAME
   19.85 -#    error "The macro LIBARCH64NAME was not defined on the compile line"
   19.86 -#  endif
   19.87 -#  include <sys/systeminfo.h>
   19.88 -#  include <sys/elf.h>
   19.89 -#  include <stdio.h>
   19.90 -#endif
   19.91 -
   19.92 -#endif /* ifndef GAMMA */
   19.93 -
   19.94 -/* pointer to environment */
   19.95 -extern char **environ;
   19.96 -
   19.97 -#ifndef GAMMA
   19.98 -/*
   19.99 - *      A collection of useful strings. One should think of these as #define
  19.100 - *      entries, but actual strings can be more efficient (with many compilers).
  19.101 - */
  19.102 -#ifdef __linux__
  19.103 -static const char *system_dir   = "/usr/java";
  19.104 -static const char *user_dir     = "/java";
  19.105 -#else /* Solaris */
  19.106 -static const char *system_dir   = "/usr/jdk";
  19.107 -static const char *user_dir     = "/jdk";
  19.108 -#endif
  19.109 -
  19.110 -#endif /* ifndef GAMMA */
  19.111 -
  19.112 -/*
  19.113 - * Flowchart of launcher execs and options processing on unix
  19.114 - *
  19.115 - * The selection of the proper vm shared library to open depends on
  19.116 - * several classes of command line options, including vm "flavor"
  19.117 - * options (-client, -server) and the data model options, -d32  and
  19.118 - * -d64, as well as a version specification which may have come from
  19.119 - * the command line or from the manifest of an executable jar file.
  19.120 - * The vm selection options are not passed to the running
  19.121 - * virtual machine; they must be screened out by the launcher.
  19.122 - *
  19.123 - * The version specification (if any) is processed first by the
  19.124 - * platform independent routine SelectVersion.  This may result in
  19.125 - * the exec of the specified launcher version.
  19.126 - *
  19.127 - * Typically, the launcher execs at least once to ensure a suitable
  19.128 - * LD_LIBRARY_PATH is in effect for the process.  The first exec
  19.129 - * screens out all the data model options; leaving the choice of data
  19.130 - * model implicit in the binary selected to run.  However, in case no
  19.131 - * exec is done, the data model options are screened out before the vm
  19.132 - * is invoked.
  19.133 - *
  19.134 - *  incoming argv ------------------------------
  19.135 - *  |                                          |
  19.136 - * \|/                                         |
  19.137 - * CheckJVMType                                |
  19.138 - * (removes -client, -server, etc.)            |
  19.139 - *                                            \|/
  19.140 - *                                            CreateExecutionEnvironment
  19.141 - *                                            (removes -d32 and -d64,
  19.142 - *                                             determines desired data model,
  19.143 - *                                             sets up LD_LIBRARY_PATH,
  19.144 - *                                             and exec's)
  19.145 - *                                             |
  19.146 - *  --------------------------------------------
  19.147 - *  |
  19.148 - * \|/
  19.149 - * exec child 1 incoming argv -----------------
  19.150 - *  |                                          |
  19.151 - * \|/                                         |
  19.152 - * CheckJVMType                                |
  19.153 - * (removes -client, -server, etc.)            |
  19.154 - *  |                                         \|/
  19.155 - *  |                                          CreateExecutionEnvironment
  19.156 - *  |                                          (verifies desired data model
  19.157 - *  |                                           is running and acceptable
  19.158 - *  |                                           LD_LIBRARY_PATH;
  19.159 - *  |                                           no-op in child)
  19.160 - *  |
  19.161 - * \|/
  19.162 - * TranslateDashJArgs...
  19.163 - * (Prepare to pass args to vm)
  19.164 - *  |
  19.165 - *  |
  19.166 - *  |
  19.167 - * \|/
  19.168 - * ParseArguments
  19.169 - * (ignores -d32 and -d64,
  19.170 - *  processes version options,
  19.171 - *  creates argument list for vm,
  19.172 - *  etc.)
  19.173 - *
  19.174 - */
  19.175 -
  19.176 -static char *SetExecname(char **argv);
  19.177 -static char * GetExecname();
  19.178 -static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
  19.179 -                           char *jvmpath, jint jvmpathsize, char * arch);
  19.180 -static jboolean GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative);
  19.181 -
  19.182 -#ifndef GAMMA
  19.183 -const char *
  19.184 -GetArch()
  19.185 -{
  19.186 -    return LIBARCHNAME;
  19.187 -}
  19.188 -#endif /* ifndef GAMMA */
  19.189 -
  19.190 -void
  19.191 -CreateExecutionEnvironment(int *_argcp,
  19.192 -                           char ***_argvp,
  19.193 -                           char jrepath[],
  19.194 -                           jint so_jrepath,
  19.195 -                           char jvmpath[],
  19.196 -                           jint so_jvmpath,
  19.197 -                           char **original_argv) {
  19.198 -  /*
  19.199 -   * First, determine if we are running the desired data model.  If we
  19.200 -   * are running the desired data model, all the error messages
  19.201 -   * associated with calling GetJREPath, ReadKnownVMs, etc. should be
  19.202 -   * output.  However, if we are not running the desired data model,
  19.203 -   * some of the errors should be suppressed since it is more
  19.204 -   * informative to issue an error message based on whether or not the
  19.205 -   * os/processor combination has dual mode capabilities.
  19.206 -   */
  19.207 -
  19.208 -    char *execname = NULL;
  19.209 -    int original_argc = *_argcp;
  19.210 -    jboolean jvmpathExists;
  19.211 -
  19.212 -    /* Compute the name of the executable */
  19.213 -    execname = SetExecname(*_argvp);
  19.214 -
  19.215 -#ifndef GAMMA
  19.216 -    /* Set the LD_LIBRARY_PATH environment variable, check data model
  19.217 -       flags, and exec process, if needed */
  19.218 -    {
  19.219 -      char *arch        = (char *)GetArch(); /* like sparc or sparcv9 */
  19.220 -      char * jvmtype    = NULL;
  19.221 -      int argc          = *_argcp;
  19.222 -      char **argv       = original_argv;
  19.223 -
  19.224 -      char *runpath     = NULL; /* existing effective LD_LIBRARY_PATH
  19.225 -                                   setting */
  19.226 -
  19.227 -      int running       =       /* What data model is being ILP32 =>
  19.228 -                                   32 bit vm; LP64 => 64 bit vm */
  19.229 -#ifdef _LP64
  19.230 -        64;
  19.231 -#else
  19.232 -      32;
  19.233 -#endif
  19.234 -
  19.235 -      int wanted        = running;      /* What data mode is being
  19.236 -                                           asked for? Current model is
  19.237 -                                           fine unless another model
  19.238 -                                           is asked for */
  19.239 -
  19.240 -      char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
  19.241 -      char* newpath     = NULL; /* path on new LD_LIBRARY_PATH */
  19.242 -      char* lastslash   = NULL;
  19.243 -
  19.244 -      char** newenvp    = NULL; /* current environment */
  19.245 -
  19.246 -      char** newargv    = NULL;
  19.247 -      int    newargc    = 0;
  19.248 -#ifdef __sun
  19.249 -      char*  dmpath     = NULL;  /* data model specific LD_LIBRARY_PATH,
  19.250 -                                    Solaris only */
  19.251 -#endif
  19.252 -
  19.253 -      /*
  19.254 -       * Starting in 1.5, all unix platforms accept the -d32 and -d64
  19.255 -       * options.  On platforms where only one data-model is supported
  19.256 -       * (e.g. ia-64 Linux), using the flag for the other data model is
  19.257 -       * an error and will terminate the program.
  19.258 -       */
  19.259 -
  19.260 -      { /* open new scope to declare local variables */
  19.261 -        int i;
  19.262 -
  19.263 -        newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(*newargv));
  19.264 -        newargv[newargc++] = argv[0];
  19.265 -
  19.266 -        /* scan for data model arguments and remove from argument list;
  19.267 -           last occurrence determines desired data model */
  19.268 -        for (i=1; i < argc; i++) {
  19.269 -
  19.270 -          if (strcmp(argv[i], "-J-d64") == 0 || strcmp(argv[i], "-d64") == 0) {
  19.271 -            wanted = 64;
  19.272 -            continue;
  19.273 -          }
  19.274 -          if (strcmp(argv[i], "-J-d32") == 0 || strcmp(argv[i], "-d32") == 0) {
  19.275 -            wanted = 32;
  19.276 -            continue;
  19.277 -          }
  19.278 -          newargv[newargc++] = argv[i];
  19.279 -
  19.280 -#ifdef JAVA_ARGS
  19.281 -          if (argv[i][0] != '-')
  19.282 -            continue;
  19.283 -#else
  19.284 -          if (strcmp(argv[i], "-classpath") == 0 || strcmp(argv[i], "-cp") == 0) {
  19.285 -            i++;
  19.286 -            if (i >= argc) break;
  19.287 -            newargv[newargc++] = argv[i];
  19.288 -            continue;
  19.289 -          }
  19.290 -          if (argv[i][0] != '-') { i++; break; }
  19.291 -#endif
  19.292 -        }
  19.293 -
  19.294 -        /* copy rest of args [i .. argc) */
  19.295 -        while (i < argc) {
  19.296 -          newargv[newargc++] = argv[i++];
  19.297 -        }
  19.298 -        newargv[newargc] = NULL;
  19.299 -
  19.300 -        /*
  19.301 -         * newargv has all proper arguments here
  19.302 -         */
  19.303 -
  19.304 -        argc = newargc;
  19.305 -        argv = newargv;
  19.306 -      }
  19.307 -
  19.308 -      /* If the data model is not changing, it is an error if the
  19.309 -         jvmpath does not exist */
  19.310 -      if (wanted == running) {
  19.311 -        /* Find out where the JRE is that we will be using. */
  19.312 -        if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
  19.313 -          fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
  19.314 -          exit(2);
  19.315 -        }
  19.316 -
  19.317 -        /* Find the specified JVM type */
  19.318 -        if (ReadKnownVMs(jrepath, arch, JNI_FALSE) < 1) {
  19.319 -          fprintf(stderr, "Error: no known VMs. (check for corrupt jvm.cfg file)\n");
  19.320 -          exit(1);
  19.321 -        }
  19.322 -
  19.323 -        jvmpath[0] = '\0';
  19.324 -        jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE);
  19.325 -
  19.326 -        if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) {
  19.327 -          fprintf(stderr, "Error: no `%s' JVM at `%s'.\n", jvmtype, jvmpath);
  19.328 -          exit(4);
  19.329 -        }
  19.330 -      } else {  /* do the same speculatively or exit */
  19.331 -#ifdef DUAL_MODE
  19.332 -        if (running != wanted) {
  19.333 -          /* Find out where the JRE is that we will be using. */
  19.334 -          if (!GetJREPath(jrepath, so_jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME), JNI_TRUE)) {
  19.335 -            goto EndDataModelSpeculate;
  19.336 -          }
  19.337 -
  19.338 -          /*
  19.339 -           * Read in jvm.cfg for target data model and process vm
  19.340 -           * selection options.
  19.341 -           */
  19.342 -          if (ReadKnownVMs(jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME), JNI_TRUE) < 1) {
  19.343 -            goto EndDataModelSpeculate;
  19.344 -          }
  19.345 -          jvmpath[0] = '\0';
  19.346 -          jvmtype = CheckJvmType(_argcp, _argvp, JNI_TRUE);
  19.347 -          /* exec child can do error checking on the existence of the path */
  19.348 -          jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath,
  19.349 -                                     ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME));
  19.350 -
  19.351 -        }
  19.352 -      EndDataModelSpeculate: /* give up and let other code report error message */
  19.353 -        ;
  19.354 -#else
  19.355 -        fprintf(stderr, "Running a %d-bit JVM is not supported on this platform.\n", wanted);
  19.356 -        exit(1);
  19.357 -#endif
  19.358 -      }
  19.359 -
  19.360 -      /*
  19.361 -       * We will set the LD_LIBRARY_PATH as follows:
  19.362 -       *
  19.363 -       *     o          $JVMPATH (directory portion only)
  19.364 -       *     o          $JRE/lib/$LIBARCHNAME
  19.365 -       *     o          $JRE/../lib/$LIBARCHNAME
  19.366 -       *
  19.367 -       * followed by the user's previous effective LD_LIBRARY_PATH, if
  19.368 -       * any.
  19.369 -       */
  19.370 -
  19.371 -#ifdef __sun
  19.372 -      /*
  19.373 -       * Starting in Solaris 7, ld.so.1 supports three LD_LIBRARY_PATH
  19.374 -       * variables:
  19.375 -       *
  19.376 -       * 1. LD_LIBRARY_PATH -- used for 32 and 64 bit searches if
  19.377 -       * data-model specific variables are not set.
  19.378 -       *
  19.379 -       * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH
  19.380 -       * for 64-bit binaries.
  19.381 -       *
  19.382 -       * 3. LD_LIBRARY_PATH_32 -- overrides and replaces LD_LIBRARY_PATH
  19.383 -       * for 32-bit binaries.
  19.384 -       *
  19.385 -       * The vm uses LD_LIBRARY_PATH to set the java.library.path system
  19.386 -       * property.  To shield the vm from the complication of multiple
  19.387 -       * LD_LIBRARY_PATH variables, if the appropriate data model
  19.388 -       * specific variable is set, we will act as if LD_LIBRARY_PATH had
  19.389 -       * the value of the data model specific variant and the data model
  19.390 -       * specific variant will be unset.  Note that the variable for the
  19.391 -       * *wanted* data model must be used (if it is set), not simply the
  19.392 -       * current running data model.
  19.393 -       */
  19.394 -
  19.395 -      switch(wanted) {
  19.396 -      case 0:
  19.397 -        if(running == 32) {
  19.398 -          dmpath = getenv("LD_LIBRARY_PATH_32");
  19.399 -          wanted = 32;
  19.400 -        }
  19.401 -        else {
  19.402 -          dmpath = getenv("LD_LIBRARY_PATH_64");
  19.403 -          wanted = 64;
  19.404 -        }
  19.405 -        break;
  19.406 -
  19.407 -      case 32:
  19.408 -        dmpath = getenv("LD_LIBRARY_PATH_32");
  19.409 -        break;
  19.410 -
  19.411 -      case 64:
  19.412 -        dmpath = getenv("LD_LIBRARY_PATH_64");
  19.413 -        break;
  19.414 -
  19.415 -      default:
  19.416 -        fprintf(stderr, "Improper value at line %d.", __LINE__);
  19.417 -        exit(1); /* unknown value in wanted */
  19.418 -        break;
  19.419 -      }
  19.420 -
  19.421 -      /*
  19.422 -       * If dmpath is NULL, the relevant data model specific variable is
  19.423 -       * not set and normal LD_LIBRARY_PATH should be used.
  19.424 -       */
  19.425 -      if( dmpath == NULL) {
  19.426 -        runpath = getenv("LD_LIBRARY_PATH");
  19.427 -      }
  19.428 -      else {
  19.429 -        runpath = dmpath;
  19.430 -      }
  19.431 -#else
  19.432 -      /*
  19.433 -       * If not on Solaris, assume only a single LD_LIBRARY_PATH
  19.434 -       * variable.
  19.435 -       */
  19.436 -      runpath = getenv(LD_LIBRARY_PATH);
  19.437 -#endif /* __sun */
  19.438 -
  19.439 -#if defined(__linux__)
  19.440 -      /*
  19.441 -       * On linux, if a binary is running as sgid or suid, glibc sets
  19.442 -       * LD_LIBRARY_PATH to the empty string for security purposes.  (In
  19.443 -       * contrast, on Solaris the LD_LIBRARY_PATH variable for a
  19.444 -       * privileged binary does not lose its settings; but the dynamic
  19.445 -       * linker does apply more scrutiny to the path.) The launcher uses
  19.446 -       * the value of LD_LIBRARY_PATH to prevent an exec loop.
  19.447 -       * Therefore, if we are running sgid or suid, this function's
  19.448 -       * setting of LD_LIBRARY_PATH will be ineffective and we should
  19.449 -       * return from the function now.  Getting the right libraries to
  19.450 -       * be found must be handled through other mechanisms.
  19.451 -       */
  19.452 -      if((getgid() != getegid()) || (getuid() != geteuid()) ) {
  19.453 -        return;
  19.454 -      }
  19.455 -#elif defined(_ALLBSD_SOURCE)
  19.456 -      /*
  19.457 -       * On BSD, if a binary is running as sgid or suid, libc sets
  19.458 -       * LD_LIBRARY_PATH to the empty string for security purposes.  (In
  19.459 -       * contrast, on Solaris the LD_LIBRARY_PATH variable for a
  19.460 -       * privileged binary does not lose its settings; but the dynamic
  19.461 -       * linker does apply more scrutiny to the path.) The launcher uses
  19.462 -       * the value of LD_LIBRARY_PATH to prevent an exec loop.
  19.463 -       * Therefore, if we are running sgid or suid, this function's
  19.464 -       * setting of LD_LIBRARY_PATH will be ineffective and we should
  19.465 -       * return from the function now.  Getting the right libraries to
  19.466 -       * be found must be handled through other mechanisms.
  19.467 -       */
  19.468 -      if(issetugid()) {
  19.469 -        return;
  19.470 -      }
  19.471 -#endif
  19.472 -
  19.473 -      /* runpath contains current effective LD_LIBRARY_PATH setting */
  19.474 -
  19.475 -      jvmpath = JLI_StringDup(jvmpath);
  19.476 -      new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) +
  19.477 -                              2*strlen(jrepath) + 2*strlen(arch) +
  19.478 -                              strlen(jvmpath) + 52);
  19.479 -      newpath = new_runpath + strlen(LD_LIBRARY_PATH "=");
  19.480 -
  19.481 -
  19.482 -      /*
  19.483 -       * Create desired LD_LIBRARY_PATH value for target data model.
  19.484 -       */
  19.485 -      {
  19.486 -        /* remove the name of the .so from the JVM path */
  19.487 -        lastslash = strrchr(jvmpath, '/');
  19.488 -        if (lastslash)
  19.489 -          *lastslash = '\0';
  19.490 -
  19.491 -
  19.492 -        /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */
  19.493 -
  19.494 -        sprintf(new_runpath, LD_LIBRARY_PATH "="
  19.495 -                "%s:"
  19.496 -                "%s/lib/%s:"
  19.497 -                "%s/../lib/%s",
  19.498 -                jvmpath,
  19.499 -#ifdef DUAL_MODE
  19.500 -                jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME),
  19.501 -                jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME)
  19.502 -#else
  19.503 -                jrepath, arch,
  19.504 -                jrepath, arch
  19.505 -#endif
  19.506 -                );
  19.507 -
  19.508 -
  19.509 -        /*
  19.510 -         * Check to make sure that the prefix of the current path is the
  19.511 -         * desired environment variable setting.
  19.512 -         */
  19.513 -        if (runpath != NULL &&
  19.514 -            strncmp(newpath, runpath, strlen(newpath))==0 &&
  19.515 -            (runpath[strlen(newpath)] == 0 || runpath[strlen(newpath)] == ':') &&
  19.516 -            (running == wanted) /* data model does not have to be changed */
  19.517 -#ifdef __sun
  19.518 -            && (dmpath == NULL)    /* data model specific variables not set  */
  19.519 -#endif
  19.520 -            ) {
  19.521 -
  19.522 -          return;
  19.523 -
  19.524 -        }
  19.525 -      }
  19.526 -
  19.527 -      /*
  19.528 -       * Place the desired environment setting onto the prefix of
  19.529 -       * LD_LIBRARY_PATH.  Note that this prevents any possible infinite
  19.530 -       * loop of execv() because we test for the prefix, above.
  19.531 -       */
  19.532 -      if (runpath != 0) {
  19.533 -        strcat(new_runpath, ":");
  19.534 -        strcat(new_runpath, runpath);
  19.535 -      }
  19.536 -
  19.537 -      if( putenv(new_runpath) != 0) {
  19.538 -        exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set
  19.539 -                    properly */
  19.540 -      }
  19.541 -
  19.542 -      /*
  19.543 -       * Unix systems document that they look at LD_LIBRARY_PATH only
  19.544 -       * once at startup, so we have to re-exec the current executable
  19.545 -       * to get the changed environment variable to have an effect.
  19.546 -       */
  19.547 -
  19.548 -#ifdef __sun
  19.549 -      /*
  19.550 -       * If dmpath is not NULL, remove the data model specific string
  19.551 -       * in the environment for the exec'ed child.
  19.552 -       */
  19.553 -
  19.554 -      if( dmpath != NULL)
  19.555 -        (void)UnsetEnv((wanted==32)?"LD_LIBRARY_PATH_32":"LD_LIBRARY_PATH_64");
  19.556 -#endif
  19.557 -
  19.558 -      newenvp = environ;
  19.559 -
  19.560 -      {
  19.561 -        char *newexec = execname;
  19.562 -#ifdef DUAL_MODE
  19.563 -        /*
  19.564 -         * If the data model is being changed, the path to the
  19.565 -         * executable must be updated accordingly; the executable name
  19.566 -         * and directory the executable resides in are separate.  In the
  19.567 -         * case of 32 => 64, the new bits are assumed to reside in, e.g.
  19.568 -         * "olddir/LIBARCH64NAME/execname"; in the case of 64 => 32,
  19.569 -         * the bits are assumed to be in "olddir/../execname".  For example,
  19.570 -         *
  19.571 -         * olddir/sparcv9/execname
  19.572 -         * olddir/amd64/execname
  19.573 -         *
  19.574 -         * for Solaris SPARC and Linux amd64, respectively.
  19.575 -         */
  19.576 -
  19.577 -        if (running != wanted) {
  19.578 -          char *oldexec = strcpy(JLI_MemAlloc(strlen(execname) + 1), execname);
  19.579 -          char *olddir = oldexec;
  19.580 -          char *oldbase = strrchr(oldexec, '/');
  19.581 -
  19.582 -
  19.583 -          newexec = JLI_MemAlloc(strlen(execname) + 20);
  19.584 -          *oldbase++ = 0;
  19.585 -          sprintf(newexec, "%s/%s/%s", olddir,
  19.586 -                  ((wanted==64) ? LIBARCH64NAME : ".."), oldbase);
  19.587 -          argv[0] = newexec;
  19.588 -        }
  19.589 -#endif
  19.590 -
  19.591 -        (void)fflush(stdout);
  19.592 -        (void)fflush(stderr);
  19.593 -        execve(newexec, argv, newenvp);
  19.594 -        perror("execve()");
  19.595 -
  19.596 -        fprintf(stderr, "Error trying to exec %s.\n", newexec);
  19.597 -        fprintf(stderr, "Check if file exists and permissions are set correctly.\n");
  19.598 -
  19.599 -#ifdef DUAL_MODE
  19.600 -        if (running != wanted) {
  19.601 -          fprintf(stderr, "Failed to start a %d-bit JVM process from a %d-bit JVM.\n",
  19.602 -                  wanted, running);
  19.603 -#  ifdef __sun
  19.604 -
  19.605 -#    ifdef __sparc
  19.606 -          fprintf(stderr, "Verify all necessary J2SE components have been installed.\n" );
  19.607 -          fprintf(stderr,
  19.608 -                  "(Solaris SPARC 64-bit components must be installed after 32-bit components.)\n" );
  19.609 -#    else
  19.610 -          fprintf(stderr, "Either 64-bit processes are not supported by this platform\n");
  19.611 -          fprintf(stderr, "or the 64-bit components have not been installed.\n");
  19.612 -#    endif
  19.613 -        }
  19.614 -#  endif
  19.615 -#endif
  19.616 -
  19.617 -      }
  19.618 -
  19.619 -      exit(1);
  19.620 -    }
  19.621 -
  19.622 -#else  /* ifndef GAMMA */
  19.623 -
  19.624 -  /*
  19.625 -   * gamma launcher is simpler in that it doesn't handle VM flavors, data
  19.626 -   * model, LD_LIBRARY_PATH, etc. Assuming everything is set-up correctly
  19.627 -   * all we need to do here is to return correct path names. See also
  19.628 -   * GetJVMPath() and GetApplicationHome().
  19.629 -   */
  19.630 -
  19.631 -  { char *arch = (char *) ARCH; /* like sparc or sparcv9 */
  19.632 -    char *p;
  19.633 -
  19.634 -    if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
  19.635 -      fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
  19.636 -      exit(2);
  19.637 -    }
  19.638 -
  19.639 -    if (!GetJVMPath(jrepath, NULL, jvmpath, so_jvmpath, arch )) {
  19.640 -      fprintf(stderr, "Error: no JVM at `%s'.\n", jvmpath);
  19.641 -      exit(4);
  19.642 -    }
  19.643 -  }
  19.644 -
  19.645 -#endif  /* ifndef GAMMA */
  19.646 -}
  19.647 -
  19.648 -
  19.649 -/*
  19.650 - * On Solaris VM choosing is done by the launcher (java.c).
  19.651 - */
  19.652 -static jboolean
  19.653 -GetJVMPath(const char *jrepath, const char *jvmtype,
  19.654 -           char *jvmpath, jint jvmpathsize, char * arch)
  19.655 -{
  19.656 -    struct stat s;
  19.657 -
  19.658 -#ifndef GAMMA
  19.659 -    if (strchr(jvmtype, '/')) {
  19.660 -        sprintf(jvmpath, "%s/" JVM_DLL, jvmtype);
  19.661 -    } else {
  19.662 -        sprintf(jvmpath, "%s/lib/%s/%s/" JVM_DLL, jrepath, arch, jvmtype);
  19.663 -    }
  19.664 -#else
  19.665 -    /*
  19.666 -     * For gamma launcher, JVM is either built-in or in the same directory.
  19.667 -     * Either way we return "<exe_path>/libjvm.so" where <exe_path> is the
  19.668 -     * directory where gamma launcher is located.
  19.669 -     */
  19.670 -
  19.671 -    char *p;
  19.672 -
  19.673 -    snprintf(jvmpath, jvmpathsize, "%s", GetExecname());
  19.674 -    p = strrchr(jvmpath, '/');
  19.675 -    if (p) {
  19.676 -       /* replace executable name with libjvm.so */
  19.677 -       snprintf(p + 1, jvmpathsize - (p + 1 - jvmpath), "%s", JVM_DLL);
  19.678 -    } else {
  19.679 -       /* this case shouldn't happen */
  19.680 -       snprintf(jvmpath, jvmpathsize, "%s", JVM_DLL);
  19.681 -    }
  19.682 -#endif /* ifndef GAMMA */
  19.683 -
  19.684 -    if (_launcher_debug)
  19.685 -      printf("Does `%s' exist ... ", jvmpath);
  19.686 -
  19.687 -    if (stat(jvmpath, &s) == 0) {
  19.688 -        if (_launcher_debug)
  19.689 -          printf("yes.\n");
  19.690 -        return JNI_TRUE;
  19.691 -    } else {
  19.692 -        if (_launcher_debug)
  19.693 -          printf("no.\n");
  19.694 -        return JNI_FALSE;
  19.695 -    }
  19.696 -}
  19.697 -
  19.698 -/*
  19.699 - * Find path to JRE based on .exe's location or registry settings.
  19.700 - */
  19.701 -static jboolean
  19.702 -GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative)
  19.703 -{
  19.704 -    char libjava[MAXPATHLEN];
  19.705 -
  19.706 -    if (GetApplicationHome(path, pathsize)) {
  19.707 -
  19.708 -        /* Is the JRE universal, i.e. no arch dir? */
  19.709 -        sprintf(libjava, "%s/jre/lib/" JAVA_DLL, path);
  19.710 -        if (access(libjava, F_OK) == 0) {
  19.711 -            strcat(path, "/jre");
  19.712 -            goto found;
  19.713 -        }
  19.714 -
  19.715 -        /* Is JRE co-located with the application? */
  19.716 -        sprintf(libjava, "%s/lib/%s/" JAVA_DLL, path, arch);
  19.717 -        if (access(libjava, F_OK) == 0) {
  19.718 -            goto found;
  19.719 -        }
  19.720 -
  19.721 -        /* Does the app ship a private JRE in <apphome>/jre directory? */
  19.722 -        sprintf(libjava, "%s/jre/lib/%s/" JAVA_DLL, path, arch);
  19.723 -        if (access(libjava, F_OK) == 0) {
  19.724 -            strcat(path, "/jre");
  19.725 -            goto found;
  19.726 -        }
  19.727 -    }
  19.728 -
  19.729 -    if (!speculative)
  19.730 -      fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
  19.731 -    return JNI_FALSE;
  19.732 -
  19.733 - found:
  19.734 -    if (_launcher_debug)
  19.735 -      printf("JRE path is %s\n", path);
  19.736 -    return JNI_TRUE;
  19.737 -}
  19.738 -
  19.739 -jboolean
  19.740 -LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
  19.741 -{
  19.742 -#ifdef GAMMA
  19.743 -    /* JVM is directly linked with gamma launcher; no dlopen() */
  19.744 -    ifn->CreateJavaVM = JNI_CreateJavaVM;
  19.745 -    ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
  19.746 -    return JNI_TRUE;
  19.747 -#else
  19.748 -    Dl_info dlinfo;
  19.749 -    void *libjvm;
  19.750 -
  19.751 -    if (_launcher_debug) {
  19.752 -        printf("JVM path is %s\n", jvmpath);
  19.753 -    }
  19.754 -
  19.755 -    libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
  19.756 -    if (libjvm == NULL) {
  19.757 -#if defined(__sparc) && !defined(_LP64) /* i.e. 32-bit sparc */
  19.758 -      FILE * fp;
  19.759 -      Elf32_Ehdr elf_head;
  19.760 -      int count;
  19.761 -      int location;
  19.762 -
  19.763 -      fp = fopen(jvmpath, "r");
  19.764 -      if(fp == NULL)
  19.765 -        goto error;
  19.766 -
  19.767 -      /* read in elf header */
  19.768 -      count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp);
  19.769 -      fclose(fp);
  19.770 -      if(count < 1)
  19.771 -        goto error;
  19.772 -
  19.773 -      /*
  19.774 -       * Check for running a server vm (compiled with -xarch=v8plus)
  19.775 -       * on a stock v8 processor.  In this case, the machine type in
  19.776 -       * the elf header would not be included the architecture list
  19.777 -       * provided by the isalist command, which is turn is gotten from
  19.778 -       * sysinfo.  This case cannot occur on 64-bit hardware and thus
  19.779 -       * does not have to be checked for in binaries with an LP64 data
  19.780 -       * model.
  19.781 -       */
  19.782 -      if(elf_head.e_machine == EM_SPARC32PLUS) {
  19.783 -        char buf[257];  /* recommended buffer size from sysinfo man
  19.784 -                           page */
  19.785 -        long length;
  19.786 -        char* location;
  19.787 -
  19.788 -        length = sysinfo(SI_ISALIST, buf, 257);
  19.789 -        if(length > 0) {
  19.790 -          location = strstr(buf, "sparcv8plus ");
  19.791 -          if(location == NULL) {
  19.792 -            fprintf(stderr, "SPARC V8 processor detected; Server compiler requires V9 or better.\n");
  19.793 -            fprintf(stderr, "Use Client compiler on V8 processors.\n");
  19.794 -            fprintf(stderr, "Could not create the Java virtual machine.\n");
  19.795 -            return JNI_FALSE;
  19.796 -          }
  19.797 -        }
  19.798 -      }
  19.799 -#endif
  19.800 -      fprintf(stderr, "dl failure on line %d", __LINE__);
  19.801 -      goto error;
  19.802 -    }
  19.803 -
  19.804 -    ifn->CreateJavaVM = (CreateJavaVM_t)
  19.805 -      dlsym(libjvm, "JNI_CreateJavaVM");
  19.806 -    if (ifn->CreateJavaVM == NULL)
  19.807 -        goto error;
  19.808 -
  19.809 -    ifn->GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)
  19.810 -        dlsym(libjvm, "JNI_GetDefaultJavaVMInitArgs");
  19.811 -    if (ifn->GetDefaultJavaVMInitArgs == NULL)
  19.812 -      goto error;
  19.813 -
  19.814 -    return JNI_TRUE;
  19.815 -
  19.816 -error:
  19.817 -    fprintf(stderr, "Error: failed %s, because %s\n", jvmpath, dlerror());
  19.818 -    return JNI_FALSE;
  19.819 -#endif /* ifndef GAMMA */
  19.820 -}
  19.821 -
  19.822 -/*
  19.823 - * If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put
  19.824 - * "/foo" into buf.
  19.825 - */
  19.826 -jboolean
  19.827 -GetApplicationHome(char *buf, jint bufsize)
  19.828 -{
  19.829 -#if defined(__linux__) || defined(_ALLBSD_SOURCE)
  19.830 -    char *execname = GetExecname();
  19.831 -    if (execname) {
  19.832 -        strncpy(buf, execname, bufsize-1);
  19.833 -        buf[bufsize-1] = '\0';
  19.834 -    } else {
  19.835 -        return JNI_FALSE;
  19.836 -    }
  19.837 -#else
  19.838 -    Dl_info dlinfo;
  19.839 -
  19.840 -    dladdr((void *)GetApplicationHome, &dlinfo);
  19.841 -    if (realpath(dlinfo.dli_fname, buf) == NULL) {
  19.842 -        fprintf(stderr, "Error: realpath(`%s') failed.\n", dlinfo.dli_fname);
  19.843 -        return JNI_FALSE;
  19.844 -    }
  19.845 -#endif
  19.846 -
  19.847 -#ifdef GAMMA
  19.848 -    {
  19.849 -       /* gamma launcher uses JAVA_HOME environment variable to find JDK/JRE */
  19.850 -       char* java_home_var = getenv("JAVA_HOME");
  19.851 -       if (java_home_var == NULL) {
  19.852 -          printf("JAVA_HOME must point to a valid JDK/JRE to run gamma\n");
  19.853 -          return JNI_FALSE;
  19.854 -       }
  19.855 -       snprintf(buf, bufsize, "%s", java_home_var);
  19.856 -    }
  19.857 -#else
  19.858 -    if (strrchr(buf, '/') == 0) {
  19.859 -        buf[0] = '\0';
  19.860 -        return JNI_FALSE;
  19.861 -    }
  19.862 -    *(strrchr(buf, '/')) = '\0';        /* executable file      */
  19.863 -    if (strlen(buf) < 4 || strrchr(buf, '/') == 0) {
  19.864 -        buf[0] = '\0';
  19.865 -        return JNI_FALSE;
  19.866 -    }
  19.867 -    if (strcmp("/bin", buf + strlen(buf) - 4) != 0)
  19.868 -        *(strrchr(buf, '/')) = '\0';    /* sparcv9 or amd64     */
  19.869 -    if (strlen(buf) < 4 || strcmp("/bin", buf + strlen(buf) - 4) != 0) {
  19.870 -        buf[0] = '\0';
  19.871 -        return JNI_FALSE;
  19.872 -    }
  19.873 -    *(strrchr(buf, '/')) = '\0';        /* bin                  */
  19.874 -#endif /* ifndef GAMMA */
  19.875 -
  19.876 -    return JNI_TRUE;
  19.877 -}
  19.878 -
  19.879 -
  19.880 -/*
  19.881 - * Return true if the named program exists
  19.882 - */
  19.883 -static int
  19.884 -ProgramExists(char *name)
  19.885 -{
  19.886 -    struct stat sb;
  19.887 -    if (stat(name, &sb) != 0) return 0;
  19.888 -    if (S_ISDIR(sb.st_mode)) return 0;
  19.889 -    return (sb.st_mode & S_IEXEC) != 0;
  19.890 -}
  19.891 -
  19.892 -
  19.893 -/*
  19.894 - * Find a command in a directory, returning the path.
  19.895 - */
  19.896 -static char *
  19.897 -Resolve(char *indir, char *cmd)
  19.898 -{
  19.899 -    char name[PATH_MAX + 2], *real;
  19.900 -
  19.901 -    if ((strlen(indir) + strlen(cmd) + 1)  > PATH_MAX) return 0;
  19.902 -    sprintf(name, "%s%c%s", indir, FILE_SEPARATOR, cmd);
  19.903 -    if (!ProgramExists(name)) return 0;
  19.904 -    real = JLI_MemAlloc(PATH_MAX + 2);
  19.905 -    if (!realpath(name, real))
  19.906 -        strcpy(real, name);
  19.907 -    return real;
  19.908 -}
  19.909 -
  19.910 -
  19.911 -/*
  19.912 - * Find a path for the executable
  19.913 - */
  19.914 -static char *
  19.915 -FindExecName(char *program)
  19.916 -{
  19.917 -    char cwdbuf[PATH_MAX+2];
  19.918 -    char *path;
  19.919 -    char *tmp_path;
  19.920 -    char *f;
  19.921 -    char *result = NULL;
  19.922 -
  19.923 -    /* absolute path? */
  19.924 -    if (*program == FILE_SEPARATOR ||
  19.925 -        (FILE_SEPARATOR=='\\' && strrchr(program, ':')))
  19.926 -        return Resolve("", program+1);
  19.927 -
  19.928 -    /* relative path? */
  19.929 -    if (strrchr(program, FILE_SEPARATOR) != 0) {
  19.930 -        char buf[PATH_MAX+2];
  19.931 -        return Resolve(getcwd(cwdbuf, sizeof(cwdbuf)), program);
  19.932 -    }
  19.933 -
  19.934 -    /* from search path? */
  19.935 -    path = getenv("PATH");
  19.936 -    if (!path || !*path) path = ".";
  19.937 -    tmp_path = JLI_MemAlloc(strlen(path) + 2);
  19.938 -    strcpy(tmp_path, path);
  19.939 -
  19.940 -    for (f=tmp_path; *f && result==0; ) {
  19.941 -        char *s = f;
  19.942 -        while (*f && (*f != PATH_SEPARATOR)) ++f;
  19.943 -        if (*f) *f++ = 0;
  19.944 -        if (*s == FILE_SEPARATOR)
  19.945 -            result = Resolve(s, program);
  19.946 -        else {
  19.947 -            /* relative path element */
  19.948 -            char dir[2*PATH_MAX];
  19.949 -            sprintf(dir, "%s%c%s", getcwd(cwdbuf, sizeof(cwdbuf)),
  19.950 -                    FILE_SEPARATOR, s);
  19.951 -            result = Resolve(dir, program);
  19.952 -        }
  19.953 -        if (result != 0) break;
  19.954 -    }
  19.955 -
  19.956 -    JLI_MemFree(tmp_path);
  19.957 -    return result;
  19.958 -}
  19.959 -
  19.960 -
  19.961 -/* Store the name of the executable once computed */
  19.962 -static char *execname = NULL;
  19.963 -
  19.964 -/*
  19.965 - * Compute the name of the executable
  19.966 - *
  19.967 - * In order to re-exec securely we need the absolute path of the
  19.968 - * executable. On Solaris getexecname(3c) may not return an absolute
  19.969 - * path so we use dladdr to get the filename of the executable and
  19.970 - * then use realpath to derive an absolute path. From Solaris 9
  19.971 - * onwards the filename returned in DL_info structure from dladdr is
  19.972 - * an absolute pathname so technically realpath isn't required.
  19.973 - * On Linux we read the executable name from /proc/self/exe.
  19.974 - * As a fallback, and for platforms other than Solaris and Linux,
  19.975 - * we use FindExecName to compute the executable name.
  19.976 - */
  19.977 -static char *
  19.978 -SetExecname(char **argv)
  19.979 -{
  19.980 -    char* exec_path = NULL;
  19.981 -
  19.982 -    if (execname != NULL)       /* Already determined */
  19.983 -        return (execname);
  19.984 -
  19.985 -#if defined(__sun)
  19.986 -    {
  19.987 -        Dl_info dlinfo;
  19.988 -        if (dladdr((void*)&SetExecname, &dlinfo)) {
  19.989 -            char *resolved = (char*)JLI_MemAlloc(PATH_MAX+1);
  19.990 -            if (resolved != NULL) {
  19.991 -                exec_path = realpath(dlinfo.dli_fname, resolved);
  19.992 -                if (exec_path == NULL) {
  19.993 -                    JLI_MemFree(resolved);
  19.994 -                }
  19.995 -            }
  19.996 -        }
  19.997 -    }
  19.998 -#elif defined(__linux__)
  19.999 -    {
 19.1000 -        const char* self = "/proc/self/exe";
 19.1001 -        char buf[PATH_MAX+1];
 19.1002 -        int len = readlink(self, buf, PATH_MAX);
 19.1003 -        if (len >= 0) {
 19.1004 -            buf[len] = '\0';            /* readlink doesn't nul terminate */
 19.1005 -            exec_path = JLI_StringDup(buf);
 19.1006 -        }
 19.1007 -    }
 19.1008 -#else /* !__sun && !__linux */
 19.1009 -    {
 19.1010 -        /* Not implemented */
 19.1011 -    }
 19.1012 -#endif
 19.1013 -
 19.1014 -    if (exec_path == NULL) {
 19.1015 -        exec_path = FindExecName(argv[0]);
 19.1016 -    }
 19.1017 -    execname = exec_path;
 19.1018 -    return exec_path;
 19.1019 -}
 19.1020 -
 19.1021 -/*
 19.1022 - * Return the name of the executable.  Used in java_md.c to find the JRE area.
 19.1023 - */
 19.1024 -static char *
 19.1025 -GetExecname() {
 19.1026 -  return execname;
 19.1027 -}
 19.1028 -
 19.1029 -void ReportErrorMessage(char * message, jboolean always) {
 19.1030 -  if (always) {
 19.1031 -    fprintf(stderr, "%s\n", message);
 19.1032 -  }
 19.1033 -}
 19.1034 -
 19.1035 -void ReportErrorMessage2(char * format, char * string, jboolean always) {
 19.1036 -  if (always) {
 19.1037 -    fprintf(stderr, format, string);
 19.1038 -    fprintf(stderr, "\n");
 19.1039 -  }
 19.1040 -}
 19.1041 -
 19.1042 -void  ReportExceptionDescription(JNIEnv * env) {
 19.1043 -  (*env)->ExceptionDescribe(env);
 19.1044 -}
 19.1045 -
 19.1046 -/*
 19.1047 - * Return JNI_TRUE for an option string that has no effect but should
 19.1048 - * _not_ be passed on to the vm; return JNI_FALSE otherwise.  On
 19.1049 - * Solaris SPARC, this screening needs to be done if:
 19.1050 - * 1) LD_LIBRARY_PATH does _not_ need to be reset and
 19.1051 - * 2) -d32 or -d64 is passed to a binary with a matching data model
 19.1052 - *    (the exec in SetLibraryPath removes -d<n> options and points the
 19.1053 - *    exec to the proper binary).  When this exec is not done, these options
 19.1054 - *    would end up getting passed onto the vm.
 19.1055 - */
 19.1056 -jboolean RemovableMachineDependentOption(char * option) {
 19.1057 -  /*
 19.1058 -   * Unconditionally remove both -d32 and -d64 options since only
 19.1059 -   * the last such options has an effect; e.g.
 19.1060 -   * java -d32 -d64 -d32 -version
 19.1061 -   * is equivalent to
 19.1062 -   * java -d32 -version
 19.1063 -   */
 19.1064 -
 19.1065 -  if( (strcmp(option, "-d32")  == 0 ) ||
 19.1066 -      (strcmp(option, "-d64")  == 0 ))
 19.1067 -    return JNI_TRUE;
 19.1068 -  else
 19.1069 -    return JNI_FALSE;
 19.1070 -}
 19.1071 -
 19.1072 -void PrintMachineDependentOptions() {
 19.1073 -      fprintf(stdout,
 19.1074 -        "    -d32          use a 32-bit data model if available\n"
 19.1075 -        "\n"
 19.1076 -        "    -d64          use a 64-bit data model if available\n");
 19.1077 -      return;
 19.1078 -}
 19.1079 -
 19.1080 -#ifndef GAMMA
 19.1081 -/*
 19.1082 - * The following methods (down to ServerClassMachine()) answer
 19.1083 - * the question about whether a machine is a "server-class"
 19.1084 - * machine.  A server-class machine is loosely defined as one
 19.1085 - * with 2 or more processors and 2 gigabytes or more physical
 19.1086 - * memory.  The definition of a processor is a physical package,
 19.1087 - * not a hyperthreaded chip masquerading as a multi-processor.
 19.1088 - * The definition of memory is also somewhat fuzzy, since x86
 19.1089 - * machines seem not to report all the memory in their DIMMs, we
 19.1090 - * think because of memory mapping of graphics cards, etc.
 19.1091 - *
 19.1092 - * This code is somewhat more confused with #ifdef's than we'd
 19.1093 - * like because this file is used by both Solaris and Linux
 19.1094 - * platforms, and so needs to be parameterized for SPARC and
 19.1095 - * i586 hardware.  The other Linux platforms (amd64 and ia64)
 19.1096 - * don't even ask this question, because they only come with
 19.1097 - * server JVMs.  */
 19.1098 -
 19.1099 -# define KB (1024UL)
 19.1100 -# define MB (1024UL * KB)
 19.1101 -# define GB (1024UL * MB)
 19.1102 -
 19.1103 -/* Compute physical memory by asking the OS */
 19.1104 -uint64_t
 19.1105 -physical_memory(void) {
 19.1106 -  const uint64_t pages     = (uint64_t) sysconf(_SC_PHYS_PAGES);
 19.1107 -  const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE);
 19.1108 -  const uint64_t result    = pages * page_size;
 19.1109 -# define UINT64_FORMAT "%" PRIu64
 19.1110 -
 19.1111 -  if (_launcher_debug) {
 19.1112 -    printf("pages: " UINT64_FORMAT
 19.1113 -           "  page_size: " UINT64_FORMAT
 19.1114 -           "  physical memory: " UINT64_FORMAT " (%.3fGB)\n",
 19.1115 -           pages, page_size, result, result / (double) GB);
 19.1116 -  }
 19.1117 -  return result;
 19.1118 -}
 19.1119 -
 19.1120 -#if defined(__sun) && defined(__sparc)
 19.1121 -
 19.1122 -/* Methods for solaris-sparc: these are easy. */
 19.1123 -
 19.1124 -/* Ask the OS how many processors there are. */
 19.1125 -unsigned long
 19.1126 -physical_processors(void) {
 19.1127 -  const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
 19.1128 -
 19.1129 -  if (_launcher_debug) {
 19.1130 -    printf("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
 19.1131 -  }
 19.1132 -  return sys_processors;
 19.1133 -}
 19.1134 -
 19.1135 -/* The solaris-sparc version of the "server-class" predicate. */
 19.1136 -jboolean
 19.1137 -solaris_sparc_ServerClassMachine(void) {
 19.1138 -  jboolean            result            = JNI_FALSE;
 19.1139 -  /* How big is a server class machine? */
 19.1140 -  const unsigned long server_processors = 2UL;
 19.1141 -  const uint64_t      server_memory     = 2UL * GB;
 19.1142 -  const uint64_t      actual_memory     = physical_memory();
 19.1143 -
 19.1144 -  /* Is this a server class machine? */
 19.1145 -  if (actual_memory >= server_memory) {
 19.1146 -    const unsigned long actual_processors = physical_processors();
 19.1147 -    if (actual_processors >= server_processors) {
 19.1148 -      result = JNI_TRUE;
 19.1149 -    }
 19.1150 -  }
 19.1151 -  if (_launcher_debug) {
 19.1152 -    printf("solaris_" LIBARCHNAME "_ServerClassMachine: %s\n",
 19.1153 -           (result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE"));
 19.1154 -  }
 19.1155 -  return result;
 19.1156 -}
 19.1157 -
 19.1158 -#endif /* __sun && __sparc */
 19.1159 -
 19.1160 -#if defined(__sun) && defined(i586)
 19.1161 -
 19.1162 -/*
 19.1163 - * A utility method for asking the CPU about itself.
 19.1164 - * There's a corresponding version of linux-i586
 19.1165 - * because the compilers are different.
 19.1166 - */
 19.1167 -void
 19.1168 -get_cpuid(uint32_t arg,
 19.1169 -          uint32_t* eaxp,
 19.1170 -          uint32_t* ebxp,
 19.1171 -          uint32_t* ecxp,
 19.1172 -          uint32_t* edxp) {
 19.1173 -#ifdef _LP64
 19.1174 -  asm(
 19.1175 -  /* rbx is a callee-saved register */
 19.1176 -      " movq    %rbx, %r11  \n"
 19.1177 -  /* rdx and rcx are 3rd and 4th argument registers */
 19.1178 -      " movq    %rdx, %r10  \n"
 19.1179 -      " movq    %rcx, %r9   \n"
 19.1180 -      " movl    %edi, %eax  \n"
 19.1181 -      " cpuid               \n"
 19.1182 -      " movl    %eax, (%rsi)\n"
 19.1183 -      " movl    %ebx, (%r10)\n"
 19.1184 -      " movl    %ecx, (%r9) \n"
 19.1185 -      " movl    %edx, (%r8) \n"
 19.1186 -  /* Restore rbx */
 19.1187 -      " movq    %r11, %rbx");
 19.1188 -#else
 19.1189 -  /* EBX is a callee-saved register */
 19.1190 -  asm(" pushl   %ebx");
 19.1191 -  /* Need ESI for storing through arguments */
 19.1192 -  asm(" pushl   %esi");
 19.1193 -  asm(" movl    8(%ebp), %eax   \n"
 19.1194 -      " cpuid                   \n"
 19.1195 -      " movl    12(%ebp), %esi  \n"
 19.1196 -      " movl    %eax, (%esi)    \n"
 19.1197 -      " movl    16(%ebp), %esi  \n"
 19.1198 -      " movl    %ebx, (%esi)    \n"
 19.1199 -      " movl    20(%ebp), %esi  \n"
 19.1200 -      " movl    %ecx, (%esi)    \n"
 19.1201 -      " movl    24(%ebp), %esi  \n"
 19.1202 -      " movl    %edx, (%esi)      ");
 19.1203 -  /* Restore ESI and EBX */
 19.1204 -  asm(" popl    %esi");
 19.1205 -  /* Restore EBX */
 19.1206 -  asm(" popl    %ebx");
 19.1207 -#endif
 19.1208 -}
 19.1209 -
 19.1210 -#endif /* __sun && i586 */
 19.1211 -
 19.1212 -#if (defined(__linux__) || defined(_ALLBSD_SOURCE)) && defined(i586)
 19.1213 -
 19.1214 -/*
 19.1215 - * A utility method for asking the CPU about itself.
 19.1216 - * There's a corresponding version of solaris-i586
 19.1217 - * because the compilers are different.
 19.1218 - */
 19.1219 -void
 19.1220 -get_cpuid(uint32_t arg,
 19.1221 -          uint32_t* eaxp,
 19.1222 -          uint32_t* ebxp,
 19.1223 -          uint32_t* ecxp,
 19.1224 -          uint32_t* edxp) {
 19.1225 -#ifdef _LP64
 19.1226 -  __asm__ volatile (/* Instructions */
 19.1227 -                    "   movl    %4, %%eax  \n"
 19.1228 -                    "   cpuid              \n"
 19.1229 -                    "   movl    %%eax, (%0)\n"
 19.1230 -                    "   movl    %%ebx, (%1)\n"
 19.1231 -                    "   movl    %%ecx, (%2)\n"
 19.1232 -                    "   movl    %%edx, (%3)\n"
 19.1233 -                    : /* Outputs */
 19.1234 -                    : /* Inputs */
 19.1235 -                    "r" (eaxp),
 19.1236 -                    "r" (ebxp),
 19.1237 -                    "r" (ecxp),
 19.1238 -                    "r" (edxp),
 19.1239 -                    "r" (arg)
 19.1240 -                    : /* Clobbers */
 19.1241 -                    "%rax", "%rbx", "%rcx", "%rdx", "memory"
 19.1242 -                    );
 19.1243 -#else
 19.1244 -  uint32_t value_of_eax = 0;
 19.1245 -  uint32_t value_of_ebx = 0;
 19.1246 -  uint32_t value_of_ecx = 0;
 19.1247 -  uint32_t value_of_edx = 0;
 19.1248 -  __asm__ volatile (/* Instructions */
 19.1249 -                        /* ebx is callee-save, so push it */
 19.1250 -                    "   pushl   %%ebx      \n"
 19.1251 -                    "   movl    %4, %%eax  \n"
 19.1252 -                    "   cpuid              \n"
 19.1253 -                    "   movl    %%eax, %0  \n"
 19.1254 -                    "   movl    %%ebx, %1  \n"
 19.1255 -                    "   movl    %%ecx, %2  \n"
 19.1256 -                    "   movl    %%edx, %3  \n"
 19.1257 -                        /* restore ebx */
 19.1258 -                    "   popl    %%ebx      \n"
 19.1259 -
 19.1260 -                    : /* Outputs */
 19.1261 -                    "=m" (value_of_eax),
 19.1262 -                    "=m" (value_of_ebx),
 19.1263 -                    "=m" (value_of_ecx),
 19.1264 -                    "=m" (value_of_edx)
 19.1265 -                    : /* Inputs */
 19.1266 -                    "m" (arg)
 19.1267 -                    : /* Clobbers */
 19.1268 -                    "%eax", "%ecx", "%edx"
 19.1269 -                    );
 19.1270 -  *eaxp = value_of_eax;
 19.1271 -  *ebxp = value_of_ebx;
 19.1272 -  *ecxp = value_of_ecx;
 19.1273 -  *edxp = value_of_edx;
 19.1274 -#endif
 19.1275 -}
 19.1276 -
 19.1277 -#endif /* __linux__ && i586 */
 19.1278 -
 19.1279 -#ifdef i586
 19.1280 -/*
 19.1281 - * Routines shared by solaris-i586 and linux-i586.
 19.1282 - */
 19.1283 -
 19.1284 -enum HyperThreadingSupport_enum {
 19.1285 -  hts_supported        =  1,
 19.1286 -  hts_too_soon_to_tell =  0,
 19.1287 -  hts_not_supported    = -1,
 19.1288 -  hts_not_pentium4     = -2,
 19.1289 -  hts_not_intel        = -3
 19.1290 -};
 19.1291 -typedef enum HyperThreadingSupport_enum HyperThreadingSupport;
 19.1292 -
 19.1293 -/* Determine if hyperthreading is supported */
 19.1294 -HyperThreadingSupport
 19.1295 -hyperthreading_support(void) {
 19.1296 -  HyperThreadingSupport result = hts_too_soon_to_tell;
 19.1297 -  /* Bits 11 through 8 is family processor id */
 19.1298 -# define FAMILY_ID_SHIFT 8
 19.1299 -# define FAMILY_ID_MASK 0xf
 19.1300 -  /* Bits 23 through 20 is extended family processor id */
 19.1301 -# define EXT_FAMILY_ID_SHIFT 20
 19.1302 -# define EXT_FAMILY_ID_MASK 0xf
 19.1303 -  /* Pentium 4 family processor id */
 19.1304 -# define PENTIUM4_FAMILY_ID 0xf
 19.1305 -  /* Bit 28 indicates Hyper-Threading Technology support */
 19.1306 -# define HT_BIT_SHIFT 28
 19.1307 -# define HT_BIT_MASK 1
 19.1308 -  uint32_t vendor_id[3] = { 0U, 0U, 0U };
 19.1309 -  uint32_t value_of_eax = 0U;
 19.1310 -  uint32_t value_of_edx = 0U;
 19.1311 -  uint32_t dummy        = 0U;
 19.1312 -
 19.1313 -  /* Yes, this is supposed to be [0], [2], [1] */
 19.1314 -  get_cpuid(0, &dummy, &vendor_id[0], &vendor_id[2], &vendor_id[1]);
 19.1315 -  if (_launcher_debug) {
 19.1316 -    printf("vendor: %c %c %c %c %c %c %c %c %c %c %c %c \n",
 19.1317 -           ((vendor_id[0] >>  0) & 0xff),
 19.1318 -           ((vendor_id[0] >>  8) & 0xff),
 19.1319 -           ((vendor_id[0] >> 16) & 0xff),
 19.1320 -           ((vendor_id[0] >> 24) & 0xff),
 19.1321 -           ((vendor_id[1] >>  0) & 0xff),
 19.1322 -           ((vendor_id[1] >>  8) & 0xff),
 19.1323 -           ((vendor_id[1] >> 16) & 0xff),
 19.1324 -           ((vendor_id[1] >> 24) & 0xff),
 19.1325 -           ((vendor_id[2] >>  0) & 0xff),
 19.1326 -           ((vendor_id[2] >>  8) & 0xff),
 19.1327 -           ((vendor_id[2] >> 16) & 0xff),
 19.1328 -           ((vendor_id[2] >> 24) & 0xff));
 19.1329 -  }
 19.1330 -  get_cpuid(1, &value_of_eax, &dummy, &dummy, &value_of_edx);
 19.1331 -  if (_launcher_debug) {
 19.1332 -    printf("value_of_eax: 0x%x  value_of_edx: 0x%x\n",
 19.1333 -           value_of_eax, value_of_edx);
 19.1334 -  }
 19.1335 -  if ((((value_of_eax >> FAMILY_ID_SHIFT) & FAMILY_ID_MASK) == PENTIUM4_FAMILY_ID) ||
 19.1336 -      (((value_of_eax >> EXT_FAMILY_ID_SHIFT) & EXT_FAMILY_ID_MASK) != 0)) {
 19.1337 -    if ((((vendor_id[0] >>  0) & 0xff) == 'G') &&
 19.1338 -        (((vendor_id[0] >>  8) & 0xff) == 'e') &&
 19.1339 -        (((vendor_id[0] >> 16) & 0xff) == 'n') &&
 19.1340 -        (((vendor_id[0] >> 24) & 0xff) == 'u') &&
 19.1341 -        (((vendor_id[1] >>  0) & 0xff) == 'i') &&
 19.1342 -        (((vendor_id[1] >>  8) & 0xff) == 'n') &&
 19.1343 -        (((vendor_id[1] >> 16) & 0xff) == 'e') &&
 19.1344 -        (((vendor_id[1] >> 24) & 0xff) == 'I') &&
 19.1345 -        (((vendor_id[2] >>  0) & 0xff) == 'n') &&
 19.1346 -        (((vendor_id[2] >>  8) & 0xff) == 't') &&
 19.1347 -        (((vendor_id[2] >> 16) & 0xff) == 'e') &&
 19.1348 -        (((vendor_id[2] >> 24) & 0xff) == 'l')) {
 19.1349 -      if (((value_of_edx >> HT_BIT_SHIFT) & HT_BIT_MASK) == HT_BIT_MASK) {
 19.1350 -        if (_launcher_debug) {
 19.1351 -          printf("Hyperthreading supported\n");
 19.1352 -        }
 19.1353 -        result = hts_supported;
 19.1354 -      } else {
 19.1355 -        if (_launcher_debug) {
 19.1356 -          printf("Hyperthreading not supported\n");
 19.1357 -        }
 19.1358 -        result = hts_not_supported;
 19.1359 -      }
 19.1360 -    } else {
 19.1361 -      if (_launcher_debug) {
 19.1362 -        printf("Not GenuineIntel\n");
 19.1363 -      }
 19.1364 -      result = hts_not_intel;
 19.1365 -    }
 19.1366 -  } else {
 19.1367 -    if (_launcher_debug) {
 19.1368 -      printf("not Pentium 4 or extended\n");
 19.1369 -    }
 19.1370 -    result = hts_not_pentium4;
 19.1371 -  }
 19.1372 -  return result;
 19.1373 -}
 19.1374 -
 19.1375 -/* Determine how many logical processors there are per CPU */
 19.1376 -unsigned int
 19.1377 -logical_processors_per_package(void) {
 19.1378 -  /*
 19.1379 -   * After CPUID with EAX==1, register EBX bits 23 through 16
 19.1380 -   * indicate the number of logical processors per package
 19.1381 -   */
 19.1382 -# define NUM_LOGICAL_SHIFT 16
 19.1383 -# define NUM_LOGICAL_MASK 0xff
 19.1384 -  unsigned int result                        = 1U;
 19.1385 -  const HyperThreadingSupport hyperthreading = hyperthreading_support();
 19.1386 -
 19.1387 -  if (hyperthreading == hts_supported) {
 19.1388 -    uint32_t value_of_ebx = 0U;
 19.1389 -    uint32_t dummy        = 0U;
 19.1390 -
 19.1391 -    get_cpuid(1, &dummy, &value_of_ebx, &dummy, &dummy);
 19.1392 -    result = (value_of_ebx >> NUM_LOGICAL_SHIFT) & NUM_LOGICAL_MASK;
 19.1393 -    if (_launcher_debug) {
 19.1394 -      printf("logical processors per package: %u\n", result);
 19.1395 -    }
 19.1396 -  }
 19.1397 -  return result;
 19.1398 -}
 19.1399 -
 19.1400 -/* Compute the number of physical processors, not logical processors */
 19.1401 -unsigned long
 19.1402 -physical_processors(void) {
 19.1403 -  const long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
 19.1404 -  unsigned long result      = sys_processors;
 19.1405 -
 19.1406 -  if (_launcher_debug) {
 19.1407 -    printf("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
 19.1408 -  }
 19.1409 -  if (sys_processors > 1) {
 19.1410 -    unsigned int logical_processors = logical_processors_per_package();
 19.1411 -    if (logical_processors > 1) {
 19.1412 -      result = (unsigned long) sys_processors / logical_processors;
 19.1413 -    }
 19.1414 -  }
 19.1415 -  if (_launcher_debug) {
 19.1416 -    printf("physical processors: %lu\n", result);
 19.1417 -  }
 19.1418 -  return result;
 19.1419 -}
 19.1420 -
 19.1421 -#endif /* i586 */
 19.1422 -
 19.1423 -#if defined(__sun) && defined(i586)
 19.1424 -
 19.1425 -/* The definition of a server-class machine for solaris-i586/amd64 */
 19.1426 -jboolean
 19.1427 -solaris_i586_ServerClassMachine(void) {
 19.1428 -  jboolean            result            = JNI_FALSE;
 19.1429 -  /* How big is a server class machine? */
 19.1430 -  const unsigned long server_processors = 2UL;
 19.1431 -  const uint64_t      server_memory     = 2UL * GB;
 19.1432 -  /*
 19.1433 -   * We seem not to get our full complement of memory.
 19.1434 -   *     We allow some part (1/8?) of the memory to be "missing",
 19.1435 -   *     based on the sizes of DIMMs, and maybe graphics cards.
 19.1436 -   */
 19.1437 -  const uint64_t      missing_memory    = 256UL * MB;
 19.1438 -  const uint64_t      actual_memory     = physical_memory();
 19.1439 -
 19.1440 -  /* Is this a server class machine? */
 19.1441 -  if (actual_memory >= (server_memory - missing_memory)) {
 19.1442 -    const unsigned long actual_processors = physical_processors();
 19.1443 -    if (actual_processors >= server_processors) {
 19.1444 -      result = JNI_TRUE;
 19.1445 -    }
 19.1446 -  }
 19.1447 -  if (_launcher_debug) {
 19.1448 -    printf("solaris_" LIBARCHNAME "_ServerClassMachine: %s\n",
 19.1449 -           (result == JNI_TRUE ? "true" : "false"));
 19.1450 -  }
 19.1451 -  return result;
 19.1452 -}
 19.1453 -
 19.1454 -#endif /* __sun && i586 */
 19.1455 -
 19.1456 -#if defined(__linux__) && defined(i586)
 19.1457 -
 19.1458 -/* The definition of a server-class machine for linux-i586 */
 19.1459 -jboolean
 19.1460 -linux_i586_ServerClassMachine(void) {
 19.1461 -  jboolean            result            = JNI_FALSE;
 19.1462 -  /* How big is a server class machine? */
 19.1463 -  const unsigned long server_processors = 2UL;
 19.1464 -  const uint64_t      server_memory     = 2UL * GB;
 19.1465 -  /*
 19.1466 -   * We seem not to get our full complement of memory.
 19.1467 -   *     We allow some part (1/8?) of the memory to be "missing",
 19.1468 -   *     based on the sizes of DIMMs, and maybe graphics cards.
 19.1469 -   */
 19.1470 -  const uint64_t      missing_memory    = 256UL * MB;
 19.1471 -  const uint64_t      actual_memory     = physical_memory();
 19.1472 -
 19.1473 -  /* Is this a server class machine? */
 19.1474 -  if (actual_memory >= (server_memory - missing_memory)) {
 19.1475 -    const unsigned long actual_processors = physical_processors();
 19.1476 -    if (actual_processors >= server_processors) {
 19.1477 -      result = JNI_TRUE;
 19.1478 -    }
 19.1479 -  }
 19.1480 -  if (_launcher_debug) {
 19.1481 -    printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
 19.1482 -           (result == JNI_TRUE ? "true" : "false"));
 19.1483 -  }
 19.1484 -  return result;
 19.1485 -}
 19.1486 -
 19.1487 -#endif /* __linux__ && i586 */
 19.1488 -
 19.1489 -#if defined(_ALLBSD_SOURCE) && defined(i586)
 19.1490 -
 19.1491 -/* The definition of a server-class machine for bsd-i586 */
 19.1492 -jboolean
 19.1493 -bsd_i586_ServerClassMachine(void) {
 19.1494 -  jboolean            result            = JNI_FALSE;
 19.1495 -  /* How big is a server class machine? */
 19.1496 -  const unsigned long server_processors = 2UL;
 19.1497 -  const uint64_t      server_memory     = 2UL * GB;
 19.1498 -  /*
 19.1499 -   * We seem not to get our full complement of memory.
 19.1500 -   *     We allow some part (1/8?) of the memory to be "missing",
 19.1501 -   *     based on the sizes of DIMMs, and maybe graphics cards.
 19.1502 -   */
 19.1503 -  const uint64_t      missing_memory    = 256UL * MB;
 19.1504 -  const uint64_t      actual_memory     = physical_memory();
 19.1505 -
 19.1506 -  /* Is this a server class machine? */
 19.1507 -  if (actual_memory >= (server_memory - missing_memory)) {
 19.1508 -    const unsigned long actual_processors = physical_processors();
 19.1509 -    if (actual_processors >= server_processors) {
 19.1510 -      result = JNI_TRUE;
 19.1511 -    }
 19.1512 -  }
 19.1513 -  if (_launcher_debug) {
 19.1514 -    printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
 19.1515 -           (result == JNI_TRUE ? "true" : "false"));
 19.1516 -  }
 19.1517 -  return result;
 19.1518 -}
 19.1519 -
 19.1520 -#endif /* _ALLBSD_SOURCE && i586 */
 19.1521 -
 19.1522 -/* Dispatch to the platform-specific definition of "server-class" */
 19.1523 -jboolean
 19.1524 -ServerClassMachine(void) {
 19.1525 -  jboolean result = JNI_FALSE;
 19.1526 -#if   defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
 19.1527 -  result = JNI_FALSE;
 19.1528 -#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
 19.1529 -  result = JNI_TRUE;
 19.1530 -#elif defined(__sun) && defined(__sparc)
 19.1531 -  result = solaris_sparc_ServerClassMachine();
 19.1532 -#elif defined(__sun) && defined(i586)
 19.1533 -  result = solaris_i586_ServerClassMachine();
 19.1534 -#elif defined(__linux__) && defined(i586)
 19.1535 -  result = linux_i586_ServerClassMachine();
 19.1536 -#elif defined(_ALLBSD_SOURCE) && defined(i586)
 19.1537 -  result = bsd_i586_ServerClassMachine();
 19.1538 -#else
 19.1539 -  if (_launcher_debug) {
 19.1540 -    printf("ServerClassMachine: returns default value of %s\n",
 19.1541 -           (result == JNI_TRUE ? "true" : "false"));
 19.1542 -  }
 19.1543 -#endif
 19.1544 -  return result;
 19.1545 -}
 19.1546 -
 19.1547 -/*
 19.1548 - *      Since using the file system as a registry is a bit risky, perform
 19.1549 - *      additional sanity checks on the identified directory to validate
 19.1550 - *      it as a valid jre/sdk.
 19.1551 - *
 19.1552 - *      Return 0 if the tests fail; otherwise return non-zero (true).
 19.1553 - *
 19.1554 - *      Note that checking for anything more than the existence of an
 19.1555 - *      executable object at bin/java relative to the path being checked
 19.1556 - *      will break the regression tests.
 19.1557 - */
 19.1558 -static int
 19.1559 -CheckSanity(char *path, char *dir)
 19.1560 -{
 19.1561 -    char    buffer[PATH_MAX];
 19.1562 -
 19.1563 -    if (strlen(path) + strlen(dir) + 11 > PATH_MAX)
 19.1564 -        return (0);     /* Silently reject "impossibly" long paths */
 19.1565 -
 19.1566 -    (void)strcat(strcat(strcat(strcpy(buffer, path), "/"), dir), "/bin/java");
 19.1567 -    return ((access(buffer, X_OK) == 0) ? 1 : 0);
 19.1568 -}
 19.1569 -
 19.1570 -/*
 19.1571 - *      Determine if there is an acceptable JRE in the directory dirname.
 19.1572 - *      Upon locating the "best" one, return a fully qualified path to
 19.1573 - *      it. "Best" is defined as the most advanced JRE meeting the
 19.1574 - *      constraints contained in the manifest_info. If no JRE in this
 19.1575 - *      directory meets the constraints, return NULL.
 19.1576 - *
 19.1577 - *      Note that we don't check for errors in reading the directory
 19.1578 - *      (which would be done by checking errno).  This is because it
 19.1579 - *      doesn't matter if we get an error reading the directory, or
 19.1580 - *      we just don't find anything interesting in the directory.  We
 19.1581 - *      just return NULL in either case.
 19.1582 - *
 19.1583 - *      The historical names of j2sdk and j2re were changed to jdk and
 19.1584 - *      jre respecively as part of the 1.5 rebranding effort.  Since the
 19.1585 - *      former names are legacy on Linux, they must be recognized for
 19.1586 - *      all time.  Fortunately, this is a minor cost.
 19.1587 - */
 19.1588 -static char
 19.1589 -*ProcessDir(manifest_info *info, char *dirname)
 19.1590 -{
 19.1591 -    DIR     *dirp;
 19.1592 -    struct dirent *dp;
 19.1593 -    char    *best = NULL;
 19.1594 -    int     offset;
 19.1595 -    int     best_offset = 0;
 19.1596 -    char    *ret_str = NULL;
 19.1597 -    char    buffer[PATH_MAX];
 19.1598 -
 19.1599 -    if ((dirp = opendir(dirname)) == NULL)
 19.1600 -        return (NULL);
 19.1601 -
 19.1602 -    do {
 19.1603 -        if ((dp = readdir(dirp)) != NULL) {
 19.1604 -            offset = 0;
 19.1605 -            if ((strncmp(dp->d_name, "jre", 3) == 0) ||
 19.1606 -                (strncmp(dp->d_name, "jdk", 3) == 0))
 19.1607 -                offset = 3;
 19.1608 -            else if (strncmp(dp->d_name, "j2re", 4) == 0)
 19.1609 -                offset = 4;
 19.1610 -            else if (strncmp(dp->d_name, "j2sdk", 5) == 0)
 19.1611 -                offset = 5;
 19.1612 -            if (offset > 0) {
 19.1613 -                if ((JLI_AcceptableRelease(dp->d_name + offset,
 19.1614 -                    info->jre_version)) && CheckSanity(dirname, dp->d_name))
 19.1615 -                    if ((best == NULL) || (JLI_ExactVersionId(
 19.1616 -                      dp->d_name + offset, best + best_offset) > 0)) {
 19.1617 -                        if (best != NULL)
 19.1618 -                            JLI_MemFree(best);
 19.1619 -                        best = JLI_StringDup(dp->d_name);
 19.1620 -                        best_offset = offset;
 19.1621 -                    }
 19.1622 -            }
 19.1623 -        }
 19.1624 -    } while (dp != NULL);
 19.1625 -    (void) closedir(dirp);
 19.1626 -    if (best == NULL)
 19.1627 -        return (NULL);
 19.1628 -    else {
 19.1629 -        ret_str = JLI_MemAlloc(strlen(dirname) + strlen(best) + 2);
 19.1630 -        ret_str = strcat(strcat(strcpy(ret_str, dirname), "/"), best);
 19.1631 -        JLI_MemFree(best);
 19.1632 -        return (ret_str);
 19.1633 -    }
 19.1634 -}
 19.1635 -
 19.1636 -/*
 19.1637 - *      This is the global entry point. It examines the host for the optimal
 19.1638 - *      JRE to be used by scanning a set of directories.  The set of directories
 19.1639 - *      is platform dependent and can be overridden by the environment
 19.1640 - *      variable JAVA_VERSION_PATH.
 19.1641 - *
 19.1642 - *      This routine itself simply determines the set of appropriate
 19.1643 - *      directories before passing control onto ProcessDir().
 19.1644 - */
 19.1645 -char*
 19.1646 -LocateJRE(manifest_info* info)
 19.1647 -{
 19.1648 -    char        *path;
 19.1649 -    char        *home;
 19.1650 -    char        *target = NULL;
 19.1651 -    char        *dp;
 19.1652 -    char        *cp;
 19.1653 -
 19.1654 -    /*
 19.1655 -     * Start by getting JAVA_VERSION_PATH
 19.1656 -     */
 19.1657 -    if (info->jre_restrict_search)
 19.1658 -        path = JLI_StringDup(system_dir);
 19.1659 -    else if ((path = getenv("JAVA_VERSION_PATH")) != NULL)
 19.1660 -        path = JLI_StringDup(path);
 19.1661 -    else
 19.1662 -        if ((home = getenv("HOME")) != NULL) {
 19.1663 -            path = (char *)JLI_MemAlloc(strlen(home) + strlen(system_dir) +
 19.1664 -                strlen(user_dir) + 2);
 19.1665 -            path = strcat(strcat(strcat(strcpy(path, home),
 19.1666 -                user_dir), ":"), system_dir);
 19.1667 -        } else
 19.1668 -            path = JLI_StringDup(system_dir);
 19.1669 -
 19.1670 -    /*
 19.1671 -     * Step through each directory on the path. Terminate the scan with
 19.1672 -     * the first directory with an acceptable JRE.
 19.1673 -     */
 19.1674 -    cp = dp = path;
 19.1675 -    while (dp != NULL) {
 19.1676 -        cp = strchr(dp, (int)':');
 19.1677 -        if (cp != NULL)
 19.1678 -            *cp = (char)NULL;
 19.1679 -        if ((target = ProcessDir(info, dp)) != NULL)
 19.1680 -            break;
 19.1681 -        dp = cp;
 19.1682 -        if (dp != NULL)
 19.1683 -            dp++;
 19.1684 -    }
 19.1685 -    JLI_MemFree(path);
 19.1686 -    return (target);
 19.1687 -}
 19.1688 -
 19.1689 -/*
 19.1690 - * Given a path to a jre to execute, this routine checks if this process
 19.1691 - * is indeed that jre.  If not, it exec's that jre.
 19.1692 - *
 19.1693 - * We want to actually check the paths rather than just the version string
 19.1694 - * built into the executable, so that given version specification (and
 19.1695 - * JAVA_VERSION_PATH) will yield the exact same Java environment, regardless
 19.1696 - * of the version of the arbitrary launcher we start with.
 19.1697 - */
 19.1698 -void
 19.1699 -ExecJRE(char *jre, char **argv)
 19.1700 -{
 19.1701 -    char    wanted[PATH_MAX];
 19.1702 -    char    *execname;
 19.1703 -    char    *progname;
 19.1704 -
 19.1705 -    /*
 19.1706 -     * Resolve the real path to the directory containing the selected JRE.
 19.1707 -     */
 19.1708 -    if (realpath(jre, wanted) == NULL) {
 19.1709 -        fprintf(stderr, "Unable to resolve %s\n", jre);
 19.1710 -        exit(1);
 19.1711 -    }
 19.1712 -
 19.1713 -    /*
 19.1714 -     * Resolve the real path to the currently running launcher.
 19.1715 -     */
 19.1716 -    execname = SetExecname(argv);
 19.1717 -    if (execname == NULL) {
 19.1718 -        fprintf(stderr, "Unable to resolve current executable\n");
 19.1719 -        exit(1);
 19.1720 -    }
 19.1721 -
 19.1722 -    /*
 19.1723 -     * If the path to the selected JRE directory is a match to the initial
 19.1724 -     * portion of the path to the currently executing JRE, we have a winner!
 19.1725 -     * If so, just return.
 19.1726 -     */
 19.1727 -    if (strncmp(wanted, execname, strlen(wanted)) == 0)
 19.1728 -        return;                 /* I am the droid you were looking for */
 19.1729 -
 19.1730 -    /*
 19.1731 -     * If this isn't the selected version, exec the selected version.
 19.1732 -     */
 19.1733 -#ifdef JAVA_ARGS  /* javac, jar and friends. */
 19.1734 -    progname = "java";
 19.1735 -#else             /* java, oldjava, javaw and friends */
 19.1736 -#ifdef PROGNAME
 19.1737 -    progname = PROGNAME;
 19.1738 -#else
 19.1739 -    progname = *argv;
 19.1740 -    if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
 19.1741 -        progname = s + 1;
 19.1742 -    }
 19.1743 -#endif /* PROGNAME */
 19.1744 -#endif /* JAVA_ARGS */
 19.1745 -
 19.1746 -    /*
 19.1747 -     * This should never happen (because of the selection code in SelectJRE),
 19.1748 -     * but check for "impossibly" long path names just because buffer overruns
 19.1749 -     * can be so deadly.
 19.1750 -     */
 19.1751 -    if (strlen(wanted) + strlen(progname) + 6 > PATH_MAX) {
 19.1752 -        fprintf(stderr, "Path length exceeds maximum length (PATH_MAX)\n");
 19.1753 -        exit(1);
 19.1754 -    }
 19.1755 -
 19.1756 -    /*
 19.1757 -     * Construct the path and exec it.
 19.1758 -     */
 19.1759 -    (void)strcat(strcat(wanted, "/bin/"), progname);
 19.1760 -    argv[0] = progname;
 19.1761 -    if (_launcher_debug) {
 19.1762 -        int i;
 19.1763 -        printf("ReExec Command: %s (%s)\n", wanted, argv[0]);
 19.1764 -        printf("ReExec Args:");
 19.1765 -        for (i = 1; argv[i] != NULL; i++)
 19.1766 -            printf(" %s", argv[i]);
 19.1767 -        printf("\n");
 19.1768 -    }
 19.1769 -    (void)fflush(stdout);
 19.1770 -    (void)fflush(stderr);
 19.1771 -    execv(wanted, argv);
 19.1772 -    perror("execv()");
 19.1773 -    fprintf(stderr, "Exec of %s failed\n", wanted);
 19.1774 -    exit(1);
 19.1775 -}
 19.1776 -#endif /* ifndef GAMMA */
 19.1777 -
 19.1778 -/*
 19.1779 - * "Borrowed" from Solaris 10 where the unsetenv() function is being added
 19.1780 - * to libc thanks to SUSv3 (Standard Unix Specification, version 3). As
 19.1781 - * such, in the fullness of time this will appear in libc on all relevant
 19.1782 - * Solaris/Linux platforms and maybe even the Windows platform.  At that
 19.1783 - * time, this stub can be removed.
 19.1784 - *
 19.1785 - * This implementation removes the environment locking for multithreaded
 19.1786 - * applications.  (We don't have access to these mutexes within libc and
 19.1787 - * the launcher isn't multithreaded.)  Note that what remains is platform
 19.1788 - * independent, because it only relies on attributes that a POSIX environment
 19.1789 - * defines.
 19.1790 - *
 19.1791 - * Returns 0 on success, -1 on failure.
 19.1792 - *
 19.1793 - * Also removed was the setting of errno.  The only value of errno set
 19.1794 - * was EINVAL ("Invalid Argument").
 19.1795 - */
 19.1796 -
 19.1797 -/*
 19.1798 - * s1(environ) is name=value
 19.1799 - * s2(name) is name(not the form of name=value).
 19.1800 - * if names match, return value of 1, else return 0
 19.1801 - */
 19.1802 -static int
 19.1803 -match_noeq(const char *s1, const char *s2)
 19.1804 -{
 19.1805 -        while (*s1 == *s2++) {
 19.1806 -                if (*s1++ == '=')
 19.1807 -                        return (1);
 19.1808 -        }
 19.1809 -        if (*s1 == '=' && s2[-1] == '\0')
 19.1810 -                return (1);
 19.1811 -        return (0);
 19.1812 -}
 19.1813 -
 19.1814 -/*
 19.1815 - * added for SUSv3 standard
 19.1816 - *
 19.1817 - * Delete entry from environ.
 19.1818 - * Do not free() memory!  Other threads may be using it.
 19.1819 - * Keep it around forever.
 19.1820 - */
 19.1821 -static int
 19.1822 -borrowed_unsetenv(const char *name)
 19.1823 -{
 19.1824 -        long    idx;            /* index into environ */
 19.1825 -
 19.1826 -        if (name == NULL || *name == '\0' ||
 19.1827 -            strchr(name, '=') != NULL) {
 19.1828 -                return (-1);
 19.1829 -        }
 19.1830 -
 19.1831 -        for (idx = 0; environ[idx] != NULL; idx++) {
 19.1832 -                if (match_noeq(environ[idx], name))
 19.1833 -                        break;
 19.1834 -        }
 19.1835 -        if (environ[idx] == NULL) {
 19.1836 -                /* name not found but still a success */
 19.1837 -                return (0);
 19.1838 -        }
 19.1839 -        /* squeeze up one entry */
 19.1840 -        do {
 19.1841 -                environ[idx] = environ[idx+1];
 19.1842 -        } while (environ[++idx] != NULL);
 19.1843 -
 19.1844 -        return (0);
 19.1845 -}
 19.1846 -/* --- End of "borrowed" code --- */
 19.1847 -
 19.1848 -/*
 19.1849 - * Wrapper for unsetenv() function.
 19.1850 - */
 19.1851 -int
 19.1852 -UnsetEnv(char *name)
 19.1853 -{
 19.1854 -    return(borrowed_unsetenv(name));
 19.1855 -}
 19.1856 -
 19.1857 -/* --- Splash Screen shared library support --- */
 19.1858 -
 19.1859 -static const char* SPLASHSCREEN_SO = "libsplashscreen.so";
 19.1860 -
 19.1861 -static void* hSplashLib = NULL;
 19.1862 -
 19.1863 -void* SplashProcAddress(const char* name) {
 19.1864 -    if (!hSplashLib) {
 19.1865 -        hSplashLib = dlopen(SPLASHSCREEN_SO, RTLD_LAZY | RTLD_GLOBAL);
 19.1866 -    }
 19.1867 -    if (hSplashLib) {
 19.1868 -        void* sym = dlsym(hSplashLib, name);
 19.1869 -        return sym;
 19.1870 -    } else {
 19.1871 -        return NULL;
 19.1872 -    }
 19.1873 -}
 19.1874 -
 19.1875 -void SplashFreeLibrary() {
 19.1876 -    if (hSplashLib) {
 19.1877 -        dlclose(hSplashLib);
 19.1878 -        hSplashLib = NULL;
 19.1879 -    }
 19.1880 -}
 19.1881 -
 19.1882 -/*
 19.1883 - * Block current thread and continue execution in a new thread
 19.1884 - */
 19.1885 -int
 19.1886 -ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 19.1887 -    int rslt;
 19.1888 -#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 19.1889 -    pthread_t tid;
 19.1890 -    pthread_attr_t attr;
 19.1891 -    pthread_attr_init(&attr);
 19.1892 -    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 19.1893 -
 19.1894 -    if (stack_size > 0) {
 19.1895 -      pthread_attr_setstacksize(&attr, stack_size);
 19.1896 -    }
 19.1897 -
 19.1898 -    if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 19.1899 -      void * tmp;
 19.1900 -      pthread_join(tid, &tmp);
 19.1901 -      rslt = (int)(intptr_t)tmp;
 19.1902 -    } else {
 19.1903 -     /*
 19.1904 -      * Continue execution in current thread if for some reason (e.g. out of
 19.1905 -      * memory/LWP)  a new thread can't be created. This will likely fail
 19.1906 -      * later in continuation as JNI_CreateJavaVM needs to create quite a
 19.1907 -      * few new threads, anyway, just give it a try..
 19.1908 -      */
 19.1909 -      rslt = continuation(args);
 19.1910 -    }
 19.1911 -
 19.1912 -    pthread_attr_destroy(&attr);
 19.1913 -#else
 19.1914 -    thread_t tid;
 19.1915 -    long flags = 0;
 19.1916 -    if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
 19.1917 -      void * tmp;
 19.1918 -      thr_join(tid, NULL, &tmp);
 19.1919 -      rslt = (int)(intptr_t)tmp;
 19.1920 -    } else {
 19.1921 -      /* See above. Continue in current thread if thr_create() failed */
 19.1922 -      rslt = continuation(args);
 19.1923 -    }
 19.1924 -#endif
 19.1925 -    return rslt;
 19.1926 -}
 19.1927 -
 19.1928 -/* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
 19.1929 -#define MAX_PID_STR_SZ   20
 19.1930 -
 19.1931 -void SetJavaLauncherPlatformProps() {
 19.1932 -   /* Linux only */
 19.1933 -#ifdef __linux__
 19.1934 -    const char *substr = "-Dsun.java.launcher.pid=";
 19.1935 -    char *pid_prop_str = (char *)JLI_MemAlloc(strlen(substr) + MAX_PID_STR_SZ + 1);
 19.1936 -    sprintf(pid_prop_str, "%s%d", substr, getpid());
 19.1937 -    AddOption(pid_prop_str, NULL);
 19.1938 -#endif
 19.1939 -}
    20.1 --- a/src/os/posix/launcher/java_md.h	Tue May 14 17:33:07 2013 +0000
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,82 +0,0 @@
    20.4 -/*
    20.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 - *
    20.8 - * This code is free software; you can redistribute it and/or modify it
    20.9 - * under the terms of the GNU General Public License version 2 only, as
   20.10 - * published by the Free Software Foundation.
   20.11 - *
   20.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 - * version 2 for more details (a copy is included in the LICENSE file that
   20.16 - * accompanied this code).
   20.17 - *
   20.18 - * You should have received a copy of the GNU General Public License version
   20.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 - *
   20.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 - * or visit www.oracle.com if you need additional information or have any
   20.24 - * questions.
   20.25 - *
   20.26 - */
   20.27 -
   20.28 -#ifndef JAVA_MD_H
   20.29 -#define JAVA_MD_H
   20.30 -
   20.31 -#include <limits.h>
   20.32 -#include <unistd.h>
   20.33 -#include <sys/param.h>
   20.34 -#ifndef GAMMA
   20.35 -#include "manifest_info.h"
   20.36 -#endif
   20.37 -#include "jli_util.h"
   20.38 -
   20.39 -#define PATH_SEPARATOR          ':'
   20.40 -#define FILESEP                 "/"
   20.41 -#define FILE_SEPARATOR          '/'
   20.42 -#define IS_FILE_SEPARATOR(c) ((c) == '/')
   20.43 -#ifndef MAXNAMELEN
   20.44 -#define MAXNAMELEN              PATH_MAX
   20.45 -#endif
   20.46 -
   20.47 -#ifdef JAVA_ARGS
   20.48 -/*
   20.49 - * ApplicationHome is prepended to each of these entries; the resulting
   20.50 - * strings are concatenated (separated by PATH_SEPARATOR) and used as the
   20.51 - * value of -cp option to the launcher.
   20.52 - */
   20.53 -#ifndef APP_CLASSPATH
   20.54 -#define APP_CLASSPATH        { "/lib/tools.jar", "/classes" }
   20.55 -#endif
   20.56 -#endif
   20.57 -
   20.58 -#ifdef HAVE_GETHRTIME
   20.59 -/*
   20.60 - * Support for doing cheap, accurate interval timing.
   20.61 - */
   20.62 -#include <sys/time.h>
   20.63 -#define CounterGet()              (gethrtime()/1000)
   20.64 -#define Counter2Micros(counts)    (counts)
   20.65 -#else
   20.66 -#define CounterGet()              (0)
   20.67 -#define Counter2Micros(counts)    (1)
   20.68 -#endif /* HAVE_GETHRTIME */
   20.69 -
   20.70 -#ifdef _LP64
   20.71 -#define JLONG_FORMAT "%ld"
   20.72 -#else
   20.73 -#define JLONG_FORMAT "%lld"
   20.74 -#endif
   20.75 -
   20.76 -/*
   20.77 - * Function prototypes.
   20.78 - */
   20.79 -#ifndef GAMMA
   20.80 -char *LocateJRE(manifest_info *info);
   20.81 -void ExecJRE(char *jre, char **argv);
   20.82 -#endif
   20.83 -int UnsetEnv(char *name);
   20.84 -
   20.85 -#endif
    21.1 --- a/src/os/posix/launcher/launcher.script	Tue May 14 17:33:07 2013 +0000
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,218 +0,0 @@
    21.4 -#!/bin/sh
    21.5 -
    21.6 -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    21.7 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.8 -#
    21.9 -# This code is free software; you can redistribute it and/or modify it
   21.10 -# under the terms of the GNU General Public License version 2 only, as
   21.11 -# published by the Free Software Foundation.
   21.12 -#
   21.13 -# This code is distributed in the hope that it will be useful, but WITHOUT
   21.14 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.15 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.16 -# version 2 for more details (a copy is included in the LICENSE file that
   21.17 -# accompanied this code).
   21.18 -#
   21.19 -# You should have received a copy of the GNU General Public License version
   21.20 -# 2 along with this work; if not, write to the Free Software Foundation,
   21.21 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.22 -#
   21.23 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.24 -# or visit www.oracle.com if you need additional information or have any
   21.25 -# questions.
   21.26 -
   21.27 -
   21.28 -# This script launches HotSpot.
   21.29 -#
   21.30 -# If the first parameter is either "-gdb" or "-gud", HotSpot will be
   21.31 -# launched inside gdb. "-gud" means "open an Emacs window and run gdb
   21.32 -# inside Emacs".
   21.33 -#
   21.34 -# If the first parameter is "-dbx", HotSpot will be launched inside dbx.
   21.35 -#
   21.36 -# If the first parameter is "-valgrind", HotSpot will be launched
   21.37 -# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
   21.38 -# and with memory leak detection enabled.  This currently (2005jan19)
   21.39 -# requires at least Valgrind 2.3.0.  -Xmx16m will also be passed as
   21.40 -# the first parameter to HotSpot, since lowering HotSpot's memory
   21.41 -# consumption makes execution inside of Valgrind *a lot* faster.
   21.42 -#
   21.43 -
   21.44 -
   21.45 -#
   21.46 -# User changeable parameters ------------------------------------------------
   21.47 -#
   21.48 -
   21.49 -# This is the name of the gdb binary to use
   21.50 -if [ ! "$GDB" ]
   21.51 -then
   21.52 -    GDB=gdb
   21.53 -fi
   21.54 -
   21.55 -# This is the name of the gdb binary to use
   21.56 -if [ ! "$DBX" ]
   21.57 -then
   21.58 -    DBX=dbx
   21.59 -fi
   21.60 -
   21.61 -# This is the name of the Valgrind binary to use
   21.62 -if [ ! "$VALGRIND" ]
   21.63 -then
   21.64 -    VALGRIND=valgrind
   21.65 -fi
   21.66 -
   21.67 -# This is the name of Emacs for running GUD
   21.68 -EMACS=emacs
   21.69 -
   21.70 -#
   21.71 -# End of user changeable parameters -----------------------------------------
   21.72 -#
   21.73 -
   21.74 -# Make sure the paths are fully specified, i.e. they must begin with /.
   21.75 -REL_MYDIR=`dirname $0`
   21.76 -MYDIR=`cd $REL_MYDIR && pwd`
   21.77 -
   21.78 -# Look whether the user wants to run inside gdb
   21.79 -case "$1" in
   21.80 -    -gdb)
   21.81 -        MODE=gdb
   21.82 -        shift
   21.83 -        ;;
   21.84 -    -gud)
   21.85 -        MODE=gud
   21.86 -        shift
   21.87 -        ;;
   21.88 -    -dbx)
   21.89 -        MODE=dbx
   21.90 -        shift
   21.91 -        ;;
   21.92 -    -valgrind)
   21.93 -        MODE=valgrind
   21.94 -        shift
   21.95 -        ;;
   21.96 -    *)
   21.97 -        MODE=run
   21.98 -        ;;
   21.99 -esac
  21.100 -
  21.101 -JDK=
  21.102 -if [ "${ALT_JAVA_HOME}" = "" ]; then
  21.103 -    . ${MYDIR}/jdkpath.sh
  21.104 -else
  21.105 -    JDK=${ALT_JAVA_HOME%%/jre};
  21.106 -fi
  21.107 -
  21.108 -if [ "${JDK}" = "" ]; then
  21.109 -    echo Failed to find JDK. ALT_JAVA_HOME is not set or ./jdkpath.sh is empty or not found.
  21.110 -    exit 1
  21.111 -fi
  21.112 -
  21.113 -# We will set the LD_LIBRARY_PATH as follows:
  21.114 -#     o		$JVMPATH (directory portion only)
  21.115 -#     o		$JRE/lib/$ARCH
  21.116 -# followed by the user's previous effective LD_LIBRARY_PATH, if
  21.117 -# any.
  21.118 -JRE=$JDK/jre
  21.119 -JAVA_HOME=$JDK
  21.120 -export JAVA_HOME
  21.121 -
  21.122 -ARCH=@@LIBARCH@@
  21.123 -SBP=${MYDIR}:${JRE}/lib/${ARCH}
  21.124 -
  21.125 -
  21.126 -# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
  21.127 -OS=`uname -s`
  21.128 -if [ "${OS}" = "Darwin" ]
  21.129 -then
  21.130 -    if [ -z "$DYLD_LIBRARY_PATH" ]
  21.131 -    then
  21.132 -        DYLD_LIBRARY_PATH="$SBP"
  21.133 -    else
  21.134 -        DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
  21.135 -    fi
  21.136 -    export DYLD_LIBRARY_PATH
  21.137 -else
  21.138 -    # not 'Darwin'
  21.139 -    if [ -z "$LD_LIBRARY_PATH" ]
  21.140 -    then
  21.141 -        LD_LIBRARY_PATH="$SBP"
  21.142 -    else
  21.143 -        LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
  21.144 -    fi
  21.145 -    export LD_LIBRARY_PATH
  21.146 -fi
  21.147 -
  21.148 -JPARMS="$@ $JAVA_ARGS";
  21.149 -
  21.150 -# Locate the gamma development launcher
  21.151 -LAUNCHER=${MYDIR}/gamma
  21.152 -if [ ! -x $LAUNCHER ] ; then
  21.153 -    echo Error: Cannot find the gamma development launcher \"$LAUNCHER\"
  21.154 -    exit 1
  21.155 -fi
  21.156 -
  21.157 -GDBSRCDIR=$MYDIR
  21.158 -BASEDIR=`cd $MYDIR/../../.. && pwd`
  21.159 -
  21.160 -init_gdb() {
  21.161 -# Create a gdb script in case we should run inside gdb
  21.162 -    GDBSCR=/tmp/hsl.$$
  21.163 -    rm -f $GDBSCR
  21.164 -    cat >>$GDBSCR <<EOF
  21.165 -cd `pwd`
  21.166 -handle SIGUSR1 nostop noprint
  21.167 -handle SIGUSR2 nostop noprint
  21.168 -set args $JPARMS
  21.169 -file $LAUNCHER
  21.170 -directory $GDBSRCDIR
  21.171 -# Get us to a point where we can set breakpoints in libjvm.so
  21.172 -break InitializeJVM
  21.173 -run
  21.174 -# Stop in InitializeJVM
  21.175 -delete 1
  21.176 -# We can now set breakpoints wherever we like
  21.177 -EOF
  21.178 -}
  21.179 -
  21.180 -
  21.181 -case "$MODE" in
  21.182 -    gdb)
  21.183 -	init_gdb
  21.184 -        $GDB -x $GDBSCR
  21.185 -	rm -f $GDBSCR
  21.186 -        ;;
  21.187 -    gud)
  21.188 -	init_gdb
  21.189 -# First find out what emacs version we're using, so that we can
  21.190 -# use the new pretty GDB mode if emacs -version >= 22.1
  21.191 -	case `$EMACS -version 2> /dev/null` in
  21.192 -	    *GNU\ Emacs\ 2[23]*)
  21.193 -	    emacs_gud_cmd="gdba"
  21.194 -	    emacs_gud_args="--annotate=3"
  21.195 -	    ;;
  21.196 -	    *)
  21.197 -		emacs_gud_cmd="gdb"
  21.198 -		emacs_gud_args=
  21.199 -		;;
  21.200 -	esac
  21.201 -        $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
  21.202 -	rm -f $GDBSCR
  21.203 -        ;;
  21.204 -    dbx)
  21.205 -        $DBX -s $HOME/.dbxrc $LAUNCHER $JPARMS
  21.206 -        ;;
  21.207 -    valgrind)
  21.208 -        echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
  21.209 -        echo
  21.210 -        $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
  21.211 -        ;;
  21.212 -    run)
  21.213 -        LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
  21.214 -        ;;
  21.215 -    *)
  21.216 -        echo Error: Internal error, unknown launch mode \"$MODE\"
  21.217 -        exit 1
  21.218 -        ;;
  21.219 -esac
  21.220 -RETVAL=$?
  21.221 -exit $RETVAL
    22.1 --- a/src/os/windows/launcher/java_md.c	Tue May 14 17:33:07 2013 +0000
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,1507 +0,0 @@
    22.4 -/*
    22.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 - *
    22.8 - * This code is free software; you can redistribute it and/or modify it
    22.9 - * under the terms of the GNU General Public License version 2 only, as
   22.10 - * published by the Free Software Foundation.
   22.11 - *
   22.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 - * version 2 for more details (a copy is included in the LICENSE file that
   22.16 - * accompanied this code).
   22.17 - *
   22.18 - * You should have received a copy of the GNU General Public License version
   22.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 - *
   22.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 - * or visit www.oracle.com if you need additional information or have any
   22.24 - * questions.
   22.25 - *
   22.26 - */
   22.27 -
   22.28 -#include <ctype.h>
   22.29 -#include <windows.h>
   22.30 -#include <io.h>
   22.31 -#include <process.h>
   22.32 -#include <stdlib.h>
   22.33 -#include <stdio.h>
   22.34 -#include <string.h>
   22.35 -#include <sys/types.h>
   22.36 -#include <sys/stat.h>
   22.37 -
   22.38 -#include <jni.h>
   22.39 -#include "java.h"
   22.40 -#ifndef GAMMA
   22.41 -#include "version_comp.h"
   22.42 -#endif
   22.43 -
   22.44 -#define JVM_DLL "jvm.dll"
   22.45 -#define JAVA_DLL "java.dll"
   22.46 -#define CRT_DLL "msvcr71.dll"
   22.47 -
   22.48 -/*
   22.49 - * Prototypes.
   22.50 - */
   22.51 -static jboolean GetPublicJREHome(char *path, jint pathsize);
   22.52 -static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
   22.53 -                           char *jvmpath, jint jvmpathsize);
   22.54 -static jboolean GetJREPath(char *path, jint pathsize);
   22.55 -static void EnsureJreInstallation(const char *jrepath);
   22.56 -
   22.57 -/* We supports warmup for UI stack that is performed in parallel
   22.58 - * to VM initialization.
   22.59 - * This helps to improve startup of UI application as warmup phase
   22.60 - * might be long due to initialization of OS or hardware resources.
   22.61 - * It is not CPU bound and therefore it does not interfere with VM init.
   22.62 - * Obviously such warmup only has sense for UI apps and therefore it needs
   22.63 - * to be explicitly requested by passing -Dsun.awt.warmup=true property
   22.64 - * (this is always the case for plugin/javaws).
   22.65 - *
   22.66 - * Implementation launches new thread after VM starts and use it to perform
   22.67 - * warmup code (platform dependent).
   22.68 - * This thread is later reused as AWT toolkit thread as graphics toolkit
   22.69 - * often assume that they are used from the same thread they were launched on.
   22.70 - *
   22.71 - * At the moment we only support warmup for D3D. It only possible on windows
   22.72 - * and only if other flags do not prohibit this (e.g. OpenGL support requested).
   22.73 - */
   22.74 -#undef ENABLE_AWT_PRELOAD
   22.75 -#ifndef JAVA_ARGS /* turn off AWT preloading for javac, jar, etc */
   22.76 -  #ifdef _X86_ /* for now disable AWT preloading for 64bit */
   22.77 -    #define ENABLE_AWT_PRELOAD
   22.78 -  #endif
   22.79 -#endif
   22.80 -
   22.81 -#ifdef ENABLE_AWT_PRELOAD
   22.82 -/* "AWT was preloaded" flag;
   22.83 - * Turned on by AWTPreload().
   22.84 - */
   22.85 -int awtPreloaded = 0;
   22.86 -
   22.87 -/* Calls a function with the name specified.
   22.88 - * The function must be int(*fn)(void).
   22.89 - */
   22.90 -int AWTPreload(const char *funcName);
   22.91 -/* Stops AWT preloading. */
   22.92 -void AWTPreloadStop();
   22.93 -
   22.94 -/* D3D preloading */
   22.95 -/* -1: not initialized; 0: OFF, 1: ON */
   22.96 -int awtPreloadD3D = -1;
   22.97 -/* Command line parameter to swith D3D preloading on. */
   22.98 -#define PARAM_PRELOAD_D3D "-Dsun.awt.warmup"
   22.99 -/* D3D/OpenGL management parameters (may disable D3D preloading) */
  22.100 -#define PARAM_NODDRAW "-Dsun.java2d.noddraw"
  22.101 -#define PARAM_D3D "-Dsun.java2d.d3d"
  22.102 -#define PARAM_OPENGL "-Dsun.java2d.opengl"
  22.103 -/* funtion in awt.dll (src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp) */
  22.104 -#define D3D_PRELOAD_FUNC "preloadD3D"
  22.105 -
  22.106 -
  22.107 -/* Extracts value of a parameter with the specified name
  22.108 - * from command line argument (returns pointer in the argument).
  22.109 - * Returns NULL if the argument does not contains the parameter.
  22.110 - * e.g.:
  22.111 - * GetParamValue("theParam", "theParam=value") returns pointer to "value".
  22.112 - */
  22.113 -const char * GetParamValue(const char *paramName, const char *arg) {
  22.114 -    int nameLen = strlen(paramName);
  22.115 -    if (strncmp(paramName, arg, nameLen) == 0) {
  22.116 -        // arg[nameLen] is valid (may contain final NULL)
  22.117 -        if (arg[nameLen] == '=') {
  22.118 -            return arg + nameLen + 1;
  22.119 -        }
  22.120 -    }
  22.121 -    return NULL;
  22.122 -}
  22.123 -
  22.124 -/* Checks if commandline argument contains property specified
  22.125 - * and analyze it as boolean property (true/false).
  22.126 - * Returns -1 if the argument does not contain the parameter;
  22.127 - * Returns 1 if the argument contains the parameter and its value is "true";
  22.128 - * Returns 0 if the argument contains the parameter and its value is "false".
  22.129 - */
  22.130 -int GetBoolParamValue(const char *paramName, const char *arg) {
  22.131 -    const char * paramValue = GetParamValue(paramName, arg);
  22.132 -    if (paramValue != NULL) {
  22.133 -        if (stricmp(paramValue, "true") == 0) {
  22.134 -            return 1;
  22.135 -        }
  22.136 -        if (stricmp(paramValue, "false") == 0) {
  22.137 -            return 0;
  22.138 -        }
  22.139 -    }
  22.140 -    return -1;
  22.141 -}
  22.142 -#endif /* ENABLE_AWT_PRELOAD */
  22.143 -
  22.144 -
  22.145 -const char *
  22.146 -GetArch()
  22.147 -{
  22.148 -
  22.149 -#ifdef _M_AMD64
  22.150 -    return "amd64";
  22.151 -#elif defined(_M_IA64)
  22.152 -    return "ia64";
  22.153 -#else
  22.154 -    return "i386";
  22.155 -#endif
  22.156 -}
  22.157 -
  22.158 -/*
  22.159 - *
  22.160 - */
  22.161 -void
  22.162 -CreateExecutionEnvironment(int *_argc,
  22.163 -                           char ***_argv,
  22.164 -                           char jrepath[],
  22.165 -                           jint so_jrepath,
  22.166 -                           char jvmpath[],
  22.167 -                           jint so_jvmpath,
  22.168 -                           char **original_argv) {
  22.169 -#ifndef GAMMA
  22.170 -   char * jvmtype;
  22.171 -
  22.172 -    /* Find out where the JRE is that we will be using. */
  22.173 -    if (!GetJREPath(jrepath, so_jrepath)) {
  22.174 -        ReportErrorMessage("Error: could not find Java SE Runtime Environment.",
  22.175 -                           JNI_TRUE);
  22.176 -        exit(2);
  22.177 -    }
  22.178 -
  22.179 -    /* Do this before we read jvm.cfg */
  22.180 -    EnsureJreInstallation(jrepath);
  22.181 -
  22.182 -    /* Find the specified JVM type */
  22.183 -    if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
  22.184 -        ReportErrorMessage("Error: no known VMs. (check for corrupt jvm.cfg file)",
  22.185 -                           JNI_TRUE);
  22.186 -        exit(1);
  22.187 -    }
  22.188 -    jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
  22.189 -
  22.190 -    jvmpath[0] = '\0';
  22.191 -    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
  22.192 -        char * message=NULL;
  22.193 -        const char * format = "Error: no `%s' JVM at `%s'.";
  22.194 -        message = (char *)JLI_MemAlloc((strlen(format)+strlen(jvmtype)+
  22.195 -                                    strlen(jvmpath)) * sizeof(char));
  22.196 -        sprintf(message,format, jvmtype, jvmpath);
  22.197 -        ReportErrorMessage(message, JNI_TRUE);
  22.198 -        exit(4);
  22.199 -    }
  22.200 -    /* If we got here, jvmpath has been correctly initialized. */
  22.201 -
  22.202 -#else  /* ifndef GAMMA */
  22.203 -
  22.204 -    /*
  22.205 -     * gamma launcher is simpler in that it doesn't handle VM flavors, data
  22.206 -     * model, etc. Assuming everything is set-up correctly
  22.207 -     * all we need to do here is to return correct path names. See also
  22.208 -     * GetJVMPath() and GetApplicationHome().
  22.209 -     */
  22.210 -
  22.211 -  {
  22.212 -    if (!GetJREPath(jrepath, so_jrepath) ) {
  22.213 -       ReportErrorMessage("Error: could not find Java SE Runtime Environment.",
  22.214 -                          JNI_TRUE);
  22.215 -       exit(2);
  22.216 -    }
  22.217 -
  22.218 -    if (!GetJVMPath(jrepath, NULL, jvmpath, so_jvmpath)) {
  22.219 -       char * message=NULL;
  22.220 -       const char * format = "Error: no JVM at `%s'.";
  22.221 -       message = (char *)JLI_MemAlloc((strlen(format)+
  22.222 -                                       strlen(jvmpath)) * sizeof(char));
  22.223 -       sprintf(message, format, jvmpath);
  22.224 -       ReportErrorMessage(message, JNI_TRUE);
  22.225 -       exit(4);
  22.226 -    }
  22.227 -  }
  22.228 -
  22.229 -#endif  /* ifndef GAMMA */
  22.230 -
  22.231 -}
  22.232 -
  22.233 -
  22.234 -static jboolean
  22.235 -LoadMSVCRT()
  22.236 -{
  22.237 -    // Only do this once
  22.238 -    static int loaded = 0;
  22.239 -    char crtpath[MAXPATHLEN];
  22.240 -
  22.241 -    if (!loaded) {
  22.242 -        /*
  22.243 -         * The Microsoft C Runtime Library needs to be loaded first.  A copy is
  22.244 -         * assumed to be present in the "JRE path" directory.  If it is not found
  22.245 -         * there (or "JRE path" fails to resolve), skip the explicit load and let
  22.246 -         * nature take its course, which is likely to be a failure to execute.
  22.247 -         */
  22.248 -        if (GetJREPath(crtpath, MAXPATHLEN)) {
  22.249 -            (void)strcat(crtpath, "\\bin\\" CRT_DLL);   /* Add crt dll */
  22.250 -            if (_launcher_debug) {
  22.251 -                printf("CRT path is %s\n", crtpath);
  22.252 -            }
  22.253 -            if (_access(crtpath, 0) == 0) {
  22.254 -                if (LoadLibrary(crtpath) == 0) {
  22.255 -                    ReportErrorMessage2("Error loading: %s", crtpath, JNI_TRUE);
  22.256 -                    return JNI_FALSE;
  22.257 -                }
  22.258 -            }
  22.259 -        }
  22.260 -        loaded = 1;
  22.261 -    }
  22.262 -    return JNI_TRUE;
  22.263 -}
  22.264 -
  22.265 -/*
  22.266 - * The preJVMStart is a function in the jkernel.dll, which
  22.267 - * performs the final step of synthesizing back the decomposed
  22.268 - * modules  (partial install) to the full JRE. Any tool which
  22.269 - * uses the  JRE must peform this step to ensure the complete synthesis.
  22.270 - * The EnsureJreInstallation function calls preJVMStart based on
  22.271 - * the conditions outlined below, noting that the operation
  22.272 - * will fail silently if any of conditions are not met.
  22.273 - * NOTE: this call must be made before jvm.dll is loaded, or jvm.cfg
  22.274 - * is read, since jvm.cfg will be modified by the preJVMStart.
  22.275 - * 1. Are we on a supported platform.
  22.276 - * 2. Find the location of the JRE or the Kernel JRE.
  22.277 - * 3. check existence of JREHOME/lib/bundles
  22.278 - * 4. check jkernel.dll and invoke the entry-point
  22.279 - */
  22.280 -typedef VOID (WINAPI *PREJVMSTART)();
  22.281 -
  22.282 -static void
  22.283 -EnsureJreInstallation(const char* jrepath)
  22.284 -{
  22.285 -    HINSTANCE handle;
  22.286 -    char tmpbuf[MAXPATHLEN];
  22.287 -    PREJVMSTART PreJVMStart;
  22.288 -    struct stat s;
  22.289 -
  22.290 -    /* 32 bit windows only please */
  22.291 -    if (strcmp(GetArch(), "i386") != 0 ) {
  22.292 -        if (_launcher_debug) {
  22.293 -            printf("EnsureJreInstallation:unsupported platform\n");
  22.294 -        }
  22.295 -        return;
  22.296 -    }
  22.297 -    /* Does our bundle directory exist ? */
  22.298 -    strcpy(tmpbuf, jrepath);
  22.299 -    strcat(tmpbuf, "\\lib\\bundles");
  22.300 -    if (stat(tmpbuf, &s) != 0) {
  22.301 -        if (_launcher_debug) {
  22.302 -            printf("EnsureJreInstallation:<%s>:not found\n", tmpbuf);
  22.303 -        }
  22.304 -        return;
  22.305 -    }
  22.306 -    /* Does our jkernel dll exist ? */
  22.307 -    strcpy(tmpbuf, jrepath);
  22.308 -    strcat(tmpbuf, "\\bin\\jkernel.dll");
  22.309 -    if (stat(tmpbuf, &s) != 0) {
  22.310 -        if (_launcher_debug) {
  22.311 -            printf("EnsureJreInstallation:<%s>:not found\n", tmpbuf);
  22.312 -        }
  22.313 -        return;
  22.314 -    }
  22.315 -    /* The Microsoft C Runtime Library needs to be loaded first. */
  22.316 -    if (!LoadMSVCRT()) {
  22.317 -        if (_launcher_debug) {
  22.318 -            printf("EnsureJreInstallation:could not load C runtime DLL\n");
  22.319 -        }
  22.320 -        return;
  22.321 -    }
  22.322 -    /* Load the jkernel.dll */
  22.323 -    if ((handle = LoadLibrary(tmpbuf)) == 0) {
  22.324 -        if (_launcher_debug) {
  22.325 -            printf("EnsureJreInstallation:%s:load failed\n", tmpbuf);
  22.326 -        }
  22.327 -        return;
  22.328 -    }
  22.329 -    /* Get the function address */
  22.330 -    PreJVMStart = (PREJVMSTART)GetProcAddress(handle, "preJVMStart");
  22.331 -    if (PreJVMStart == NULL) {
  22.332 -        if (_launcher_debug) {
  22.333 -            printf("EnsureJreInstallation:preJVMStart:function lookup failed\n");
  22.334 -        }
  22.335 -        FreeLibrary(handle);
  22.336 -        return;
  22.337 -    }
  22.338 -    PreJVMStart();
  22.339 -    if (_launcher_debug) {
  22.340 -        printf("EnsureJreInstallation:preJVMStart:called\n");
  22.341 -    }
  22.342 -    FreeLibrary(handle);
  22.343 -    return;
  22.344 -}
  22.345 -
  22.346 -/*
  22.347 - * Find path to JRE based on .exe's location or registry settings.
  22.348 - */
  22.349 -jboolean
  22.350 -GetJREPath(char *path, jint pathsize)
  22.351 -{
  22.352 -    char javadll[MAXPATHLEN];
  22.353 -    struct stat s;
  22.354 -
  22.355 -    if (GetApplicationHome(path, pathsize)) {
  22.356 -        /* Is JRE co-located with the application? */
  22.357 -        sprintf(javadll, "%s\\bin\\" JAVA_DLL, path);
  22.358 -        if (stat(javadll, &s) == 0) {
  22.359 -            goto found;
  22.360 -        }
  22.361 -
  22.362 -        /* Does this app ship a private JRE in <apphome>\jre directory? */
  22.363 -        sprintf(javadll, "%s\\jre\\bin\\" JAVA_DLL, path);
  22.364 -        if (stat(javadll, &s) == 0) {
  22.365 -            strcat(path, "\\jre");
  22.366 -            goto found;
  22.367 -        }
  22.368 -    }
  22.369 -
  22.370 -#ifndef GAMMA
  22.371 -    /* Look for a public JRE on this machine. */
  22.372 -    if (GetPublicJREHome(path, pathsize)) {
  22.373 -        goto found;
  22.374 -    }
  22.375 -#endif
  22.376 -
  22.377 -    fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
  22.378 -    return JNI_FALSE;
  22.379 -
  22.380 - found:
  22.381 -    if (_launcher_debug)
  22.382 -      printf("JRE path is %s\n", path);
  22.383 -    return JNI_TRUE;
  22.384 -}
  22.385 -
  22.386 -/*
  22.387 - * Given a JRE location and a JVM type, construct what the name the
  22.388 - * JVM shared library will be.  Return true, if such a library
  22.389 - * exists, false otherwise.
  22.390 - */
  22.391 -static jboolean
  22.392 -GetJVMPath(const char *jrepath, const char *jvmtype,
  22.393 -           char *jvmpath, jint jvmpathsize)
  22.394 -{
  22.395 -    struct stat s;
  22.396 -
  22.397 -#ifndef GAMMA
  22.398 -    if (strchr(jvmtype, '/') || strchr(jvmtype, '\\')) {
  22.399 -        sprintf(jvmpath, "%s\\" JVM_DLL, jvmtype);
  22.400 -    } else {
  22.401 -        sprintf(jvmpath, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype);
  22.402 -    }
  22.403 -#else
  22.404 -    /*
  22.405 -     * For gamma launcher, JVM is either built-in or in the same directory.
  22.406 -     * Either way we return "<exe_path>/jvm.dll" where <exe_path> is the
  22.407 -     * directory where gamma launcher is located.
  22.408 -     */
  22.409 -
  22.410 -    char *p;
  22.411 -    GetModuleFileName(0, jvmpath, jvmpathsize);
  22.412 -
  22.413 -    p = strrchr(jvmpath, '\\');
  22.414 -    if (p) {
  22.415 -       /* replace executable name with libjvm.so */
  22.416 -       snprintf(p + 1, jvmpathsize - (p + 1 - jvmpath), "%s", JVM_DLL);
  22.417 -    } else {
  22.418 -       /* this case shouldn't happen */
  22.419 -       snprintf(jvmpath, jvmpathsize, "%s", JVM_DLL);
  22.420 -    }
  22.421 -#endif /* ifndef GAMMA */
  22.422 -
  22.423 -    if (stat(jvmpath, &s) == 0) {
  22.424 -        return JNI_TRUE;
  22.425 -    } else {
  22.426 -        return JNI_FALSE;
  22.427 -    }
  22.428 -}
  22.429 -
  22.430 -/*
  22.431 - * Load a jvm from "jvmpath" and initialize the invocation functions.
  22.432 - */
  22.433 -jboolean
  22.434 -LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
  22.435 -{
  22.436 -#ifdef GAMMA
  22.437 -    /* JVM is directly linked with gamma launcher; no Loadlibrary() */
  22.438 -    ifn->CreateJavaVM = JNI_CreateJavaVM;
  22.439 -    ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
  22.440 -    return JNI_TRUE;
  22.441 -#else
  22.442 -    HINSTANCE handle;
  22.443 -
  22.444 -    if (_launcher_debug) {
  22.445 -        printf("JVM path is %s\n", jvmpath);
  22.446 -    }
  22.447 -
  22.448 -    /* The Microsoft C Runtime Library needs to be loaded first. */
  22.449 -    LoadMSVCRT();
  22.450 -
  22.451 -    /* Load the Java VM DLL */
  22.452 -    if ((handle = LoadLibrary(jvmpath)) == 0) {
  22.453 -        ReportErrorMessage2("Error loading: %s", (char *)jvmpath, JNI_TRUE);
  22.454 -        return JNI_FALSE;
  22.455 -    }
  22.456 -
  22.457 -    /* Now get the function addresses */
  22.458 -    ifn->CreateJavaVM =
  22.459 -        (void *)GetProcAddress(handle, "JNI_CreateJavaVM");
  22.460 -    ifn->GetDefaultJavaVMInitArgs =
  22.461 -        (void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
  22.462 -    if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
  22.463 -        ReportErrorMessage2("Error: can't find JNI interfaces in: %s",
  22.464 -                            (char *)jvmpath, JNI_TRUE);
  22.465 -        return JNI_FALSE;
  22.466 -    }
  22.467 -
  22.468 -    return JNI_TRUE;
  22.469 -#endif /* ifndef GAMMA */
  22.470 -}
  22.471 -
  22.472 -/*
  22.473 - * If app is "c:\foo\bin\javac", then put "c:\foo" into buf.
  22.474 - */
  22.475 -jboolean
  22.476 -GetApplicationHome(char *buf, jint bufsize)
  22.477 -{
  22.478 -#ifndef GAMMA
  22.479 -    char *cp;
  22.480 -    GetModuleFileName(0, buf, bufsize);
  22.481 -    *strrchr(buf, '\\') = '\0'; /* remove .exe file name */
  22.482 -    if ((cp = strrchr(buf, '\\')) == 0) {
  22.483 -        /* This happens if the application is in a drive root, and
  22.484 -         * there is no bin directory. */
  22.485 -        buf[0] = '\0';
  22.486 -        return JNI_FALSE;
  22.487 -    }
  22.488 -    *cp = '\0';  /* remove the bin\ part */
  22.489 -    return JNI_TRUE;
  22.490 -
  22.491 -#else /* ifndef GAMMA */
  22.492 -
  22.493 -    char env[MAXPATHLEN + 1];
  22.494 -
  22.495 -    /* gamma launcher uses ALT_JAVA_HOME environment variable or jdkpath.txt file to find JDK/JRE */
  22.496 -
  22.497 -    if (getenv("ALT_JAVA_HOME") != NULL) {
  22.498 -       snprintf(buf, bufsize, "%s", getenv("ALT_JAVA_HOME"));
  22.499 -    }
  22.500 -    else {
  22.501 -       char path[MAXPATHLEN + 1];
  22.502 -       char* p;
  22.503 -       int len;
  22.504 -       FILE* fp;
  22.505 -
  22.506 -       // find the path to the currect executable
  22.507 -       len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
  22.508 -       if (len == 0 || len > MAXPATHLEN) {
  22.509 -          printf("Could not get directory of current executable.");
  22.510 -          return JNI_FALSE;
  22.511 -       }
  22.512 -       // remove last path component ("hotspot.exe")
  22.513 -       p = strrchr(path, '\\');
  22.514 -       if (p == NULL) {
  22.515 -          printf("Could not parse directory of current executable.\n");
  22.516 -          return JNI_FALSE;
  22.517 -       }
  22.518 -       *p = '\0';
  22.519 -
  22.520 -       // open jdkpath.txt and read JAVA_HOME from it
  22.521 -       if (strlen(path) + strlen("\\jdkpath.txt") + 1 >= MAXPATHLEN) {
  22.522 -          printf("Path too long: %s\n", path);
  22.523 -          return JNI_FALSE;
  22.524 -       }
  22.525 -       strcat(path, "\\jdkpath.txt");
  22.526 -       fp = fopen(path, "r");
  22.527 -       if (fp == NULL) {
  22.528 -          printf("Could not open file %s to get path to JDK.\n", path);
  22.529 -          return JNI_FALSE;
  22.530 -       }
  22.531 -
  22.532 -       if (fgets(buf, bufsize, fp) == NULL) {
  22.533 -          printf("Could not read from file %s to get path to JDK.\n", path);
  22.534 -          fclose(fp);
  22.535 -          return JNI_FALSE;
  22.536 -       }
  22.537 -       // trim the buffer
  22.538 -       p = buf + strlen(buf) - 1;
  22.539 -       while(isspace(*p)) {
  22.540 -          *p = '\0';
  22.541 -          p--;
  22.542 -       }
  22.543 -       fclose(fp);
  22.544 -    }
  22.545 -
  22.546 -    _snprintf(env, MAXPATHLEN, "JAVA_HOME=%s", buf);
  22.547 -    _putenv(env);
  22.548 -
  22.549 -    return JNI_TRUE;
  22.550 -#endif /* ifndef GAMMA */
  22.551 -}
  22.552 -
  22.553 -#ifdef JAVAW
  22.554 -__declspec(dllimport) char **__initenv;
  22.555 -
  22.556 -int WINAPI
  22.557 -WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
  22.558 -{
  22.559 -    int   ret;
  22.560 -
  22.561 -    __initenv = _environ;
  22.562 -    ret = main(__argc, __argv);
  22.563 -
  22.564 -    return ret;
  22.565 -}
  22.566 -#endif
  22.567 -
  22.568 -#ifndef GAMMA
  22.569 -
  22.570 -/*
  22.571 - * Helpers to look in the registry for a public JRE.
  22.572 - */
  22.573 -                    /* Same for 1.5.0, 1.5.1, 1.5.2 etc. */
  22.574 -#define DOTRELEASE  JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
  22.575 -#define JRE_KEY     "Software\\JavaSoft\\Java Runtime Environment"
  22.576 -
  22.577 -static jboolean
  22.578 -GetStringFromRegistry(HKEY key, const char *name, char *buf, jint bufsize)
  22.579 -{
  22.580 -    DWORD type, size;
  22.581 -
  22.582 -    if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0
  22.583 -        && type == REG_SZ
  22.584 -        && (size < (unsigned int)bufsize)) {
  22.585 -        if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0) {
  22.586 -            return JNI_TRUE;
  22.587 -        }
  22.588 -    }
  22.589 -    return JNI_FALSE;
  22.590 -}
  22.591 -
  22.592 -static jboolean
  22.593 -GetPublicJREHome(char *buf, jint bufsize)
  22.594 -{
  22.595 -    HKEY key, subkey;
  22.596 -    char version[MAXPATHLEN];
  22.597 -
  22.598 -    /*
  22.599 -     * Note: There is a very similar implementation of the following
  22.600 -     * registry reading code in the Windows java control panel (javacp.cpl).
  22.601 -     * If there are bugs here, a similar bug probably exists there.  Hence,
  22.602 -     * changes here require inspection there.
  22.603 -     */
  22.604 -
  22.605 -    /* Find the current version of the JRE */
  22.606 -    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) {
  22.607 -        fprintf(stderr, "Error opening registry key '" JRE_KEY "'\n");
  22.608 -        return JNI_FALSE;
  22.609 -    }
  22.610 -
  22.611 -    if (!GetStringFromRegistry(key, "CurrentVersion",
  22.612 -                               version, sizeof(version))) {
  22.613 -        fprintf(stderr, "Failed reading value of registry key:\n\t"
  22.614 -                JRE_KEY "\\CurrentVersion\n");
  22.615 -        RegCloseKey(key);
  22.616 -        return JNI_FALSE;
  22.617 -    }
  22.618 -
  22.619 -    if (strcmp(version, DOTRELEASE) != 0) {
  22.620 -        fprintf(stderr, "Registry key '" JRE_KEY "\\CurrentVersion'\nhas "
  22.621 -                "value '%s', but '" DOTRELEASE "' is required.\n", version);
  22.622 -        RegCloseKey(key);
  22.623 -        return JNI_FALSE;
  22.624 -    }
  22.625 -
  22.626 -    /* Find directory where the current version is installed. */
  22.627 -    if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) {
  22.628 -        fprintf(stderr, "Error opening registry key '"
  22.629 -                JRE_KEY "\\%s'\n", version);
  22.630 -        RegCloseKey(key);
  22.631 -        return JNI_FALSE;
  22.632 -    }
  22.633 -
  22.634 -    if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) {
  22.635 -        fprintf(stderr, "Failed reading value of registry key:\n\t"
  22.636 -                JRE_KEY "\\%s\\JavaHome\n", version);
  22.637 -        RegCloseKey(key);
  22.638 -        RegCloseKey(subkey);
  22.639 -        return JNI_FALSE;
  22.640 -    }
  22.641 -
  22.642 -    if (_launcher_debug) {
  22.643 -        char micro[MAXPATHLEN];
  22.644 -        if (!GetStringFromRegistry(subkey, "MicroVersion", micro,
  22.645 -                                   sizeof(micro))) {
  22.646 -            printf("Warning: Can't read MicroVersion\n");
  22.647 -            micro[0] = '\0';
  22.648 -        }
  22.649 -        printf("Version major.minor.micro = %s.%s\n", version, micro);
  22.650 -    }
  22.651 -
  22.652 -    RegCloseKey(key);
  22.653 -    RegCloseKey(subkey);
  22.654 -    return JNI_TRUE;
  22.655 -}
  22.656 -
  22.657 -#endif /* ifndef GAMMA */
  22.658 -
  22.659 -/*
  22.660 - * Support for doing cheap, accurate interval timing.
  22.661 - */
  22.662 -static jboolean counterAvailable = JNI_FALSE;
  22.663 -static jboolean counterInitialized = JNI_FALSE;
  22.664 -static LARGE_INTEGER counterFrequency;
  22.665 -
  22.666 -jlong CounterGet()
  22.667 -{
  22.668 -    LARGE_INTEGER count;
  22.669 -
  22.670 -    if (!counterInitialized) {
  22.671 -        counterAvailable = QueryPerformanceFrequency(&counterFrequency);
  22.672 -        counterInitialized = JNI_TRUE;
  22.673 -    }
  22.674 -    if (!counterAvailable) {
  22.675 -        return 0;
  22.676 -    }
  22.677 -    QueryPerformanceCounter(&count);
  22.678 -    return (jlong)(count.QuadPart);
  22.679 -}
  22.680 -
  22.681 -jlong Counter2Micros(jlong counts)
  22.682 -{
  22.683 -    if (!counterAvailable || !counterInitialized) {
  22.684 -        return 0;
  22.685 -    }
  22.686 -    return (counts * 1000 * 1000)/counterFrequency.QuadPart;
  22.687 -}
  22.688 -
  22.689 -void ReportErrorMessage(char * message, jboolean always) {
  22.690 -#ifdef JAVAW
  22.691 -  if (message != NULL) {
  22.692 -    MessageBox(NULL, message, "Java Virtual Machine Launcher",
  22.693 -               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
  22.694 -  }
  22.695 -#else
  22.696 -  if (always) {
  22.697 -    fprintf(stderr, "%s\n", message);
  22.698 -  }
  22.699 -#endif
  22.700 -}
  22.701 -
  22.702 -void ReportErrorMessage2(char * format, char * string, jboolean always) {
  22.703 -  /*
  22.704 -   * The format argument must be a printf format string with one %s
  22.705 -   * argument, which is passed the string argument.
  22.706 -   */
  22.707 -#ifdef JAVAW
  22.708 -  size_t size;
  22.709 -  char * message;
  22.710 -  size = strlen(format) + strlen(string);
  22.711 -  message = (char*)JLI_MemAlloc(size*sizeof(char));
  22.712 -  sprintf(message, (const char *)format, string);
  22.713 -
  22.714 -  if (message != NULL) {
  22.715 -    MessageBox(NULL, message, "Java Virtual Machine Launcher",
  22.716 -               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
  22.717 -    JLI_MemFree(message);
  22.718 -  }
  22.719 -#else
  22.720 -  if (always) {
  22.721 -    fprintf(stderr, (const char *)format, string);
  22.722 -    fprintf(stderr, "\n");
  22.723 -  }
  22.724 -#endif
  22.725 -}
  22.726 -
  22.727 -/*
  22.728 - * As ReportErrorMessage2 (above) except the system message (if any)
  22.729 - * associated with this error is written to a second %s format specifier
  22.730 - * in the format argument.
  22.731 - */
  22.732 -void ReportSysErrorMessage2(char * format, char * string, jboolean always) {
  22.733 -  int   save_errno = errno;
  22.734 -  DWORD errval;
  22.735 -  int   freeit = 0;
  22.736 -  char  *errtext = NULL;
  22.737 -
  22.738 -  if ((errval = GetLastError()) != 0) {         /* Platform SDK / DOS Error */
  22.739 -    int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
  22.740 -      FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER,
  22.741 -      NULL, errval, 0, (LPTSTR)&errtext, 0, NULL);
  22.742 -    if (errtext == NULL || n == 0) {            /* Paranoia check */
  22.743 -      errtext = "";
  22.744 -      n = 0;
  22.745 -    } else {
  22.746 -      freeit = 1;
  22.747 -      if (n > 2) {                              /* Drop final CR, LF */
  22.748 -        if (errtext[n - 1] == '\n') n--;
  22.749 -        if (errtext[n - 1] == '\r') n--;
  22.750 -        errtext[n] = '\0';
  22.751 -      }
  22.752 -    }
  22.753 -  } else        /* C runtime error that has no corresponding DOS error code */
  22.754 -    errtext = strerror(save_errno);
  22.755 -
  22.756 -#ifdef JAVAW
  22.757 -  {
  22.758 -    size_t size;
  22.759 -    char * message;
  22.760 -    size = strlen(format) + strlen(string) + strlen(errtext);
  22.761 -    message = (char*)JLI_MemAlloc(size*sizeof(char));
  22.762 -    sprintf(message, (const char *)format, string, errtext);
  22.763 -
  22.764 -    if (message != NULL) {
  22.765 -      MessageBox(NULL, message, "Java Virtual Machine Launcher",
  22.766 -               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
  22.767 -      JLI_MemFree(message);
  22.768 -    }
  22.769 -  }
  22.770 -#else
  22.771 -  if (always) {
  22.772 -    fprintf(stderr, (const char *)format, string, errtext);
  22.773 -    fprintf(stderr, "\n");
  22.774 -  }
  22.775 -#endif
  22.776 -  if (freeit)
  22.777 -    (void)LocalFree((HLOCAL)errtext);
  22.778 -}
  22.779 -
  22.780 -void  ReportExceptionDescription(JNIEnv * env) {
  22.781 -#ifdef JAVAW
  22.782 -  /*
  22.783 -   * This code should be replaced by code which opens a window with
  22.784 -   * the exception detail message.
  22.785 -   */
  22.786 -  (*env)->ExceptionDescribe(env);
  22.787 -#else
  22.788 -  (*env)->ExceptionDescribe(env);
  22.789 -#endif
  22.790 -}
  22.791 -
  22.792 -
  22.793 -/*
  22.794 - * Return JNI_TRUE for an option string that has no effect but should
  22.795 - * _not_ be passed on to the vm; return JNI_FALSE otherwise. On
  22.796 - * windows, there are no options that should be screened in this
  22.797 - * manner.
  22.798 - */
  22.799 -jboolean RemovableMachineDependentOption(char * option) {
  22.800 -#ifdef ENABLE_AWT_PRELOAD
  22.801 -    if (awtPreloadD3D < 0) {
  22.802 -        /* Tests the command line parameter only if not set yet. */
  22.803 -        if (GetBoolParamValue(PARAM_PRELOAD_D3D, option) == 1) {
  22.804 -            awtPreloadD3D = 1;
  22.805 -        }
  22.806 -    }
  22.807 -    if (awtPreloadD3D != 0) {
  22.808 -        /* Don't test the command line parameters if already disabled. */
  22.809 -        if (GetBoolParamValue(PARAM_NODDRAW, option) == 1
  22.810 -            || GetBoolParamValue(PARAM_D3D, option) == 0
  22.811 -            || GetBoolParamValue(PARAM_OPENGL, option) == 1)
  22.812 -        {
  22.813 -            awtPreloadD3D = 0;
  22.814 -        }
  22.815 -    }
  22.816 -#endif /* ENABLE_AWT_PRELOAD */
  22.817 -
  22.818 -    return JNI_FALSE;
  22.819 -}
  22.820 -
  22.821 -void PrintMachineDependentOptions() {
  22.822 -  return;
  22.823 -}
  22.824 -
  22.825 -#ifndef GAMMA
  22.826 -
  22.827 -jboolean
  22.828 -ServerClassMachine() {
  22.829 -  jboolean result = JNI_FALSE;
  22.830 -#if   defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
  22.831 -  result = JNI_FALSE;
  22.832 -#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
  22.833 -  result = JNI_TRUE;
  22.834 -#endif
  22.835 -  return result;
  22.836 -}
  22.837 -
  22.838 -/*
  22.839 - * Determine if there is an acceptable JRE in the registry directory top_key.
  22.840 - * Upon locating the "best" one, return a fully qualified path to it.
  22.841 - * "Best" is defined as the most advanced JRE meeting the constraints
  22.842 - * contained in the manifest_info. If no JRE in this directory meets the
  22.843 - * constraints, return NULL.
  22.844 - *
  22.845 - * It doesn't matter if we get an error reading the registry, or we just
  22.846 - * don't find anything interesting in the directory.  We just return NULL
  22.847 - * in either case.
  22.848 - */
  22.849 -static char *
  22.850 -ProcessDir(manifest_info* info, HKEY top_key) {
  22.851 -    DWORD   index = 0;
  22.852 -    HKEY    ver_key;
  22.853 -    char    name[MAXNAMELEN];
  22.854 -    int     len;
  22.855 -    char    *best = NULL;
  22.856 -
  22.857 -    /*
  22.858 -     * Enumerate "<top_key>/SOFTWARE/JavaSoft/Java Runtime Environment"
  22.859 -     * searching for the best available version.
  22.860 -     */
  22.861 -    while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) {
  22.862 -        index++;
  22.863 -        if (JLI_AcceptableRelease(name, info->jre_version))
  22.864 -            if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) {
  22.865 -                if (best != NULL)
  22.866 -                    JLI_MemFree(best);
  22.867 -                best = JLI_StringDup(name);
  22.868 -            }
  22.869 -    }
  22.870 -
  22.871 -    /*
  22.872 -     * Extract "JavaHome" from the "best" registry directory and return
  22.873 -     * that path.  If no appropriate version was located, or there is an
  22.874 -     * error in extracting the "JavaHome" string, return null.
  22.875 -     */
  22.876 -    if (best == NULL)
  22.877 -        return (NULL);
  22.878 -    else {
  22.879 -        if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key)
  22.880 -          != ERROR_SUCCESS) {
  22.881 -            JLI_MemFree(best);
  22.882 -            if (ver_key != NULL)
  22.883 -                RegCloseKey(ver_key);
  22.884 -            return (NULL);
  22.885 -        }
  22.886 -        JLI_MemFree(best);
  22.887 -        len = MAXNAMELEN;
  22.888 -        if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len)
  22.889 -          != ERROR_SUCCESS) {
  22.890 -            if (ver_key != NULL)
  22.891 -                RegCloseKey(ver_key);
  22.892 -            return (NULL);
  22.893 -        }
  22.894 -        if (ver_key != NULL)
  22.895 -            RegCloseKey(ver_key);
  22.896 -        return (JLI_StringDup(name));
  22.897 -    }
  22.898 -}
  22.899 -
  22.900 -/*
  22.901 - * This is the global entry point. It examines the host for the optimal
  22.902 - * JRE to be used by scanning a set of registry entries.  This set of entries
  22.903 - * is hardwired on Windows as "Software\JavaSoft\Java Runtime Environment"
  22.904 - * under the set of roots "{ HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }".
  22.905 - *
  22.906 - * This routine simply opens each of these registry directories before passing
  22.907 - * control onto ProcessDir().
  22.908 - */
  22.909 -char *
  22.910 -LocateJRE(manifest_info* info) {
  22.911 -    HKEY    key = NULL;
  22.912 -    char    *path;
  22.913 -    int     key_index;
  22.914 -    HKEY    root_keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
  22.915 -
  22.916 -    for (key_index = 0; key_index <= 1; key_index++) {
  22.917 -        if (RegOpenKeyEx(root_keys[key_index], JRE_KEY, 0, KEY_READ, &key)
  22.918 -          == ERROR_SUCCESS)
  22.919 -            if ((path = ProcessDir(info, key)) != NULL) {
  22.920 -                if (key != NULL)
  22.921 -                    RegCloseKey(key);
  22.922 -                return (path);
  22.923 -            }
  22.924 -        if (key != NULL)
  22.925 -            RegCloseKey(key);
  22.926 -    }
  22.927 -    return NULL;
  22.928 -}
  22.929 -
  22.930 -
  22.931 -/*
  22.932 - * Local helper routine to isolate a single token (option or argument)
  22.933 - * from the command line.
  22.934 - *
  22.935 - * This routine accepts a pointer to a character pointer.  The first
  22.936 - * token (as defined by MSDN command-line argument syntax) is isolated
  22.937 - * from that string.
  22.938 - *
  22.939 - * Upon return, the input character pointer pointed to by the parameter s
  22.940 - * is updated to point to the remainding, unscanned, portion of the string,
  22.941 - * or to a null character if the entire string has been consummed.
  22.942 - *
  22.943 - * This function returns a pointer to a null-terminated string which
  22.944 - * contains the isolated first token, or to the null character if no
  22.945 - * token could be isolated.
  22.946 - *
  22.947 - * Note the side effect of modifying the input string s by the insertion
  22.948 - * of a null character, making it two strings.
  22.949 - *
  22.950 - * See "Parsing C Command-Line Arguments" in the MSDN Library for the
  22.951 - * parsing rule details.  The rule summary from that specification is:
  22.952 - *
  22.953 - *  * Arguments are delimited by white space, which is either a space or a tab.
  22.954 - *
  22.955 - *  * A string surrounded by double quotation marks is interpreted as a single
  22.956 - *    argument, regardless of white space contained within. A quoted string can
  22.957 - *    be embedded in an argument. Note that the caret (^) is not recognized as
  22.958 - *    an escape character or delimiter.
  22.959 - *
  22.960 - *  * A double quotation mark preceded by a backslash, \", is interpreted as a
  22.961 - *    literal double quotation mark (").
  22.962 - *
  22.963 - *  * Backslashes are interpreted literally, unless they immediately precede a
  22.964 - *    double quotation mark.
  22.965 - *
  22.966 - *  * If an even number of backslashes is followed by a double quotation mark,
  22.967 - *    then one backslash (\) is placed in the argv array for every pair of
  22.968 - *    backslashes (\\), and the double quotation mark (") is interpreted as a
  22.969 - *    string delimiter.
  22.970 - *
  22.971 - *  * If an odd number of backslashes is followed by a double quotation mark,
  22.972 - *    then one backslash (\) is placed in the argv array for every pair of
  22.973 - *    backslashes (\\) and the double quotation mark is interpreted as an
  22.974 - *    escape sequence by the remaining backslash, causing a literal double
  22.975 - *    quotation mark (") to be placed in argv.
  22.976 - */
  22.977 -static char*
  22.978 -nextarg(char** s) {
  22.979 -    char    *p = *s;
  22.980 -    char    *head;
  22.981 -    int     slashes = 0;
  22.982 -    int     inquote = 0;
  22.983 -
  22.984 -    /*
  22.985 -     * Strip leading whitespace, which MSDN defines as only space or tab.
  22.986 -     * (Hence, no locale specific "isspace" here.)
  22.987 -     */
  22.988 -    while (*p != (char)0 && (*p == ' ' || *p == '\t'))
  22.989 -        p++;
  22.990 -    head = p;                   /* Save the start of the token to return */
  22.991 -
  22.992 -    /*
  22.993 -     * Isolate a token from the command line.
  22.994 -     */
  22.995 -    while (*p != (char)0 && (inquote || !(*p == ' ' || *p == '\t'))) {
  22.996 -        if (*p == '\\' && *(p+1) == '"' && slashes % 2 == 0)
  22.997 -            p++;
  22.998 -        else if (*p == '"')
  22.999 -            inquote = !inquote;
 22.1000 -        slashes = (*p++ == '\\') ? slashes + 1 : 0;
 22.1001 -    }
 22.1002 -
 22.1003 -    /*
 22.1004 -     * If the token isolated isn't already terminated in a "char zero",
 22.1005 -     * then replace the whitespace character with one and move to the
 22.1006 -     * next character.
 22.1007 -     */
 22.1008 -    if (*p != (char)0)
 22.1009 -        *p++ = (char)0;
 22.1010 -
 22.1011 -    /*
 22.1012 -     * Update the parameter to point to the head of the remaining string
 22.1013 -     * reflecting the command line and return a pointer to the leading
 22.1014 -     * token which was isolated from the command line.
 22.1015 -     */
 22.1016 -    *s = p;
 22.1017 -    return (head);
 22.1018 -}
 22.1019 -
 22.1020 -/*
 22.1021 - * Local helper routine to return a string equivalent to the input string
 22.1022 - * s, but with quotes removed so the result is a string as would be found
 22.1023 - * in argv[].  The returned string should be freed by a call to JLI_MemFree().
 22.1024 - *
 22.1025 - * The rules for quoting (and escaped quotes) are:
 22.1026 - *
 22.1027 - *  1 A double quotation mark preceded by a backslash, \", is interpreted as a
 22.1028 - *    literal double quotation mark (").
 22.1029 - *
 22.1030 - *  2 Backslashes are interpreted literally, unless they immediately precede a
 22.1031 - *    double quotation mark.
 22.1032 - *
 22.1033 - *  3 If an even number of backslashes is followed by a double quotation mark,
 22.1034 - *    then one backslash (\) is placed in the argv array for every pair of
 22.1035 - *    backslashes (\\), and the double quotation mark (") is interpreted as a
 22.1036 - *    string delimiter.
 22.1037 - *
 22.1038 - *  4 If an odd number of backslashes is followed by a double quotation mark,
 22.1039 - *    then one backslash (\) is placed in the argv array for every pair of
 22.1040 - *    backslashes (\\) and the double quotation mark is interpreted as an
 22.1041 - *    escape sequence by the remaining backslash, causing a literal double
 22.1042 - *    quotation mark (") to be placed in argv.
 22.1043 - */
 22.1044 -static char*
 22.1045 -unquote(const char *s) {
 22.1046 -    const char *p = s;          /* Pointer to the tail of the original string */
 22.1047 -    char *un = (char*)JLI_MemAlloc(strlen(s) + 1);  /* Ptr to unquoted string */
 22.1048 -    char *pun = un;             /* Pointer to the tail of the unquoted string */
 22.1049 -
 22.1050 -    while (*p != '\0') {
 22.1051 -        if (*p == '"') {
 22.1052 -            p++;
 22.1053 -        } else if (*p == '\\') {
 22.1054 -            const char *q = p + strspn(p,"\\");
 22.1055 -            if (*q == '"')
 22.1056 -                do {
 22.1057 -                    *pun++ = '\\';
 22.1058 -                    p += 2;
 22.1059 -                 } while (*p == '\\' && p < q);
 22.1060 -            else
 22.1061 -                while (p < q)
 22.1062 -                    *pun++ = *p++;
 22.1063 -        } else {
 22.1064 -            *pun++ = *p++;
 22.1065 -        }
 22.1066 -    }
 22.1067 -    *pun = '\0';
 22.1068 -    return un;
 22.1069 -}
 22.1070 -
 22.1071 -/*
 22.1072 - * Given a path to a jre to execute, this routine checks if this process
 22.1073 - * is indeed that jre.  If not, it exec's that jre.
 22.1074 - *
 22.1075 - * We want to actually check the paths rather than just the version string
 22.1076 - * built into the executable, so that given version specification will yield
 22.1077 - * the exact same Java environment, regardless of the version of the arbitrary
 22.1078 - * launcher we start with.
 22.1079 - */
 22.1080 -void
 22.1081 -ExecJRE(char *jre, char **argv) {
 22.1082 -    int     len;
 22.1083 -    char    *progname;
 22.1084 -    char    path[MAXPATHLEN + 1];
 22.1085 -
 22.1086 -    /*
 22.1087 -     * Determine the executable we are building (or in the rare case, running).
 22.1088 -     */
 22.1089 -#ifdef JAVA_ARGS  /* javac, jar and friends. */
 22.1090 -    progname = "java";
 22.1091 -#else             /* java, oldjava, javaw and friends */
 22.1092 -#ifdef PROGNAME
 22.1093 -    progname = PROGNAME;
 22.1094 -#else
 22.1095 -    {
 22.1096 -        char *s;
 22.1097 -        progname = *argv;
 22.1098 -        if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
 22.1099 -            progname = s + 1;
 22.1100 -        }
 22.1101 -    }
 22.1102 -#endif /* PROGNAME */
 22.1103 -#endif /* JAVA_ARGS */
 22.1104 -
 22.1105 -    /*
 22.1106 -     * Resolve the real path to the currently running launcher.
 22.1107 -     */
 22.1108 -    len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
 22.1109 -    if (len == 0 || len > MAXPATHLEN) {
 22.1110 -        ReportSysErrorMessage2(
 22.1111 -          "Unable to resolve path to current %s executable: %s",
 22.1112 -          progname, JNI_TRUE);
 22.1113 -        exit(1);
 22.1114 -    }
 22.1115 -
 22.1116 -    if (_launcher_debug) {
 22.1117 -        printf("ExecJRE: old: %s\n", path);
 22.1118 -        printf("ExecJRE: new: %s\n", jre);
 22.1119 -    }
 22.1120 -
 22.1121 -    /*
 22.1122 -     * If the path to the selected JRE directory is a match to the initial
 22.1123 -     * portion of the path to the currently executing JRE, we have a winner!
 22.1124 -     * If so, just return. (strnicmp() is the Windows equiv. of strncasecmp().)
 22.1125 -     */
 22.1126 -    if (strnicmp(jre, path, strlen(jre)) == 0)
 22.1127 -        return;                 /* I am the droid you were looking for */
 22.1128 -
 22.1129 -    /*
 22.1130 -     * If this isn't the selected version, exec the selected version.
 22.1131 -     */
 22.1132 -    (void)strcat(strcat(strcpy(path, jre), "\\bin\\"), progname);
 22.1133 -    (void)strcat(path, ".exe");
 22.1134 -
 22.1135 -    /*
 22.1136 -     * Although Windows has an execv() entrypoint, it doesn't actually
 22.1137 -     * overlay a process: it can only create a new process and terminate
 22.1138 -     * the old process.  Therefore, any processes waiting on the initial
 22.1139 -     * process wake up and they shouldn't.  Hence, a chain of pseudo-zombie
 22.1140 -     * processes must be retained to maintain the proper wait semantics.
 22.1141 -     * Fortunately the image size of the launcher isn't too large at this
 22.1142 -     * time.
 22.1143 -     *
 22.1144 -     * If it weren't for this semantic flaw, the code below would be ...
 22.1145 -     *
 22.1146 -     *     execv(path, argv);
 22.1147 -     *     ReportErrorMessage2("Exec of %s failed\n", path, JNI_TRUE);
 22.1148 -     *     exit(1);
 22.1149 -     *
 22.1150 -     * The incorrect exec semantics could be addressed by:
 22.1151 -     *
 22.1152 -     *     exit((int)spawnv(_P_WAIT, path, argv));
 22.1153 -     *
 22.1154 -     * Unfortunately, a bug in Windows spawn/exec impementation prevents
 22.1155 -     * this from completely working.  All the Windows POSIX process creation
 22.1156 -     * interfaces are implemented as wrappers around the native Windows
 22.1157 -     * function CreateProcess().  CreateProcess() takes a single string
 22.1158 -     * to specify command line options and arguments, so the POSIX routine
 22.1159 -     * wrappers build a single string from the argv[] array and in the
 22.1160 -     * process, any quoting information is lost.
 22.1161 -     *
 22.1162 -     * The solution to this to get the original command line, to process it
 22.1163 -     * to remove the new multiple JRE options (if any) as was done for argv
 22.1164 -     * in the common SelectVersion() routine and finally to pass it directly
 22.1165 -     * to the native CreateProcess() Windows process control interface.
 22.1166 -     */
 22.1167 -    {
 22.1168 -        char    *cmdline;
 22.1169 -        char    *p;
 22.1170 -        char    *np;
 22.1171 -        char    *ocl;
 22.1172 -        char    *ccl;
 22.1173 -        char    *unquoted;
 22.1174 -        DWORD   exitCode;
 22.1175 -        STARTUPINFO si;
 22.1176 -        PROCESS_INFORMATION pi;
 22.1177 -
 22.1178 -        /*
 22.1179 -         * The following code block gets and processes the original command
 22.1180 -         * line, replacing the argv[0] equivalent in the command line with
 22.1181 -         * the path to the new executable and removing the appropriate
 22.1182 -         * Multiple JRE support options. Note that similar logic exists
 22.1183 -         * in the platform independent SelectVersion routine, but is
 22.1184 -         * replicated here due to the syntax of CreateProcess().
 22.1185 -         *
 22.1186 -         * The magic "+ 4" characters added to the command line length are
 22.1187 -         * 2 possible quotes around the path (argv[0]), a space after the
 22.1188 -         * path and a terminating null character.
 22.1189 -         */
 22.1190 -        ocl = GetCommandLine();
 22.1191 -        np = ccl = JLI_StringDup(ocl);
 22.1192 -        p = nextarg(&np);               /* Discard argv[0] */
 22.1193 -        cmdline = (char *)JLI_MemAlloc(strlen(path) + strlen(np) + 4);
 22.1194 -        if (strchr(path, (int)' ') == NULL && strchr(path, (int)'\t') == NULL)
 22.1195 -            cmdline = strcpy(cmdline, path);
 22.1196 -        else
 22.1197 -            cmdline = strcat(strcat(strcpy(cmdline, "\""), path), "\"");
 22.1198 -
 22.1199 -        while (*np != (char)0) {                /* While more command-line */
 22.1200 -            p = nextarg(&np);
 22.1201 -            if (*p != (char)0) {                /* If a token was isolated */
 22.1202 -                unquoted = unquote(p);
 22.1203 -                if (*unquoted == '-') {         /* Looks like an option */
 22.1204 -                    if (strcmp(unquoted, "-classpath") == 0 ||
 22.1205 -                      strcmp(unquoted, "-cp") == 0) {   /* Unique cp syntax */
 22.1206 -                        cmdline = strcat(strcat(cmdline, " "), p);
 22.1207 -                        p = nextarg(&np);
 22.1208 -                        if (*p != (char)0)      /* If a token was isolated */
 22.1209 -                            cmdline = strcat(strcat(cmdline, " "), p);
 22.1210 -                    } else if (strncmp(unquoted, "-version:", 9) != 0 &&
 22.1211 -                      strcmp(unquoted, "-jre-restrict-search") != 0 &&
 22.1212 -                      strcmp(unquoted, "-no-jre-restrict-search") != 0) {
 22.1213 -                        cmdline = strcat(strcat(cmdline, " "), p);
 22.1214 -                    }
 22.1215 -                } else {                        /* End of options */
 22.1216 -                    cmdline = strcat(strcat(cmdline, " "), p);
 22.1217 -                    cmdline = strcat(strcat(cmdline, " "), np);
 22.1218 -                    JLI_MemFree((void *)unquoted);
 22.1219 -                    break;
 22.1220 -                }
 22.1221 -                JLI_MemFree((void *)unquoted);
 22.1222 -            }
 22.1223 -        }
 22.1224 -        JLI_MemFree((void *)ccl);
 22.1225 -
 22.1226 -        if (_launcher_debug) {
 22.1227 -            np = ccl = JLI_StringDup(cmdline);
 22.1228 -            p = nextarg(&np);
 22.1229 -            printf("ReExec Command: %s (%s)\n", path, p);
 22.1230 -            printf("ReExec Args: %s\n", np);
 22.1231 -            JLI_MemFree((void *)ccl);
 22.1232 -        }
 22.1233 -        (void)fflush(stdout);
 22.1234 -        (void)fflush(stderr);
 22.1235 -
 22.1236 -        /*
 22.1237 -         * The following code is modeled after a model presented in the
 22.1238 -         * Microsoft Technical Article "Moving Unix Applications to
 22.1239 -         * Windows NT" (March 6, 1994) and "Creating Processes" on MSDN
 22.1240 -         * (Februrary 2005).  It approximates UNIX spawn semantics with
 22.1241 -         * the parent waiting for termination of the child.
 22.1242 -         */
 22.1243 -        memset(&si, 0, sizeof(si));
 22.1244 -        si.cb =sizeof(STARTUPINFO);
 22.1245 -        memset(&pi, 0, sizeof(pi));
 22.1246 -
 22.1247 -        if (!CreateProcess((LPCTSTR)path,       /* executable name */
 22.1248 -          (LPTSTR)cmdline,                      /* command line */
 22.1249 -          (LPSECURITY_ATTRIBUTES)NULL,          /* process security attr. */
 22.1250 -          (LPSECURITY_ATTRIBUTES)NULL,          /* thread security attr. */
 22.1251 -          (BOOL)TRUE,                           /* inherits system handles */
 22.1252 -          (DWORD)0,                             /* creation flags */
 22.1253 -          (LPVOID)NULL,                         /* environment block */
 22.1254 -          (LPCTSTR)NULL,                        /* current directory */
 22.1255 -          (LPSTARTUPINFO)&si,                   /* (in) startup information */
 22.1256 -          (LPPROCESS_INFORMATION)&pi)) {        /* (out) process information */
 22.1257 -            ReportSysErrorMessage2("CreateProcess(%s, ...) failed: %s",
 22.1258 -              path, JNI_TRUE);
 22.1259 -              exit(1);
 22.1260 -        }
 22.1261 -
 22.1262 -        if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_FAILED) {
 22.1263 -            if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE)
 22.1264 -                exitCode = 1;
 22.1265 -        } else {
 22.1266 -            ReportErrorMessage("WaitForSingleObject() failed.", JNI_TRUE);
 22.1267 -            exitCode = 1;
 22.1268 -        }
 22.1269 -
 22.1270 -        CloseHandle(pi.hThread);
 22.1271 -        CloseHandle(pi.hProcess);
 22.1272 -
 22.1273 -        exit(exitCode);
 22.1274 -    }
 22.1275 -
 22.1276 -}
 22.1277 -
 22.1278 -#endif /* ifndef GAMMA */
 22.1279 -
 22.1280 -
 22.1281 -/*
 22.1282 - * Wrapper for platform dependent unsetenv function.
 22.1283 - */
 22.1284 -int
 22.1285 -UnsetEnv(char *name)
 22.1286 -{
 22.1287 -    int ret;
 22.1288 -    char *buf = JLI_MemAlloc(strlen(name) + 2);
 22.1289 -    buf = strcat(strcpy(buf, name), "=");
 22.1290 -    ret = _putenv(buf);
 22.1291 -    JLI_MemFree(buf);
 22.1292 -    return (ret);
 22.1293 -}
 22.1294 -
 22.1295 -/* --- Splash Screen shared library support --- */
 22.1296 -
 22.1297 -static const char* SPLASHSCREEN_SO = "\\bin\\splashscreen.dll";
 22.1298 -
 22.1299 -static HMODULE hSplashLib = NULL;
 22.1300 -
 22.1301 -void* SplashProcAddress(const char* name) {
 22.1302 -    char libraryPath[MAXPATHLEN]; /* some extra space for strcat'ing SPLASHSCREEN_SO */
 22.1303 -
 22.1304 -    if (!GetJREPath(libraryPath, MAXPATHLEN)) {
 22.1305 -        return NULL;
 22.1306 -    }
 22.1307 -    if (strlen(libraryPath)+strlen(SPLASHSCREEN_SO) >= MAXPATHLEN) {
 22.1308 -        return NULL;
 22.1309 -    }
 22.1310 -    strcat(libraryPath, SPLASHSCREEN_SO);
 22.1311 -
 22.1312 -    if (!hSplashLib) {
 22.1313 -        hSplashLib = LoadLibrary(libraryPath);
 22.1314 -    }
 22.1315 -    if (hSplashLib) {
 22.1316 -        return GetProcAddress(hSplashLib, name);
 22.1317 -    } else {
 22.1318 -        return NULL;
 22.1319 -    }
 22.1320 -}
 22.1321 -
 22.1322 -void SplashFreeLibrary() {
 22.1323 -    if (hSplashLib) {
 22.1324 -        FreeLibrary(hSplashLib);
 22.1325 -        hSplashLib = NULL;
 22.1326 -    }
 22.1327 -}
 22.1328 -
 22.1329 -/*
 22.1330 - * Block current thread and continue execution in a new thread
 22.1331 - */
 22.1332 -int
 22.1333 -ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 22.1334 -    int rslt = 0;
 22.1335 -    unsigned thread_id;
 22.1336 -
 22.1337 -#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
 22.1338 -#define STACK_SIZE_PARAM_IS_A_RESERVATION  (0x10000)
 22.1339 -#endif
 22.1340 -
 22.1341 -    /*
 22.1342 -     * STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not
 22.1343 -     * supported on older version of Windows. Try first with the flag; and
 22.1344 -     * if that fails try again without the flag. See MSDN document or HotSpot
 22.1345 -     * source (os_win32.cpp) for details.
 22.1346 -     */
 22.1347 -    HANDLE thread_handle =
 22.1348 -      (HANDLE)_beginthreadex(NULL,
 22.1349 -                             (unsigned)stack_size,
 22.1350 -                             continuation,
 22.1351 -                             args,
 22.1352 -                             STACK_SIZE_PARAM_IS_A_RESERVATION,
 22.1353 -                             &thread_id);
 22.1354 -    if (thread_handle == NULL) {
 22.1355 -      thread_handle =
 22.1356 -      (HANDLE)_beginthreadex(NULL,
 22.1357 -                             (unsigned)stack_size,
 22.1358 -                             continuation,
 22.1359 -                             args,
 22.1360 -                             0,
 22.1361 -                             &thread_id);
 22.1362 -    }
 22.1363 -
 22.1364 -    /* AWT preloading (AFTER main thread start) */
 22.1365 -#ifdef ENABLE_AWT_PRELOAD
 22.1366 -    /* D3D preloading */
 22.1367 -    if (awtPreloadD3D != 0) {
 22.1368 -        char *envValue;
 22.1369 -        /* D3D routines checks env.var J2D_D3D if no appropriate
 22.1370 -         * command line params was specified
 22.1371 -         */
 22.1372 -        envValue = getenv("J2D_D3D");
 22.1373 -        if (envValue != NULL && stricmp(envValue, "false") == 0) {
 22.1374 -            awtPreloadD3D = 0;
 22.1375 -        }
 22.1376 -        /* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */
 22.1377 -        envValue = getenv("J2D_D3D_PRELOAD");
 22.1378 -        if (envValue != NULL && stricmp(envValue, "false") == 0) {
 22.1379 -            awtPreloadD3D = 0;
 22.1380 -        }
 22.1381 -        if (awtPreloadD3D < 0) {
 22.1382 -            /* If awtPreloadD3D is still undefined (-1), test
 22.1383 -             * if it is turned on by J2D_D3D_PRELOAD env.var.
 22.1384 -             * By default it's turned OFF.
 22.1385 -             */
 22.1386 -            awtPreloadD3D = 0;
 22.1387 -            if (envValue != NULL && stricmp(envValue, "true") == 0) {
 22.1388 -                awtPreloadD3D = 1;
 22.1389 -            }
 22.1390 -        }
 22.1391 -    }
 22.1392 -    if (awtPreloadD3D) {
 22.1393 -        AWTPreload(D3D_PRELOAD_FUNC);
 22.1394 -    }
 22.1395 -#endif /* ENABLE_AWT_PRELOAD */
 22.1396 -
 22.1397 -    if (thread_handle) {
 22.1398 -      WaitForSingleObject(thread_handle, INFINITE);
 22.1399 -      GetExitCodeThread(thread_handle, &rslt);
 22.1400 -      CloseHandle(thread_handle);
 22.1401 -    } else {
 22.1402 -      rslt = continuation(args);
 22.1403 -    }
 22.1404 -
 22.1405 -#ifdef ENABLE_AWT_PRELOAD
 22.1406 -    if (awtPreloaded) {
 22.1407 -        AWTPreloadStop();
 22.1408 -    }
 22.1409 -#endif /* ENABLE_AWT_PRELOAD */
 22.1410 -
 22.1411 -    return rslt;
 22.1412 -}
 22.1413 -
 22.1414 -/* Linux only, empty on windows. */
 22.1415 -void SetJavaLauncherPlatformProps() {}
 22.1416 -
 22.1417 -
 22.1418 -//==============================
 22.1419 -// AWT preloading
 22.1420 -#ifdef ENABLE_AWT_PRELOAD
 22.1421 -
 22.1422 -typedef int FnPreloadStart(void);
 22.1423 -typedef void FnPreloadStop(void);
 22.1424 -static FnPreloadStop *fnPreloadStop = NULL;
 22.1425 -static HMODULE hPreloadAwt = NULL;
 22.1426 -
 22.1427 -/*
 22.1428 - * Starts AWT preloading
 22.1429 - */
 22.1430 -int AWTPreload(const char *funcName)
 22.1431 -{
 22.1432 -    int result = -1;
 22.1433 -
 22.1434 -    // load AWT library once (if several preload function should be called)
 22.1435 -    if (hPreloadAwt == NULL) {
 22.1436 -        // awt.dll is not loaded yet
 22.1437 -        char libraryPath[MAXPATHLEN];
 22.1438 -        int jrePathLen = 0;
 22.1439 -        HMODULE hJava = NULL;
 22.1440 -        HMODULE hVerify = NULL;
 22.1441 -
 22.1442 -        while (1) {
 22.1443 -            // awt.dll depends on jvm.dll & java.dll;
 22.1444 -            // jvm.dll is already loaded, so we need only java.dll;
 22.1445 -            // java.dll depends on MSVCRT lib & verify.dll.
 22.1446 -            if (!GetJREPath(libraryPath, MAXPATHLEN)) {
 22.1447 -                break;
 22.1448 -            }
 22.1449 -
 22.1450 -            // save path length
 22.1451 -            jrePathLen = strlen(libraryPath);
 22.1452 -
 22.1453 -            // load msvcrt 1st
 22.1454 -            LoadMSVCRT();
 22.1455 -
 22.1456 -            // load verify.dll
 22.1457 -            strcat(libraryPath, "\\bin\\verify.dll");
 22.1458 -            hVerify = LoadLibrary(libraryPath);
 22.1459 -            if (hVerify == NULL) {
 22.1460 -                break;
 22.1461 -            }
 22.1462 -
 22.1463 -            // restore jrePath
 22.1464 -            libraryPath[jrePathLen] = 0;
 22.1465 -            // load java.dll
 22.1466 -            strcat(libraryPath, "\\bin\\" JAVA_DLL);
 22.1467 -            hJava = LoadLibrary(libraryPath);
 22.1468 -            if (hJava == NULL) {
 22.1469 -                break;
 22.1470 -            }
 22.1471 -
 22.1472 -            // restore jrePath
 22.1473 -            libraryPath[jrePathLen] = 0;
 22.1474 -            // load awt.dll
 22.1475 -            strcat(libraryPath, "\\bin\\awt.dll");
 22.1476 -            hPreloadAwt = LoadLibrary(libraryPath);
 22.1477 -            if (hPreloadAwt == NULL) {
 22.1478 -                break;
 22.1479 -            }
 22.1480 -
 22.1481 -            // get "preloadStop" func ptr
 22.1482 -            fnPreloadStop = (FnPreloadStop *)GetProcAddress(hPreloadAwt, "preloadStop");
 22.1483 -
 22.1484 -            break;
 22.1485 -        }
 22.1486 -    }
 22.1487 -
 22.1488 -    if (hPreloadAwt != NULL) {
 22.1489 -        FnPreloadStart *fnInit = (FnPreloadStart *)GetProcAddress(hPreloadAwt, funcName);
 22.1490 -        if (fnInit != NULL) {
 22.1491 -            // don't forget to stop preloading
 22.1492 -            awtPreloaded = 1;
 22.1493 -
 22.1494 -            result = fnInit();
 22.1495 -        }
 22.1496 -    }
 22.1497 -
 22.1498 -    return result;
 22.1499 -}
 22.1500 -
 22.1501 -/*
 22.1502 - * Terminates AWT preloading
 22.1503 - */
 22.1504 -void AWTPreloadStop() {
 22.1505 -    if (fnPreloadStop != NULL) {
 22.1506 -        fnPreloadStop();
 22.1507 -    }
 22.1508 -}
 22.1509 -
 22.1510 -#endif /* ENABLE_AWT_PRELOAD */
    23.1 --- a/src/os/windows/launcher/java_md.h	Tue May 14 17:33:07 2013 +0000
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,83 +0,0 @@
    23.4 -/*
    23.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    23.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 - *
    23.8 - * This code is free software; you can redistribute it and/or modify it
    23.9 - * under the terms of the GNU General Public License version 2 only, as
   23.10 - * published by the Free Software Foundation.
   23.11 - *
   23.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 - * version 2 for more details (a copy is included in the LICENSE file that
   23.16 - * accompanied this code).
   23.17 - *
   23.18 - * You should have received a copy of the GNU General Public License version
   23.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 - *
   23.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 - * or visit www.oracle.com if you need additional information or have any
   23.24 - * questions.
   23.25 - *
   23.26 - */
   23.27 -
   23.28 -#ifndef JAVA_MD_H
   23.29 -#define JAVA_MD_H
   23.30 -
   23.31 -#include <jni.h>
   23.32 -#include <windows.h>
   23.33 -#include <io.h>
   23.34 -#ifndef GAMMA
   23.35 -#include "manifest_info.h"
   23.36 -#endif
   23.37 -#include "jli_util.h"
   23.38 -
   23.39 -#ifdef GAMMA
   23.40 -#define stricmp _stricmp
   23.41 -#define strnicmp _strnicmp
   23.42 -#define snprintf _snprintf
   23.43 -#define strdup _strdup
   23.44 -#endif
   23.45 -
   23.46 -#define PATH_SEPARATOR  ';'
   23.47 -#define FILESEP         "\\"
   23.48 -#define FILE_SEPARATOR  '\\'
   23.49 -#define IS_FILE_SEPARATOR(c) ((c) == '\\' || (c) == '/')
   23.50 -#define MAXPATHLEN      MAX_PATH
   23.51 -#define MAXNAMELEN      MAX_PATH
   23.52 -
   23.53 -#ifdef JAVA_ARGS
   23.54 -/*
   23.55 - * ApplicationHome is prepended to each of these entries; the resulting
   23.56 - * strings are concatenated (separated by PATH_SEPARATOR) and used as the
   23.57 - * value of -cp option to the launcher.
   23.58 - */
   23.59 -#ifndef APP_CLASSPATH
   23.60 -#define APP_CLASSPATH        { "\\lib\\tools.jar", "\\classes" }
   23.61 -#endif
   23.62 -#endif
   23.63 -
   23.64 -/*
   23.65 - * Support for doing cheap, accurate interval timing.
   23.66 - */
   23.67 -extern jlong CounterGet(void);
   23.68 -extern jlong Counter2Micros(jlong counts);
   23.69 -
   23.70 -#ifdef JAVAW
   23.71 -#define main _main
   23.72 -extern int _main(int argc, char **argv);
   23.73 -#endif
   23.74 -
   23.75 -#define JLONG_FORMAT "%I64d"
   23.76 -
   23.77 -/*
   23.78 - * Function prototypes.
   23.79 - */
   23.80 -#ifndef GAMMA
   23.81 -char *LocateJRE(manifest_info *info);
   23.82 -void ExecJRE(char *jre, char **argv);
   23.83 -#endif
   23.84 -int UnsetEnv(char *name);
   23.85 -
   23.86 -#endif
    24.1 --- a/src/share/tools/ProjectCreator/BuildConfig.java	Tue May 14 17:33:07 2013 +0000
    24.2 +++ b/src/share/tools/ProjectCreator/BuildConfig.java	Thu May 16 13:47:55 2013 -0700
    24.3 @@ -65,6 +65,7 @@
    24.4          String sourceBase = getFieldString(null, "SourceBase");
    24.5          String buildSpace = getFieldString(null, "BuildSpace");
    24.6          String outDir = buildBase;
    24.7 +        String jdkTargetRoot = getFieldString(null, "JdkTargetRoot");
    24.8  
    24.9          put("Id", flavourBuild);
   24.10          put("OutputDir", outDir);
   24.11 @@ -72,6 +73,7 @@
   24.12          put("BuildBase", buildBase);
   24.13          put("BuildSpace", buildSpace);
   24.14          put("OutputDll", outDir + Util.sep + outDll);
   24.15 +        put("JdkTargetRoot", jdkTargetRoot);
   24.16  
   24.17          context = new String [] {flavourBuild, flavour, build, null};
   24.18      }
    25.1 --- a/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java	Tue May 14 17:33:07 2013 +0000
    25.2 +++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java	Thu May 16 13:47:55 2013 -0700
    25.3 @@ -98,11 +98,6 @@
    25.4              tagV(cfg.getV("LinkerFlags"));
    25.5              endTag();
    25.6  
    25.7 -            startTag("PostBuildEvent");
    25.8 -            tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription"));
    25.9 -            tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n")));
   25.10 -            endTag();
   25.11 -
   25.12              startTag("PreLinkEvent");
   25.13              tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription"));
   25.14              tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n")));
   25.15 @@ -141,7 +136,9 @@
   25.16  
   25.17          for (BuildConfig cfg : allConfigs) {
   25.18              startTag(cfg, "PropertyGroup");
   25.19 -            tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe");
   25.20 +            tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe");
   25.21 +            tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) -Dsun.java.launcher=gamma");
   25.22 +            tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot"));
   25.23              endTag();
   25.24          }
   25.25  
    26.1 --- a/src/share/tools/launcher/java.c	Tue May 14 17:33:07 2013 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,2080 +0,0 @@
    26.4 -/*
    26.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    26.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 - *
    26.8 - * This code is free software; you can redistribute it and/or modify it
    26.9 - * under the terms of the GNU General Public License version 2 only, as
   26.10 - * published by the Free Software Foundation.
   26.11 - *
   26.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 - * version 2 for more details (a copy is included in the LICENSE file that
   26.16 - * accompanied this code).
   26.17 - *
   26.18 - * You should have received a copy of the GNU General Public License version
   26.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 - *
   26.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 - * or visit www.oracle.com if you need additional information or have any
   26.24 - * questions.
   26.25 - *
   26.26 - */
   26.27 -
   26.28 -/*
   26.29 - * Gamma (Hotspot internal engineering test) launcher based on 6.0u22 JDK,
   26.30 - * search "GAMMA" for gamma specific changes.
   26.31 - *
   26.32 - * GAMMA: gamma launcher is much simpler than regular java launcher in that
   26.33 - *        JVM is either statically linked in or it is installed in the
   26.34 - *        same directory where the launcher exists, so we don't have to
   26.35 - *        worry about choosing the right JVM based on command line flag, jar
   26.36 - *        file and/or ergonomics. Intead of removing unused logic from source
   26.37 - *        they are commented out with #ifndef GAMMA, hopefully it'll be easier
   26.38 - *        to maintain this file in sync with regular JDK launcher.
   26.39 - */
   26.40 -
   26.41 -/*
   26.42 - * Shared source for 'java' command line tool.
   26.43 - *
   26.44 - * If JAVA_ARGS is defined, then acts as a launcher for applications. For
   26.45 - * instance, the JDK command line tools such as javac and javadoc (see
   26.46 - * makefiles for more details) are built with this program.  Any arguments
   26.47 - * prefixed with '-J' will be passed directly to the 'java' command.
   26.48 - */
   26.49 -
   26.50 -#ifdef GAMMA
   26.51 -#  ifdef JAVA_ARGS
   26.52 -#    error Do NOT define JAVA_ARGS when building gamma launcher
   26.53 -#  endif
   26.54 -#  if !defined(LINK_INTO_AOUT) && !defined(LINK_INTO_LIBJVM)
   26.55 -#    error Either LINK_INTO_AOUT or LINK_INTO_LIBJVM must be defined
   26.56 -#  endif
   26.57 -#endif
   26.58 -
   26.59 -/*
   26.60 - * One job of the launcher is to remove command line options which the
   26.61 - * vm does not understand and will not process.  These options include
   26.62 - * options which select which style of vm is run (e.g. -client and
   26.63 - * -server) as well as options which select the data model to use.
   26.64 - * Additionally, for tools which invoke an underlying vm "-J-foo"
   26.65 - * options are turned into "-foo" options to the vm.  This option
   26.66 - * filtering is handled in a number of places in the launcher, some of
   26.67 - * it in machine-dependent code.  In this file, the function
   26.68 - * CheckJVMType removes vm style options and TranslateApplicationArgs
   26.69 - * removes "-J" prefixes.  On unix platforms, the
   26.70 - * CreateExecutionEnvironment function from the unix java_md.c file
   26.71 - * processes and removes -d<n> options.  However, in case
   26.72 - * CreateExecutionEnvironment does not need to exec because
   26.73 - * LD_LIBRARY_PATH is set acceptably and the data model does not need
   26.74 - * to be changed, ParseArguments will screen out the redundant -d<n>
   26.75 - * options and prevent them from being passed to the vm; this is done
   26.76 - * by using the machine-dependent call
   26.77 - * RemovableMachineDependentOption.
   26.78 - */
   26.79 -
   26.80 -#include <stdio.h>
   26.81 -#include <stdlib.h>
   26.82 -#include <string.h>
   26.83 -
   26.84 -#include <jni.h>
   26.85 -#include <jvm.h>
   26.86 -#include "java.h"
   26.87 -#ifndef GAMMA
   26.88 -#include "manifest_info.h"
   26.89 -#include "version_comp.h"
   26.90 -#include "splashscreen.h"
   26.91 -#endif
   26.92 -#include "wildcard.h"
   26.93 -
   26.94 -#ifndef FULL_VERSION
   26.95 -#define FULL_VERSION JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
   26.96 -#endif
   26.97 -
   26.98 -/*
   26.99 - * The following environment variable is used to influence the behavior
  26.100 - * of the jre exec'd through the SelectVersion routine.  The command line
  26.101 - * options which specify the version are not passed to the exec'd version,
  26.102 - * because that jre may be an older version which wouldn't recognize them.
  26.103 - * This environment variable is known to this (and later) version and serves
  26.104 - * to suppress the version selection code.  This is not only for efficiency,
  26.105 - * but also for correctness, since any command line options have been
  26.106 - * removed which would cause any value found in the manifest to be used.
  26.107 - * This would be incorrect because the command line options are defined
  26.108 - * to take precedence.
  26.109 - *
  26.110 - * The value associated with this environment variable is the MainClass
  26.111 - * name from within the executable jar file (if any). This is strictly a
  26.112 - * performance enhancement to avoid re-reading the jar file manifest.
  26.113 - *
  26.114 - * A NOTE TO DEVELOPERS: For performance reasons it is important that
  26.115 - * the program image remain relatively small until after SelectVersion
  26.116 - * CreateExecutionEnvironment have finished their possibly recursive
  26.117 - * processing. Watch everything, but resist all temptations to use Java
  26.118 - * interfaces.
  26.119 - */
  26.120 -#define ENV_ENTRY "_JAVA_VERSION_SET"
  26.121 -
  26.122 -#ifndef GAMMA
  26.123 -#define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
  26.124 -#define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
  26.125 -#endif
  26.126 -
  26.127 -static jboolean printVersion = JNI_FALSE; /* print and exit */
  26.128 -static jboolean showVersion = JNI_FALSE;  /* print but continue */
  26.129 -static char *progname;
  26.130 -jboolean _launcher_debug = JNI_FALSE;
  26.131 -
  26.132 -#ifndef GAMMA
  26.133 -/*
  26.134 - * Entries for splash screen environment variables.
  26.135 - * putenv is performed in SelectVersion. We need
  26.136 - * them in memory until UnsetEnv, so they are made static
  26.137 - * global instead of auto local.
  26.138 - */
  26.139 -static char* splash_file_entry = NULL;
  26.140 -static char* splash_jar_entry = NULL;
  26.141 -#endif
  26.142 -
  26.143 -/*
  26.144 - * List of VM options to be specified when the VM is created.
  26.145 - */
  26.146 -static JavaVMOption *options;
  26.147 -static int numOptions, maxOptions;
  26.148 -
  26.149 -/*
  26.150 - * Prototypes for functions internal to launcher.
  26.151 - */
  26.152 -static void SetClassPath(const char *s);
  26.153 -static void SelectVersion(int argc, char **argv, char **main_class);
  26.154 -static jboolean ParseArguments(int *pargc, char ***pargv, char **pjarfile,
  26.155 -                               char **pclassname, int *pret, const char *jvmpath);
  26.156 -static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
  26.157 -                              InvocationFunctions *ifn);
  26.158 -static jstring NewPlatformString(JNIEnv *env, char *s);
  26.159 -static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
  26.160 -static jclass LoadClass(JNIEnv *env, char *name);
  26.161 -static jstring GetMainClassName(JNIEnv *env, char *jarname);
  26.162 -static void SetJavaCommandLineProp(char* classname, char* jarfile, int argc, char** argv);
  26.163 -static void SetJavaLauncherProp(void);
  26.164 -
  26.165 -#ifdef JAVA_ARGS
  26.166 -static void TranslateApplicationArgs(int *pargc, char ***pargv);
  26.167 -static jboolean AddApplicationOptions(void);
  26.168 -#endif
  26.169 -
  26.170 -static void PrintJavaVersion(JNIEnv *env);
  26.171 -static void PrintUsage(void);
  26.172 -static jint PrintXUsage(const char *jvmpath);
  26.173 -
  26.174 -static void SetPaths(int argc, char **argv);
  26.175 -
  26.176 -#ifndef GAMMA
  26.177 -
  26.178 -/* Maximum supported entries from jvm.cfg. */
  26.179 -#define INIT_MAX_KNOWN_VMS      10
  26.180 -/* Values for vmdesc.flag */
  26.181 -#define VM_UNKNOWN              -1
  26.182 -#define VM_KNOWN                 0
  26.183 -#define VM_ALIASED_TO            1
  26.184 -#define VM_WARN                  2
  26.185 -#define VM_ERROR                 3
  26.186 -#define VM_IF_SERVER_CLASS       4
  26.187 -#define VM_IGNORE                5
  26.188 -struct vmdesc {
  26.189 -    char *name;
  26.190 -    int flag;
  26.191 -    char *alias;
  26.192 -    char *server_class;
  26.193 -};
  26.194 -static struct vmdesc *knownVMs = NULL;
  26.195 -static int knownVMsCount = 0;
  26.196 -static int knownVMsLimit = 0;
  26.197 -
  26.198 -static void GrowKnownVMs();
  26.199 -static int  KnownVMIndex(const char* name);
  26.200 -static void FreeKnownVMs();
  26.201 -static void ShowSplashScreen();
  26.202 -
  26.203 -#endif /* ifndef GAMMA */
  26.204 -
  26.205 -jboolean ServerClassMachine();
  26.206 -
  26.207 -/* flag which if set suppresses error messages from the launcher */
  26.208 -static int noExitErrorMessage = 0;
  26.209 -
  26.210 -/*
  26.211 - * Running Java code in primordial thread caused many problems. We will
  26.212 - * create a new thread to invoke JVM. See 6316197 for more information.
  26.213 - */
  26.214 -static jlong threadStackSize = 0;  /* stack size of the new thread */
  26.215 -
  26.216 -int JNICALL JavaMain(void * args); /* entry point                  */
  26.217 -
  26.218 -struct JavaMainArgs {
  26.219 -  int     argc;
  26.220 -  char ** argv;
  26.221 -  char *  jarfile;
  26.222 -  char *  classname;
  26.223 -  InvocationFunctions ifn;
  26.224 -};
  26.225 -
  26.226 -/*
  26.227 - * Entry point.
  26.228 - */
  26.229 -int
  26.230 -main(int argc, char ** argv)
  26.231 -{
  26.232 -    char *jarfile = 0;
  26.233 -    char *classname = 0;
  26.234 -    char *s = 0;
  26.235 -    char *main_class = NULL;
  26.236 -    int ret;
  26.237 -    InvocationFunctions ifn;
  26.238 -    jlong start, end;
  26.239 -    char jrepath[MAXPATHLEN], jvmpath[MAXPATHLEN];
  26.240 -    char ** original_argv = argv;
  26.241 -
  26.242 -    if (getenv("_JAVA_LAUNCHER_DEBUG") != 0) {
  26.243 -        _launcher_debug = JNI_TRUE;
  26.244 -        printf("----_JAVA_LAUNCHER_DEBUG----\n");
  26.245 -    }
  26.246 -
  26.247 -#ifndef GAMMA
  26.248 -    /*
  26.249 -     * Make sure the specified version of the JRE is running.
  26.250 -     *
  26.251 -     * There are three things to note about the SelectVersion() routine:
  26.252 -     *  1) If the version running isn't correct, this routine doesn't
  26.253 -     *     return (either the correct version has been exec'd or an error
  26.254 -     *     was issued).
  26.255 -     *  2) Argc and Argv in this scope are *not* altered by this routine.
  26.256 -     *     It is the responsibility of subsequent code to ignore the
  26.257 -     *     arguments handled by this routine.
  26.258 -     *  3) As a side-effect, the variable "main_class" is guaranteed to
  26.259 -     *     be set (if it should ever be set).  This isn't exactly the
  26.260 -     *     poster child for structured programming, but it is a small
  26.261 -     *     price to pay for not processing a jar file operand twice.
  26.262 -     *     (Note: This side effect has been disabled.  See comment on
  26.263 -     *     bugid 5030265 below.)
  26.264 -     */
  26.265 -    SelectVersion(argc, argv, &main_class);
  26.266 -#endif /* ifndef GAMMA */
  26.267 -
  26.268 -    /* copy original argv */
  26.269 -    {
  26.270 -      int i;
  26.271 -      original_argv = (char**)JLI_MemAlloc(sizeof(char*)*(argc+1));
  26.272 -      for(i = 0; i < argc+1; i++)
  26.273 -        original_argv[i] = argv[i];
  26.274 -    }
  26.275 -
  26.276 -    CreateExecutionEnvironment(&argc, &argv,
  26.277 -                               jrepath, sizeof(jrepath),
  26.278 -                               jvmpath, sizeof(jvmpath),
  26.279 -                               original_argv);
  26.280 -
  26.281 -    printf("Using java runtime at: %s\n", jrepath);
  26.282 -
  26.283 -    ifn.CreateJavaVM = 0;
  26.284 -    ifn.GetDefaultJavaVMInitArgs = 0;
  26.285 -
  26.286 -    if (_launcher_debug)
  26.287 -      start = CounterGet();
  26.288 -    if (!LoadJavaVM(jvmpath, &ifn)) {
  26.289 -      exit(6);
  26.290 -    }
  26.291 -    if (_launcher_debug) {
  26.292 -      end   = CounterGet();
  26.293 -      printf("%ld micro seconds to LoadJavaVM\n",
  26.294 -             (long)(jint)Counter2Micros(end-start));
  26.295 -    }
  26.296 -
  26.297 -#ifdef JAVA_ARGS  /* javac, jar and friends. */
  26.298 -    progname = "java";
  26.299 -#else             /* java, oldjava, javaw and friends */
  26.300 -#ifdef PROGNAME
  26.301 -    progname = PROGNAME;
  26.302 -#else
  26.303 -    progname = *argv;
  26.304 -    if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
  26.305 -        progname = s + 1;
  26.306 -    }
  26.307 -#endif /* PROGNAME */
  26.308 -#endif /* JAVA_ARGS */
  26.309 -    ++argv;
  26.310 -    --argc;
  26.311 -
  26.312 -#ifdef JAVA_ARGS
  26.313 -    /* Preprocess wrapper arguments */
  26.314 -    TranslateApplicationArgs(&argc, &argv);
  26.315 -    if (!AddApplicationOptions()) {
  26.316 -        exit(1);
  26.317 -    }
  26.318 -#endif
  26.319 -
  26.320 -    /* Set default CLASSPATH */
  26.321 -    if ((s = getenv("CLASSPATH")) == 0) {
  26.322 -        s = ".";
  26.323 -    }
  26.324 -#ifndef JAVA_ARGS
  26.325 -    SetClassPath(s);
  26.326 -#endif
  26.327 -
  26.328 -    /*
  26.329 -     *  Parse command line options; if the return value of
  26.330 -     *  ParseArguments is false, the program should exit.
  26.331 -     */
  26.332 -    if (!ParseArguments(&argc, &argv, &jarfile, &classname, &ret, jvmpath)) {
  26.333 -      exit(ret);
  26.334 -    }
  26.335 -
  26.336 -    /* Override class path if -jar flag was specified */
  26.337 -    if (jarfile != 0) {
  26.338 -        SetClassPath(jarfile);
  26.339 -    }
  26.340 -
  26.341 -    /* set the -Dsun.java.command pseudo property */
  26.342 -    SetJavaCommandLineProp(classname, jarfile, argc, argv);
  26.343 -
  26.344 -    /* Set the -Dsun.java.launcher pseudo property */
  26.345 -    SetJavaLauncherProp();
  26.346 -
  26.347 -    /* set the -Dsun.java.launcher.* platform properties */
  26.348 -    SetJavaLauncherPlatformProps();
  26.349 -
  26.350 -#ifndef GAMMA
  26.351 -    /* Show the splash screen if needed */
  26.352 -    ShowSplashScreen();
  26.353 -#endif
  26.354 -
  26.355 -    /*
  26.356 -     * Done with all command line processing and potential re-execs so
  26.357 -     * clean up the environment.
  26.358 -     */
  26.359 -    (void)UnsetEnv(ENV_ENTRY);
  26.360 -#ifndef GAMMA
  26.361 -    (void)UnsetEnv(SPLASH_FILE_ENV_ENTRY);
  26.362 -    (void)UnsetEnv(SPLASH_JAR_ENV_ENTRY);
  26.363 -
  26.364 -    JLI_MemFree(splash_jar_entry);
  26.365 -    JLI_MemFree(splash_file_entry);
  26.366 -#endif
  26.367 -
  26.368 -    /*
  26.369 -     * If user doesn't specify stack size, check if VM has a preference.
  26.370 -     * Note that HotSpot no longer supports JNI_VERSION_1_1 but it will
  26.371 -     * return its default stack size through the init args structure.
  26.372 -     */
  26.373 -    if (threadStackSize == 0) {
  26.374 -      struct JDK1_1InitArgs args1_1;
  26.375 -      memset((void*)&args1_1, 0, sizeof(args1_1));
  26.376 -      args1_1.version = JNI_VERSION_1_1;
  26.377 -      ifn.GetDefaultJavaVMInitArgs(&args1_1);  /* ignore return value */
  26.378 -      if (args1_1.javaStackSize > 0) {
  26.379 -         threadStackSize = args1_1.javaStackSize;
  26.380 -      }
  26.381 -    }
  26.382 -
  26.383 -    { /* Create a new thread to create JVM and invoke main method */
  26.384 -      struct JavaMainArgs args;
  26.385 -
  26.386 -      args.argc = argc;
  26.387 -      args.argv = argv;
  26.388 -      args.jarfile = jarfile;
  26.389 -      args.classname = classname;
  26.390 -      args.ifn = ifn;
  26.391 -
  26.392 -      return ContinueInNewThread(JavaMain, threadStackSize, (void*)&args);
  26.393 -    }
  26.394 -}
  26.395 -
  26.396 -int JNICALL
  26.397 -JavaMain(void * _args)
  26.398 -{
  26.399 -    struct JavaMainArgs *args = (struct JavaMainArgs *)_args;
  26.400 -    int argc = args->argc;
  26.401 -    char **argv = args->argv;
  26.402 -    char *jarfile = args->jarfile;
  26.403 -    char *classname = args->classname;
  26.404 -    InvocationFunctions ifn = args->ifn;
  26.405 -
  26.406 -    JavaVM *vm = 0;
  26.407 -    JNIEnv *env = 0;
  26.408 -    jstring mainClassName;
  26.409 -    jclass mainClass;
  26.410 -    jmethodID mainID;
  26.411 -    jobjectArray mainArgs;
  26.412 -    int ret = 0;
  26.413 -    jlong start, end;
  26.414 -
  26.415 -    /*
  26.416 -     * Error message to print or display; by default the message will
  26.417 -     * only be displayed in a window.
  26.418 -     */
  26.419 -    char * message = "Fatal exception occurred.  Program will exit.";
  26.420 -    jboolean messageDest = JNI_FALSE;
  26.421 -
  26.422 -    /* Initialize the virtual machine */
  26.423 -
  26.424 -    if (_launcher_debug)
  26.425 -        start = CounterGet();
  26.426 -    if (!InitializeJVM(&vm, &env, &ifn)) {
  26.427 -        ReportErrorMessage("Could not create the Java virtual machine.",
  26.428 -                           JNI_TRUE);
  26.429 -        exit(1);
  26.430 -    }
  26.431 -
  26.432 -    if (printVersion || showVersion) {
  26.433 -        PrintJavaVersion(env);
  26.434 -        if ((*env)->ExceptionOccurred(env)) {
  26.435 -            ReportExceptionDescription(env);
  26.436 -            goto leave;
  26.437 -        }
  26.438 -        if (printVersion) {
  26.439 -            ret = 0;
  26.440 -            message = NULL;
  26.441 -            goto leave;
  26.442 -        }
  26.443 -        if (showVersion) {
  26.444 -            fprintf(stderr, "\n");
  26.445 -        }
  26.446 -    }
  26.447 -
  26.448 -    /* If the user specified neither a class name nor a JAR file */
  26.449 -    if (jarfile == 0 && classname == 0) {
  26.450 -        PrintUsage();
  26.451 -        message = NULL;
  26.452 -        goto leave;
  26.453 -    }
  26.454 -
  26.455 -#ifndef GAMMA
  26.456 -    FreeKnownVMs();  /* after last possible PrintUsage() */
  26.457 -#endif
  26.458 -
  26.459 -    if (_launcher_debug) {
  26.460 -        end   = CounterGet();
  26.461 -        printf("%ld micro seconds to InitializeJVM\n",
  26.462 -               (long)(jint)Counter2Micros(end-start));
  26.463 -    }
  26.464 -
  26.465 -    /* At this stage, argc/argv have the applications' arguments */
  26.466 -    if (_launcher_debug) {
  26.467 -        int i = 0;
  26.468 -        printf("Main-Class is '%s'\n", classname ? classname : "");
  26.469 -        printf("Apps' argc is %d\n", argc);
  26.470 -        for (; i < argc; i++) {
  26.471 -            printf("    argv[%2d] = '%s'\n", i, argv[i]);
  26.472 -        }
  26.473 -    }
  26.474 -
  26.475 -    ret = 1;
  26.476 -
  26.477 -    /*
  26.478 -     * Get the application's main class.
  26.479 -     *
  26.480 -     * See bugid 5030265.  The Main-Class name has already been parsed
  26.481 -     * from the manifest, but not parsed properly for UTF-8 support.
  26.482 -     * Hence the code here ignores the value previously extracted and
  26.483 -     * uses the pre-existing code to reextract the value.  This is
  26.484 -     * possibly an end of release cycle expedient.  However, it has
  26.485 -     * also been discovered that passing some character sets through
  26.486 -     * the environment has "strange" behavior on some variants of
  26.487 -     * Windows.  Hence, maybe the manifest parsing code local to the
  26.488 -     * launcher should never be enhanced.
  26.489 -     *
  26.490 -     * Hence, future work should either:
  26.491 -     *     1)   Correct the local parsing code and verify that the
  26.492 -     *          Main-Class attribute gets properly passed through
  26.493 -     *          all environments,
  26.494 -     *     2)   Remove the vestages of maintaining main_class through
  26.495 -     *          the environment (and remove these comments).
  26.496 -     */
  26.497 -    if (jarfile != 0) {
  26.498 -        mainClassName = GetMainClassName(env, jarfile);
  26.499 -        if ((*env)->ExceptionOccurred(env)) {
  26.500 -            ReportExceptionDescription(env);
  26.501 -            goto leave;
  26.502 -        }
  26.503 -        if (mainClassName == NULL) {
  26.504 -          const char * format = "Failed to load Main-Class manifest "
  26.505 -                                "attribute from\n%s";
  26.506 -          message = (char*)JLI_MemAlloc((strlen(format) + strlen(jarfile)) *
  26.507 -                                    sizeof(char));
  26.508 -          sprintf(message, format, jarfile);
  26.509 -          messageDest = JNI_TRUE;
  26.510 -          goto leave;
  26.511 -        }
  26.512 -        classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
  26.513 -        if (classname == NULL) {
  26.514 -            ReportExceptionDescription(env);
  26.515 -            goto leave;
  26.516 -        }
  26.517 -        mainClass = LoadClass(env, classname);
  26.518 -        if(mainClass == NULL) { /* exception occured */
  26.519 -            const char * format = "Could not find the main class: %s. Program will exit.";
  26.520 -            ReportExceptionDescription(env);
  26.521 -            message = (char *)JLI_MemAlloc((strlen(format) +
  26.522 -                                            strlen(classname)) * sizeof(char) );
  26.523 -            messageDest = JNI_TRUE;
  26.524 -            sprintf(message, format, classname);
  26.525 -            goto leave;
  26.526 -        }
  26.527 -        (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
  26.528 -    } else {
  26.529 -      mainClassName = NewPlatformString(env, classname);
  26.530 -      if (mainClassName == NULL) {
  26.531 -        const char * format = "Failed to load Main Class: %s";
  26.532 -        message = (char *)JLI_MemAlloc((strlen(format) + strlen(classname)) *
  26.533 -                                   sizeof(char) );
  26.534 -        sprintf(message, format, classname);
  26.535 -        messageDest = JNI_TRUE;
  26.536 -        goto leave;
  26.537 -      }
  26.538 -      classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
  26.539 -      if (classname == NULL) {
  26.540 -        ReportExceptionDescription(env);
  26.541 -        goto leave;
  26.542 -      }
  26.543 -      mainClass = LoadClass(env, classname);
  26.544 -      if(mainClass == NULL) { /* exception occured */
  26.545 -        const char * format = "Could not find the main class: %s.  Program will exit.";
  26.546 -        ReportExceptionDescription(env);
  26.547 -        message = (char *)JLI_MemAlloc((strlen(format) +
  26.548 -                                        strlen(classname)) * sizeof(char) );
  26.549 -        messageDest = JNI_TRUE;
  26.550 -        sprintf(message, format, classname);
  26.551 -        goto leave;
  26.552 -      }
  26.553 -      (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
  26.554 -    }
  26.555 -
  26.556 -    /* Get the application's main method */
  26.557 -    mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
  26.558 -                                       "([Ljava/lang/String;)V");
  26.559 -    if (mainID == NULL) {
  26.560 -        if ((*env)->ExceptionOccurred(env)) {
  26.561 -            ReportExceptionDescription(env);
  26.562 -        } else {
  26.563 -          message = "No main method found in specified class.";
  26.564 -          messageDest = JNI_TRUE;
  26.565 -        }
  26.566 -        goto leave;
  26.567 -    }
  26.568 -
  26.569 -    {    /* Make sure the main method is public */
  26.570 -        jint mods;
  26.571 -        jmethodID mid;
  26.572 -        jobject obj = (*env)->ToReflectedMethod(env, mainClass,
  26.573 -                                                mainID, JNI_TRUE);
  26.574 -
  26.575 -        if( obj == NULL) { /* exception occurred */
  26.576 -            ReportExceptionDescription(env);
  26.577 -            goto leave;
  26.578 -        }
  26.579 -
  26.580 -        mid =
  26.581 -          (*env)->GetMethodID(env,
  26.582 -                              (*env)->GetObjectClass(env, obj),
  26.583 -                              "getModifiers", "()I");
  26.584 -        if ((*env)->ExceptionOccurred(env)) {
  26.585 -            ReportExceptionDescription(env);
  26.586 -            goto leave;
  26.587 -        }
  26.588 -
  26.589 -        mods = (*env)->CallIntMethod(env, obj, mid);
  26.590 -        if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
  26.591 -            message = "Main method not public.";
  26.592 -            messageDest = JNI_TRUE;
  26.593 -            goto leave;
  26.594 -        }
  26.595 -    }
  26.596 -
  26.597 -    /* Build argument array */
  26.598 -    mainArgs = NewPlatformStringArray(env, argv, argc);
  26.599 -    if (mainArgs == NULL) {
  26.600 -        ReportExceptionDescription(env);
  26.601 -        goto leave;
  26.602 -    }
  26.603 -
  26.604 -    /* Invoke main method. */
  26.605 -    (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
  26.606 -
  26.607 -    /*
  26.608 -     * The launcher's exit code (in the absence of calls to
  26.609 -     * System.exit) will be non-zero if main threw an exception.
  26.610 -     */
  26.611 -    ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
  26.612 -
  26.613 -    /*
  26.614 -     * Detach the main thread so that it appears to have ended when
  26.615 -     * the application's main method exits.  This will invoke the
  26.616 -     * uncaught exception handler machinery if main threw an
  26.617 -     * exception.  An uncaught exception handler cannot change the
  26.618 -     * launcher's return code except by calling System.exit.
  26.619 -     */
  26.620 -    if ((*vm)->DetachCurrentThread(vm) != 0) {
  26.621 -        message = "Could not detach main thread.";
  26.622 -        messageDest = JNI_TRUE;
  26.623 -        ret = 1;
  26.624 -        goto leave;
  26.625 -    }
  26.626 -
  26.627 -    message = NULL;
  26.628 -
  26.629 - leave:
  26.630 -    /*
  26.631 -     * Wait for all non-daemon threads to end, then destroy the VM.
  26.632 -     * This will actually create a trivial new Java waiter thread
  26.633 -     * named "DestroyJavaVM", but this will be seen as a different
  26.634 -     * thread from the one that executed main, even though they are
  26.635 -     * the same C thread.  This allows mainThread.join() and
  26.636 -     * mainThread.isAlive() to work as expected.
  26.637 -     */
  26.638 -    (*vm)->DestroyJavaVM(vm);
  26.639 -
  26.640 -    if(message != NULL && !noExitErrorMessage)
  26.641 -      ReportErrorMessage(message, messageDest);
  26.642 -    return ret;
  26.643 -}
  26.644 -
  26.645 -#ifndef GAMMA
  26.646 -/*
  26.647 - * Checks the command line options to find which JVM type was
  26.648 - * specified.  If no command line option was given for the JVM type,
  26.649 - * the default type is used.  The environment variable
  26.650 - * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
  26.651 - * checked as ways of specifying which JVM type to invoke.
  26.652 - */
  26.653 -char *
  26.654 -CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
  26.655 -    int i, argi;
  26.656 -    int argc;
  26.657 -    char **newArgv;
  26.658 -    int newArgvIdx = 0;
  26.659 -    int isVMType;
  26.660 -    int jvmidx = -1;
  26.661 -    char *jvmtype = getenv("JDK_ALTERNATE_VM");
  26.662 -
  26.663 -    argc = *pargc;
  26.664 -
  26.665 -    /* To make things simpler we always copy the argv array */
  26.666 -    newArgv = JLI_MemAlloc((argc + 1) * sizeof(char *));
  26.667 -
  26.668 -    /* The program name is always present */
  26.669 -    newArgv[newArgvIdx++] = (*argv)[0];
  26.670 -
  26.671 -    for (argi = 1; argi < argc; argi++) {
  26.672 -        char *arg = (*argv)[argi];
  26.673 -        isVMType = 0;
  26.674 -
  26.675 -#ifdef JAVA_ARGS
  26.676 -        if (arg[0] != '-') {
  26.677 -            newArgv[newArgvIdx++] = arg;
  26.678 -            continue;
  26.679 -        }
  26.680 -#else
  26.681 -        if (strcmp(arg, "-classpath") == 0 ||
  26.682 -            strcmp(arg, "-cp") == 0) {
  26.683 -            newArgv[newArgvIdx++] = arg;
  26.684 -            argi++;
  26.685 -            if (argi < argc) {
  26.686 -                newArgv[newArgvIdx++] = (*argv)[argi];
  26.687 -            }
  26.688 -            continue;
  26.689 -        }
  26.690 -        if (arg[0] != '-') break;
  26.691 -#endif
  26.692 -
  26.693 -        /* Did the user pass an explicit VM type? */
  26.694 -        i = KnownVMIndex(arg);
  26.695 -        if (i >= 0) {
  26.696 -            jvmtype = knownVMs[jvmidx = i].name + 1; /* skip the - */
  26.697 -            isVMType = 1;
  26.698 -            *pargc = *pargc - 1;
  26.699 -        }
  26.700 -
  26.701 -        /* Did the user specify an "alternate" VM? */
  26.702 -        else if (strncmp(arg, "-XXaltjvm=", 10) == 0 || strncmp(arg, "-J-XXaltjvm=", 12) == 0) {
  26.703 -            isVMType = 1;
  26.704 -            jvmtype = arg+((arg[1]=='X')? 10 : 12);
  26.705 -            jvmidx = -1;
  26.706 -        }
  26.707 -
  26.708 -        if (!isVMType) {
  26.709 -            newArgv[newArgvIdx++] = arg;
  26.710 -        }
  26.711 -    }
  26.712 -
  26.713 -    /*
  26.714 -     * Finish copying the arguments if we aborted the above loop.
  26.715 -     * NOTE that if we aborted via "break" then we did NOT copy the
  26.716 -     * last argument above, and in addition argi will be less than
  26.717 -     * argc.
  26.718 -     */
  26.719 -    while (argi < argc) {
  26.720 -        newArgv[newArgvIdx++] = (*argv)[argi];
  26.721 -        argi++;
  26.722 -    }
  26.723 -
  26.724 -    /* argv is null-terminated */
  26.725 -    newArgv[newArgvIdx] = 0;
  26.726 -
  26.727 -    /* Copy back argv */
  26.728 -    *argv = newArgv;
  26.729 -    *pargc = newArgvIdx;
  26.730 -
  26.731 -    /* use the default VM type if not specified (no alias processing) */
  26.732 -    if (jvmtype == NULL) {
  26.733 -      char* result = knownVMs[0].name+1;
  26.734 -      /* Use a different VM type if we are on a server class machine? */
  26.735 -      if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) &&
  26.736 -          (ServerClassMachine() == JNI_TRUE)) {
  26.737 -        result = knownVMs[0].server_class+1;
  26.738 -      }
  26.739 -      if (_launcher_debug) {
  26.740 -        printf("Default VM: %s\n", result);
  26.741 -      }
  26.742 -      return result;
  26.743 -    }
  26.744 -
  26.745 -    /* if using an alternate VM, no alias processing */
  26.746 -    if (jvmidx < 0)
  26.747 -      return jvmtype;
  26.748 -
  26.749 -    /* Resolve aliases first */
  26.750 -    {
  26.751 -      int loopCount = 0;
  26.752 -      while (knownVMs[jvmidx].flag == VM_ALIASED_TO) {
  26.753 -        int nextIdx = KnownVMIndex(knownVMs[jvmidx].alias);
  26.754 -
  26.755 -        if (loopCount > knownVMsCount) {
  26.756 -          if (!speculative) {
  26.757 -            ReportErrorMessage("Error: Corrupt jvm.cfg file; cycle in alias list.",
  26.758 -                               JNI_TRUE);
  26.759 -            exit(1);
  26.760 -          } else {
  26.761 -            return "ERROR";
  26.762 -            /* break; */
  26.763 -          }
  26.764 -        }
  26.765 -
  26.766 -        if (nextIdx < 0) {
  26.767 -          if (!speculative) {
  26.768 -            ReportErrorMessage2("Error: Unable to resolve VM alias %s",
  26.769 -                                knownVMs[jvmidx].alias, JNI_TRUE);
  26.770 -            exit(1);
  26.771 -          } else {
  26.772 -            return "ERROR";
  26.773 -          }
  26.774 -        }
  26.775 -        jvmidx = nextIdx;
  26.776 -        jvmtype = knownVMs[jvmidx].name+1;
  26.777 -        loopCount++;
  26.778 -      }
  26.779 -    }
  26.780 -
  26.781 -    switch (knownVMs[jvmidx].flag) {
  26.782 -    case VM_WARN:
  26.783 -        if (!speculative) {
  26.784 -            fprintf(stderr, "Warning: %s VM not supported; %s VM will be used\n",
  26.785 -                    jvmtype, knownVMs[0].name + 1);
  26.786 -        }
  26.787 -        /* fall through */
  26.788 -    case VM_IGNORE:
  26.789 -        jvmtype = knownVMs[jvmidx=0].name + 1;
  26.790 -        /* fall through */
  26.791 -    case VM_KNOWN:
  26.792 -        break;
  26.793 -    case VM_ERROR:
  26.794 -        if (!speculative) {
  26.795 -            ReportErrorMessage2("Error: %s VM not supported", jvmtype, JNI_TRUE);
  26.796 -            exit(1);
  26.797 -        } else {
  26.798 -            return "ERROR";
  26.799 -        }
  26.800 -    }
  26.801 -
  26.802 -    return jvmtype;
  26.803 -}
  26.804 -#endif /* ifndef GAMMA */
  26.805 -
  26.806 -# define KB (1024UL)
  26.807 -# define MB (1024UL * KB)
  26.808 -# define GB (1024UL * MB)
  26.809 -
  26.810 -/* copied from HotSpot function "atomll()" */
  26.811 -static int
  26.812 -parse_stack_size(const char *s, jlong *result) {
  26.813 -  jlong n = 0;
  26.814 -  int args_read = sscanf(s, JLONG_FORMAT, &n);
  26.815 -  if (args_read != 1) {
  26.816 -    return 0;
  26.817 -  }
  26.818 -  while (*s != '\0' && *s >= '0' && *s <= '9') {
  26.819 -    s++;
  26.820 -  }
  26.821 -  // 4705540: illegal if more characters are found after the first non-digit
  26.822 -  if (strlen(s) > 1) {
  26.823 -    return 0;
  26.824 -  }
  26.825 -  switch (*s) {
  26.826 -    case 'T': case 't':
  26.827 -      *result = n * GB * KB;
  26.828 -      return 1;
  26.829 -    case 'G': case 'g':
  26.830 -      *result = n * GB;
  26.831 -      return 1;
  26.832 -    case 'M': case 'm':
  26.833 -      *result = n * MB;
  26.834 -      return 1;
  26.835 -    case 'K': case 'k':
  26.836 -      *result = n * KB;
  26.837 -      return 1;
  26.838 -    case '\0':
  26.839 -      *result = n;
  26.840 -      return 1;
  26.841 -    default:
  26.842 -      /* Create JVM with default stack and let VM handle malformed -Xss string*/
  26.843 -      return 0;
  26.844 -  }
  26.845 -}
  26.846 -
  26.847 -/*
  26.848 - * Adds a new VM option with the given given name and value.
  26.849 - */
  26.850 -void
  26.851 -AddOption(char *str, void *info)
  26.852 -{
  26.853 -    /*
  26.854 -     * Expand options array if needed to accommodate at least one more
  26.855 -     * VM option.
  26.856 -     */
  26.857 -    if (numOptions >= maxOptions) {
  26.858 -        if (options == 0) {
  26.859 -            maxOptions = 4;
  26.860 -            options = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
  26.861 -        } else {
  26.862 -            JavaVMOption *tmp;
  26.863 -            maxOptions *= 2;
  26.864 -            tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
  26.865 -            memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
  26.866 -            JLI_MemFree(options);
  26.867 -            options = tmp;
  26.868 -        }
  26.869 -    }
  26.870 -    options[numOptions].optionString = str;
  26.871 -    options[numOptions++].extraInfo = info;
  26.872 -
  26.873 -    if (strncmp(str, "-Xss", 4) == 0) {
  26.874 -      jlong tmp;
  26.875 -      if (parse_stack_size(str + 4, &tmp)) {
  26.876 -        threadStackSize = tmp;
  26.877 -      }
  26.878 -    }
  26.879 -}
  26.880 -
  26.881 -static void
  26.882 -SetClassPath(const char *s)
  26.883 -{
  26.884 -    char *def;
  26.885 -    s = JLI_WildcardExpandClasspath(s);
  26.886 -    def = JLI_MemAlloc(strlen(s) + 40);
  26.887 -    sprintf(def, "-Djava.class.path=%s", s);
  26.888 -    AddOption(def, NULL);
  26.889 -}
  26.890 -
  26.891 -#ifndef GAMMA
  26.892 -/*
  26.893 - * The SelectVersion() routine ensures that an appropriate version of
  26.894 - * the JRE is running.  The specification for the appropriate version
  26.895 - * is obtained from either the manifest of a jar file (preferred) or
  26.896 - * from command line options.
  26.897 - * The routine also parses splash screen command line options and
  26.898 - * passes on their values in private environment variables.
  26.899 - */
  26.900 -static void
  26.901 -SelectVersion(int argc, char **argv, char **main_class)
  26.902 -{
  26.903 -    char    *arg;
  26.904 -    char    **new_argv;
  26.905 -    char    **new_argp;
  26.906 -    char    *operand;
  26.907 -    char    *version = NULL;
  26.908 -    char    *jre = NULL;
  26.909 -    int     jarflag = 0;
  26.910 -    int     headlessflag = 0;
  26.911 -    int     restrict_search = -1;               /* -1 implies not known */
  26.912 -    manifest_info info;
  26.913 -    char    env_entry[MAXNAMELEN + 24] = ENV_ENTRY "=";
  26.914 -    char    *splash_file_name = NULL;
  26.915 -    char    *splash_jar_name = NULL;
  26.916 -    char    *env_in;
  26.917 -    int     res;
  26.918 -
  26.919 -    /*
  26.920 -     * If the version has already been selected, set *main_class
  26.921 -     * with the value passed through the environment (if any) and
  26.922 -     * simply return.
  26.923 -     */
  26.924 -    if ((env_in = getenv(ENV_ENTRY)) != NULL) {
  26.925 -        if (*env_in != '\0')
  26.926 -            *main_class = JLI_StringDup(env_in);
  26.927 -        return;
  26.928 -    }
  26.929 -
  26.930 -    /*
  26.931 -     * Scan through the arguments for options relevant to multiple JRE
  26.932 -     * support.  For reference, the command line syntax is defined as:
  26.933 -     *
  26.934 -     * SYNOPSIS
  26.935 -     *      java [options] class [argument...]
  26.936 -     *
  26.937 -     *      java [options] -jar file.jar [argument...]
  26.938 -     *
  26.939 -     * As the scan is performed, make a copy of the argument list with
  26.940 -     * the version specification options (new to 1.5) removed, so that
  26.941 -     * a version less than 1.5 can be exec'd.
  26.942 -     *
  26.943 -     * Note that due to the syntax of the native Windows interface
  26.944 -     * CreateProcess(), processing similar to the following exists in
  26.945 -     * the Windows platform specific routine ExecJRE (in java_md.c).
  26.946 -     * Changes here should be reproduced there.
  26.947 -     */
  26.948 -    new_argv = JLI_MemAlloc((argc + 1) * sizeof(char*));
  26.949 -    new_argv[0] = argv[0];
  26.950 -    new_argp = &new_argv[1];
  26.951 -    argc--;
  26.952 -    argv++;
  26.953 -    while ((arg = *argv) != 0 && *arg == '-') {
  26.954 -        if (strncmp(arg, "-version:", 9) == 0) {
  26.955 -            version = arg + 9;
  26.956 -        } else if (strcmp(arg, "-jre-restrict-search") == 0) {
  26.957 -            restrict_search = 1;
  26.958 -        } else if (strcmp(arg, "-no-jre-restrict-search") == 0) {
  26.959 -            restrict_search = 0;
  26.960 -        } else {
  26.961 -            if (strcmp(arg, "-jar") == 0)
  26.962 -                jarflag = 1;
  26.963 -            /* deal with "unfortunate" classpath syntax */
  26.964 -            if ((strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) &&
  26.965 -              (argc >= 2)) {
  26.966 -                *new_argp++ = arg;
  26.967 -                argc--;
  26.968 -                argv++;
  26.969 -                arg = *argv;
  26.970 -            }
  26.971 -
  26.972 -            /*
  26.973 -             * Checking for headless toolkit option in the some way as AWT does:
  26.974 -             * "true" means true and any other value means false
  26.975 -             */
  26.976 -            if (strcmp(arg, "-Djava.awt.headless=true") == 0) {
  26.977 -                headlessflag = 1;
  26.978 -            } else if (strncmp(arg, "-Djava.awt.headless=", 20) == 0) {
  26.979 -                headlessflag = 0;
  26.980 -            } else if (strncmp(arg, "-splash:", 8) == 0) {
  26.981 -                splash_file_name = arg+8;
  26.982 -            }
  26.983 -            *new_argp++ = arg;
  26.984 -        }
  26.985 -        argc--;
  26.986 -        argv++;
  26.987 -    }
  26.988 -    if (argc <= 0) {    /* No operand? Possibly legit with -[full]version */
  26.989 -        operand = NULL;
  26.990 -    } else {
  26.991 -        argc--;
  26.992 -        *new_argp++ = operand = *argv++;
  26.993 -    }
  26.994 -    while (argc-- > 0)  /* Copy over [argument...] */
  26.995 -        *new_argp++ = *argv++;
  26.996 -    *new_argp = NULL;
  26.997 -
  26.998 -    /*
  26.999 -     * If there is a jar file, read the manifest. If the jarfile can't be
 26.1000 -     * read, the manifest can't be read from the jar file, or the manifest
 26.1001 -     * is corrupt, issue the appropriate error messages and exit.
 26.1002 -     *
 26.1003 -     * Even if there isn't a jar file, construct a manifest_info structure
 26.1004 -     * containing the command line information.  It's a convenient way to carry
 26.1005 -     * this data around.
 26.1006 -     */
 26.1007 -    if (jarflag && operand) {
 26.1008 -        if ((res = JLI_ParseManifest(operand, &info)) != 0) {
 26.1009 -            if (res == -1)
 26.1010 -                ReportErrorMessage2("Unable to access jarfile %s",
 26.1011 -                  operand, JNI_TRUE);
 26.1012 -            else
 26.1013 -                ReportErrorMessage2("Invalid or corrupt jarfile %s",
 26.1014 -                  operand, JNI_TRUE);
 26.1015 -            exit(1);
 26.1016 -        }
 26.1017 -
 26.1018 -        /*
 26.1019 -         * Command line splash screen option should have precedence
 26.1020 -         * over the manifest, so the manifest data is used only if
 26.1021 -         * splash_file_name has not been initialized above during command
 26.1022 -         * line parsing
 26.1023 -         */
 26.1024 -        if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) {
 26.1025 -            splash_file_name = info.splashscreen_image_file_name;
 26.1026 -            splash_jar_name = operand;
 26.1027 -        }
 26.1028 -    } else {
 26.1029 -        info.manifest_version = NULL;
 26.1030 -        info.main_class = NULL;
 26.1031 -        info.jre_version = NULL;
 26.1032 -        info.jre_restrict_search = 0;
 26.1033 -    }
 26.1034 -
 26.1035 -    /*
 26.1036 -     * Passing on splash screen info in environment variables
 26.1037 -     */
 26.1038 -    if (splash_file_name && !headlessflag) {
 26.1039 -        char* splash_file_entry = JLI_MemAlloc(strlen(SPLASH_FILE_ENV_ENTRY "=")+strlen(splash_file_name)+1);
 26.1040 -        strcpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "=");
 26.1041 -        strcat(splash_file_entry, splash_file_name);
 26.1042 -        putenv(splash_file_entry);
 26.1043 -    }
 26.1044 -    if (splash_jar_name && !headlessflag) {
 26.1045 -        char* splash_jar_entry = JLI_MemAlloc(strlen(SPLASH_JAR_ENV_ENTRY "=")+strlen(splash_jar_name)+1);
 26.1046 -        strcpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "=");
 26.1047 -        strcat(splash_jar_entry, splash_jar_name);
 26.1048 -        putenv(splash_jar_entry);
 26.1049 -    }
 26.1050 -
 26.1051 -    /*
 26.1052 -     * The JRE-Version and JRE-Restrict-Search values (if any) from the
 26.1053 -     * manifest are overwritten by any specified on the command line.
 26.1054 -     */
 26.1055 -    if (version != NULL)
 26.1056 -        info.jre_version = version;
 26.1057 -    if (restrict_search != -1)
 26.1058 -        info.jre_restrict_search = restrict_search;
 26.1059 -
 26.1060 -    /*
 26.1061 -     * "Valid" returns (other than unrecoverable errors) follow.  Set
 26.1062 -     * main_class as a side-effect of this routine.
 26.1063 -     */
 26.1064 -    if (info.main_class != NULL)
 26.1065 -        *main_class = JLI_StringDup(info.main_class);
 26.1066 -
 26.1067 -    /*
 26.1068 -     * If no version selection information is found either on the command
 26.1069 -     * line or in the manifest, simply return.
 26.1070 -     */
 26.1071 -    if (info.jre_version == NULL) {
 26.1072 -        JLI_FreeManifest();
 26.1073 -        JLI_MemFree(new_argv);
 26.1074 -        return;
 26.1075 -    }
 26.1076 -
 26.1077 -    /*
 26.1078 -     * Check for correct syntax of the version specification (JSR 56).
 26.1079 -     */
 26.1080 -    if (!JLI_ValidVersionString(info.jre_version)) {
 26.1081 -        ReportErrorMessage2("Syntax error in version specification \"%s\"",
 26.1082 -          info.jre_version, JNI_TRUE);
 26.1083 -        exit(1);
 26.1084 -    }
 26.1085 -
 26.1086 -    /*
 26.1087 -     * Find the appropriate JVM on the system. Just to be as forgiving as
 26.1088 -     * possible, if the standard algorithms don't locate an appropriate
 26.1089 -     * jre, check to see if the one running will satisfy the requirements.
 26.1090 -     * This can happen on systems which haven't been set-up for multiple
 26.1091 -     * JRE support.
 26.1092 -     */
 26.1093 -    jre = LocateJRE(&info);
 26.1094 -    if (_launcher_debug)
 26.1095 -        printf("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n",
 26.1096 -          (info.jre_version?info.jre_version:"null"),
 26.1097 -          (info.jre_restrict_search?"true":"false"), (jre?jre:"null"));
 26.1098 -    if (jre == NULL) {
 26.1099 -        if (JLI_AcceptableRelease(FULL_VERSION, info.jre_version)) {
 26.1100 -            JLI_FreeManifest();
 26.1101 -            JLI_MemFree(new_argv);
 26.1102 -            return;
 26.1103 -        } else {
 26.1104 -            ReportErrorMessage2(
 26.1105 -              "Unable to locate JRE meeting specification \"%s\"",
 26.1106 -              info.jre_version, JNI_TRUE);
 26.1107 -            exit(1);
 26.1108 -        }
 26.1109 -    }
 26.1110 -
 26.1111 -    /*
 26.1112 -     * If I'm not the chosen one, exec the chosen one.  Returning from
 26.1113 -     * ExecJRE indicates that I am indeed the chosen one.
 26.1114 -     *
 26.1115 -     * The private environment variable _JAVA_VERSION_SET is used to
 26.1116 -     * prevent the chosen one from re-reading the manifest file and
 26.1117 -     * using the values found within to override the (potential) command
 26.1118 -     * line flags stripped from argv (because the target may not
 26.1119 -     * understand them).  Passing the MainClass value is an optimization
 26.1120 -     * to avoid locating, expanding and parsing the manifest extra
 26.1121 -     * times.
 26.1122 -     */
 26.1123 -    if (info.main_class != NULL) {
 26.1124 -        if (strlen(info.main_class) <= MAXNAMELEN) {
 26.1125 -            (void)strcat(env_entry, info.main_class);
 26.1126 -        } else {
 26.1127 -            ReportErrorMessage("Error: main-class: attribute exceeds system limits\n", JNI_TRUE);
 26.1128 -            exit(1);
 26.1129 -        }
 26.1130 -    }
 26.1131 -    (void)putenv(env_entry);
 26.1132 -    ExecJRE(jre, new_argv);
 26.1133 -    JLI_FreeManifest();
 26.1134 -    JLI_MemFree(new_argv);
 26.1135 -    return;
 26.1136 -}
 26.1137 -#endif /* ifndef GAMMA */
 26.1138 -
 26.1139 -/*
 26.1140 - * Parses command line arguments.  Returns JNI_FALSE if launcher
 26.1141 - * should exit without starting vm (e.g. certain version and usage
 26.1142 - * options); returns JNI_TRUE if vm needs to be started to process
 26.1143 - * given options.  *pret (the launcher process return value) is set to
 26.1144 - * 0 for a normal exit.
 26.1145 - */
 26.1146 -static jboolean
 26.1147 -ParseArguments(int *pargc, char ***pargv, char **pjarfile,
 26.1148 -                       char **pclassname, int *pret, const char *jvmpath)
 26.1149 -{
 26.1150 -    int argc = *pargc;
 26.1151 -    char **argv = *pargv;
 26.1152 -    jboolean jarflag = JNI_FALSE;
 26.1153 -    char *arg;
 26.1154 -
 26.1155 -    *pret = 1;
 26.1156 -    while ((arg = *argv) != 0 && *arg == '-') {
 26.1157 -        argv++; --argc;
 26.1158 -        if (strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) {
 26.1159 -            if (argc < 1) {
 26.1160 -                ReportErrorMessage2("%s requires class path specification",
 26.1161 -                                    arg, JNI_TRUE);
 26.1162 -                PrintUsage();
 26.1163 -                return JNI_FALSE;
 26.1164 -            }
 26.1165 -            SetClassPath(*argv);
 26.1166 -            argv++; --argc;
 26.1167 -        } else if (strcmp(arg, "-jar") == 0) {
 26.1168 -            jarflag = JNI_TRUE;
 26.1169 -        } else if (strcmp(arg, "-help") == 0 ||
 26.1170 -                   strcmp(arg, "-h") == 0 ||
 26.1171 -                   strcmp(arg, "-?") == 0) {
 26.1172 -            PrintUsage();
 26.1173 -            *pret = 0;
 26.1174 -            return JNI_FALSE;
 26.1175 -        } else if (strcmp(arg, "-version") == 0) {
 26.1176 -            printVersion = JNI_TRUE;
 26.1177 -            return JNI_TRUE;
 26.1178 -        } else if (strcmp(arg, "-showversion") == 0) {
 26.1179 -            showVersion = JNI_TRUE;
 26.1180 -        } else if (strcmp(arg, "-X") == 0) {
 26.1181 -            *pret = PrintXUsage(jvmpath);
 26.1182 -            return JNI_FALSE;
 26.1183 -/*
 26.1184 - * The following case provide backward compatibility with old-style
 26.1185 - * command line options.
 26.1186 - */
 26.1187 -        } else if (strcmp(arg, "-fullversion") == 0) {
 26.1188 -            fprintf(stderr, "%s full version \"%s\"\n", progname,
 26.1189 -                    FULL_VERSION);
 26.1190 -            *pret = 0;
 26.1191 -            return JNI_FALSE;
 26.1192 -        } else if (strcmp(arg, "-verbosegc") == 0) {
 26.1193 -            AddOption("-verbose:gc", NULL);
 26.1194 -        } else if (strcmp(arg, "-t") == 0) {
 26.1195 -            AddOption("-Xt", NULL);
 26.1196 -        } else if (strcmp(arg, "-tm") == 0) {
 26.1197 -            AddOption("-Xtm", NULL);
 26.1198 -        } else if (strcmp(arg, "-debug") == 0) {
 26.1199 -            AddOption("-Xdebug", NULL);
 26.1200 -        } else if (strcmp(arg, "-noclassgc") == 0) {
 26.1201 -            AddOption("-Xnoclassgc", NULL);
 26.1202 -        } else if (strcmp(arg, "-Xfuture") == 0) {
 26.1203 -            AddOption("-Xverify:all", NULL);
 26.1204 -        } else if (strcmp(arg, "-verify") == 0) {
 26.1205 -            AddOption("-Xverify:all", NULL);
 26.1206 -        } else if (strcmp(arg, "-verifyremote") == 0) {
 26.1207 -            AddOption("-Xverify:remote", NULL);
 26.1208 -        } else if (strcmp(arg, "-noverify") == 0) {
 26.1209 -            AddOption("-Xverify:none", NULL);
 26.1210 -        } else if (strcmp(arg, "-XXsuppressExitMessage") == 0) {
 26.1211 -            noExitErrorMessage = 1;
 26.1212 -        } else if (strncmp(arg, "-prof", 5) == 0) {
 26.1213 -            char *p = arg + 5;
 26.1214 -            char *tmp = JLI_MemAlloc(strlen(arg) + 50);
 26.1215 -            if (*p) {
 26.1216 -                sprintf(tmp, "-Xrunhprof:cpu=old,file=%s", p + 1);
 26.1217 -            } else {
 26.1218 -                sprintf(tmp, "-Xrunhprof:cpu=old,file=java.prof");
 26.1219 -            }
 26.1220 -            AddOption(tmp, NULL);
 26.1221 -        } else if (strncmp(arg, "-ss", 3) == 0 ||
 26.1222 -                   strncmp(arg, "-oss", 4) == 0 ||
 26.1223 -                   strncmp(arg, "-ms", 3) == 0 ||
 26.1224 -                   strncmp(arg, "-mx", 3) == 0) {
 26.1225 -            char *tmp = JLI_MemAlloc(strlen(arg) + 6);
 26.1226 -            sprintf(tmp, "-X%s", arg + 1); /* skip '-' */
 26.1227 -            AddOption(tmp, NULL);
 26.1228 -        } else if (strcmp(arg, "-checksource") == 0 ||
 26.1229 -                   strcmp(arg, "-cs") == 0 ||
 26.1230 -                   strcmp(arg, "-noasyncgc") == 0) {
 26.1231 -            /* No longer supported */
 26.1232 -            fprintf(stderr,
 26.1233 -                    "Warning: %s option is no longer supported.\n",
 26.1234 -                    arg);
 26.1235 -        } else if (strncmp(arg, "-version:", 9) == 0 ||
 26.1236 -                   strcmp(arg, "-no-jre-restrict-search") == 0 ||
 26.1237 -                   strcmp(arg, "-jre-restrict-search") == 0 ||
 26.1238 -                   strncmp(arg, "-splash:", 8) == 0) {
 26.1239 -            ; /* Ignore machine independent options already handled */
 26.1240 -        } else if (RemovableMachineDependentOption(arg) ) {
 26.1241 -            ; /* Do not pass option to vm. */
 26.1242 -        }
 26.1243 -        else {
 26.1244 -            AddOption(arg, NULL);
 26.1245 -        }
 26.1246 -    }
 26.1247 -
 26.1248 -    if (--argc >= 0) {
 26.1249 -        if (jarflag) {
 26.1250 -            *pjarfile = *argv++;
 26.1251 -            *pclassname = 0;
 26.1252 -        } else {
 26.1253 -            *pjarfile = 0;
 26.1254 -            *pclassname = *argv++;
 26.1255 -        }
 26.1256 -        *pargc = argc;
 26.1257 -        *pargv = argv;
 26.1258 -    }
 26.1259 -
 26.1260 -    return JNI_TRUE;
 26.1261 -}
 26.1262 -
 26.1263 -/*
 26.1264 - * Initializes the Java Virtual Machine. Also frees options array when
 26.1265 - * finished.
 26.1266 - */
 26.1267 -static jboolean
 26.1268 -InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
 26.1269 -{
 26.1270 -    JavaVMInitArgs args;
 26.1271 -    jint r;
 26.1272 -
 26.1273 -    memset(&args, 0, sizeof(args));
 26.1274 -    args.version  = JNI_VERSION_1_2;
 26.1275 -    args.nOptions = numOptions;
 26.1276 -    args.options  = options;
 26.1277 -    args.ignoreUnrecognized = JNI_FALSE;
 26.1278 -
 26.1279 -    if (_launcher_debug) {
 26.1280 -        int i = 0;
 26.1281 -        printf("JavaVM args:\n    ");
 26.1282 -        printf("version 0x%08lx, ", (long)args.version);
 26.1283 -        printf("ignoreUnrecognized is %s, ",
 26.1284 -               args.ignoreUnrecognized ? "JNI_TRUE" : "JNI_FALSE");
 26.1285 -        printf("nOptions is %ld\n", (long)args.nOptions);
 26.1286 -        for (i = 0; i < numOptions; i++)
 26.1287 -            printf("    option[%2d] = '%s'\n",
 26.1288 -                   i, args.options[i].optionString);
 26.1289 -    }
 26.1290 -
 26.1291 -    r = ifn->CreateJavaVM(pvm, (void **)penv, &args);
 26.1292 -    JLI_MemFree(options);
 26.1293 -    return r == JNI_OK;
 26.1294 -}
 26.1295 -
 26.1296 -
 26.1297 -#define NULL_CHECK0(e) if ((e) == 0) return 0
 26.1298 -#define NULL_CHECK(e) if ((e) == 0) return
 26.1299 -
 26.1300 -static jstring platformEncoding = NULL;
 26.1301 -static jstring getPlatformEncoding(JNIEnv *env) {
 26.1302 -    if (platformEncoding == NULL) {
 26.1303 -        jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding");
 26.1304 -        if (propname) {
 26.1305 -            jclass cls;
 26.1306 -            jmethodID mid;
 26.1307 -            NULL_CHECK0 (cls = (*env)->FindClass(env, "java/lang/System"));
 26.1308 -            NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
 26.1309 -                                   env, cls,
 26.1310 -                                   "getProperty",
 26.1311 -                                   "(Ljava/lang/String;)Ljava/lang/String;"));
 26.1312 -            platformEncoding = (*env)->CallStaticObjectMethod (
 26.1313 -                                    env, cls, mid, propname);
 26.1314 -        }
 26.1315 -    }
 26.1316 -    return platformEncoding;
 26.1317 -}
 26.1318 -
 26.1319 -static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
 26.1320 -    jclass cls;
 26.1321 -    jmethodID mid;
 26.1322 -    NULL_CHECK0 (cls = (*env)->FindClass(env, "java/nio/charset/Charset"));
 26.1323 -    NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
 26.1324 -                           env, cls,
 26.1325 -                           "isSupported",
 26.1326 -                           "(Ljava/lang/String;)Z"));
 26.1327 -    return (*env)->CallStaticBooleanMethod(env, cls, mid, enc);
 26.1328 -}
 26.1329 -
 26.1330 -/*
 26.1331 - * Returns a new Java string object for the specified platform string.
 26.1332 - */
 26.1333 -static jstring
 26.1334 -NewPlatformString(JNIEnv *env, char *s)
 26.1335 -{
 26.1336 -    int len = (int)strlen(s);
 26.1337 -    jclass cls;
 26.1338 -    jmethodID mid;
 26.1339 -    jbyteArray ary;
 26.1340 -    jstring enc;
 26.1341 -
 26.1342 -    if (s == NULL)
 26.1343 -        return 0;
 26.1344 -    enc = getPlatformEncoding(env);
 26.1345 -
 26.1346 -    ary = (*env)->NewByteArray(env, len);
 26.1347 -    if (ary != 0) {
 26.1348 -        jstring str = 0;
 26.1349 -        (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
 26.1350 -        if (!(*env)->ExceptionOccurred(env)) {
 26.1351 -            if (isEncodingSupported(env, enc) == JNI_TRUE) {
 26.1352 -                NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
 26.1353 -                NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
 26.1354 -                                          "([BLjava/lang/String;)V"));
 26.1355 -                str = (*env)->NewObject(env, cls, mid, ary, enc);
 26.1356 -            } else {
 26.1357 -                /*If the encoding specified in sun.jnu.encoding is not
 26.1358 -                  endorsed by "Charset.isSupported" we have to fall back
 26.1359 -                  to use String(byte[]) explicitly here without specifying
 26.1360 -                  the encoding name, in which the StringCoding class will
 26.1361 -                  pickup the iso-8859-1 as the fallback converter for us.
 26.1362 -                */
 26.1363 -                NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
 26.1364 -                NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
 26.1365 -                                          "([B)V"));
 26.1366 -                str = (*env)->NewObject(env, cls, mid, ary);
 26.1367 -            }
 26.1368 -            (*env)->DeleteLocalRef(env, ary);
 26.1369 -            return str;
 26.1370 -        }
 26.1371 -    }
 26.1372 -    return 0;
 26.1373 -}
 26.1374 -
 26.1375 -/*
 26.1376 - * Returns a new array of Java string objects for the specified
 26.1377 - * array of platform strings.
 26.1378 - */
 26.1379 -static jobjectArray
 26.1380 -NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
 26.1381 -{
 26.1382 -    jarray cls;
 26.1383 -    jarray ary;
 26.1384 -    int i;
 26.1385 -
 26.1386 -    NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
 26.1387 -    NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));
 26.1388 -    for (i = 0; i < strc; i++) {
 26.1389 -        jstring str = NewPlatformString(env, *strv++);
 26.1390 -        NULL_CHECK0(str);
 26.1391 -        (*env)->SetObjectArrayElement(env, ary, i, str);
 26.1392 -        (*env)->DeleteLocalRef(env, str);
 26.1393 -    }
 26.1394 -    return ary;
 26.1395 -}
 26.1396 -
 26.1397 -/*
 26.1398 - * Loads a class, convert the '.' to '/'.
 26.1399 - */
 26.1400 -static jclass
 26.1401 -LoadClass(JNIEnv *env, char *name)
 26.1402 -{
 26.1403 -    char *buf = JLI_MemAlloc(strlen(name) + 1);
 26.1404 -    char *s = buf, *t = name, c;
 26.1405 -    jclass cls;
 26.1406 -    jlong start, end;
 26.1407 -
 26.1408 -    if (_launcher_debug)
 26.1409 -        start = CounterGet();
 26.1410 -
 26.1411 -    do {
 26.1412 -        c = *t++;
 26.1413 -        *s++ = (c == '.') ? '/' : c;
 26.1414 -    } while (c != '\0');
 26.1415 -    cls = (*env)->FindClass(env, buf);
 26.1416 -    JLI_MemFree(buf);
 26.1417 -
 26.1418 -    if (_launcher_debug) {
 26.1419 -        end   = CounterGet();
 26.1420 -        printf("%ld micro seconds to load main class\n",
 26.1421 -               (long)(jint)Counter2Micros(end-start));
 26.1422 -        printf("----_JAVA_LAUNCHER_DEBUG----\n");
 26.1423 -    }
 26.1424 -
 26.1425 -    return cls;
 26.1426 -}
 26.1427 -
 26.1428 -
 26.1429 -/*
 26.1430 - * Returns the main class name for the specified jar file.
 26.1431 - */
 26.1432 -static jstring
 26.1433 -GetMainClassName(JNIEnv *env, char *jarname)
 26.1434 -{
 26.1435 -#define MAIN_CLASS "Main-Class"
 26.1436 -    jclass cls;
 26.1437 -    jmethodID mid;
 26.1438 -    jobject jar, man, attr;
 26.1439 -    jstring str, result = 0;
 26.1440 -
 26.1441 -    NULL_CHECK0(cls = (*env)->FindClass(env, "java/util/jar/JarFile"));
 26.1442 -    NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
 26.1443 -                                          "(Ljava/lang/String;)V"));
 26.1444 -    NULL_CHECK0(str = NewPlatformString(env, jarname));
 26.1445 -    NULL_CHECK0(jar = (*env)->NewObject(env, cls, mid, str));
 26.1446 -    NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "getManifest",
 26.1447 -                                          "()Ljava/util/jar/Manifest;"));
 26.1448 -    man = (*env)->CallObjectMethod(env, jar, mid);
 26.1449 -    if (man != 0) {
 26.1450 -        NULL_CHECK0(mid = (*env)->GetMethodID(env,
 26.1451 -                                    (*env)->GetObjectClass(env, man),
 26.1452 -                                    "getMainAttributes",
 26.1453 -                                    "()Ljava/util/jar/Attributes;"));
 26.1454 -        attr = (*env)->CallObjectMethod(env, man, mid);
 26.1455 -        if (attr != 0) {
 26.1456 -            NULL_CHECK0(mid = (*env)->GetMethodID(env,
 26.1457 -                                    (*env)->GetObjectClass(env, attr),
 26.1458 -                                    "getValue",
 26.1459 -                                    "(Ljava/lang/String;)Ljava/lang/String;"));
 26.1460 -            NULL_CHECK0(str = NewPlatformString(env, MAIN_CLASS));
 26.1461 -            result = (*env)->CallObjectMethod(env, attr, mid, str);
 26.1462 -        }
 26.1463 -    }
 26.1464 -    return result;
 26.1465 -}
 26.1466 -
 26.1467 -#ifdef JAVA_ARGS
 26.1468 -static char *java_args[] = JAVA_ARGS;
 26.1469 -static char *app_classpath[] = APP_CLASSPATH;
 26.1470 -
 26.1471 -/*
 26.1472 - * For tools, convert command line args thus:
 26.1473 - *   javac -cp foo:foo/"*" -J-ms32m ...
 26.1474 - *   java -ms32m -cp JLI_WildcardExpandClasspath(foo:foo/"*") ...
 26.1475 - */
 26.1476 -static void
 26.1477 -TranslateApplicationArgs(int *pargc, char ***pargv)
 26.1478 -{
 26.1479 -    const int NUM_ARGS = (sizeof(java_args) / sizeof(char *));
 26.1480 -    int argc = *pargc;
 26.1481 -    char **argv = *pargv;
 26.1482 -    int nargc = argc + NUM_ARGS;
 26.1483 -    char **nargv = JLI_MemAlloc((nargc + 1) * sizeof(char *));
 26.1484 -    int i;
 26.1485 -
 26.1486 -    *pargc = nargc;
 26.1487 -    *pargv = nargv;
 26.1488 -
 26.1489 -    /* Copy the VM arguments (i.e. prefixed with -J) */
 26.1490 -    for (i = 0; i < NUM_ARGS; i++) {
 26.1491 -        char *arg = java_args[i];
 26.1492 -        if (arg[0] == '-' && arg[1] == 'J') {
 26.1493 -            *nargv++ = arg + 2;
 26.1494 -        }
 26.1495 -    }
 26.1496 -
 26.1497 -    for (i = 0; i < argc; i++) {
 26.1498 -        char *arg = argv[i];
 26.1499 -        if (arg[0] == '-' && arg[1] == 'J') {
 26.1500 -            if (arg[2] == '\0') {
 26.1501 -                ReportErrorMessage("Error: the -J option should not be "
 26.1502 -                                   "followed by a space.", JNI_TRUE);
 26.1503 -                exit(1);
 26.1504 -            }
 26.1505 -            *nargv++ = arg + 2;
 26.1506 -        }
 26.1507 -    }
 26.1508 -
 26.1509 -    /* Copy the rest of the arguments */
 26.1510 -    for (i = 0; i < NUM_ARGS; i++) {
 26.1511 -        char *arg = java_args[i];
 26.1512 -        if (arg[0] != '-' || arg[1] != 'J') {
 26.1513 -            *nargv++ = arg;
 26.1514 -        }
 26.1515 -    }
 26.1516 -    for (i = 0; i < argc; i++) {
 26.1517 -        char *arg = argv[i];
 26.1518 -        if (arg[0] == '-') {
 26.1519 -            if (arg[1] == 'J')
 26.1520 -                continue;
 26.1521 -#ifdef EXPAND_CLASSPATH_WILDCARDS
 26.1522 -            if (arg[1] == 'c'
 26.1523 -                && (strcmp(arg, "-cp") == 0 ||
 26.1524 -                    strcmp(arg, "-classpath") == 0)
 26.1525 -                && i < argc - 1) {
 26.1526 -                *nargv++ = arg;
 26.1527 -                *nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]);
 26.1528 -                i++;
 26.1529 -                continue;
 26.1530 -            }
 26.1531 -#endif
 26.1532 -        }
 26.1533 -        *nargv++ = arg;
 26.1534 -    }
 26.1535 -    *nargv = 0;
 26.1536 -}
 26.1537 -
 26.1538 -/*
 26.1539 - * For our tools, we try to add 3 VM options:
 26.1540 - *      -Denv.class.path=<envcp>
 26.1541 - *      -Dapplication.home=<apphome>
 26.1542 - *      -Djava.class.path=<appcp>
 26.1543 - * <envcp>   is the user's setting of CLASSPATH -- for instance the user
 26.1544 - *           tells javac where to find binary classes through this environment
 26.1545 - *           variable.  Notice that users will be able to compile against our
 26.1546 - *           tools classes (sun.tools.javac.Main) only if they explicitly add
 26.1547 - *           tools.jar to CLASSPATH.
 26.1548 - * <apphome> is the directory where the application is installed.
 26.1549 - * <appcp>   is the classpath to where our apps' classfiles are.
 26.1550 - */
 26.1551 -static jboolean
 26.1552 -AddApplicationOptions()
 26.1553 -{
 26.1554 -    const int NUM_APP_CLASSPATH = (sizeof(app_classpath) / sizeof(char *));
 26.1555 -    char *envcp, *appcp, *apphome;
 26.1556 -    char home[MAXPATHLEN]; /* application home */
 26.1557 -    char separator[] = { PATH_SEPARATOR, '\0' };
 26.1558 -    int size, i;
 26.1559 -    int strlenHome;
 26.1560 -
 26.1561 -    {
 26.1562 -        const char *s = getenv("CLASSPATH");
 26.1563 -        if (s) {
 26.1564 -            s = (char *) JLI_WildcardExpandClasspath(s);
 26.1565 -            /* 40 for -Denv.class.path= */
 26.1566 -            envcp = (char *)JLI_MemAlloc(strlen(s) + 40);
 26.1567 -            sprintf(envcp, "-Denv.class.path=%s", s);
 26.1568 -            AddOption(envcp, NULL);
 26.1569 -        }
 26.1570 -    }
 26.1571 -
 26.1572 -    if (!GetApplicationHome(home, sizeof(home))) {
 26.1573 -        ReportErrorMessage("Can't determine application home", JNI_TRUE);
 26.1574 -        return JNI_FALSE;
 26.1575 -    }
 26.1576 -
 26.1577 -    /* 40 for '-Dapplication.home=' */
 26.1578 -    apphome = (char *)JLI_MemAlloc(strlen(home) + 40);
 26.1579 -    sprintf(apphome, "-Dapplication.home=%s", home);
 26.1580 -    AddOption(apphome, NULL);
 26.1581 -
 26.1582 -    /* How big is the application's classpath? */
 26.1583 -    size = 40;                                 /* 40: "-Djava.class.path=" */
 26.1584 -    strlenHome = (int)strlen(home);
 26.1585 -    for (i = 0; i < NUM_APP_CLASSPATH; i++) {
 26.1586 -        size += strlenHome + (int)strlen(app_classpath[i]) + 1; /* 1: separator */
 26.1587 -    }
 26.1588 -    appcp = (char *)JLI_MemAlloc(size + 1);
 26.1589 -    strcpy(appcp, "-Djava.class.path=");
 26.1590 -    for (i = 0; i < NUM_APP_CLASSPATH; i++) {
 26.1591 -        strcat(appcp, home);                    /* c:\program files\myapp */
 26.1592 -        strcat(appcp, app_classpath[i]);        /* \lib\myapp.jar         */
 26.1593 -        strcat(appcp, separator);               /* ;                      */
 26.1594 -    }
 26.1595 -    appcp[strlen(appcp)-1] = '\0';  /* remove trailing path separator */
 26.1596 -    AddOption(appcp, NULL);
 26.1597 -    return JNI_TRUE;
 26.1598 -}
 26.1599 -#endif /* JAVA_ARGS */
 26.1600 -
 26.1601 -/*
 26.1602 - * inject the -Dsun.java.command pseudo property into the args structure
 26.1603 - * this pseudo property is used in the HotSpot VM to expose the
 26.1604 - * Java class name and arguments to the main method to the VM. The
 26.1605 - * HotSpot VM uses this pseudo property to store the Java class name
 26.1606 - * (or jar file name) and the arguments to the class's main method
 26.1607 - * to the instrumentation memory region. The sun.java.command pseudo
 26.1608 - * property is not exported by HotSpot to the Java layer.
 26.1609 - */
 26.1610 -void
 26.1611 -SetJavaCommandLineProp(char *classname, char *jarfile,
 26.1612 -                       int argc, char **argv)
 26.1613 -{
 26.1614 -
 26.1615 -    int i = 0;
 26.1616 -    size_t len = 0;
 26.1617 -    char* javaCommand = NULL;
 26.1618 -    char* dashDstr = "-Dsun.java.command=";
 26.1619 -
 26.1620 -    if (classname == NULL && jarfile == NULL) {
 26.1621 -        /* unexpected, one of these should be set. just return without
 26.1622 -         * setting the property
 26.1623 -         */
 26.1624 -        return;
 26.1625 -    }
 26.1626 -
 26.1627 -    /* if the class name is not set, then use the jarfile name */
 26.1628 -    if (classname == NULL) {
 26.1629 -        classname = jarfile;
 26.1630 -    }
 26.1631 -
 26.1632 -    /* determine the amount of memory to allocate assuming
 26.1633 -     * the individual components will be space separated
 26.1634 -     */
 26.1635 -    len = strlen(classname);
 26.1636 -    for (i = 0; i < argc; i++) {
 26.1637 -        len += strlen(argv[i]) + 1;
 26.1638 -    }
 26.1639 -
 26.1640 -    /* allocate the memory */
 26.1641 -    javaCommand = (char*) JLI_MemAlloc(len + strlen(dashDstr) + 1);
 26.1642 -
 26.1643 -    /* build the -D string */
 26.1644 -    *javaCommand = '\0';
 26.1645 -    strcat(javaCommand, dashDstr);
 26.1646 -    strcat(javaCommand, classname);
 26.1647 -
 26.1648 -    for (i = 0; i < argc; i++) {
 26.1649 -        /* the components of the string are space separated. In
 26.1650 -         * the case of embedded white space, the relationship of
 26.1651 -         * the white space separated components to their true
 26.1652 -         * positional arguments will be ambiguous. This issue may
 26.1653 -         * be addressed in a future release.
 26.1654 -         */
 26.1655 -        strcat(javaCommand, " ");
 26.1656 -        strcat(javaCommand, argv[i]);
 26.1657 -    }
 26.1658 -
 26.1659 -    AddOption(javaCommand, NULL);
 26.1660 -}
 26.1661 -
 26.1662 -/*
 26.1663 - * JVM would like to know if it's created by a standard Sun launcher, or by
 26.1664 - * user native application, the following property indicates the former.
 26.1665 - */
 26.1666 -void SetJavaLauncherProp() {
 26.1667 -  AddOption("-Dsun.java.launcher=" LAUNCHER_TYPE, NULL);
 26.1668 -}
 26.1669 -
 26.1670 -/*
 26.1671 - * Prints the version information from the java.version and other properties.
 26.1672 - */
 26.1673 -static void
 26.1674 -PrintJavaVersion(JNIEnv *env)
 26.1675 -{
 26.1676 -    jclass ver;
 26.1677 -    jmethodID print;
 26.1678 -
 26.1679 -    NULL_CHECK(ver = (*env)->FindClass(env, "sun/misc/Version"));
 26.1680 -    NULL_CHECK(print = (*env)->GetStaticMethodID(env, ver, "print", "()V"));
 26.1681 -
 26.1682 -    (*env)->CallStaticVoidMethod(env, ver, print);
 26.1683 -}
 26.1684 -
 26.1685 -/*
 26.1686 - * Prints default usage message.
 26.1687 - */
 26.1688 -static void
 26.1689 -PrintUsage(void)
 26.1690 -{
 26.1691 -#ifndef GAMMA
 26.1692 -    int i;
 26.1693 -#endif
 26.1694 -
 26.1695 -    fprintf(stdout,
 26.1696 -        "Usage: %s [-options] class [args...]\n"
 26.1697 -        "           (to execute a class)\n"
 26.1698 -        "   or  %s [-options] -jar jarfile [args...]\n"
 26.1699 -        "           (to execute a jar file)\n"
 26.1700 -        "\n"
 26.1701 -        "where options include:\n",
 26.1702 -        progname,
 26.1703 -        progname);
 26.1704 -
 26.1705 -#ifndef GAMMA
 26.1706 -    PrintMachineDependentOptions();
 26.1707 -
 26.1708 -    if ((knownVMs[0].flag == VM_KNOWN) ||
 26.1709 -        (knownVMs[0].flag == VM_IF_SERVER_CLASS)) {
 26.1710 -      fprintf(stdout, "    %s\t  to select the \"%s\" VM\n",
 26.1711 -              knownVMs[0].name, knownVMs[0].name+1);
 26.1712 -    }
 26.1713 -    for (i=1; i<knownVMsCount; i++) {
 26.1714 -        if (knownVMs[i].flag == VM_KNOWN)
 26.1715 -            fprintf(stdout, "    %s\t  to select the \"%s\" VM\n",
 26.1716 -                    knownVMs[i].name, knownVMs[i].name+1);
 26.1717 -    }
 26.1718 -    for (i=1; i<knownVMsCount; i++) {
 26.1719 -        if (knownVMs[i].flag == VM_ALIASED_TO)
 26.1720 -            fprintf(stdout, "    %s\t  is a synonym for "
 26.1721 -                    "the \"%s\" VM  [deprecated]\n",
 26.1722 -                    knownVMs[i].name, knownVMs[i].alias+1);
 26.1723 -    }
 26.1724 -    /* The first known VM is the default */
 26.1725 -    {
 26.1726 -      const char* defaultVM   = knownVMs[0].name+1;
 26.1727 -      const char* punctuation = ".";
 26.1728 -      const char* reason      = "";
 26.1729 -      if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) &&
 26.1730 -          (ServerClassMachine() == JNI_TRUE)) {
 26.1731 -        defaultVM = knownVMs[0].server_class+1;
 26.1732 -        punctuation = ", ";
 26.1733 -        reason = "because you are running on a server-class machine.\n";
 26.1734 -      }
 26.1735 -      fprintf(stdout, "                  The default VM is %s%s\n",
 26.1736 -              defaultVM, punctuation);
 26.1737 -      fprintf(stdout, "                  %s\n",
 26.1738 -              reason);
 26.1739 -    }
 26.1740 -#endif /* ifndef GAMMA */
 26.1741 -
 26.1742 -    fprintf(stdout,
 26.1743 -"    -cp <class search path of directories and zip/jar files>\n"
 26.1744 -"    -classpath <class search path of directories and zip/jar files>\n"
 26.1745 -"                  A %c separated list of directories, JAR archives,\n"
 26.1746 -"                  and ZIP archives to search for class files.\n"
 26.1747 -"    -D<name>=<value>\n"
 26.1748 -"                  set a system property\n"
 26.1749 -"    -verbose[:class|gc|jni]\n"
 26.1750 -"                  enable verbose output\n"
 26.1751 -"    -version      print product version and exit\n"
 26.1752 -"    -version:<value>\n"
 26.1753 -"                  require the specified version to run\n"
 26.1754 -"    -showversion  print product version and continue\n"
 26.1755 -"    -jre-restrict-search | -jre-no-restrict-search\n"
 26.1756 -"                  include/exclude user private JREs in the version search\n"
 26.1757 -"    -? -help      print this help message\n"
 26.1758 -"    -X            print help on non-standard options\n"
 26.1759 -"    -ea[:<packagename>...|:<classname>]\n"
 26.1760 -"    -enableassertions[:<packagename>...|:<classname>]\n"
 26.1761 -"                  enable assertions\n"
 26.1762 -"    -da[:<packagename>...|:<classname>]\n"
 26.1763 -"    -disableassertions[:<packagename>...|:<classname>]\n"
 26.1764 -"                  disable assertions\n"
 26.1765 -"    -esa | -enablesystemassertions\n"
 26.1766 -"                  enable system assertions\n"
 26.1767 -"    -dsa | -disablesystemassertions\n"
 26.1768 -"                  disable system assertions\n"
 26.1769 -"    -agentlib:<libname>[=<options>]\n"
 26.1770 -"                  load native agent library <libname>, e.g. -agentlib:hprof\n"
 26.1771 -"                    see also, -agentlib:jdwp=help and -agentlib:hprof=help\n"
 26.1772 -"    -agentpath:<pathname>[=<options>]\n"
 26.1773 -"                  load native agent library by full pathname\n"
 26.1774 -"    -javaagent:<jarpath>[=<options>]\n"
 26.1775 -"                  load Java programming language agent, see java.lang.instrument\n"
 26.1776 -"    -splash:<imagepath>\n"
 26.1777 -"                  show splash screen with specified image\n"
 26.1778 -
 26.1779 -            ,PATH_SEPARATOR);
 26.1780 -}
 26.1781 -
 26.1782 -/*
 26.1783 - * Print usage message for -X options.
 26.1784 - */
 26.1785 -static jint
 26.1786 -PrintXUsage(const char *jvmpath)
 26.1787 -{
 26.1788 -    /*
 26.1789 -       A 32 bit cushion to prevent buffer overrun, noting that
 26.1790 -       fopen(3C) may fail if the buffer exceeds MAXPATHLEN.
 26.1791 -    */
 26.1792 -    char path[MAXPATHLEN+32];
 26.1793 -    char buf[128];
 26.1794 -    size_t n;
 26.1795 -    FILE *fp;
 26.1796 -    static const char Xusage_txt[] = "/Xusage.txt";
 26.1797 -
 26.1798 -    strcpy(path, jvmpath);
 26.1799 -    /* Note the FILE_SEPARATOR is platform dependent */
 26.1800 -    strcpy(strrchr(path, FILE_SEPARATOR), Xusage_txt);
 26.1801 -    fp = fopen(path, "r");
 26.1802 -    if (fp == 0) {
 26.1803 -        fprintf(stderr, "Can't open %s\n", path);
 26.1804 -        return 1;
 26.1805 -    }
 26.1806 -    while ((n = fread(buf, 1, sizeof(buf), fp)) != 0) {
 26.1807 -        fwrite(buf, 1, n, stdout);
 26.1808 -    }
 26.1809 -    fclose(fp);
 26.1810 -    return 0;
 26.1811 -}
 26.1812 -
 26.1813 -#ifndef GAMMA
 26.1814 -/*
 26.1815 - * Read the jvm.cfg file and fill the knownJVMs[] array.
 26.1816 - *
 26.1817 - * The functionality of the jvm.cfg file is subject to change without
 26.1818 - * notice and the mechanism will be removed in the future.
 26.1819 - *
 26.1820 - * The lexical structure of the jvm.cfg file is as follows:
 26.1821 - *
 26.1822 - *     jvmcfg         :=  { vmLine }
 26.1823 - *     vmLine         :=  knownLine
 26.1824 - *                    |   aliasLine
 26.1825 - *                    |   warnLine
 26.1826 - *                    |   ignoreLine
 26.1827 - *                    |   errorLine
 26.1828 - *                    |   predicateLine
 26.1829 - *                    |   commentLine
 26.1830 - *     knownLine      :=  flag  "KNOWN"                  EOL
 26.1831 - *     warnLine       :=  flag  "WARN"                   EOL
 26.1832 - *     ignoreLine     :=  flag  "IGNORE"                 EOL
 26.1833 - *     errorLine      :=  flag  "ERROR"                  EOL
 26.1834 - *     aliasLine      :=  flag  "ALIASED_TO"       flag  EOL
 26.1835 - *     predicateLine  :=  flag  "IF_SERVER_CLASS"  flag  EOL
 26.1836 - *     commentLine    :=  "#" text                       EOL
 26.1837 - *     flag           :=  "-" identifier
 26.1838 - *
 26.1839 - * The semantics are that when someone specifies a flag on the command line:
 26.1840 - * - if the flag appears on a knownLine, then the identifier is used as
 26.1841 - *   the name of the directory holding the JVM library (the name of the JVM).
 26.1842 - * - if the flag appears as the first flag on an aliasLine, the identifier
 26.1843 - *   of the second flag is used as the name of the JVM.
 26.1844 - * - if the flag appears on a warnLine, the identifier is used as the
 26.1845 - *   name of the JVM, but a warning is generated.
 26.1846 - * - if the flag appears on an ignoreLine, the identifier is recognized as the
 26.1847 - *   name of a JVM, but the identifier is ignored and the default vm used
 26.1848 - * - if the flag appears on an errorLine, an error is generated.
 26.1849 - * - if the flag appears as the first flag on a predicateLine, and
 26.1850 - *   the machine on which you are running passes the predicate indicated,
 26.1851 - *   then the identifier of the second flag is used as the name of the JVM,
 26.1852 - *   otherwise the identifier of the first flag is used as the name of the JVM.
 26.1853 - * If no flag is given on the command line, the first vmLine of the jvm.cfg
 26.1854 - * file determines the name of the JVM.
 26.1855 - * PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
 26.1856 - * since they only make sense if someone hasn't specified the name of the
 26.1857 - * JVM on the command line.
 26.1858 - *
 26.1859 - * The intent of the jvm.cfg file is to allow several JVM libraries to
 26.1860 - * be installed in different subdirectories of a single JRE installation,
 26.1861 - * for space-savings and convenience in testing.
 26.1862 - * The intent is explicitly not to provide a full aliasing or predicate
 26.1863 - * mechanism.
 26.1864 - */
 26.1865 -jint
 26.1866 -ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative)
 26.1867 -{
 26.1868 -    FILE *jvmCfg;
 26.1869 -    char jvmCfgName[MAXPATHLEN+20];
 26.1870 -    char line[MAXPATHLEN+20];
 26.1871 -    int cnt = 0;
 26.1872 -    int lineno = 0;
 26.1873 -    jlong start, end;
 26.1874 -    int vmType;
 26.1875 -    char *tmpPtr;
 26.1876 -    char *altVMName = NULL;
 26.1877 -    char *serverClassVMName = NULL;
 26.1878 -    static char *whiteSpace = " \t";
 26.1879 -    if (_launcher_debug) {
 26.1880 -        start = CounterGet();
 26.1881 -    }
 26.1882 -
 26.1883 -    strcpy(jvmCfgName, jrepath);
 26.1884 -    strcat(jvmCfgName, FILESEP "lib" FILESEP);
 26.1885 -    strcat(jvmCfgName, arch);
 26.1886 -    strcat(jvmCfgName, FILESEP "jvm.cfg");
 26.1887 -
 26.1888 -    jvmCfg = fopen(jvmCfgName, "r");
 26.1889 -    if (jvmCfg == NULL) {
 26.1890 -      if (!speculative) {
 26.1891 -        ReportErrorMessage2("Error: could not open `%s'", jvmCfgName,
 26.1892 -                            JNI_TRUE);
 26.1893 -        exit(1);
 26.1894 -      } else {
 26.1895 -        return -1;
 26.1896 -      }
 26.1897 -    }
 26.1898 -    while (fgets(line, sizeof(line), jvmCfg) != NULL) {
 26.1899 -        vmType = VM_UNKNOWN;
 26.1900 -        lineno++;
 26.1901 -        if (line[0] == '#')
 26.1902 -            continue;
 26.1903 -        if (line[0] != '-') {
 26.1904 -            fprintf(stderr, "Warning: no leading - on line %d of `%s'\n",
 26.1905 -                    lineno, jvmCfgName);
 26.1906 -        }
 26.1907 -        if (cnt >= knownVMsLimit) {
 26.1908 -            GrowKnownVMs(cnt);
 26.1909 -        }
 26.1910 -        line[strlen(line)-1] = '\0'; /* remove trailing newline */
 26.1911 -        tmpPtr = line + strcspn(line, whiteSpace);
 26.1912 -        if (*tmpPtr == 0) {
 26.1913 -            fprintf(stderr, "Warning: missing VM type on line %d of `%s'\n",
 26.1914 -                    lineno, jvmCfgName);
 26.1915 -        } else {
 26.1916 -            /* Null-terminate this string for JLI_StringDup below */
 26.1917 -            *tmpPtr++ = 0;
 26.1918 -            tmpPtr += strspn(tmpPtr, whiteSpace);
 26.1919 -            if (*tmpPtr == 0) {
 26.1920 -                fprintf(stderr, "Warning: missing VM type on line %d of `%s'\n",
 26.1921 -                        lineno, jvmCfgName);
 26.1922 -            } else {
 26.1923 -                if (!strncmp(tmpPtr, "KNOWN", strlen("KNOWN"))) {
 26.1924 -                    vmType = VM_KNOWN;
 26.1925 -                } else if (!strncmp(tmpPtr, "ALIASED_TO", strlen("ALIASED_TO"))) {
 26.1926 -                    tmpPtr += strcspn(tmpPtr, whiteSpace);
 26.1927 -                    if (*tmpPtr != 0) {
 26.1928 -                        tmpPtr += strspn(tmpPtr, whiteSpace);
 26.1929 -                    }
 26.1930 -                    if (*tmpPtr == 0) {
 26.1931 -                        fprintf(stderr, "Warning: missing VM alias on line %d of `%s'\n",
 26.1932 -                                lineno, jvmCfgName);
 26.1933 -                    } else {
 26.1934 -                        /* Null terminate altVMName */
 26.1935 -                        altVMName = tmpPtr;
 26.1936 -                        tmpPtr += strcspn(tmpPtr, whiteSpace);
 26.1937 -                        *tmpPtr = 0;
 26.1938 -                        vmType = VM_ALIASED_TO;
 26.1939 -                    }
 26.1940 -                } else if (!strncmp(tmpPtr, "WARN", strlen("WARN"))) {
 26.1941 -                    vmType = VM_WARN;
 26.1942 -                } else if (!strncmp(tmpPtr, "IGNORE", strlen("IGNORE"))) {
 26.1943 -                    vmType = VM_IGNORE;
 26.1944 -                } else if (!strncmp(tmpPtr, "ERROR", strlen("ERROR"))) {
 26.1945 -                    vmType = VM_ERROR;
 26.1946 -                } else if (!strncmp(tmpPtr,
 26.1947 -                                    "IF_SERVER_CLASS",
 26.1948 -                                    strlen("IF_SERVER_CLASS"))) {
 26.1949 -                    tmpPtr += strcspn(tmpPtr, whiteSpace);
 26.1950 -                    if (*tmpPtr != 0) {
 26.1951 -                        tmpPtr += strspn(tmpPtr, whiteSpace);
 26.1952 -                    }
 26.1953 -                    if (*tmpPtr == 0) {
 26.1954 -                        fprintf(stderr, "Warning: missing server class VM on line %d of `%s'\n",
 26.1955 -                                lineno, jvmCfgName);
 26.1956 -                    } else {
 26.1957 -                        /* Null terminate server class VM name */
 26.1958 -                        serverClassVMName = tmpPtr;
 26.1959 -                        tmpPtr += strcspn(tmpPtr, whiteSpace);
 26.1960 -                        *tmpPtr = 0;
 26.1961 -                        vmType = VM_IF_SERVER_CLASS;
 26.1962 -                    }
 26.1963 -                } else {
 26.1964 -                    fprintf(stderr, "Warning: unknown VM type on line %d of `%s'\n",
 26.1965 -                            lineno, &jvmCfgName[0]);
 26.1966 -                    vmType = VM_KNOWN;
 26.1967 -                }
 26.1968 -            }
 26.1969 -        }
 26.1970 -
 26.1971 -        if (_launcher_debug)
 26.1972 -            printf("jvm.cfg[%d] = ->%s<-\n", cnt, line);
 26.1973 -        if (vmType != VM_UNKNOWN) {
 26.1974 -            knownVMs[cnt].name = JLI_StringDup(line);
 26.1975 -            knownVMs[cnt].flag = vmType;
 26.1976 -            switch (vmType) {
 26.1977 -            default:
 26.1978 -                break;
 26.1979 -            case VM_ALIASED_TO:
 26.1980 -                knownVMs[cnt].alias = JLI_StringDup(altVMName);
 26.1981 -                if (_launcher_debug) {
 26.1982 -                    printf("    name: %s  vmType: %s  alias: %s\n",
 26.1983 -                           knownVMs[cnt].name, "VM_ALIASED_TO", knownVMs[cnt].alias);
 26.1984 -                }
 26.1985 -                break;
 26.1986 -            case VM_IF_SERVER_CLASS:
 26.1987 -                knownVMs[cnt].server_class = JLI_StringDup(serverClassVMName);
 26.1988 -                if (_launcher_debug) {
 26.1989 -                    printf("    name: %s  vmType: %s  server_class: %s\n",
 26.1990 -                           knownVMs[cnt].name, "VM_IF_SERVER_CLASS", knownVMs[cnt].server_class);
 26.1991 -                }
 26.1992 -                break;
 26.1993 -            }
 26.1994 -            cnt++;
 26.1995 -        }
 26.1996 -    }
 26.1997 -    fclose(jvmCfg);
 26.1998 -    knownVMsCount = cnt;
 26.1999 -
 26.2000 -    if (_launcher_debug) {
 26.2001 -        end   = CounterGet();
 26.2002 -        printf("%ld micro seconds to parse jvm.cfg\n",
 26.2003 -               (long)(jint)Counter2Micros(end-start));
 26.2004 -    }
 26.2005 -
 26.2006 -    return cnt;
 26.2007 -}
 26.2008 -
 26.2009 -
 26.2010 -static void
 26.2011 -GrowKnownVMs(int minimum)
 26.2012 -{
 26.2013 -    struct vmdesc* newKnownVMs;
 26.2014 -    int newMax;
 26.2015 -
 26.2016 -    newMax = (knownVMsLimit == 0 ? INIT_MAX_KNOWN_VMS : (2 * knownVMsLimit));
 26.2017 -    if (newMax <= minimum) {
 26.2018 -        newMax = minimum;
 26.2019 -    }
 26.2020 -    newKnownVMs = (struct vmdesc*) JLI_MemAlloc(newMax * sizeof(struct vmdesc));
 26.2021 -    if (knownVMs != NULL) {
 26.2022 -        memcpy(newKnownVMs, knownVMs, knownVMsLimit * sizeof(struct vmdesc));
 26.2023 -    }
 26.2024 -    JLI_MemFree(knownVMs);
 26.2025 -    knownVMs = newKnownVMs;
 26.2026 -    knownVMsLimit = newMax;
 26.2027 -}
 26.2028 -
 26.2029 -
 26.2030 -/* Returns index of VM or -1 if not found */
 26.2031 -static int
 26.2032 -KnownVMIndex(const char* name)
 26.2033 -{
 26.2034 -    int i;
 26.2035 -    if (strncmp(name, "-J", 2) == 0) name += 2;
 26.2036 -    for (i = 0; i < knownVMsCount; i++) {
 26.2037 -        if (!strcmp(name, knownVMs[i].name)) {
 26.2038 -            return i;
 26.2039 -        }
 26.2040 -    }
 26.2041 -    return -1;
 26.2042 -}
 26.2043 -
 26.2044 -static void
 26.2045 -FreeKnownVMs()
 26.2046 -{
 26.2047 -    int i;
 26.2048 -    for (i = 0; i < knownVMsCount; i++) {
 26.2049 -        JLI_MemFree(knownVMs[i].name);
 26.2050 -        knownVMs[i].name = NULL;
 26.2051 -    }
 26.2052 -    JLI_MemFree(knownVMs);
 26.2053 -}
 26.2054 -
 26.2055 -
 26.2056 -/*
 26.2057 - * Displays the splash screen according to the jar file name
 26.2058 - * and image file names stored in environment variables
 26.2059 - */
 26.2060 -static void
 26.2061 -ShowSplashScreen()
 26.2062 -{
 26.2063 -    const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
 26.2064 -    const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY);
 26.2065 -    int data_size;
 26.2066 -    void *image_data;
 26.2067 -    if (jar_name) {
 26.2068 -        image_data = JLI_JarUnpackFile(jar_name, file_name, &data_size);
 26.2069 -        if (image_data) {
 26.2070 -            DoSplashInit();
 26.2071 -            DoSplashLoadMemory(image_data, data_size);
 26.2072 -            JLI_MemFree(image_data);
 26.2073 -        }
 26.2074 -    } else if (file_name) {
 26.2075 -        DoSplashInit();
 26.2076 -        DoSplashLoadFile(file_name);
 26.2077 -    } else {
 26.2078 -        return;
 26.2079 -    }
 26.2080 -    DoSplashSetFileJarName(file_name, jar_name);
 26.2081 -}
 26.2082 -
 26.2083 -#endif /* ifndef GAMMA */
    27.1 --- a/src/share/tools/launcher/java.h	Tue May 14 17:33:07 2013 +0000
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,110 +0,0 @@
    27.4 -/*
    27.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    27.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.7 - *
    27.8 - * This code is free software; you can redistribute it and/or modify it
    27.9 - * under the terms of the GNU General Public License version 2 only, as
   27.10 - * published by the Free Software Foundation.
   27.11 - *
   27.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   27.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   27.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   27.15 - * version 2 for more details (a copy is included in the LICENSE file that
   27.16 - * accompanied this code).
   27.17 - *
   27.18 - * You should have received a copy of the GNU General Public License version
   27.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   27.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   27.21 - *
   27.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   27.23 - * or visit www.oracle.com if you need additional information or have any
   27.24 - * questions.
   27.25 - *
   27.26 - */
   27.27 -
   27.28 -
   27.29 -#ifndef _JAVA_H_
   27.30 -#define _JAVA_H_
   27.31 -
   27.32 -/*
   27.33 - * Get system specific defines.
   27.34 - */
   27.35 -#include "jni.h"
   27.36 -#include "java_md.h"
   27.37 -#include "jli_util.h"
   27.38 -
   27.39 -/*
   27.40 - * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
   27.41 - */
   27.42 -typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
   27.43 -typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
   27.44 -
   27.45 -typedef struct {
   27.46 -    CreateJavaVM_t CreateJavaVM;
   27.47 -    GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
   27.48 -} InvocationFunctions;
   27.49 -
   27.50 -/*
   27.51 - * Prototypes for launcher functions in the system specific java_md.c.
   27.52 - */
   27.53 -
   27.54 -jboolean
   27.55 -LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
   27.56 -
   27.57 -void
   27.58 -GetXUsagePath(char *buf, jint bufsize);
   27.59 -
   27.60 -jboolean
   27.61 -GetApplicationHome(char *buf, jint bufsize);
   27.62 -
   27.63 -const char *
   27.64 -GetArch();
   27.65 -
   27.66 -void CreateExecutionEnvironment(int *_argc,
   27.67 -                                       char ***_argv,
   27.68 -                                       char jrepath[],
   27.69 -                                       jint so_jrepath,
   27.70 -                                       char jvmpath[],
   27.71 -                                       jint so_jvmpath,
   27.72 -                                       char **original_argv);
   27.73 -
   27.74 -/*
   27.75 - * Report an error message to stderr or a window as appropriate.  The
   27.76 - * flag always is set to JNI_TRUE if message is to be reported to both
   27.77 - * strerr and windows and set to JNI_FALSE if the message should only
   27.78 - * be sent to a window.
   27.79 - */
   27.80 -void ReportErrorMessage(char * message, jboolean always);
   27.81 -void ReportErrorMessage2(char * format, char * string, jboolean always);
   27.82 -
   27.83 -/*
   27.84 - * Report an exception which terminates the vm to stderr or a window
   27.85 - * as appropriate.
   27.86 - */
   27.87 -void ReportExceptionDescription(JNIEnv * env);
   27.88 -
   27.89 -jboolean RemovableMachineDependentOption(char * option);
   27.90 -void PrintMachineDependentOptions();
   27.91 -
   27.92 -/*
   27.93 - * Block current thread and continue execution in new thread
   27.94 - */
   27.95 -int ContinueInNewThread(int (JNICALL *continuation)(void *),
   27.96 -                        jlong stack_size, void * args);
   27.97 -
   27.98 -/* sun.java.launcher.* platform properties. */
   27.99 -void SetJavaLauncherPlatformProps(void);
  27.100 -
  27.101 -/*
  27.102 - * Functions defined in java.c and used in java_md.c.
  27.103 - */
  27.104 -jint ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative);
  27.105 -char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
  27.106 -void AddOption(char *str, void *info);
  27.107 -
  27.108 -/*
  27.109 - * Make launcher spit debug output.
  27.110 - */
  27.111 -extern jboolean _launcher_debug;
  27.112 -
  27.113 -#endif /* _JAVA_H_ */
    28.1 --- a/src/share/tools/launcher/jli_util.c	Tue May 14 17:33:07 2013 +0000
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,89 +0,0 @@
    28.4 -
    28.5 -/*
    28.6 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    28.7 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.8 - *
    28.9 - * This code is free software; you can redistribute it and/or modify it
   28.10 - * under the terms of the GNU General Public License version 2 only, as
   28.11 - * published by the Free Software Foundation.
   28.12 - *
   28.13 - * This code is distributed in the hope that it will be useful, but WITHOUT
   28.14 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.15 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.16 - * version 2 for more details (a copy is included in the LICENSE file that
   28.17 - * accompanied this code).
   28.18 - *
   28.19 - * You should have received a copy of the GNU General Public License version
   28.20 - * 2 along with this work; if not, write to the Free Software Foundation,
   28.21 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.22 - *
   28.23 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.24 - * or visit www.oracle.com if you need additional information or have any
   28.25 - * questions.
   28.26 - *
   28.27 - */
   28.28 -
   28.29 -#include <stdio.h>
   28.30 -#include <string.h>
   28.31 -#include "jli_util.h"
   28.32 -
   28.33 -#ifdef GAMMA
   28.34 -#ifdef TARGET_OS_FAMILY_windows
   28.35 -#define strdup _strdup
   28.36 -#endif
   28.37 -#endif
   28.38 -
   28.39 -/*
   28.40 - * Returns a pointer to a block of at least 'size' bytes of memory.
   28.41 - * Prints error message and exits if the memory could not be allocated.
   28.42 - */
   28.43 -void *
   28.44 -JLI_MemAlloc(size_t size)
   28.45 -{
   28.46 -    void *p = malloc(size);
   28.47 -    if (p == 0) {
   28.48 -        perror("malloc");
   28.49 -        exit(1);
   28.50 -    }
   28.51 -    return p;
   28.52 -}
   28.53 -
   28.54 -/*
   28.55 - * Equivalent to realloc(size).
   28.56 - * Prints error message and exits if the memory could not be reallocated.
   28.57 - */
   28.58 -void *
   28.59 -JLI_MemRealloc(void *ptr, size_t size)
   28.60 -{
   28.61 -    void *p = realloc(ptr, size);
   28.62 -    if (p == 0) {
   28.63 -        perror("realloc");
   28.64 -        exit(1);
   28.65 -    }
   28.66 -    return p;
   28.67 -}
   28.68 -
   28.69 -/*
   28.70 - * Wrapper over strdup(3C) which prints an error message and exits if memory
   28.71 - * could not be allocated.
   28.72 - */
   28.73 -char *
   28.74 -JLI_StringDup(const char *s1)
   28.75 -{
   28.76 -    char *s = strdup(s1);
   28.77 -    if (s == NULL) {
   28.78 -        perror("strdup");
   28.79 -        exit(1);
   28.80 -    }
   28.81 -    return s;
   28.82 -}
   28.83 -
   28.84 -/*
   28.85 - * Very equivalent to free(ptr).
   28.86 - * Here to maintain pairing with the above routines.
   28.87 - */
   28.88 -void
   28.89 -JLI_MemFree(void *ptr)
   28.90 -{
   28.91 -    free(ptr);
   28.92 -}
    29.1 --- a/src/share/tools/launcher/jli_util.h	Tue May 14 17:33:07 2013 +0000
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,35 +0,0 @@
    29.4 -/*
    29.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    29.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 - *
    29.8 - * This code is free software; you can redistribute it and/or modify it
    29.9 - * under the terms of the GNU General Public License version 2 only, as
   29.10 - * published by the Free Software Foundation.
   29.11 - *
   29.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 - * version 2 for more details (a copy is included in the LICENSE file that
   29.16 - * accompanied this code).
   29.17 - *
   29.18 - * You should have received a copy of the GNU General Public License version
   29.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 - *
   29.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.23 - * or visit www.oracle.com if you need additional information or have any
   29.24 - * questions.
   29.25 - *
   29.26 - */
   29.27 -
   29.28 -#ifndef _JLI_UTIL_H
   29.29 -#define _JLI_UTIL_H
   29.30 -
   29.31 -#include <stdlib.h>
   29.32 -
   29.33 -void *JLI_MemAlloc(size_t size);
   29.34 -void *JLI_MemRealloc(void *ptr, size_t size);
   29.35 -char *JLI_StringDup(const char *s1);
   29.36 -void  JLI_MemFree(void *ptr);
   29.37 -
   29.38 -#endif  /* _JLI_UTIL_H */
    30.1 --- a/src/share/tools/launcher/wildcard.c	Tue May 14 17:33:07 2013 +0000
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,496 +0,0 @@
    30.4 -/*
    30.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    30.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 - *
    30.8 - * This code is free software; you can redistribute it and/or modify it
    30.9 - * under the terms of the GNU General Public License version 2 only, as
   30.10 - * published by the Free Software Foundation.
   30.11 - *
   30.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 - * version 2 for more details (a copy is included in the LICENSE file that
   30.16 - * accompanied this code).
   30.17 - *
   30.18 - * You should have received a copy of the GNU General Public License version
   30.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 - *
   30.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 - * or visit www.oracle.com if you need additional information or have any
   30.24 - * questions.
   30.25 - *
   30.26 - */
   30.27 -
   30.28 -/*
   30.29 - * Class-Path Wildcards
   30.30 - *
   30.31 - * The syntax for wildcards is a single asterisk. The class path
   30.32 - * foo/"*", e.g., loads all jar files in the directory named foo.
   30.33 - * (This requires careful quotation when used in shell scripts.)
   30.34 - *
   30.35 - * Only files whose names end in .jar or .JAR are matched.
   30.36 - * Files whose names end in .zip, or which have a particular
   30.37 - * magic number, regardless of filename extension, are not
   30.38 - * matched.
   30.39 - *
   30.40 - * Files are considered regardless of whether or not they are
   30.41 - * "hidden" in the UNIX sense, i.e., have names beginning with '.'.
   30.42 - *
   30.43 - * A wildcard only matches jar files, not class files in the same
   30.44 - * directory.  If you want to load both class files and jar files from
   30.45 - * a single directory foo then you can say foo:foo/"*", or foo/"*":foo
   30.46 - * if you want the jar files to take precedence.
   30.47 - *
   30.48 - * Subdirectories are not searched recursively, i.e., foo/"*" only
   30.49 - * looks for jar files in foo, not in foo/bar, foo/baz, etc.
   30.50 - *
   30.51 - * Expansion of wildcards is done early, prior to the invocation of a
   30.52 - * program's main method, rather than late, during the class-loading
   30.53 - * process itself.  Each element of the input class path containing a
   30.54 - * wildcard is replaced by the (possibly empty) sequence of elements
   30.55 - * generated by enumerating the jar files in the named directory.  If
   30.56 - * the directory foo contains a.jar, b.jar, and c.jar,
   30.57 - * e.g., then the class path foo/"*" is expanded into
   30.58 - * foo/a.jar:foo/b.jar:foo/c.jar, and that string would be the value
   30.59 - * of the system property java.class.path.
   30.60 - *
   30.61 - * The order in which the jar files in a directory are enumerated in
   30.62 - * the expanded class path is not specified and may vary from platform
   30.63 - * to platform and even from moment to moment on the same machine.  A
   30.64 - * well-constructed application should not depend upon any particular
   30.65 - * order.  If a specific order is required then the jar files can be
   30.66 - * enumerated explicitly in the class path.
   30.67 - *
   30.68 - * The CLASSPATH environment variable is not treated any differently
   30.69 - * from the -classpath (equiv. -cp) command-line option,
   30.70 - * i.e. wildcards are honored in all these cases.
   30.71 - *
   30.72 - * Class-path wildcards are not honored in the Class-Path jar-manifest
   30.73 - * header.
   30.74 - *
   30.75 - * Class-path wildcards are honored not only by the Java launcher but
   30.76 - * also by most other command-line tools that accept class paths, and
   30.77 - * in particular by javac and javadoc.
   30.78 - *
   30.79 - * Class-path wildcards are not honored in any other kind of path, and
   30.80 - * especially not in the bootstrap class path, which is a mere
   30.81 - * artifact of our implementation and not something that developers
   30.82 - * should use.
   30.83 - *
   30.84 - * Classpath wildcards are only expanded in the Java launcher code,
   30.85 - * supporting the use of wildcards on the command line and in the
   30.86 - * CLASSPATH environment variable.  We do not support the use of
   30.87 - * wildcards by applications that embed the JVM.
   30.88 - */
   30.89 -
   30.90 -#include <stddef.h>
   30.91 -#include <stdio.h>
   30.92 -#include <stdlib.h>
   30.93 -#include <string.h>
   30.94 -#include <sys/types.h>
   30.95 -#include "java.h"       /* Strictly for PATH_SEPARATOR/FILE_SEPARATOR */
   30.96 -#include "jli_util.h"
   30.97 -
   30.98 -#ifdef _WIN32
   30.99 -#include <windows.h>
  30.100 -#else /* Unix */
  30.101 -#include <unistd.h>
  30.102 -#include <dirent.h>
  30.103 -#endif /* Unix */
  30.104 -
  30.105 -static int
  30.106 -exists(const char* filename)
  30.107 -{
  30.108 -#ifdef _WIN32
  30.109 -    return _access(filename, 0) == 0;
  30.110 -#else
  30.111 -    return access(filename, F_OK) == 0;
  30.112 -#endif
  30.113 -}
  30.114 -
  30.115 -#define NEW_(TYPE) ((TYPE) JLI_MemAlloc(sizeof(struct TYPE##_)))
  30.116 -
  30.117 -/*
  30.118 - * Wildcard directory iteration.
  30.119 - * WildcardIterator_for(wildcard) returns an iterator.
  30.120 - * Each call to that iterator's next() method returns the basename
  30.121 - * of an entry in the wildcard's directory.  The basename's memory
  30.122 - * belongs to the iterator.  The caller is responsible for prepending
  30.123 - * the directory name and file separator, if necessary.
  30.124 - * When done with the iterator, call the close method to clean up.
  30.125 - */
  30.126 -typedef struct WildcardIterator_* WildcardIterator;
  30.127 -
  30.128 -#ifdef _WIN32
  30.129 -struct WildcardIterator_
  30.130 -{
  30.131 -    HANDLE handle;
  30.132 -    char *firstFile; /* Stupid FindFirstFile...FindNextFile */
  30.133 -};
  30.134 -
  30.135 -static WildcardIterator
  30.136 -WildcardIterator_for(const char *wildcard)
  30.137 -{
  30.138 -    WIN32_FIND_DATA find_data;
  30.139 -    WildcardIterator it = NEW_(WildcardIterator);
  30.140 -    HANDLE handle = FindFirstFile(wildcard, &find_data);
  30.141 -    if (handle == INVALID_HANDLE_VALUE)
  30.142 -        return NULL;
  30.143 -    it->handle = handle;
  30.144 -    it->firstFile = find_data.cFileName;
  30.145 -    return it;
  30.146 -}
  30.147 -
  30.148 -static char *
  30.149 -WildcardIterator_next(WildcardIterator it)
  30.150 -{
  30.151 -    WIN32_FIND_DATA find_data;
  30.152 -    if (it->firstFile != NULL) {
  30.153 -        char *firstFile = it->firstFile;
  30.154 -        it->firstFile = NULL;
  30.155 -        return firstFile;
  30.156 -    }
  30.157 -    return FindNextFile(it->handle, &find_data)
  30.158 -        ? find_data.cFileName : NULL;
  30.159 -}
  30.160 -
  30.161 -static void
  30.162 -WildcardIterator_close(WildcardIterator it)
  30.163 -{
  30.164 -    if (it) {
  30.165 -        FindClose(it->handle);
  30.166 -        JLI_MemFree(it->firstFile);
  30.167 -        JLI_MemFree(it);
  30.168 -    }
  30.169 -}
  30.170 -
  30.171 -#else /* Unix */
  30.172 -struct WildcardIterator_
  30.173 -{
  30.174 -    DIR *dir;
  30.175 -};
  30.176 -
  30.177 -static WildcardIterator
  30.178 -WildcardIterator_for(const char *wildcard)
  30.179 -{
  30.180 -    DIR *dir;
  30.181 -    int wildlen = strlen(wildcard);
  30.182 -    if (wildlen < 2) {
  30.183 -        dir = opendir(".");
  30.184 -    } else {
  30.185 -        char *dirname = JLI_StringDup(wildcard);
  30.186 -        dirname[wildlen - 1] = '\0';
  30.187 -        dir = opendir(dirname);
  30.188 -        JLI_MemFree(dirname);
  30.189 -    }
  30.190 -    if (dir == NULL)
  30.191 -        return NULL;
  30.192 -    else {
  30.193 -        WildcardIterator it = NEW_(WildcardIterator);
  30.194 -        it->dir = dir;
  30.195 -        return it;
  30.196 -    }
  30.197 -}
  30.198 -
  30.199 -static char *
  30.200 -WildcardIterator_next(WildcardIterator it)
  30.201 -{
  30.202 -    struct dirent* dirp = readdir(it->dir);
  30.203 -    return dirp ? dirp->d_name : NULL;
  30.204 -}
  30.205 -
  30.206 -static void
  30.207 -WildcardIterator_close(WildcardIterator it)
  30.208 -{
  30.209 -    if (it) {
  30.210 -        closedir(it->dir);
  30.211 -        JLI_MemFree(it);
  30.212 -    }
  30.213 -}
  30.214 -#endif /* Unix */
  30.215 -
  30.216 -static int
  30.217 -equal(const char *s1, const char *s2)
  30.218 -{
  30.219 -    return strcmp(s1, s2) == 0;
  30.220 -}
  30.221 -
  30.222 -/*
  30.223 - * FileList ADT - a dynamic list of C filenames
  30.224 - */
  30.225 -struct FileList_
  30.226 -{
  30.227 -    char **files;
  30.228 -    int size;
  30.229 -    int capacity;
  30.230 -};
  30.231 -typedef struct FileList_ *FileList;
  30.232 -
  30.233 -static FileList
  30.234 -FileList_new(int capacity)
  30.235 -{
  30.236 -    FileList fl = NEW_(FileList);
  30.237 -    fl->capacity = capacity;
  30.238 -    fl->files = (char **) JLI_MemAlloc(capacity * sizeof(fl->files[0]));
  30.239 -    fl->size = 0;
  30.240 -    return fl;
  30.241 -}
  30.242 -
  30.243 -#ifdef DEBUG_WILDCARD
  30.244 -static void
  30.245 -FileList_print(FileList fl)
  30.246 -{
  30.247 -    int i;
  30.248 -    putchar('[');
  30.249 -    for (i = 0; i < fl->size; i++) {
  30.250 -        if (i > 0) printf(", ");
  30.251 -        printf("\"%s\"",fl->files[i]);
  30.252 -    }
  30.253 -    putchar(']');
  30.254 -}
  30.255 -#endif
  30.256 -
  30.257 -static void
  30.258 -FileList_free(FileList fl)
  30.259 -{
  30.260 -    if (fl) {
  30.261 -        if (fl->files) {
  30.262 -            int i;
  30.263 -            for (i = 0; i < fl->size; i++)
  30.264 -                JLI_MemFree(fl->files[i]);
  30.265 -            JLI_MemFree(fl->files);
  30.266 -        }
  30.267 -        JLI_MemFree(fl);
  30.268 -    }
  30.269 -}
  30.270 -
  30.271 -static void
  30.272 -FileList_ensureCapacity(FileList fl, int capacity)
  30.273 -{
  30.274 -    if (fl->capacity < capacity) {
  30.275 -        while (fl->capacity < capacity)
  30.276 -            fl->capacity *= 2;
  30.277 -        fl->files = JLI_MemRealloc(fl->files,
  30.278 -                               fl->capacity * sizeof(fl->files[0]));
  30.279 -    }
  30.280 -}
  30.281 -
  30.282 -static void
  30.283 -FileList_add(FileList fl, char *file)
  30.284 -{
  30.285 -    FileList_ensureCapacity(fl, fl->size+1);
  30.286 -    fl->files[fl->size++] = file;
  30.287 -}
  30.288 -
  30.289 -static void
  30.290 -FileList_addSubstring(FileList fl, const char *beg, int len)
  30.291 -{
  30.292 -    char *filename = (char *) JLI_MemAlloc(len+1);
  30.293 -    memcpy(filename, beg, len);
  30.294 -    filename[len] = '\0';
  30.295 -    FileList_ensureCapacity(fl, fl->size+1);
  30.296 -    fl->files[fl->size++] = filename;
  30.297 -}
  30.298 -
  30.299 -static char *
  30.300 -FileList_join(FileList fl, char sep)
  30.301 -{
  30.302 -    int i;
  30.303 -    int size;
  30.304 -    char *path;
  30.305 -    char *p;
  30.306 -    for (i = 0, size = 1; i < fl->size; i++)
  30.307 -        size += strlen(fl->files[i]) + 1;
  30.308 -
  30.309 -    path = JLI_MemAlloc(size);
  30.310 -
  30.311 -    for (i = 0, p = path; i < fl->size; i++) {
  30.312 -        int len = strlen(fl->files[i]);
  30.313 -        if (i > 0) *p++ = sep;
  30.314 -        memcpy(p, fl->files[i], len);
  30.315 -        p += len;
  30.316 -    }
  30.317 -    *p = '\0';
  30.318 -
  30.319 -    return path;
  30.320 -}
  30.321 -
  30.322 -static FileList
  30.323 -FileList_split(const char *path, char sep)
  30.324 -{
  30.325 -    const char *p, *q;
  30.326 -    int len = strlen(path);
  30.327 -    int count;
  30.328 -    FileList fl;
  30.329 -    for (count = 1, p = path; p < path + len; p++)
  30.330 -        count += (*p == sep);
  30.331 -    fl = FileList_new(count);
  30.332 -    for (p = path;;) {
  30.333 -        for (q = p; q <= path + len; q++) {
  30.334 -            if (*q == sep || *q == '\0') {
  30.335 -                FileList_addSubstring(fl, p, q - p);
  30.336 -                if (*q == '\0')
  30.337 -                    return fl;
  30.338 -                p = q + 1;
  30.339 -            }
  30.340 -        }
  30.341 -    }
  30.342 -}
  30.343 -
  30.344 -static int
  30.345 -isJarFileName(const char *filename)
  30.346 -{
  30.347 -    int len = strlen(filename);
  30.348 -    return (len >= 4) &&
  30.349 -        (filename[len - 4] == '.') &&
  30.350 -        (equal(filename + len - 3, "jar") ||
  30.351 -         equal(filename + len - 3, "JAR")) &&
  30.352 -        /* Paranoia: Maybe filename is "DIR:foo.jar" */
  30.353 -        (strchr(filename, PATH_SEPARATOR) == NULL);
  30.354 -}
  30.355 -
  30.356 -static char *
  30.357 -wildcardConcat(const char *wildcard, const char *basename)
  30.358 -{
  30.359 -    int wildlen = strlen(wildcard);
  30.360 -    int baselen = strlen(basename);
  30.361 -    char *filename = (char *) JLI_MemAlloc(wildlen + baselen);
  30.362 -    /* Replace the trailing '*' with basename */
  30.363 -    memcpy(filename, wildcard, wildlen-1);
  30.364 -    memcpy(filename+wildlen-1, basename, baselen+1);
  30.365 -    return filename;
  30.366 -}
  30.367 -
  30.368 -static FileList
  30.369 -wildcardFileList(const char *wildcard)
  30.370 -{
  30.371 -    const char *basename;
  30.372 -    FileList fl = FileList_new(16);
  30.373 -    WildcardIterator it = WildcardIterator_for(wildcard);
  30.374 -    if (it == NULL) {
  30.375 -        FileList_free(fl);
  30.376 -        return NULL;
  30.377 -    }
  30.378 -    while ((basename = WildcardIterator_next(it)) != NULL)
  30.379 -        if (isJarFileName(basename))
  30.380 -            FileList_add(fl, wildcardConcat(wildcard, basename));
  30.381 -    WildcardIterator_close(it);
  30.382 -    return fl;
  30.383 -}
  30.384 -
  30.385 -static int
  30.386 -isWildcard(const char *filename)
  30.387 -{
  30.388 -    int len = strlen(filename);
  30.389 -    return (len > 0) &&
  30.390 -        (filename[len - 1] == '*') &&
  30.391 -        (len == 1 || IS_FILE_SEPARATOR(filename[len - 2])) &&
  30.392 -        (! exists(filename));
  30.393 -}
  30.394 -
  30.395 -static void
  30.396 -FileList_expandWildcards(FileList fl)
  30.397 -{
  30.398 -    int i, j;
  30.399 -    for (i = 0; i < fl->size; i++) {
  30.400 -        if (isWildcard(fl->files[i])) {
  30.401 -            FileList expanded = wildcardFileList(fl->files[i]);
  30.402 -            if (expanded != NULL && expanded->size > 0) {
  30.403 -                JLI_MemFree(fl->files[i]);
  30.404 -                FileList_ensureCapacity(fl, fl->size + expanded->size);
  30.405 -                for (j = fl->size - 1; j >= i+1; j--)
  30.406 -                    fl->files[j+expanded->size-1] = fl->files[j];
  30.407 -                for (j = 0; j < expanded->size; j++)
  30.408 -                    fl->files[i+j] = expanded->files[j];
  30.409 -                i += expanded->size - 1;
  30.410 -                fl->size += expanded->size - 1;
  30.411 -                /* fl expropriates expanded's elements. */
  30.412 -                expanded->size = 0;
  30.413 -            }
  30.414 -            FileList_free(expanded);
  30.415 -        }
  30.416 -    }
  30.417 -}
  30.418 -
  30.419 -const char *
  30.420 -JLI_WildcardExpandClasspath(const char *classpath)
  30.421 -{
  30.422 -    char *expanded;
  30.423 -    FileList fl;
  30.424 -
  30.425 -    if (strchr(classpath, '*') == NULL)
  30.426 -        return classpath;
  30.427 -    fl = FileList_split(classpath, PATH_SEPARATOR);
  30.428 -    FileList_expandWildcards(fl);
  30.429 -    expanded = FileList_join(fl, PATH_SEPARATOR);
  30.430 -    FileList_free(fl);
  30.431 -    if (getenv("_JAVA_LAUNCHER_DEBUG") != 0)
  30.432 -        printf("Expanded wildcards:\n"
  30.433 -               "    before: \"%s\"\n"
  30.434 -               "    after : \"%s\"\n",
  30.435 -               classpath, expanded);
  30.436 -    return expanded;
  30.437 -}
  30.438 -
  30.439 -#ifdef DEBUG_WILDCARD
  30.440 -static void
  30.441 -wildcardExpandArgv(const char ***argv)
  30.442 -{
  30.443 -    int i;
  30.444 -    for (i = 0; (*argv)[i]; i++) {
  30.445 -        if (equal((*argv)[i], "-cp") ||
  30.446 -            equal((*argv)[i], "-classpath")) {
  30.447 -            i++;
  30.448 -            (*argv)[i] = wildcardExpandClasspath((*argv)[i]);
  30.449 -        }
  30.450 -    }
  30.451 -}
  30.452 -
  30.453 -static void
  30.454 -debugPrintArgv(char *argv[])
  30.455 -{
  30.456 -    int i;
  30.457 -    putchar('[');
  30.458 -    for (i = 0; argv[i]; i++) {
  30.459 -        if (i > 0) printf(", ");
  30.460 -        printf("\"%s\"", argv[i]);
  30.461 -    }
  30.462 -    printf("]\n");
  30.463 -}
  30.464 -
  30.465 -int
  30.466 -main(int argc, char *argv[])
  30.467 -{
  30.468 -    argv[0] = "java";
  30.469 -    wildcardExpandArgv((const char***)&argv);
  30.470 -    debugPrintArgv(argv);
  30.471 -    /* execvp("java", argv); */
  30.472 -    return 0;
  30.473 -}
  30.474 -#endif /* DEBUG_WILDCARD */
  30.475 -
  30.476 -/* Cute little perl prototype implementation....
  30.477 -
  30.478 -my $sep = ($^O =~ /^(Windows|cygwin)/) ? ";" : ":";
  30.479 -
  30.480 -sub expand($) {
  30.481 -  opendir DIR, $_[0] or return $_[0];
  30.482 -  join $sep, map {"$_[0]/$_"} grep {/\.(jar|JAR)$/} readdir DIR;
  30.483 -}
  30.484 -
  30.485 -sub munge($) {
  30.486 -  join $sep,
  30.487 -    map {(! -r $_ and s/[\/\\]+\*$//) ? expand $_ : $_} split $sep, $_[0];
  30.488 -}
  30.489 -
  30.490 -for (my $i = 0; $i < @ARGV - 1; $i++) {
  30.491 -  $ARGV[$i+1] = munge $ARGV[$i+1] if $ARGV[$i] =~ /^-c(p|lasspath)$/;
  30.492 -}
  30.493 -
  30.494 -$ENV{CLASSPATH} = munge $ENV{CLASSPATH} if exists $ENV{CLASSPATH};
  30.495 -@ARGV = ("java", @ARGV);
  30.496 -print "@ARGV\n";
  30.497 -exec @ARGV;
  30.498 -
  30.499 -*/
    31.1 --- a/src/share/tools/launcher/wildcard.h	Tue May 14 17:33:07 2013 +0000
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,34 +0,0 @@
    31.4 -/*
    31.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    31.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.7 - *
    31.8 - * This code is free software; you can redistribute it and/or modify it
    31.9 - * under the terms of the GNU General Public License version 2 only, as
   31.10 - * published by the Free Software Foundation.
   31.11 - *
   31.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   31.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   31.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   31.15 - * version 2 for more details (a copy is included in the LICENSE file that
   31.16 - * accompanied this code).
   31.17 - *
   31.18 - * You should have received a copy of the GNU General Public License version
   31.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   31.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   31.21 - *
   31.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   31.23 - * or visit www.oracle.com if you need additional information or have any
   31.24 - * questions.
   31.25 - *
   31.26 - */
   31.27 -
   31.28 -#ifndef WILDCARD_H_
   31.29 -#define WILDCARD_H_
   31.30 -
   31.31 -#ifdef EXPAND_CLASSPATH_WILDCARDS
   31.32 -const char *JLI_WildcardExpandClasspath(const char *classpath);
   31.33 -#else
   31.34 -#define JLI_WildcardExpandClasspath(s) (s)
   31.35 -#endif
   31.36 -
   31.37 -#endif /* include guard */
    32.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp	Tue May 14 17:33:07 2013 +0000
    32.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp	Thu May 16 13:47:55 2013 -0700
    32.3 @@ -211,13 +211,42 @@
    32.4  
    32.5  // ------------------------------------------------------------------
    32.6  // ciInstanceKlass::uses_default_loader
    32.7 -bool ciInstanceKlass::uses_default_loader() {
    32.8 +bool ciInstanceKlass::uses_default_loader() const {
    32.9    // Note:  We do not need to resolve the handle or enter the VM
   32.10    // in order to test null-ness.
   32.11    return _loader == NULL;
   32.12  }
   32.13  
   32.14  // ------------------------------------------------------------------
   32.15 +
   32.16 +/**
   32.17 + * Return basic type of boxed value for box klass or T_OBJECT if not.
   32.18 + */
   32.19 +BasicType ciInstanceKlass::box_klass_type() const {
   32.20 +  if (uses_default_loader() && is_loaded()) {
   32.21 +    return SystemDictionary::box_klass_type(get_Klass());
   32.22 +  } else {
   32.23 +    return T_OBJECT;
   32.24 +  }
   32.25 +}
   32.26 +
   32.27 +/**
   32.28 + * Is this boxing klass?
   32.29 + */
   32.30 +bool ciInstanceKlass::is_box_klass() const {
   32.31 +  return is_java_primitive(box_klass_type());
   32.32 +}
   32.33 +
   32.34 +/**
   32.35 + *  Is this boxed value offset?
   32.36 + */
   32.37 +bool ciInstanceKlass::is_boxed_value_offset(int offset) const {
   32.38 +  BasicType bt = box_klass_type();
   32.39 +  return is_java_primitive(bt) &&
   32.40 +         (offset == java_lang_boxing_object::value_offset_in_bytes(bt));
   32.41 +}
   32.42 +
   32.43 +// ------------------------------------------------------------------
   32.44  // ciInstanceKlass::is_in_package
   32.45  //
   32.46  // Is this klass in the given package?
    33.1 --- a/src/share/vm/ci/ciInstanceKlass.hpp	Tue May 14 17:33:07 2013 +0000
    33.2 +++ b/src/share/vm/ci/ciInstanceKlass.hpp	Thu May 16 13:47:55 2013 -0700
    33.3 @@ -217,10 +217,14 @@
    33.4    ciInstanceKlass* implementor();
    33.5  
    33.6    // Is the defining class loader of this class the default loader?
    33.7 -  bool uses_default_loader();
    33.8 +  bool uses_default_loader() const;
    33.9  
   33.10    bool is_java_lang_Object() const;
   33.11  
   33.12 +  BasicType box_klass_type() const;
   33.13 +  bool is_box_klass() const;
   33.14 +  bool is_boxed_value_offset(int offset) const;
   33.15 +
   33.16    // Is this klass in the given package?
   33.17    bool is_in_package(const char* packagename) {
   33.18      return is_in_package(packagename, (int) strlen(packagename));
    34.1 --- a/src/share/vm/ci/ciMethod.cpp	Tue May 14 17:33:07 2013 +0000
    34.2 +++ b/src/share/vm/ci/ciMethod.cpp	Thu May 16 13:47:55 2013 -0700
    34.3 @@ -1179,6 +1179,44 @@
    34.4  bool ciMethod::is_accessor    () const {         FETCH_FLAG_FROM_VM(is_accessor); }
    34.5  bool ciMethod::is_initializer () const {         FETCH_FLAG_FROM_VM(is_initializer); }
    34.6  
    34.7 +bool ciMethod::is_boxing_method() const {
    34.8 +  if (holder()->is_box_klass()) {
    34.9 +    switch (intrinsic_id()) {
   34.10 +      case vmIntrinsics::_Boolean_valueOf:
   34.11 +      case vmIntrinsics::_Byte_valueOf:
   34.12 +      case vmIntrinsics::_Character_valueOf:
   34.13 +      case vmIntrinsics::_Short_valueOf:
   34.14 +      case vmIntrinsics::_Integer_valueOf:
   34.15 +      case vmIntrinsics::_Long_valueOf:
   34.16 +      case vmIntrinsics::_Float_valueOf:
   34.17 +      case vmIntrinsics::_Double_valueOf:
   34.18 +        return true;
   34.19 +      default:
   34.20 +        return false;
   34.21 +    }
   34.22 +  }
   34.23 +  return false;
   34.24 +}
   34.25 +
   34.26 +bool ciMethod::is_unboxing_method() const {
   34.27 +  if (holder()->is_box_klass()) {
   34.28 +    switch (intrinsic_id()) {
   34.29 +      case vmIntrinsics::_booleanValue:
   34.30 +      case vmIntrinsics::_byteValue:
   34.31 +      case vmIntrinsics::_charValue:
   34.32 +      case vmIntrinsics::_shortValue:
   34.33 +      case vmIntrinsics::_intValue:
   34.34 +      case vmIntrinsics::_longValue:
   34.35 +      case vmIntrinsics::_floatValue:
   34.36 +      case vmIntrinsics::_doubleValue:
   34.37 +        return true;
   34.38 +      default:
   34.39 +        return false;
   34.40 +    }
   34.41 +  }
   34.42 +  return false;
   34.43 +}
   34.44 +
   34.45  BCEscapeAnalyzer  *ciMethod::get_bcea() {
   34.46  #ifdef COMPILER2
   34.47    if (_bcea == NULL) {
    35.1 --- a/src/share/vm/ci/ciMethod.hpp	Tue May 14 17:33:07 2013 +0000
    35.2 +++ b/src/share/vm/ci/ciMethod.hpp	Thu May 16 13:47:55 2013 -0700
    35.3 @@ -298,6 +298,8 @@
    35.4    bool is_initializer () const;
    35.5    bool can_be_statically_bound() const           { return _can_be_statically_bound; }
    35.6    void dump_replay_data(outputStream* st);
    35.7 +  bool is_boxing_method() const;
    35.8 +  bool is_unboxing_method() const;
    35.9  
   35.10    // Print the bytecodes of this method.
   35.11    void print_codes_on(outputStream* st);
    36.1 --- a/src/share/vm/classfile/classFileParser.cpp	Tue May 14 17:33:07 2013 +0000
    36.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Thu May 16 13:47:55 2013 -0700
    36.3 @@ -3028,7 +3028,7 @@
    36.4  }
    36.5  
    36.6  
    36.7 -#ifndef PRODUCT
    36.8 +#ifdef ASSERT
    36.9  static void parseAndPrintGenericSignatures(
   36.10      instanceKlassHandle this_klass, TRAPS) {
   36.11    assert(ParseAllGenericSignatures == true, "Shouldn't call otherwise");
   36.12 @@ -3053,7 +3053,7 @@
   36.13      }
   36.14    }
   36.15  }
   36.16 -#endif // ndef PRODUCT
   36.17 +#endif // def ASSERT
   36.18  
   36.19  
   36.20  instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index,
    37.1 --- a/src/share/vm/classfile/vmSymbols.cpp	Tue May 14 17:33:07 2013 +0000
    37.2 +++ b/src/share/vm/classfile/vmSymbols.cpp	Thu May 16 13:47:55 2013 -0700
    37.3 @@ -49,7 +49,7 @@
    37.4    }
    37.5  }
    37.6  
    37.7 -#ifndef PRODUCT
    37.8 +#ifdef ASSERT
    37.9  #define VM_SYMBOL_ENUM_NAME_BODY(name, string) #name "\0"
   37.10  static const char* vm_symbol_enum_names =
   37.11    VM_SYMBOLS_DO(VM_SYMBOL_ENUM_NAME_BODY, VM_ALIAS_IGNORE)
   37.12 @@ -64,7 +64,7 @@
   37.13    }
   37.14    return string;
   37.15  }
   37.16 -#endif //PRODUCT
   37.17 +#endif //ASSERT
   37.18  
   37.19  // Put all the VM symbol strings in one place.
   37.20  // Makes for a more compact libjvm.
    38.1 --- a/src/share/vm/classfile/vmSymbols.hpp	Tue May 14 17:33:07 2013 +0000
    38.2 +++ b/src/share/vm/classfile/vmSymbols.hpp	Thu May 16 13:47:55 2013 -0700
    38.3 @@ -68,7 +68,7 @@
    38.4    template(java_lang_Float,                           "java/lang/Float")                          \
    38.5    template(java_lang_Double,                          "java/lang/Double")                         \
    38.6    template(java_lang_Byte,                            "java/lang/Byte")                           \
    38.7 -  template(java_lang_Byte_Cache,                      "java/lang/Byte$ByteCache")                 \
    38.8 +  template(java_lang_Byte_ByteCache,                  "java/lang/Byte$ByteCache")                 \
    38.9    template(java_lang_Short,                           "java/lang/Short")                          \
   38.10    template(java_lang_Short_ShortCache,                "java/lang/Short$ShortCache")               \
   38.11    template(java_lang_Integer,                         "java/lang/Integer")                        \
    39.1 --- a/src/share/vm/compiler/compileBroker.cpp	Tue May 14 17:33:07 2013 +0000
    39.2 +++ b/src/share/vm/compiler/compileBroker.cpp	Thu May 16 13:47:55 2013 -0700
    39.3 @@ -1854,8 +1854,10 @@
    39.4      tty->print("%7d ", (int) tty->time_stamp().milliseconds());  // print timestamp
    39.5      tty->print("%4d ", compile_id);    // print compilation number
    39.6      tty->print("%s ", (is_osr ? "%" : " "));
    39.7 -    int code_size = (task->code() == NULL) ? 0 : task->code()->total_size();
    39.8 -    tty->print_cr("size: %d time: %d inlined: %d bytes", code_size, (int)time.milliseconds(), task->num_inlined_bytecodes());
    39.9 +    if (task->code() != NULL) {
   39.10 +      tty->print("size: %d(%d) ", task->code()->total_size(), task->code()->insts_size());
   39.11 +    }
   39.12 +    tty->print_cr("time: %d inlined: %d bytes", (int)time.milliseconds(), task->num_inlined_bytecodes());
   39.13    }
   39.14  
   39.15    if (PrintCodeCacheOnCompilation)
    40.1 --- a/src/share/vm/oops/method.cpp	Tue May 14 17:33:07 2013 +0000
    40.2 +++ b/src/share/vm/oops/method.cpp	Thu May 16 13:47:55 2013 -0700
    40.3 @@ -832,7 +832,9 @@
    40.4    assert(entry != NULL, "interpreter entry must be non-null");
    40.5    // Sets both _i2i_entry and _from_interpreted_entry
    40.6    set_interpreter_entry(entry);
    40.7 -  if (is_native() && !is_method_handle_intrinsic()) {
    40.8 +
    40.9 +  // Don't overwrite already registered native entries.
   40.10 +  if (is_native() && !has_native_function()) {
   40.11      set_native_function(
   40.12        SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
   40.13        !native_bind_event_is_interesting);
    41.1 --- a/src/share/vm/opto/bytecodeInfo.cpp	Tue May 14 17:33:07 2013 +0000
    41.2 +++ b/src/share/vm/opto/bytecodeInfo.cpp	Thu May 16 13:47:55 2013 -0700
    41.3 @@ -85,16 +85,35 @@
    41.4    assert(!UseOldInlining, "do not use for old stuff");
    41.5  }
    41.6  
    41.7 +/**
    41.8 + *  Return true when EA is ON and a java constructor is called or
    41.9 + *  a super constructor is called from an inlined java constructor.
   41.10 + *  Also return true for boxing methods.
   41.11 + */
   41.12  static bool is_init_with_ea(ciMethod* callee_method,
   41.13                              ciMethod* caller_method, Compile* C) {
   41.14 -  // True when EA is ON and a java constructor is called or
   41.15 -  // a super constructor is called from an inlined java constructor.
   41.16 -  return C->do_escape_analysis() && EliminateAllocations &&
   41.17 -         ( callee_method->is_initializer() ||
   41.18 -           (caller_method->is_initializer() &&
   41.19 -            caller_method != C->method() &&
   41.20 -            caller_method->holder()->is_subclass_of(callee_method->holder()))
   41.21 -         );
   41.22 +  if (!C->do_escape_analysis() || !EliminateAllocations) {
   41.23 +    return false; // EA is off
   41.24 +  }
   41.25 +  if (callee_method->is_initializer()) {
   41.26 +    return true; // constuctor
   41.27 +  }
   41.28 +  if (caller_method->is_initializer() &&
   41.29 +      caller_method != C->method() &&
   41.30 +      caller_method->holder()->is_subclass_of(callee_method->holder())) {
   41.31 +    return true; // super constructor is called from inlined constructor
   41.32 +  }
   41.33 +  if (C->eliminate_boxing() && callee_method->is_boxing_method()) {
   41.34 +    return true;
   41.35 +  }
   41.36 +  return false;
   41.37 +}
   41.38 +
   41.39 +/**
   41.40 + *  Force inlining unboxing accessor.
   41.41 + */
   41.42 +static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
   41.43 +  return C->eliminate_boxing() && callee_method->is_unboxing_method();
   41.44  }
   41.45  
   41.46  // positive filter: should callee be inlined?
   41.47 @@ -144,6 +163,7 @@
   41.48    // bump the max size if the call is frequent
   41.49    if ((freq >= InlineFrequencyRatio) ||
   41.50        (call_site_count >= InlineFrequencyCount) ||
   41.51 +      is_unboxing_method(callee_method, C) ||
   41.52        is_init_with_ea(callee_method, caller_method, C)) {
   41.53  
   41.54      max_inline_size = C->freq_inline_size();
   41.55 @@ -237,8 +257,25 @@
   41.56      return false;
   41.57    }
   41.58  
   41.59 +  if (callee_method->should_not_inline()) {
   41.60 +    set_msg("disallowed by CompilerOracle");
   41.61 +    return true;
   41.62 +  }
   41.63 +
   41.64 +#ifndef PRODUCT
   41.65 +  if (ciReplay::should_not_inline(callee_method)) {
   41.66 +    set_msg("disallowed by ciReplay");
   41.67 +    return true;
   41.68 +  }
   41.69 +#endif
   41.70 +
   41.71    // Now perform checks which are heuristic
   41.72  
   41.73 +  if (is_unboxing_method(callee_method, C)) {
   41.74 +    // Inline unboxing methods.
   41.75 +    return false;
   41.76 +  }
   41.77 +
   41.78    if (!callee_method->force_inline()) {
   41.79      if (callee_method->has_compiled_code() &&
   41.80          callee_method->instructions_size() > InlineSmallCode) {
   41.81 @@ -260,18 +297,6 @@
   41.82      }
   41.83    }
   41.84  
   41.85 -  if (callee_method->should_not_inline()) {
   41.86 -    set_msg("disallowed by CompilerOracle");
   41.87 -    return true;
   41.88 -  }
   41.89 -
   41.90 -#ifndef PRODUCT
   41.91 -  if (ciReplay::should_not_inline(callee_method)) {
   41.92 -    set_msg("disallowed by ciReplay");
   41.93 -    return true;
   41.94 -  }
   41.95 -#endif
   41.96 -
   41.97    if (UseStringCache) {
   41.98      // Do not inline StringCache::profile() method used only at the beginning.
   41.99      if (callee_method->name() == ciSymbol::profile_name() &&
  41.100 @@ -296,9 +321,8 @@
  41.101      }
  41.102  
  41.103      if (is_init_with_ea(callee_method, caller_method, C)) {
  41.104 -
  41.105        // Escape Analysis: inline all executed constructors
  41.106 -
  41.107 +      return false;
  41.108      } else if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold,
  41.109                                                             CompileThreshold >> 1))) {
  41.110        set_msg("executed < MinInliningThreshold times");
    42.1 --- a/src/share/vm/opto/c2_globals.hpp	Tue May 14 17:33:07 2013 +0000
    42.2 +++ b/src/share/vm/opto/c2_globals.hpp	Thu May 16 13:47:55 2013 -0700
    42.3 @@ -442,12 +442,15 @@
    42.4    notproduct(bool, PrintEliminateLocks, false,                              \
    42.5            "Print out when locks are eliminated")                            \
    42.6                                                                              \
    42.7 -  diagnostic(bool, EliminateAutoBox, false,                                 \
    42.8 -          "Private flag to control optimizations for autobox elimination")  \
    42.9 +  product(bool, EliminateAutoBox, true,                                     \
   42.10 +          "Control optimizations for autobox elimination")                  \
   42.11                                                                              \
   42.12    product(intx, AutoBoxCacheMax, 128,                                       \
   42.13            "Sets max value cached by the java.lang.Integer autobox cache")   \
   42.14                                                                              \
   42.15 +  experimental(bool, AggressiveUnboxing, false,                             \
   42.16 +          "Control optimizations for aggressive boxing elimination")        \
   42.17 +                                                                            \
   42.18    product(bool, DoEscapeAnalysis, true,                                     \
   42.19            "Perform escape analysis")                                        \
   42.20                                                                              \
    43.1 --- a/src/share/vm/opto/c2compiler.cpp	Tue May 14 17:33:07 2013 +0000
    43.2 +++ b/src/share/vm/opto/c2compiler.cpp	Thu May 16 13:47:55 2013 -0700
    43.3 @@ -125,9 +125,10 @@
    43.4    bool subsume_loads = SubsumeLoads;
    43.5    bool do_escape_analysis = DoEscapeAnalysis &&
    43.6      !env->jvmti_can_access_local_variables();
    43.7 +  bool eliminate_boxing = EliminateAutoBox;
    43.8    while (!env->failing()) {
    43.9      // Attempt to compile while subsuming loads into machine instructions.
   43.10 -    Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
   43.11 +    Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
   43.12  
   43.13  
   43.14      // Check result and retry if appropriate.
   43.15 @@ -142,6 +143,12 @@
   43.16          do_escape_analysis = false;
   43.17          continue;  // retry
   43.18        }
   43.19 +      if (C.has_boxed_value()) {
   43.20 +        // Recompile without boxing elimination regardless failure reason.
   43.21 +        assert(eliminate_boxing, "must make progress");
   43.22 +        eliminate_boxing = false;
   43.23 +        continue;  // retry
   43.24 +      }
   43.25        // Pass any other failure reason up to the ciEnv.
   43.26        // Note that serious, irreversible failures are already logged
   43.27        // on the ciEnv via env->record_method_not_compilable().
    44.1 --- a/src/share/vm/opto/callGenerator.cpp	Tue May 14 17:33:07 2013 +0000
    44.2 +++ b/src/share/vm/opto/callGenerator.cpp	Thu May 16 13:47:55 2013 -0700
    44.3 @@ -134,7 +134,7 @@
    44.4      kit.C->log()->elem("direct_call bci='%d'", jvms->bci());
    44.5    }
    44.6  
    44.7 -  CallStaticJavaNode *call = new (kit.C) CallStaticJavaNode(tf(), target, method(), kit.bci());
    44.8 +  CallStaticJavaNode *call = new (kit.C) CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci());
    44.9    _call_node = call;  // Save the call node in case we need it later
   44.10    if (!is_static) {
   44.11      // Make an explicit receiver null_check as part of this call.
   44.12 @@ -304,29 +304,34 @@
   44.13  
   44.14  void LateInlineCallGenerator::do_late_inline() {
   44.15    // Can't inline it
   44.16 -  if (call_node() == NULL || call_node()->outcnt() == 0 ||
   44.17 -      call_node()->in(0) == NULL || call_node()->in(0)->is_top()) {
   44.18 +  CallStaticJavaNode* call = call_node();
   44.19 +  if (call == NULL || call->outcnt() == 0 ||
   44.20 +      call->in(0) == NULL || call->in(0)->is_top()) {
   44.21      return;
   44.22    }
   44.23  
   44.24 -  const TypeTuple *r = call_node()->tf()->domain();
   44.25 +  const TypeTuple *r = call->tf()->domain();
   44.26    for (int i1 = 0; i1 < method()->arg_size(); i1++) {
   44.27 -    if (call_node()->in(TypeFunc::Parms + i1)->is_top() && r->field_at(TypeFunc::Parms + i1) != Type::HALF) {
   44.28 +    if (call->in(TypeFunc::Parms + i1)->is_top() && r->field_at(TypeFunc::Parms + i1) != Type::HALF) {
   44.29        assert(Compile::current()->inlining_incrementally(), "shouldn't happen during parsing");
   44.30        return;
   44.31      }
   44.32    }
   44.33  
   44.34 -  if (call_node()->in(TypeFunc::Memory)->is_top()) {
   44.35 +  if (call->in(TypeFunc::Memory)->is_top()) {
   44.36      assert(Compile::current()->inlining_incrementally(), "shouldn't happen during parsing");
   44.37      return;
   44.38    }
   44.39  
   44.40 -  CallStaticJavaNode* call = call_node();
   44.41 +  Compile* C = Compile::current();
   44.42 +  // Remove inlined methods from Compiler's lists.
   44.43 +  if (call->is_macro()) {
   44.44 +    C->remove_macro_node(call);
   44.45 +  }
   44.46  
   44.47    // Make a clone of the JVMState that appropriate to use for driving a parse
   44.48 -  Compile* C = Compile::current();
   44.49 -  JVMState* jvms     = call->jvms()->clone_shallow(C);
   44.50 +  JVMState* old_jvms = call->jvms();
   44.51 +  JVMState* jvms = old_jvms->clone_shallow(C);
   44.52    uint size = call->req();
   44.53    SafePointNode* map = new (C) SafePointNode(size, jvms);
   44.54    for (uint i1 = 0; i1 < size; i1++) {
   44.55 @@ -340,16 +345,23 @@
   44.56      map->set_req(TypeFunc::Memory, mem);
   44.57    }
   44.58  
   44.59 -  // Make enough space for the expression stack and transfer the incoming arguments
   44.60 -  int nargs    = method()->arg_size();
   44.61 +  uint nargs = method()->arg_size();
   44.62 +  // blow away old call arguments
   44.63 +  Node* top = C->top();
   44.64 +  for (uint i1 = 0; i1 < nargs; i1++) {
   44.65 +    map->set_req(TypeFunc::Parms + i1, top);
   44.66 +  }
   44.67    jvms->set_map(map);
   44.68 +
   44.69 +  // Make enough space in the expression stack to transfer
   44.70 +  // the incoming arguments and return value.
   44.71    map->ensure_stack(jvms, jvms->method()->max_stack());
   44.72 -  if (nargs > 0) {
   44.73 -    for (int i1 = 0; i1 < nargs; i1++) {
   44.74 -      map->set_req(i1 + jvms->argoff(), call->in(TypeFunc::Parms + i1));
   44.75 -    }
   44.76 +  for (uint i1 = 0; i1 < nargs; i1++) {
   44.77 +    map->set_argument(jvms, i1, call->in(TypeFunc::Parms + i1));
   44.78    }
   44.79  
   44.80 +  // This check is done here because for_method_handle_inline() method
   44.81 +  // needs jvms for inlined state.
   44.82    if (!do_late_inline_check(jvms)) {
   44.83      map->disconnect_inputs(NULL, C);
   44.84      return;
   44.85 @@ -480,6 +492,26 @@
   44.86    return new LateInlineStringCallGenerator(method, inline_cg);
   44.87  }
   44.88  
   44.89 +class LateInlineBoxingCallGenerator : public LateInlineCallGenerator {
   44.90 +
   44.91 + public:
   44.92 +  LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
   44.93 +    LateInlineCallGenerator(method, inline_cg) {}
   44.94 +
   44.95 +  virtual JVMState* generate(JVMState* jvms) {
   44.96 +    Compile *C = Compile::current();
   44.97 +    C->print_inlining_skip(this);
   44.98 +
   44.99 +    C->add_boxing_late_inline(this);
  44.100 +
  44.101 +    JVMState* new_jvms =  DirectCallGenerator::generate(jvms);
  44.102 +    return new_jvms;
  44.103 +  }
  44.104 +};
  44.105 +
  44.106 +CallGenerator* CallGenerator::for_boxing_late_inline(ciMethod* method, CallGenerator* inline_cg) {
  44.107 +  return new LateInlineBoxingCallGenerator(method, inline_cg);
  44.108 +}
  44.109  
  44.110  //---------------------------WarmCallGenerator--------------------------------
  44.111  // Internal class which handles initial deferral of inlining decisions.
    45.1 --- a/src/share/vm/opto/callGenerator.hpp	Tue May 14 17:33:07 2013 +0000
    45.2 +++ b/src/share/vm/opto/callGenerator.hpp	Thu May 16 13:47:55 2013 -0700
    45.3 @@ -125,6 +125,7 @@
    45.4    static CallGenerator* for_late_inline(ciMethod* m, CallGenerator* inline_cg);
    45.5    static CallGenerator* for_mh_late_inline(ciMethod* caller, ciMethod* callee, bool input_not_const);
    45.6    static CallGenerator* for_string_late_inline(ciMethod* m, CallGenerator* inline_cg);
    45.7 +  static CallGenerator* for_boxing_late_inline(ciMethod* m, CallGenerator* inline_cg);
    45.8  
    45.9    // How to make a call but defer the decision whether to inline or not.
   45.10    static CallGenerator* for_warm_call(WarmCallInfo* ci,
    46.1 --- a/src/share/vm/opto/callnode.cpp	Tue May 14 17:33:07 2013 +0000
    46.2 +++ b/src/share/vm/opto/callnode.cpp	Thu May 16 13:47:55 2013 -0700
    46.3 @@ -523,7 +523,9 @@
    46.4  
    46.5  
    46.6  void JVMState::dump_on(outputStream* st) const {
    46.7 -  if (_map && !((uintptr_t)_map & 1)) {
    46.8 +  bool print_map = _map && !((uintptr_t)_map & 1) &&
    46.9 +                  ((caller() == NULL) || (caller()->map() != _map));
   46.10 +  if (print_map) {
   46.11      if (_map->len() > _map->req()) {  // _map->has_exceptions()
   46.12        Node* ex = _map->in(_map->req());  // _map->next_exception()
   46.13        // skip the first one; it's already being printed
   46.14 @@ -532,7 +534,10 @@
   46.15          ex->dump(1);
   46.16        }
   46.17      }
   46.18 -    _map->dump(2);
   46.19 +    _map->dump(Verbose ? 2 : 1);
   46.20 +  }
   46.21 +  if (caller() != NULL) {
   46.22 +    caller()->dump_on(st);
   46.23    }
   46.24    st->print("JVMS depth=%d loc=%d stk=%d arg=%d mon=%d scalar=%d end=%d mondepth=%d sp=%d bci=%d reexecute=%s method=",
   46.25               depth(), locoff(), stkoff(), argoff(), monoff(), scloff(), endoff(), monitor_depth(), sp(), bci(), should_reexecute()?"true":"false");
   46.26 @@ -546,9 +551,6 @@
   46.27        _method->print_codes_on(bci(), bci()+1, st);
   46.28      }
   46.29    }
   46.30 -  if (caller() != NULL) {
   46.31 -    caller()->dump_on(st);
   46.32 -  }
   46.33  }
   46.34  
   46.35  // Extra way to dump a jvms from the debugger,
   46.36 @@ -584,6 +586,15 @@
   46.37    return n;
   46.38  }
   46.39  
   46.40 +/**
   46.41 + * Reset map for all callers
   46.42 + */
   46.43 +void JVMState::set_map_deep(SafePointNode* map) {
   46.44 +  for (JVMState* p = this; p->_caller != NULL; p = p->_caller) {
   46.45 +    p->set_map(map);
   46.46 +  }
   46.47 +}
   46.48 +
   46.49  //=============================================================================
   46.50  uint CallNode::cmp( const Node &n ) const
   46.51  { return _tf == ((CallNode&)n)._tf && _jvms == ((CallNode&)n)._jvms; }
   46.52 @@ -663,17 +674,49 @@
   46.53  // Determine whether the call could modify the field of the specified
   46.54  // instance at the specified offset.
   46.55  //
   46.56 -bool CallNode::may_modify(const TypePtr *addr_t, PhaseTransform *phase) {
   46.57 -  const TypeOopPtr *adrInst_t  = addr_t->isa_oopptr();
   46.58 -
   46.59 -  // If not an OopPtr or not an instance type, assume the worst.
   46.60 -  // Note: currently this method is called only for instance types.
   46.61 -  if (adrInst_t == NULL || !adrInst_t->is_known_instance()) {
   46.62 -    return true;
   46.63 +bool CallNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) {
   46.64 +  assert((t_oop != NULL), "sanity");
   46.65 +  if (t_oop->is_known_instance()) {
   46.66 +    // The instance_id is set only for scalar-replaceable allocations which
   46.67 +    // are not passed as arguments according to Escape Analysis.
   46.68 +    return false;
   46.69    }
   46.70 -  // The instance_id is set only for scalar-replaceable allocations which
   46.71 -  // are not passed as arguments according to Escape Analysis.
   46.72 -  return false;
   46.73 +  if (t_oop->is_ptr_to_boxed_value()) {
   46.74 +    ciKlass* boxing_klass = t_oop->klass();
   46.75 +    if (is_CallStaticJava() && as_CallStaticJava()->is_boxing_method()) {
   46.76 +      // Skip unrelated boxing methods.
   46.77 +      Node* proj = proj_out(TypeFunc::Parms);
   46.78 +      if ((proj == NULL) || (phase->type(proj)->is_instptr()->klass() != boxing_klass)) {
   46.79 +        return false;
   46.80 +      }
   46.81 +    }
   46.82 +    if (is_CallJava() && as_CallJava()->method() != NULL) {
   46.83 +      ciMethod* meth = as_CallJava()->method();
   46.84 +      if (meth->is_accessor()) {
   46.85 +        return false;
   46.86 +      }
   46.87 +      // May modify (by reflection) if an boxing object is passed
   46.88 +      // as argument or returned.
   46.89 +      if (returns_pointer() && (proj_out(TypeFunc::Parms) != NULL)) {
   46.90 +        Node* proj = proj_out(TypeFunc::Parms);
   46.91 +        const TypeInstPtr* inst_t = phase->type(proj)->isa_instptr();
   46.92 +        if ((inst_t != NULL) && (!inst_t->klass_is_exact() ||
   46.93 +                                 (inst_t->klass() == boxing_klass))) {
   46.94 +          return true;
   46.95 +        }
   46.96 +      }
   46.97 +      const TypeTuple* d = tf()->domain();
   46.98 +      for (uint i = TypeFunc::Parms; i < d->cnt(); i++) {
   46.99 +        const TypeInstPtr* inst_t = d->field_at(i)->isa_instptr();
  46.100 +        if ((inst_t != NULL) && (!inst_t->klass_is_exact() ||
  46.101 +                                 (inst_t->klass() == boxing_klass))) {
  46.102 +          return true;
  46.103 +        }
  46.104 +      }
  46.105 +      return false;
  46.106 +    }
  46.107 +  }
  46.108 +  return true;
  46.109  }
  46.110  
  46.111  // Does this call have a direct reference to n other than debug information?
  46.112 @@ -1020,6 +1063,7 @@
  46.113    int scloff = jvms->scloff();
  46.114    int endoff = jvms->endoff();
  46.115    assert(endoff == (int)req(), "no other states or debug info after me");
  46.116 +  assert(jvms->scl_size() == 0, "parsed code should not have scalar objects");
  46.117    Node* top = Compile::current()->top();
  46.118    for (uint i = 0; i < grow_by; i++) {
  46.119      ins_req(monoff, top);
  46.120 @@ -1035,6 +1079,7 @@
  46.121    const int MonitorEdges = 2;
  46.122    assert(JVMState::logMonitorEdges == exact_log2(MonitorEdges), "correct MonitorEdges");
  46.123    assert(req() == jvms()->endoff(), "correct sizing");
  46.124 +  assert((jvms()->scl_size() == 0), "parsed code should not have scalar objects");
  46.125    int nextmon = jvms()->scloff();
  46.126    if (GenerateSynchronizationCode) {
  46.127      add_req(lock->box_node());
  46.128 @@ -1050,6 +1095,7 @@
  46.129  
  46.130  void SafePointNode::pop_monitor() {
  46.131    // Delete last monitor from debug info
  46.132 +  assert((jvms()->scl_size() == 0), "parsed code should not have scalar objects");
  46.133    debug_only(int num_before_pop = jvms()->nof_monitors());
  46.134    const int MonitorEdges = (1<<JVMState::logMonitorEdges);
  46.135    int scloff = jvms()->scloff();
  46.136 @@ -1154,6 +1200,7 @@
  46.137    init_class_id(Class_Allocate);
  46.138    init_flags(Flag_is_macro);
  46.139    _is_scalar_replaceable = false;
  46.140 +  _is_non_escaping = false;
  46.141    Node *topnode = C->top();
  46.142  
  46.143    init_req( TypeFunc::Control  , ctrl );
  46.144 @@ -1169,8 +1216,6 @@
  46.145  }
  46.146  
  46.147  //=============================================================================
  46.148 -uint AllocateArrayNode::size_of() const { return sizeof(*this); }
  46.149 -
  46.150  Node* AllocateArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) {
  46.151    if (remove_dead_region(phase, can_reshape))  return this;
  46.152    // Don't bother trying to transform a dead node
  46.153 @@ -1235,6 +1280,8 @@
  46.154        //   - the narrow_length is 0
  46.155        //   - the narrow_length is not wider than length
  46.156        assert(narrow_length_type == TypeInt::ZERO ||
  46.157 +             length_type->is_con() && narrow_length_type->is_con() &&
  46.158 +                (narrow_length_type->_hi <= length_type->_lo) ||
  46.159               (narrow_length_type->_hi <= length_type->_hi &&
  46.160                narrow_length_type->_lo >= length_type->_lo),
  46.161               "narrow type must be narrower than length type");
    47.1 --- a/src/share/vm/opto/callnode.hpp	Tue May 14 17:33:07 2013 +0000
    47.2 +++ b/src/share/vm/opto/callnode.hpp	Thu May 16 13:47:55 2013 -0700
    47.3 @@ -49,6 +49,7 @@
    47.4  class         CallLeafNoFPNode;
    47.5  class     AllocateNode;
    47.6  class       AllocateArrayNode;
    47.7 +class     BoxLockNode;
    47.8  class     LockNode;
    47.9  class     UnlockNode;
   47.10  class JVMState;
   47.11 @@ -235,7 +236,6 @@
   47.12  
   47.13    int            loc_size() const { return stkoff() - locoff(); }
   47.14    int            stk_size() const { return monoff() - stkoff(); }
   47.15 -  int            arg_size() const { return monoff() - argoff(); }
   47.16    int            mon_size() const { return scloff() - monoff(); }
   47.17    int            scl_size() const { return endoff() - scloff(); }
   47.18  
   47.19 @@ -298,6 +298,7 @@
   47.20    // Miscellaneous utility functions
   47.21    JVMState* clone_deep(Compile* C) const;    // recursively clones caller chain
   47.22    JVMState* clone_shallow(Compile* C) const; // retains uncloned caller
   47.23 +  void      set_map_deep(SafePointNode *map);// reset map for all callers
   47.24  
   47.25  #ifndef PRODUCT
   47.26    void      format(PhaseRegAlloc *regalloc, const Node *n, outputStream* st) const;
   47.27 @@ -439,7 +440,7 @@
   47.28    static  bool           needs_polling_address_input();
   47.29  
   47.30  #ifndef PRODUCT
   47.31 -  virtual void              dump_spec(outputStream *st) const;
   47.32 +  virtual void           dump_spec(outputStream *st) const;
   47.33  #endif
   47.34  };
   47.35  
   47.36 @@ -554,10 +555,10 @@
   47.37    virtual bool        guaranteed_safepoint()  { return true; }
   47.38    // For macro nodes, the JVMState gets modified during expansion, so when cloning
   47.39    // the node the JVMState must be cloned.
   47.40 -  virtual void        clone_jvms() { }   // default is not to clone
   47.41 +  virtual void        clone_jvms(Compile* C) { }   // default is not to clone
   47.42  
   47.43    // Returns true if the call may modify n
   47.44 -  virtual bool        may_modify(const TypePtr *addr_t, PhaseTransform *phase);
   47.45 +  virtual bool        may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase);
   47.46    // Does this node have a use of n other than in debug information?
   47.47    bool                has_non_debug_use(Node *n);
   47.48    // Returns the unique CheckCastPP of a call
   47.49 @@ -630,9 +631,15 @@
   47.50    virtual uint cmp( const Node &n ) const;
   47.51    virtual uint size_of() const; // Size is bigger
   47.52  public:
   47.53 -  CallStaticJavaNode(const TypeFunc* tf, address addr, ciMethod* method, int bci)
   47.54 +  CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method, int bci)
   47.55      : CallJavaNode(tf, addr, method, bci), _name(NULL) {
   47.56      init_class_id(Class_CallStaticJava);
   47.57 +    if (C->eliminate_boxing() && (method != NULL) && method->is_boxing_method()) {
   47.58 +      init_flags(Flag_is_macro);
   47.59 +      C->add_macro_node(this);
   47.60 +    }
   47.61 +    _is_scalar_replaceable = false;
   47.62 +    _is_non_escaping = false;
   47.63    }
   47.64    CallStaticJavaNode(const TypeFunc* tf, address addr, const char* name, int bci,
   47.65                       const TypePtr* adr_type)
   47.66 @@ -640,13 +647,31 @@
   47.67      init_class_id(Class_CallStaticJava);
   47.68      // This node calls a runtime stub, which often has narrow memory effects.
   47.69      _adr_type = adr_type;
   47.70 +    _is_scalar_replaceable = false;
   47.71 +    _is_non_escaping = false;
   47.72    }
   47.73 -  const char *_name;            // Runtime wrapper name
   47.74 +  const char *_name;      // Runtime wrapper name
   47.75 +
   47.76 +  // Result of Escape Analysis
   47.77 +  bool _is_scalar_replaceable;
   47.78 +  bool _is_non_escaping;
   47.79  
   47.80    // If this is an uncommon trap, return the request code, else zero.
   47.81    int uncommon_trap_request() const;
   47.82    static int extract_uncommon_trap_request(const Node* call);
   47.83  
   47.84 +  bool is_boxing_method() const {
   47.85 +    return is_macro() && (method() != NULL) && method()->is_boxing_method();
   47.86 +  }
   47.87 +  // Later inlining modifies the JVMState, so we need to clone it
   47.88 +  // when the call node is cloned (because it is macro node).
   47.89 +  virtual void  clone_jvms(Compile* C) {
   47.90 +    if ((jvms() != NULL) && is_boxing_method()) {
   47.91 +      set_jvms(jvms()->clone_deep(C));
   47.92 +      jvms()->set_map_deep(this);
   47.93 +    }
   47.94 +  }
   47.95 +
   47.96    virtual int         Opcode() const;
   47.97  #ifndef PRODUCT
   47.98    virtual void        dump_spec(outputStream *st) const;
   47.99 @@ -748,12 +773,12 @@
  47.100      ParmLimit
  47.101    };
  47.102  
  47.103 -  static const TypeFunc* alloc_type() {
  47.104 +  static const TypeFunc* alloc_type(const Type* t) {
  47.105      const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
  47.106      fields[AllocSize]   = TypeInt::POS;
  47.107      fields[KlassNode]   = TypeInstPtr::NOTNULL;
  47.108      fields[InitialTest] = TypeInt::BOOL;
  47.109 -    fields[ALength]     = TypeInt::INT;  // length (can be a bad length)
  47.110 +    fields[ALength]     = t;  // length (can be a bad length)
  47.111  
  47.112      const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
  47.113  
  47.114 @@ -766,21 +791,26 @@
  47.115      return TypeFunc::make(domain, range);
  47.116    }
  47.117  
  47.118 -  bool _is_scalar_replaceable;  // Result of Escape Analysis
  47.119 +  // Result of Escape Analysis
  47.120 +  bool _is_scalar_replaceable;
  47.121 +  bool _is_non_escaping;
  47.122  
  47.123    virtual uint size_of() const; // Size is bigger
  47.124    AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
  47.125                 Node *size, Node *klass_node, Node *initial_test);
  47.126    // Expansion modifies the JVMState, so we need to clone it
  47.127 -  virtual void  clone_jvms() {
  47.128 -    set_jvms(jvms()->clone_deep(Compile::current()));
  47.129 +  virtual void  clone_jvms(Compile* C) {
  47.130 +    if (jvms() != NULL) {
  47.131 +      set_jvms(jvms()->clone_deep(C));
  47.132 +      jvms()->set_map_deep(this);
  47.133 +    }
  47.134    }
  47.135    virtual int Opcode() const;
  47.136    virtual uint ideal_reg() const { return Op_RegP; }
  47.137    virtual bool        guaranteed_safepoint()  { return false; }
  47.138  
  47.139    // allocations do not modify their arguments
  47.140 -  virtual bool        may_modify(const TypePtr *addr_t, PhaseTransform *phase) { return false;}
  47.141 +  virtual bool        may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) { return false;}
  47.142  
  47.143    // Pattern-match a possible usage of AllocateNode.
  47.144    // Return null if no allocation is recognized.
  47.145 @@ -815,10 +845,6 @@
  47.146    // are defined in graphKit.cpp, which sets up the bidirectional relation.)
  47.147    InitializeNode* initialization();
  47.148  
  47.149 -  // Return the corresponding storestore barrier (or null if none).
  47.150 -  // Walks out edges to find it...
  47.151 -  MemBarStoreStoreNode* storestore();
  47.152 -
  47.153    // Convenience for initialization->maybe_set_complete(phase)
  47.154    bool maybe_set_complete(PhaseGVN* phase);
  47.155  };
  47.156 @@ -840,7 +866,6 @@
  47.157      set_req(AllocateNode::ALength,        count_val);
  47.158    }
  47.159    virtual int Opcode() const;
  47.160 -  virtual uint size_of() const; // Size is bigger
  47.161    virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  47.162  
  47.163    // Dig the length operand out of a array allocation site.
  47.164 @@ -918,7 +943,7 @@
  47.165    void set_nested()      { _kind = Nested; set_eliminated_lock_counter(); }
  47.166  
  47.167    // locking does not modify its arguments
  47.168 -  virtual bool may_modify(const TypePtr *addr_t, PhaseTransform *phase){ return false;}
  47.169 +  virtual bool may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase){ return false;}
  47.170  
  47.171  #ifndef PRODUCT
  47.172    void create_lock_counter(JVMState* s);
  47.173 @@ -965,8 +990,11 @@
  47.174  
  47.175    virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  47.176    // Expansion modifies the JVMState, so we need to clone it
  47.177 -  virtual void  clone_jvms() {
  47.178 -    set_jvms(jvms()->clone_deep(Compile::current()));
  47.179 +  virtual void  clone_jvms(Compile* C) {
  47.180 +    if (jvms() != NULL) {
  47.181 +      set_jvms(jvms()->clone_deep(C));
  47.182 +      jvms()->set_map_deep(this);
  47.183 +    }
  47.184    }
  47.185  
  47.186    bool is_nested_lock_region(); // Is this Lock nested?
    48.1 --- a/src/share/vm/opto/cfgnode.cpp	Tue May 14 17:33:07 2013 +0000
    48.2 +++ b/src/share/vm/opto/cfgnode.cpp	Thu May 16 13:47:55 2013 -0700
    48.3 @@ -806,7 +806,7 @@
    48.4        Node *in = ophi->in(i);
    48.5        if (in == NULL || igvn->type(in) == Type::TOP)
    48.6          continue;
    48.7 -      Node *opt = MemNode::optimize_simple_memory_chain(in, at, igvn);
    48.8 +      Node *opt = MemNode::optimize_simple_memory_chain(in, t_oop, NULL, igvn);
    48.9        PhiNode *optphi = opt->is_Phi() ? opt->as_Phi() : NULL;
   48.10        if (optphi != NULL && optphi->adr_type() == TypePtr::BOTTOM) {
   48.11          opt = node_map[optphi->_idx];
   48.12 @@ -1921,7 +1921,7 @@
   48.13      const TypePtr* at = adr_type();
   48.14      for( uint i=1; i<req(); ++i ) {// For all paths in
   48.15        Node *ii = in(i);
   48.16 -      Node *new_in = MemNode::optimize_memory_chain(ii, at, phase);
   48.17 +      Node *new_in = MemNode::optimize_memory_chain(ii, at, NULL, phase);
   48.18        if (ii != new_in ) {
   48.19          set_req(i, new_in);
   48.20          progress = this;
    49.1 --- a/src/share/vm/opto/compile.cpp	Tue May 14 17:33:07 2013 +0000
    49.2 +++ b/src/share/vm/opto/compile.cpp	Thu May 16 13:47:55 2013 -0700
    49.3 @@ -418,6 +418,7 @@
    49.4    }
    49.5    // clean up the late inline lists
    49.6    remove_useless_late_inlines(&_string_late_inlines, useful);
    49.7 +  remove_useless_late_inlines(&_boxing_late_inlines, useful);
    49.8    remove_useless_late_inlines(&_late_inlines, useful);
    49.9    debug_only(verify_graph_edges(true/*check for no_dead_code*/);)
   49.10  }
   49.11 @@ -485,6 +486,12 @@
   49.12      tty->print_cr("** Bailout: Recompile without escape analysis          **");
   49.13      tty->print_cr("*********************************************************");
   49.14    }
   49.15 +  if (_eliminate_boxing != EliminateAutoBox && PrintOpto) {
   49.16 +    // Recompiling without boxing elimination
   49.17 +    tty->print_cr("*********************************************************");
   49.18 +    tty->print_cr("** Bailout: Recompile without boxing elimination       **");
   49.19 +    tty->print_cr("*********************************************************");
   49.20 +  }
   49.21    if (env()->break_at_compile()) {
   49.22      // Open the debugger when compiling this method.
   49.23      tty->print("### Breaking when compiling: ");
   49.24 @@ -601,7 +608,8 @@
   49.25  // the continuation bci for on stack replacement.
   49.26  
   49.27  
   49.28 -Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci, bool subsume_loads, bool do_escape_analysis )
   49.29 +Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr_bci,
   49.30 +                  bool subsume_loads, bool do_escape_analysis, bool eliminate_boxing )
   49.31                  : Phase(Compiler),
   49.32                    _env(ci_env),
   49.33                    _log(ci_env->log()),
   49.34 @@ -617,6 +625,7 @@
   49.35                    _warm_calls(NULL),
   49.36                    _subsume_loads(subsume_loads),
   49.37                    _do_escape_analysis(do_escape_analysis),
   49.38 +                  _eliminate_boxing(eliminate_boxing),
   49.39                    _failure_reason(NULL),
   49.40                    _code_buffer("Compile::Fill_buffer"),
   49.41                    _orig_pc_slot(0),
   49.42 @@ -638,6 +647,7 @@
   49.43                    _congraph(NULL),
   49.44                    _late_inlines(comp_arena(), 2, 0, NULL),
   49.45                    _string_late_inlines(comp_arena(), 2, 0, NULL),
   49.46 +                  _boxing_late_inlines(comp_arena(), 2, 0, NULL),
   49.47                    _late_inlines_pos(0),
   49.48                    _number_of_mh_late_inlines(0),
   49.49                    _inlining_progress(false),
   49.50 @@ -906,6 +916,7 @@
   49.51      _orig_pc_slot_offset_in_bytes(0),
   49.52      _subsume_loads(true),
   49.53      _do_escape_analysis(false),
   49.54 +    _eliminate_boxing(false),
   49.55      _failure_reason(NULL),
   49.56      _code_buffer("Compile::Fill_buffer"),
   49.57      _has_method_handle_invokes(false),
   49.58 @@ -1016,6 +1027,7 @@
   49.59    set_has_split_ifs(false);
   49.60    set_has_loops(has_method() && method()->has_loops()); // first approximation
   49.61    set_has_stringbuilder(false);
   49.62 +  set_has_boxed_value(false);
   49.63    _trap_can_recompile = false;  // no traps emitted yet
   49.64    _major_progress = true; // start out assuming good things will happen
   49.65    set_has_unsafe_access(false);
   49.66 @@ -1807,6 +1819,38 @@
   49.67    _string_late_inlines.trunc_to(0);
   49.68  }
   49.69  
   49.70 +// Late inlining of boxing methods
   49.71 +void Compile::inline_boxing_calls(PhaseIterGVN& igvn) {
   49.72 +  if (_boxing_late_inlines.length() > 0) {
   49.73 +    assert(has_boxed_value(), "inconsistent");
   49.74 +
   49.75 +    PhaseGVN* gvn = initial_gvn();
   49.76 +    set_inlining_incrementally(true);
   49.77 +
   49.78 +    assert( igvn._worklist.size() == 0, "should be done with igvn" );
   49.79 +    for_igvn()->clear();
   49.80 +    gvn->replace_with(&igvn);
   49.81 +
   49.82 +    while (_boxing_late_inlines.length() > 0) {
   49.83 +      CallGenerator* cg = _boxing_late_inlines.pop();
   49.84 +      cg->do_late_inline();
   49.85 +      if (failing())  return;
   49.86 +    }
   49.87 +    _boxing_late_inlines.trunc_to(0);
   49.88 +
   49.89 +    {
   49.90 +      ResourceMark rm;
   49.91 +      PhaseRemoveUseless pru(gvn, for_igvn());
   49.92 +    }
   49.93 +
   49.94 +    igvn = PhaseIterGVN(gvn);
   49.95 +    igvn.optimize();
   49.96 +
   49.97 +    set_inlining_progress(false);
   49.98 +    set_inlining_incrementally(false);
   49.99 +  }
  49.100 +}
  49.101 +
  49.102  void Compile::inline_incrementally_one(PhaseIterGVN& igvn) {
  49.103    assert(IncrementalInline, "incremental inlining should be on");
  49.104    PhaseGVN* gvn = initial_gvn();
  49.105 @@ -1831,7 +1875,7 @@
  49.106  
  49.107    {
  49.108      ResourceMark rm;
  49.109 -    PhaseRemoveUseless pru(C->initial_gvn(), C->for_igvn());
  49.110 +    PhaseRemoveUseless pru(gvn, for_igvn());
  49.111    }
  49.112  
  49.113    igvn = PhaseIterGVN(gvn);
  49.114 @@ -1929,12 +1973,25 @@
  49.115  
  49.116    if (failing())  return;
  49.117  
  49.118 -  inline_incrementally(igvn);
  49.119 +  {
  49.120 +    NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); )
  49.121 +    inline_incrementally(igvn);
  49.122 +  }
  49.123  
  49.124    print_method("Incremental Inline", 2);
  49.125  
  49.126    if (failing())  return;
  49.127  
  49.128 +  if (eliminate_boxing()) {
  49.129 +    NOT_PRODUCT( TracePhase t2("incrementalInline", &_t_incrInline, TimeCompiler); )
  49.130 +    // Inline valueOf() methods now.
  49.131 +    inline_boxing_calls(igvn);
  49.132 +
  49.133 +    print_method("Incremental Boxing Inline", 2);
  49.134 +
  49.135 +    if (failing())  return;
  49.136 +  }
  49.137 +
  49.138    // No more new expensive nodes will be added to the list from here
  49.139    // so keep only the actual candidates for optimizations.
  49.140    cleanup_expensive_nodes(igvn);
  49.141 @@ -2896,6 +2953,7 @@
  49.142      }
  49.143      break;
  49.144    case Op_MemBarStoreStore:
  49.145 +  case Op_MemBarRelease:
  49.146      // Break the link with AllocateNode: it is no longer useful and
  49.147      // confuses register allocation.
  49.148      if (n->req() > MemBarNode::Precedent) {
    50.1 --- a/src/share/vm/opto/compile.hpp	Tue May 14 17:33:07 2013 +0000
    50.2 +++ b/src/share/vm/opto/compile.hpp	Thu May 16 13:47:55 2013 -0700
    50.3 @@ -262,6 +262,7 @@
    50.4    const bool            _save_argument_registers; // save/restore arg regs for trampolines
    50.5    const bool            _subsume_loads;         // Load can be matched as part of a larger op.
    50.6    const bool            _do_escape_analysis;    // Do escape analysis.
    50.7 +  const bool            _eliminate_boxing;      // Do boxing elimination.
    50.8    ciMethod*             _method;                // The method being compiled.
    50.9    int                   _entry_bci;             // entry bci for osr methods.
   50.10    const TypeFunc*       _tf;                    // My kind of signature
   50.11 @@ -287,6 +288,7 @@
   50.12    bool                  _has_split_ifs;         // True if the method _may_ have some split-if
   50.13    bool                  _has_unsafe_access;     // True if the method _may_ produce faults in unsafe loads or stores.
   50.14    bool                  _has_stringbuilder;     // True StringBuffers or StringBuilders are allocated
   50.15 +  bool                  _has_boxed_value;       // True if a boxed object is allocated
   50.16    int                   _max_vector_size;       // Maximum size of generated vectors
   50.17    uint                  _trap_hist[trapHistLength];  // Cumulative traps
   50.18    bool                  _trap_can_recompile;    // Have we emitted a recompiling trap?
   50.19 @@ -375,6 +377,8 @@
   50.20                                                        // main parsing has finished.
   50.21    GrowableArray<CallGenerator*> _string_late_inlines; // same but for string operations
   50.22  
   50.23 +  GrowableArray<CallGenerator*> _boxing_late_inlines; // same but for boxing operations
   50.24 +
   50.25    int                           _late_inlines_pos;    // Where in the queue should the next late inlining candidate go (emulate depth first inlining)
   50.26    uint                          _number_of_mh_late_inlines; // number of method handle late inlining still pending
   50.27  
   50.28 @@ -486,8 +490,12 @@
   50.29    // instructions that subsume a load may result in an unschedulable
   50.30    // instruction sequence.
   50.31    bool              subsume_loads() const       { return _subsume_loads; }
   50.32 -  // Do escape analysis.
   50.33 +  /** Do escape analysis. */
   50.34    bool              do_escape_analysis() const  { return _do_escape_analysis; }
   50.35 +  /** Do boxing elimination. */
   50.36 +  bool              eliminate_boxing() const    { return _eliminate_boxing; }
   50.37 +  /** Do aggressive boxing elimination. */
   50.38 +  bool              aggressive_unboxing() const { return _eliminate_boxing && AggressiveUnboxing; }
   50.39    bool              save_argument_registers() const { return _save_argument_registers; }
   50.40  
   50.41  
   50.42 @@ -527,6 +535,8 @@
   50.43    void          set_has_unsafe_access(bool z)   { _has_unsafe_access = z; }
   50.44    bool              has_stringbuilder() const   { return _has_stringbuilder; }
   50.45    void          set_has_stringbuilder(bool z)   { _has_stringbuilder = z; }
   50.46 +  bool              has_boxed_value() const     { return _has_boxed_value; }
   50.47 +  void          set_has_boxed_value(bool z)     { _has_boxed_value = z; }
   50.48    int               max_vector_size() const     { return _max_vector_size; }
   50.49    void          set_max_vector_size(int s)      { _max_vector_size = s; }
   50.50    void          set_trap_count(uint r, uint c)  { assert(r < trapHistLength, "oob");        _trap_hist[r] = c; }
   50.51 @@ -579,12 +589,12 @@
   50.52  #endif
   50.53    }
   50.54  
   50.55 -  int           macro_count()                   { return _macro_nodes->length(); }
   50.56 -  int           predicate_count()               { return _predicate_opaqs->length();}
   50.57 -  int           expensive_count()               { return _expensive_nodes->length(); }
   50.58 -  Node*         macro_node(int idx)             { return _macro_nodes->at(idx); }
   50.59 -  Node*         predicate_opaque1_node(int idx) { return _predicate_opaqs->at(idx);}
   50.60 -  Node*         expensive_node(int idx)         { return _expensive_nodes->at(idx); }
   50.61 +  int           macro_count()             const { return _macro_nodes->length(); }
   50.62 +  int           predicate_count()         const { return _predicate_opaqs->length();}
   50.63 +  int           expensive_count()         const { return _expensive_nodes->length(); }
   50.64 +  Node*         macro_node(int idx)       const { return _macro_nodes->at(idx); }
   50.65 +  Node*         predicate_opaque1_node(int idx) const { return _predicate_opaqs->at(idx);}
   50.66 +  Node*         expensive_node(int idx)   const { return _expensive_nodes->at(idx); }
   50.67    ConnectionGraph* congraph()                   { return _congraph;}
   50.68    void set_congraph(ConnectionGraph* congraph)  { _congraph = congraph;}
   50.69    void add_macro_node(Node * n) {
   50.70 @@ -766,7 +776,12 @@
   50.71    // Decide how to build a call.
   50.72    // The profile factor is a discount to apply to this site's interp. profile.
   50.73    CallGenerator*    call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch, JVMState* jvms, bool allow_inline, float profile_factor, bool allow_intrinsics = true, bool delayed_forbidden = false);
   50.74 -  bool should_delay_inlining(ciMethod* call_method, JVMState* jvms);
   50.75 +  bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
   50.76 +    return should_delay_string_inlining(call_method, jvms) ||
   50.77 +           should_delay_boxing_inlining(call_method, jvms);
   50.78 +  }
   50.79 +  bool should_delay_string_inlining(ciMethod* call_method, JVMState* jvms);
   50.80 +  bool should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms);
   50.81  
   50.82    // Helper functions to identify inlining potential at call-site
   50.83    ciMethod* optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass,
   50.84 @@ -822,6 +837,10 @@
   50.85      _string_late_inlines.push(cg);
   50.86    }
   50.87  
   50.88 +  void              add_boxing_late_inline(CallGenerator* cg) {
   50.89 +    _boxing_late_inlines.push(cg);
   50.90 +  }
   50.91 +
   50.92    void remove_useless_late_inlines(GrowableArray<CallGenerator*>* inlines, Unique_Node_List &useful);
   50.93  
   50.94    void dump_inlining();
   50.95 @@ -841,6 +860,7 @@
   50.96    void inline_incrementally_one(PhaseIterGVN& igvn);
   50.97    void inline_incrementally(PhaseIterGVN& igvn);
   50.98    void inline_string_calls(bool parse_time);
   50.99 +  void inline_boxing_calls(PhaseIterGVN& igvn);
  50.100  
  50.101    // Matching, CFG layout, allocation, code generation
  50.102    PhaseCFG*         cfg()                       { return _cfg; }
  50.103 @@ -913,7 +933,8 @@
  50.104    // replacement, entry_bci indicates the bytecode for which to compile a
  50.105    // continuation.
  50.106    Compile(ciEnv* ci_env, C2Compiler* compiler, ciMethod* target,
  50.107 -          int entry_bci, bool subsume_loads, bool do_escape_analysis);
  50.108 +          int entry_bci, bool subsume_loads, bool do_escape_analysis,
  50.109 +          bool eliminate_boxing);
  50.110  
  50.111    // Second major entry point.  From the TypeFunc signature, generate code
  50.112    // to pass arguments from the Java calling convention to the C calling
    51.1 --- a/src/share/vm/opto/doCall.cpp	Tue May 14 17:33:07 2013 +0000
    51.2 +++ b/src/share/vm/opto/doCall.cpp	Thu May 16 13:47:55 2013 -0700
    51.3 @@ -176,9 +176,12 @@
    51.4            // Delay the inlining of this method to give us the
    51.5            // opportunity to perform some high level optimizations
    51.6            // first.
    51.7 -          if (should_delay_inlining(callee, jvms)) {
    51.8 +          if (should_delay_string_inlining(callee, jvms)) {
    51.9              assert(!delayed_forbidden, "strange");
   51.10              return CallGenerator::for_string_late_inline(callee, cg);
   51.11 +          } else if (should_delay_boxing_inlining(callee, jvms)) {
   51.12 +            assert(!delayed_forbidden, "strange");
   51.13 +            return CallGenerator::for_boxing_late_inline(callee, cg);
   51.14            } else if ((should_delay || AlwaysIncrementalInline) && !delayed_forbidden) {
   51.15              return CallGenerator::for_late_inline(callee, cg);
   51.16            }
   51.17 @@ -276,7 +279,7 @@
   51.18  
   51.19  // Return true for methods that shouldn't be inlined early so that
   51.20  // they are easier to analyze and optimize as intrinsics.
   51.21 -bool Compile::should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
   51.22 +bool Compile::should_delay_string_inlining(ciMethod* call_method, JVMState* jvms) {
   51.23    if (has_stringbuilder()) {
   51.24  
   51.25      if ((call_method->holder() == C->env()->StringBuilder_klass() ||
   51.26 @@ -327,6 +330,13 @@
   51.27    return false;
   51.28  }
   51.29  
   51.30 +bool Compile::should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms) {
   51.31 +  if (eliminate_boxing() && call_method->is_boxing_method()) {
   51.32 +    set_has_boxed_value(true);
   51.33 +    return true;
   51.34 +  }
   51.35 +  return false;
   51.36 +}
   51.37  
   51.38  // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
   51.39  bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
    52.1 --- a/src/share/vm/opto/escape.cpp	Tue May 14 17:33:07 2013 +0000
    52.2 +++ b/src/share/vm/opto/escape.cpp	Thu May 16 13:47:55 2013 -0700
    52.3 @@ -63,15 +63,19 @@
    52.4    // EA brings benefits only when the code has allocations and/or locks which
    52.5    // are represented by ideal Macro nodes.
    52.6    int cnt = C->macro_count();
    52.7 -  for( int i=0; i < cnt; i++ ) {
    52.8 +  for (int i = 0; i < cnt; i++) {
    52.9      Node *n = C->macro_node(i);
   52.10 -    if ( n->is_Allocate() )
   52.11 +    if (n->is_Allocate())
   52.12        return true;
   52.13 -    if( n->is_Lock() ) {
   52.14 +    if (n->is_Lock()) {
   52.15        Node* obj = n->as_Lock()->obj_node()->uncast();
   52.16 -      if( !(obj->is_Parm() || obj->is_Con()) )
   52.17 +      if (!(obj->is_Parm() || obj->is_Con()))
   52.18          return true;
   52.19      }
   52.20 +    if (n->is_CallStaticJava() &&
   52.21 +        n->as_CallStaticJava()->is_boxing_method()) {
   52.22 +      return true;
   52.23 +    }
   52.24    }
   52.25    return false;
   52.26  }
   52.27 @@ -115,7 +119,7 @@
   52.28    { Compile::TracePhase t3("connectionGraph", &Phase::_t_connectionGraph, true);
   52.29  
   52.30    // 1. Populate Connection Graph (CG) with PointsTo nodes.
   52.31 -  ideal_nodes.map(C->unique(), NULL);  // preallocate space
   52.32 +  ideal_nodes.map(C->live_nodes(), NULL);  // preallocate space
   52.33    // Initialize worklist
   52.34    if (C->root() != NULL) {
   52.35      ideal_nodes.push(C->root());
   52.36 @@ -152,8 +156,11 @@
   52.37        // escape status of the associated Allocate node some of them
   52.38        // may be eliminated.
   52.39        storestore_worklist.append(n);
   52.40 +    } else if (n->is_MemBar() && (n->Opcode() == Op_MemBarRelease) &&
   52.41 +               (n->req() > MemBarNode::Precedent)) {
   52.42 +      record_for_optimizer(n);
   52.43  #ifdef ASSERT
   52.44 -    } else if(n->is_AddP()) {
   52.45 +    } else if (n->is_AddP()) {
   52.46        // Collect address nodes for graph verification.
   52.47        addp_worklist.append(n);
   52.48  #endif
   52.49 @@ -206,8 +213,15 @@
   52.50    int non_escaped_length = non_escaped_worklist.length();
   52.51    for (int next = 0; next < non_escaped_length; next++) {
   52.52      JavaObjectNode* ptn = non_escaped_worklist.at(next);
   52.53 -    if (ptn->escape_state() == PointsToNode::NoEscape &&
   52.54 -        ptn->scalar_replaceable()) {
   52.55 +    bool noescape = (ptn->escape_state() == PointsToNode::NoEscape);
   52.56 +    Node* n = ptn->ideal_node();
   52.57 +    if (n->is_Allocate()) {
   52.58 +      n->as_Allocate()->_is_non_escaping = noescape;
   52.59 +    }
   52.60 +    if (n->is_CallStaticJava()) {
   52.61 +      n->as_CallStaticJava()->_is_non_escaping = noescape;
   52.62 +    }
   52.63 +    if (noescape && ptn->scalar_replaceable()) {
   52.64        adjust_scalar_replaceable_state(ptn);
   52.65        if (ptn->scalar_replaceable()) {
   52.66          alloc_worklist.append(ptn->ideal_node());
   52.67 @@ -330,8 +344,10 @@
   52.68        // Don't mark as processed since call's arguments have to be processed.
   52.69        delayed_worklist->push(n);
   52.70        // Check if a call returns an object.
   52.71 -      if (n->as_Call()->returns_pointer() &&
   52.72 -          n->as_Call()->proj_out(TypeFunc::Parms) != NULL) {
   52.73 +      if ((n->as_Call()->returns_pointer() &&
   52.74 +           n->as_Call()->proj_out(TypeFunc::Parms) != NULL) ||
   52.75 +          (n->is_CallStaticJava() &&
   52.76 +           n->as_CallStaticJava()->is_boxing_method())) {
   52.77          add_call_node(n->as_Call());
   52.78        }
   52.79      }
   52.80 @@ -387,8 +403,8 @@
   52.81      case Op_ConNKlass: {
   52.82        // assume all oop constants globally escape except for null
   52.83        PointsToNode::EscapeState es;
   52.84 -      if (igvn->type(n) == TypePtr::NULL_PTR ||
   52.85 -          igvn->type(n) == TypeNarrowOop::NULL_PTR) {
   52.86 +      const Type* t = igvn->type(n);
   52.87 +      if (t == TypePtr::NULL_PTR || t == TypeNarrowOop::NULL_PTR) {
   52.88          es = PointsToNode::NoEscape;
   52.89        } else {
   52.90          es = PointsToNode::GlobalEscape;
   52.91 @@ -468,6 +484,9 @@
   52.92        Node* adr = n->in(MemNode::Address);
   52.93        const Type *adr_type = igvn->type(adr);
   52.94        adr_type = adr_type->make_ptr();
   52.95 +      if (adr_type == NULL) {
   52.96 +        break; // skip dead nodes
   52.97 +      }
   52.98        if (adr_type->isa_oopptr() ||
   52.99            (opcode == Op_StoreP || opcode == Op_StoreN || opcode == Op_StoreNKlass) &&
  52.100                          (adr_type == TypeRawPtr::NOTNULL &&
  52.101 @@ -660,14 +679,18 @@
  52.102      case Op_GetAndSetP:
  52.103      case Op_GetAndSetN: {
  52.104        Node* adr = n->in(MemNode::Address);
  52.105 -      if (opcode == Op_GetAndSetP || opcode == Op_GetAndSetN) {
  52.106 -        const Type* t = _igvn->type(n);
  52.107 -        if (t->make_ptr() != NULL) {
  52.108 -          add_local_var_and_edge(n, PointsToNode::NoEscape, adr, NULL);
  52.109 -        }
  52.110 -      }
  52.111        const Type *adr_type = _igvn->type(adr);
  52.112        adr_type = adr_type->make_ptr();
  52.113 +#ifdef ASSERT
  52.114 +      if (adr_type == NULL) {
  52.115 +        n->dump(1);
  52.116 +        assert(adr_type != NULL, "dead node should not be on list");
  52.117 +        break;
  52.118 +      }
  52.119 +#endif
  52.120 +      if (opcode == Op_GetAndSetP || opcode == Op_GetAndSetN) {
  52.121 +        add_local_var_and_edge(n, PointsToNode::NoEscape, adr, NULL);
  52.122 +      }
  52.123        if (adr_type->isa_oopptr() ||
  52.124            (opcode == Op_StoreP || opcode == Op_StoreN || opcode == Op_StoreNKlass) &&
  52.125                          (adr_type == TypeRawPtr::NOTNULL &&
  52.126 @@ -797,6 +820,18 @@
  52.127        // Returns a newly allocated unescaped object.
  52.128        add_java_object(call, PointsToNode::NoEscape);
  52.129        ptnode_adr(call_idx)->set_scalar_replaceable(false);
  52.130 +    } else if (meth->is_boxing_method()) {
  52.131 +      // Returns boxing object
  52.132 +      PointsToNode::EscapeState es;
  52.133 +      vmIntrinsics::ID intr = meth->intrinsic_id();
  52.134 +      if (intr == vmIntrinsics::_floatValue || intr == vmIntrinsics::_doubleValue) {
  52.135 +        // It does not escape if object is always allocated.
  52.136 +        es = PointsToNode::NoEscape;
  52.137 +      } else {
  52.138 +        // It escapes globally if object could be loaded from cache.
  52.139 +        es = PointsToNode::GlobalEscape;
  52.140 +      }
  52.141 +      add_java_object(call, es);
  52.142      } else {
  52.143        BCEscapeAnalyzer* call_analyzer = meth->get_bcea();
  52.144        call_analyzer->copy_dependencies(_compile->dependencies());
  52.145 @@ -943,6 +978,9 @@
  52.146        assert((name == NULL || strcmp(name, "uncommon_trap") != 0), "normal calls only");
  52.147  #endif
  52.148        ciMethod* meth = call->as_CallJava()->method();
  52.149 +      if ((meth != NULL) && meth->is_boxing_method()) {
  52.150 +        break; // Boxing methods do not modify any oops.
  52.151 +      }
  52.152        BCEscapeAnalyzer* call_analyzer = (meth !=NULL) ? meth->get_bcea() : NULL;
  52.153        // fall-through if not a Java method or no analyzer information
  52.154        if (call_analyzer != NULL) {
  52.155 @@ -1791,9 +1829,8 @@
  52.156        jobj2->ideal_node()->is_Con()) {
  52.157      // Klass or String constants compare. Need to be careful with
  52.158      // compressed pointers - compare types of ConN and ConP instead of nodes.
  52.159 -    const Type* t1 = jobj1->ideal_node()->bottom_type()->make_ptr();
  52.160 -    const Type* t2 = jobj2->ideal_node()->bottom_type()->make_ptr();
  52.161 -    assert(t1 != NULL && t2 != NULL, "sanity");
  52.162 +    const Type* t1 = jobj1->ideal_node()->get_ptr_type();
  52.163 +    const Type* t2 = jobj2->ideal_node()->get_ptr_type();
  52.164      if (t1->make_ptr() == t2->make_ptr()) {
  52.165        return _pcmp_eq;
  52.166      } else {
  52.167 @@ -2744,6 +2781,11 @@
  52.168            // so it could be eliminated if it has no uses.
  52.169            alloc->as_Allocate()->_is_scalar_replaceable = true;
  52.170          }
  52.171 +        if (alloc->is_CallStaticJava()) {
  52.172 +          // Set the scalar_replaceable flag for boxing method
  52.173 +          // so it could be eliminated if it has no uses.
  52.174 +          alloc->as_CallStaticJava()->_is_scalar_replaceable = true;
  52.175 +        }
  52.176          continue;
  52.177        }
  52.178        if (!n->is_CheckCastPP()) { // not unique CheckCastPP.
  52.179 @@ -2782,6 +2824,11 @@
  52.180          // so it could be eliminated.
  52.181          alloc->as_Allocate()->_is_scalar_replaceable = true;
  52.182        }
  52.183 +      if (alloc->is_CallStaticJava()) {
  52.184 +        // Set the scalar_replaceable flag for boxing method
  52.185 +        // so it could be eliminated.
  52.186 +        alloc->as_CallStaticJava()->_is_scalar_replaceable = true;
  52.187 +      }
  52.188        set_escape_state(ptnode_adr(n->_idx), es); // CheckCastPP escape state
  52.189        // in order for an object to be scalar-replaceable, it must be:
  52.190        //   - a direct allocation (not a call returning an object)
  52.191 @@ -2911,7 +2958,9 @@
  52.192          // Load/store to instance's field
  52.193          memnode_worklist.append_if_missing(use);
  52.194        } else if (use->is_MemBar()) {
  52.195 -        memnode_worklist.append_if_missing(use);
  52.196 +        if (use->in(TypeFunc::Memory) == n) { // Ignore precedent edge
  52.197 +          memnode_worklist.append_if_missing(use);
  52.198 +        }
  52.199        } else if (use->is_AddP() && use->outcnt() > 0) { // No dead nodes
  52.200          Node* addp2 = find_second_addp(use, n);
  52.201          if (addp2 != NULL) {
  52.202 @@ -3028,7 +3077,9 @@
  52.203            continue;
  52.204          memnode_worklist.append_if_missing(use);
  52.205        } else if (use->is_MemBar()) {
  52.206 -        memnode_worklist.append_if_missing(use);
  52.207 +        if (use->in(TypeFunc::Memory) == n) { // Ignore precedent edge
  52.208 +          memnode_worklist.append_if_missing(use);
  52.209 +        }
  52.210  #ifdef ASSERT
  52.211        } else if(use->is_Mem()) {
  52.212          assert(use->in(MemNode::Memory) != n, "EA: missing memory path");
  52.213 @@ -3264,7 +3315,12 @@
  52.214      if (ptn == NULL || !ptn->is_JavaObject())
  52.215        continue;
  52.216      PointsToNode::EscapeState es = ptn->escape_state();
  52.217 -    if (ptn->ideal_node()->is_Allocate() && (es == PointsToNode::NoEscape || Verbose)) {
  52.218 +    if ((es != PointsToNode::NoEscape) && !Verbose) {
  52.219 +      continue;
  52.220 +    }
  52.221 +    Node* n = ptn->ideal_node();
  52.222 +    if (n->is_Allocate() || (n->is_CallStaticJava() &&
  52.223 +                             n->as_CallStaticJava()->is_boxing_method())) {
  52.224        if (first) {
  52.225          tty->cr();
  52.226          tty->print("======== Connection graph for ");
    53.1 --- a/src/share/vm/opto/graphKit.cpp	Tue May 14 17:33:07 2013 +0000
    53.2 +++ b/src/share/vm/opto/graphKit.cpp	Thu May 16 13:47:55 2013 -0700
    53.3 @@ -333,6 +333,7 @@
    53.4    assert(ex_jvms->stkoff() == phi_map->_jvms->stkoff(), "matching locals");
    53.5    assert(ex_jvms->sp() == phi_map->_jvms->sp(), "matching stack sizes");
    53.6    assert(ex_jvms->monoff() == phi_map->_jvms->monoff(), "matching JVMS");
    53.7 +  assert(ex_jvms->scloff() == phi_map->_jvms->scloff(), "matching scalar replaced objects");
    53.8    assert(ex_map->req() == phi_map->req(), "matching maps");
    53.9    uint tos = ex_jvms->stkoff() + ex_jvms->sp();
   53.10    Node*         hidden_merge_mark = root();
   53.11 @@ -409,7 +410,7 @@
   53.12          while (dst->req() > orig_width)  dst->del_req(dst->req()-1);
   53.13        } else {
   53.14          assert(dst->is_Phi(), "nobody else uses a hidden region");
   53.15 -        phi = (PhiNode*)dst;
   53.16 +        phi = dst->as_Phi();
   53.17        }
   53.18        if (add_multiple && src->in(0) == ex_control) {
   53.19          // Both are phis.
   53.20 @@ -1438,7 +1439,12 @@
   53.21    } else {
   53.22      ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt);
   53.23    }
   53.24 -  return _gvn.transform(ld);
   53.25 +  ld = _gvn.transform(ld);
   53.26 +  if ((bt == T_OBJECT) && C->do_escape_analysis() || C->eliminate_boxing()) {
   53.27 +    // Improve graph before escape analysis and boxing elimination.
   53.28 +    record_for_igvn(ld);
   53.29 +  }
   53.30 +  return ld;
   53.31  }
   53.32  
   53.33  Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt,
   53.34 @@ -3144,7 +3150,7 @@
   53.35    set_all_memory(mem); // Create new memory state
   53.36  
   53.37    AllocateNode* alloc
   53.38 -    = new (C) AllocateNode(C, AllocateNode::alloc_type(),
   53.39 +    = new (C) AllocateNode(C, AllocateNode::alloc_type(Type::TOP),
   53.40                             control(), mem, i_o(),
   53.41                             size, klass_node,
   53.42                             initial_slow_test);
   53.43 @@ -3285,7 +3291,7 @@
   53.44  
   53.45    // Create the AllocateArrayNode and its result projections
   53.46    AllocateArrayNode* alloc
   53.47 -    = new (C) AllocateArrayNode(C, AllocateArrayNode::alloc_type(),
   53.48 +    = new (C) AllocateArrayNode(C, AllocateArrayNode::alloc_type(TypeInt::INT),
   53.49                                  control(), mem, i_o(),
   53.50                                  size, klass_node,
   53.51                                  initial_slow_test,
   53.52 @@ -3326,10 +3332,9 @@
   53.53    if (ptr == NULL) {     // reduce dumb test in callers
   53.54      return NULL;
   53.55    }
   53.56 -  if (ptr->is_CheckCastPP()) {  // strip a raw-to-oop cast
   53.57 -    ptr = ptr->in(1);
   53.58 -    if (ptr == NULL)  return NULL;
   53.59 -  }
   53.60 +  ptr = ptr->uncast();  // strip a raw-to-oop cast
   53.61 +  if (ptr == NULL)  return NULL;
   53.62 +
   53.63    if (ptr->is_Proj()) {
   53.64      Node* allo = ptr->in(0);
   53.65      if (allo != NULL && allo->is_Allocate()) {
   53.66 @@ -3374,19 +3379,6 @@
   53.67    return NULL;
   53.68  }
   53.69  
   53.70 -// Trace Allocate -> Proj[Parm] -> MemBarStoreStore
   53.71 -MemBarStoreStoreNode* AllocateNode::storestore() {
   53.72 -  ProjNode* rawoop = proj_out(AllocateNode::RawAddress);
   53.73 -  if (rawoop == NULL)  return NULL;
   53.74 -  for (DUIterator_Fast imax, i = rawoop->fast_outs(imax); i < imax; i++) {
   53.75 -    Node* storestore = rawoop->fast_out(i);
   53.76 -    if (storestore->is_MemBarStoreStore()) {
   53.77 -      return storestore->as_MemBarStoreStore();
   53.78 -    }
   53.79 -  }
   53.80 -  return NULL;
   53.81 -}
   53.82 -
   53.83  //----------------------------- loop predicates ---------------------------
   53.84  
   53.85  //------------------------------add_predicate_impl----------------------------
    54.1 --- a/src/share/vm/opto/ifnode.cpp	Tue May 14 17:33:07 2013 +0000
    54.2 +++ b/src/share/vm/opto/ifnode.cpp	Thu May 16 13:47:55 2013 -0700
    54.3 @@ -673,7 +673,7 @@
    54.4  //           /    Region
    54.5  //
    54.6  Node* IfNode::fold_compares(PhaseGVN* phase) {
    54.7 -  if (!EliminateAutoBox || Opcode() != Op_If) return NULL;
    54.8 +  if (!phase->C->eliminate_boxing() || Opcode() != Op_If) return NULL;
    54.9  
   54.10    Node* this_cmp = in(1)->in(1);
   54.11    if (this_cmp != NULL && this_cmp->Opcode() == Op_CmpI &&
    55.1 --- a/src/share/vm/opto/lcm.cpp	Tue May 14 17:33:07 2013 +0000
    55.2 +++ b/src/share/vm/opto/lcm.cpp	Thu May 16 13:47:55 2013 -0700
    55.3 @@ -219,9 +219,10 @@
    55.4          // cannot reason about it; is probably not implicit null exception
    55.5        } else {
    55.6          const TypePtr* tptr;
    55.7 -        if (UseCompressedOops && Universe::narrow_oop_shift() == 0) {
    55.8 +        if (UseCompressedOops && (Universe::narrow_oop_shift() == 0 ||
    55.9 +                                  Universe::narrow_klass_shift() == 0)) {
   55.10            // 32-bits narrow oop can be the base of address expressions
   55.11 -          tptr = base->bottom_type()->make_ptr();
   55.12 +          tptr = base->get_ptr_type();
   55.13          } else {
   55.14            // only regular oops are expected here
   55.15            tptr = base->bottom_type()->is_ptr();
    56.1 --- a/src/share/vm/opto/library_call.cpp	Tue May 14 17:33:07 2013 +0000
    56.2 +++ b/src/share/vm/opto/library_call.cpp	Thu May 16 13:47:55 2013 -0700
    56.3 @@ -2783,7 +2783,7 @@
    56.4  
    56.5  #ifdef _LP64
    56.6    if (type == T_OBJECT && adr->bottom_type()->is_ptr_to_narrowoop() && kind == LS_xchg) {
    56.7 -    load_store = _gvn.transform(new (C) DecodeNNode(load_store, load_store->bottom_type()->make_ptr()));
    56.8 +    load_store = _gvn.transform(new (C) DecodeNNode(load_store, load_store->get_ptr_type()));
    56.9    }
   56.10  #endif
   56.11  
   56.12 @@ -3703,7 +3703,7 @@
   56.13    CallJavaNode* slow_call;
   56.14    if (is_static) {
   56.15      assert(!is_virtual, "");
   56.16 -    slow_call = new(C) CallStaticJavaNode(tf,
   56.17 +    slow_call = new(C) CallStaticJavaNode(C, tf,
   56.18                             SharedRuntime::get_resolve_static_call_stub(),
   56.19                             method, bci());
   56.20    } else if (is_virtual) {
   56.21 @@ -3722,7 +3722,7 @@
   56.22                            method, vtable_index, bci());
   56.23    } else {  // neither virtual nor static:  opt_virtual
   56.24      null_check_receiver();
   56.25 -    slow_call = new(C) CallStaticJavaNode(tf,
   56.26 +    slow_call = new(C) CallStaticJavaNode(C, tf,
   56.27                                  SharedRuntime::get_resolve_opt_virtual_call_stub(),
   56.28                                  method, bci());
   56.29      slow_call->set_optimized_virtual(true);
    57.1 --- a/src/share/vm/opto/loopPredicate.cpp	Tue May 14 17:33:07 2013 +0000
    57.2 +++ b/src/share/vm/opto/loopPredicate.cpp	Thu May 16 13:47:55 2013 -0700
    57.3 @@ -821,8 +821,8 @@
    57.4          loop->dump_head();
    57.5        }
    57.6  #endif
    57.7 -    } else if (cl != NULL && loop->is_range_check_if(iff, this, invar)) {
    57.8 -      assert(proj->_con == predicate_proj->_con, "must match");
    57.9 +    } else if ((cl != NULL) && (proj->_con == predicate_proj->_con) &&
   57.10 +               loop->is_range_check_if(iff, this, invar)) {
   57.11  
   57.12        // Range check for counted loops
   57.13        const Node*    cmp    = bol->in(1)->as_Cmp();
    58.1 --- a/src/share/vm/opto/machnode.cpp	Tue May 14 17:33:07 2013 +0000
    58.2 +++ b/src/share/vm/opto/machnode.cpp	Thu May 16 13:47:55 2013 -0700
    58.3 @@ -349,11 +349,11 @@
    58.4    if (base == NodeSentinel)  return TypePtr::BOTTOM;
    58.5  
    58.6    const Type* t = base->bottom_type();
    58.7 -  if (UseCompressedOops && Universe::narrow_oop_shift() == 0) {
    58.8 +  if (t->isa_narrowoop() && Universe::narrow_oop_shift() == 0) {
    58.9      // 32-bit unscaled narrow oop can be the base of any address expression
   58.10      t = t->make_ptr();
   58.11    }
   58.12 -  if (UseCompressedKlassPointers && Universe::narrow_klass_shift() == 0) {
   58.13 +  if (t->isa_narrowklass() && Universe::narrow_klass_shift() == 0) {
   58.14      // 32-bit unscaled narrow oop can be the base of any address expression
   58.15      t = t->make_ptr();
   58.16    }
    59.1 --- a/src/share/vm/opto/macro.cpp	Tue May 14 17:33:07 2013 +0000
    59.2 +++ b/src/share/vm/opto/macro.cpp	Thu May 16 13:47:55 2013 -0700
    59.3 @@ -666,7 +666,7 @@
    59.4          alloc->dump();
    59.5        else
    59.6          res->dump();
    59.7 -    } else {
    59.8 +    } else if (alloc->_is_scalar_replaceable) {
    59.9        tty->print("NotScalar (%s)", fail_eliminate);
   59.10        if (res == NULL)
   59.11          alloc->dump();
   59.12 @@ -834,7 +834,7 @@
   59.13          if (field_val->is_EncodeP()) {
   59.14            field_val = field_val->in(1);
   59.15          } else {
   59.16 -          field_val = transform_later(new (C) DecodeNNode(field_val, field_val->bottom_type()->make_ptr()));
   59.17 +          field_val = transform_later(new (C) DecodeNNode(field_val, field_val->get_ptr_type()));
   59.18          }
   59.19        }
   59.20        sfpt->add_req(field_val);
   59.21 @@ -845,18 +845,14 @@
   59.22      // to the allocated object with "sobj"
   59.23      int start = jvms->debug_start();
   59.24      int end   = jvms->debug_end();
   59.25 -    for (int i = start; i < end; i++) {
   59.26 -      if (sfpt->in(i) == res) {
   59.27 -        sfpt->set_req(i, sobj);
   59.28 -      }
   59.29 -    }
   59.30 +    sfpt->replace_edges_in_range(res, sobj, start, end);
   59.31      safepoints_done.append_if_missing(sfpt); // keep it for rollback
   59.32    }
   59.33    return true;
   59.34  }
   59.35  
   59.36  // Process users of eliminated allocation.
   59.37 -void PhaseMacroExpand::process_users_of_allocation(AllocateNode *alloc) {
   59.38 +void PhaseMacroExpand::process_users_of_allocation(CallNode *alloc) {
   59.39    Node* res = alloc->result_cast();
   59.40    if (res != NULL) {
   59.41      for (DUIterator_Last jmin, j = res->last_outs(jmin); j >= jmin; ) {
   59.42 @@ -899,6 +895,17 @@
   59.43    // Process other users of allocation's projections
   59.44    //
   59.45    if (_resproj != NULL && _resproj->outcnt() != 0) {
   59.46 +    // First disconnect stores captured by Initialize node.
   59.47 +    // If Initialize node is eliminated first in the following code,
   59.48 +    // it will kill such stores and DUIterator_Last will assert.
   59.49 +    for (DUIterator_Fast jmax, j = _resproj->fast_outs(jmax);  j < jmax; j++) {
   59.50 +      Node *use = _resproj->fast_out(j);
   59.51 +      if (use->is_AddP()) {
   59.52 +        // raw memory addresses used only by the initialization
   59.53 +        _igvn.replace_node(use, C->top());
   59.54 +        --j; --jmax;
   59.55 +      }
   59.56 +    }
   59.57      for (DUIterator_Last jmin, j = _resproj->last_outs(jmin); j >= jmin; ) {
   59.58        Node *use = _resproj->last_out(j);
   59.59        uint oc1 = _resproj->outcnt();
   59.60 @@ -923,9 +930,6 @@
   59.61  #endif
   59.62            _igvn.replace_node(mem_proj, mem);
   59.63          }
   59.64 -      } else if (use->is_AddP()) {
   59.65 -        // raw memory addresses used only by the initialization
   59.66 -        _igvn.replace_node(use, C->top());
   59.67        } else  {
   59.68          assert(false, "only Initialize or AddP expected");
   59.69        }
   59.70 @@ -953,8 +957,18 @@
   59.71  }
   59.72  
   59.73  bool PhaseMacroExpand::eliminate_allocate_node(AllocateNode *alloc) {
   59.74 -
   59.75 -  if (!EliminateAllocations || !alloc->_is_scalar_replaceable) {
   59.76 +  if (!EliminateAllocations || !alloc->_is_non_escaping) {
   59.77 +    return false;
   59.78 +  }
   59.79 +  Node* klass = alloc->in(AllocateNode::KlassNode);
   59.80 +  const TypeKlassPtr* tklass = _igvn.type(klass)->is_klassptr();
   59.81 +  Node* res = alloc->result_cast();
   59.82 +  // Eliminate boxing allocations which are not used
   59.83 +  // regardless scalar replacable status.
   59.84 +  bool boxing_alloc = C->eliminate_boxing() &&
   59.85 +                      tklass->klass()->is_instance_klass()  &&
   59.86 +                      tklass->klass()->as_instance_klass()->is_box_klass();
   59.87 +  if (!alloc->_is_scalar_replaceable && (!boxing_alloc || (res != NULL))) {
   59.88      return false;
   59.89    }
   59.90  
   59.91 @@ -965,14 +979,22 @@
   59.92      return false;
   59.93    }
   59.94  
   59.95 +  if (!alloc->_is_scalar_replaceable) {
   59.96 +    assert(res == NULL, "sanity");
   59.97 +    // We can only eliminate allocation if all debug info references
   59.98 +    // are already replaced with SafePointScalarObject because
   59.99 +    // we can't search for a fields value without instance_id.
  59.100 +    if (safepoints.length() > 0) {
  59.101 +      return false;
  59.102 +    }
  59.103 +  }
  59.104 +
  59.105    if (!scalar_replacement(alloc, safepoints)) {
  59.106      return false;
  59.107    }
  59.108  
  59.109    CompileLog* log = C->log();
  59.110    if (log != NULL) {
  59.111 -    Node* klass = alloc->in(AllocateNode::KlassNode);
  59.112 -    const TypeKlassPtr* tklass = _igvn.type(klass)->is_klassptr();
  59.113      log->head("eliminate_allocation type='%d'",
  59.114                log->identify(tklass->klass()));
  59.115      JVMState* p = alloc->jvms();
  59.116 @@ -997,6 +1019,43 @@
  59.117    return true;
  59.118  }
  59.119  
  59.120 +bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) {
  59.121 +  // EA should remove all uses of non-escaping boxing node.
  59.122 +  if (!C->eliminate_boxing() || boxing->proj_out(TypeFunc::Parms) != NULL) {
  59.123 +    return false;
  59.124 +  }
  59.125 +
  59.126 +  extract_call_projections(boxing);
  59.127 +
  59.128 +  const TypeTuple* r = boxing->tf()->range();
  59.129 +  assert(r->cnt() > TypeFunc::Parms, "sanity");
  59.130 +  const TypeInstPtr* t = r->field_at(TypeFunc::Parms)->isa_instptr();
  59.131 +  assert(t != NULL, "sanity");
  59.132 +
  59.133 +  CompileLog* log = C->log();
  59.134 +  if (log != NULL) {
  59.135 +    log->head("eliminate_boxing type='%d'",
  59.136 +              log->identify(t->klass()));
  59.137 +    JVMState* p = boxing->jvms();
  59.138 +    while (p != NULL) {
  59.139 +      log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
  59.140 +      p = p->caller();
  59.141 +    }
  59.142 +    log->tail("eliminate_boxing");
  59.143 +  }
  59.144 +
  59.145 +  process_users_of_allocation(boxing);
  59.146 +
  59.147 +#ifndef PRODUCT
  59.148 +  if (PrintEliminateAllocations) {
  59.149 +    tty->print("++++ Eliminated: %d ", boxing->_idx);
  59.150 +    boxing->method()->print_short_name(tty);
  59.151 +    tty->cr();
  59.152 +  }
  59.153 +#endif
  59.154 +
  59.155 +  return true;
  59.156 +}
  59.157  
  59.158  //---------------------------set_eden_pointers-------------------------
  59.159  void PhaseMacroExpand::set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr) {
  59.160 @@ -2384,6 +2443,9 @@
  59.161        case Node::Class_AllocateArray:
  59.162          success = eliminate_allocate_node(n->as_Allocate());
  59.163          break;
  59.164 +      case Node::Class_CallStaticJava:
  59.165 +        success = eliminate_boxing_node(n->as_CallStaticJava());
  59.166 +        break;
  59.167        case Node::Class_Lock:
  59.168        case Node::Class_Unlock:
  59.169          assert(!n->as_AbstractLock()->is_eliminated(), "sanity");
  59.170 @@ -2424,6 +2486,11 @@
  59.171          C->remove_macro_node(n);
  59.172          _igvn._worklist.push(n);
  59.173          success = true;
  59.174 +      } else if (n->Opcode() == Op_CallStaticJava) {
  59.175 +        // Remove it from macro list and put on IGVN worklist to optimize.
  59.176 +        C->remove_macro_node(n);
  59.177 +        _igvn._worklist.push(n);
  59.178 +        success = true;
  59.179        } else if (n->Opcode() == Op_Opaque1 || n->Opcode() == Op_Opaque2) {
  59.180          _igvn.replace_node(n, n->in(1));
  59.181          success = true;
    60.1 --- a/src/share/vm/opto/macro.hpp	Tue May 14 17:33:07 2013 +0000
    60.2 +++ b/src/share/vm/opto/macro.hpp	Thu May 16 13:47:55 2013 -0700
    60.3 @@ -86,10 +86,11 @@
    60.4    Node *value_from_mem(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, Node *alloc);
    60.5    Node *value_from_mem_phi(Node *mem, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, Node *alloc, Node_Stack *value_phis, int level);
    60.6  
    60.7 +  bool eliminate_boxing_node(CallStaticJavaNode *boxing);
    60.8    bool eliminate_allocate_node(AllocateNode *alloc);
    60.9    bool can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints);
   60.10    bool scalar_replacement(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints_done);
   60.11 -  void process_users_of_allocation(AllocateNode *alloc);
   60.12 +  void process_users_of_allocation(CallNode *alloc);
   60.13  
   60.14    void eliminate_card_mark(Node *cm);
   60.15    void mark_eliminated_box(Node* box, Node* obj);
    61.1 --- a/src/share/vm/opto/memnode.cpp	Tue May 14 17:33:07 2013 +0000
    61.2 +++ b/src/share/vm/opto/memnode.cpp	Thu May 16 13:47:55 2013 -0700
    61.3 @@ -103,11 +103,15 @@
    61.4  
    61.5  #endif
    61.6  
    61.7 -Node *MemNode::optimize_simple_memory_chain(Node *mchain, const TypePtr *t_adr, PhaseGVN *phase) {
    61.8 -  const TypeOopPtr *tinst = t_adr->isa_oopptr();
    61.9 -  if (tinst == NULL || !tinst->is_known_instance_field())
   61.10 +Node *MemNode::optimize_simple_memory_chain(Node *mchain, const TypeOopPtr *t_oop, Node *load, PhaseGVN *phase) {
   61.11 +  assert((t_oop != NULL), "sanity");
   61.12 +  bool is_instance = t_oop->is_known_instance_field();
   61.13 +  bool is_boxed_value_load = t_oop->is_ptr_to_boxed_value() &&
   61.14 +                             (load != NULL) && load->is_Load() &&
   61.15 +                             (phase->is_IterGVN() != NULL);
   61.16 +  if (!(is_instance || is_boxed_value_load))
   61.17      return mchain;  // don't try to optimize non-instance types
   61.18 -  uint instance_id = tinst->instance_id();
   61.19 +  uint instance_id = t_oop->instance_id();
   61.20    Node *start_mem = phase->C->start()->proj_out(TypeFunc::Memory);
   61.21    Node *prev = NULL;
   61.22    Node *result = mchain;
   61.23 @@ -122,15 +126,24 @@
   61.24          break;  // hit one of our sentinels
   61.25        } else if (proj_in->is_Call()) {
   61.26          CallNode *call = proj_in->as_Call();
   61.27 -        if (!call->may_modify(t_adr, phase)) {
   61.28 +        if (!call->may_modify(t_oop, phase)) { // returns false for instances
   61.29            result = call->in(TypeFunc::Memory);
   61.30          }
   61.31        } else if (proj_in->is_Initialize()) {
   61.32          AllocateNode* alloc = proj_in->as_Initialize()->allocation();
   61.33          // Stop if this is the initialization for the object instance which
   61.34          // which contains this memory slice, otherwise skip over it.
   61.35 -        if (alloc != NULL && alloc->_idx != instance_id) {
   61.36 +        if ((alloc == NULL) || (alloc->_idx == instance_id)) {
   61.37 +          break;
   61.38 +        }
   61.39 +        if (is_instance) {
   61.40            result = proj_in->in(TypeFunc::Memory);
   61.41 +        } else if (is_boxed_value_load) {
   61.42 +          Node* klass = alloc->in(AllocateNode::KlassNode);
   61.43 +          const TypeKlassPtr* tklass = phase->type(klass)->is_klassptr();
   61.44 +          if (tklass->klass_is_exact() && !tklass->klass()->equals(t_oop->klass())) {
   61.45 +            result = proj_in->in(TypeFunc::Memory); // not related allocation
   61.46 +          }
   61.47          }
   61.48        } else if (proj_in->is_MemBar()) {
   61.49          result = proj_in->in(TypeFunc::Memory);
   61.50 @@ -138,25 +151,26 @@
   61.51          assert(false, "unexpected projection");
   61.52        }
   61.53      } else if (result->is_ClearArray()) {
   61.54 -      if (!ClearArrayNode::step_through(&result, instance_id, phase)) {
   61.55 +      if (!is_instance || !ClearArrayNode::step_through(&result, instance_id, phase)) {
   61.56          // Can not bypass initialization of the instance
   61.57          // we are looking for.
   61.58          break;
   61.59        }
   61.60        // Otherwise skip it (the call updated 'result' value).
   61.61      } else if (result->is_MergeMem()) {
   61.62 -      result = step_through_mergemem(phase, result->as_MergeMem(), t_adr, NULL, tty);
   61.63 +      result = step_through_mergemem(phase, result->as_MergeMem(), t_oop, NULL, tty);
   61.64      }
   61.65    }
   61.66    return result;
   61.67  }
   61.68  
   61.69 -Node *MemNode::optimize_memory_chain(Node *mchain, const TypePtr *t_adr, PhaseGVN *phase) {
   61.70 -  const TypeOopPtr *t_oop = t_adr->isa_oopptr();
   61.71 -  bool is_instance = (t_oop != NULL) && t_oop->is_known_instance_field();
   61.72 +Node *MemNode::optimize_memory_chain(Node *mchain, const TypePtr *t_adr, Node *load, PhaseGVN *phase) {
   61.73 +  const TypeOopPtr* t_oop = t_adr->isa_oopptr();
   61.74 +  if (t_oop == NULL)
   61.75 +    return mchain;  // don't try to optimize non-oop types
   61.76 +  Node* result = optimize_simple_memory_chain(mchain, t_oop, load, phase);
   61.77 +  bool is_instance = t_oop->is_known_instance_field();
   61.78    PhaseIterGVN *igvn = phase->is_IterGVN();
   61.79 -  Node *result = mchain;
   61.80 -  result = optimize_simple_memory_chain(result, t_adr, phase);
   61.81    if (is_instance && igvn != NULL  && result->is_Phi()) {
   61.82      PhiNode *mphi = result->as_Phi();
   61.83      assert(mphi->bottom_type() == Type::MEMORY, "memory phi required");
   61.84 @@ -383,7 +397,7 @@
   61.85    // Or Region for the check in LoadNode::Ideal();
   61.86    // 'sub' should have sub->in(0) != NULL.
   61.87    assert(sub->is_Allocate() || sub->is_Initialize() || sub->is_Start() ||
   61.88 -         sub->is_Region(), "expecting only these nodes");
   61.89 +         sub->is_Region() || sub->is_Call(), "expecting only these nodes");
   61.90  
   61.91    // Get control edge of 'sub'.
   61.92    Node* orig_sub = sub;
   61.93 @@ -957,11 +971,14 @@
   61.94  // of aliasing.
   61.95  Node* MemNode::can_see_stored_value(Node* st, PhaseTransform* phase) const {
   61.96    Node* ld_adr = in(MemNode::Address);
   61.97 -
   61.98 +  intptr_t ld_off = 0;
   61.99 +  AllocateNode* ld_alloc = AllocateNode::Ideal_allocation(ld_adr, phase, ld_off);
  61.100    const TypeInstPtr* tp = phase->type(ld_adr)->isa_instptr();
  61.101 -  Compile::AliasType* atp = tp != NULL ? phase->C->alias_type(tp) : NULL;
  61.102 -  if (EliminateAutoBox && atp != NULL && atp->index() >= Compile::AliasIdxRaw &&
  61.103 -      atp->field() != NULL && !atp->field()->is_volatile()) {
  61.104 +  Compile::AliasType* atp = (tp != NULL) ? phase->C->alias_type(tp) : NULL;
  61.105 +  // This is more general than load from boxing objects.
  61.106 +  if (phase->C->eliminate_boxing() && (atp != NULL) &&
  61.107 +      (atp->index() >= Compile::AliasIdxRaw) &&
  61.108 +      (atp->field() != NULL) && !atp->field()->is_volatile()) {
  61.109      uint alias_idx = atp->index();
  61.110      bool final = atp->field()->is_final();
  61.111      Node* result = NULL;
  61.112 @@ -983,7 +1000,7 @@
  61.113            Node* new_st = merge->memory_at(alias_idx);
  61.114            if (new_st == merge->base_memory()) {
  61.115              // Keep searching
  61.116 -            current = merge->base_memory();
  61.117 +            current = new_st;
  61.118              continue;
  61.119            }
  61.120            // Save the new memory state for the slice and fall through
  61.121 @@ -1010,9 +1027,7 @@
  61.122          intptr_t st_off = 0;
  61.123          AllocateNode* alloc = AllocateNode::Ideal_allocation(st_adr, phase, st_off);
  61.124          if (alloc == NULL)       return NULL;
  61.125 -        intptr_t ld_off = 0;
  61.126 -        AllocateNode* allo2 = AllocateNode::Ideal_allocation(ld_adr, phase, ld_off);
  61.127 -        if (alloc != allo2)      return NULL;
  61.128 +        if (alloc != ld_alloc)   return NULL;
  61.129          if (ld_off != st_off)    return NULL;
  61.130          // At this point we have proven something like this setup:
  61.131          //  A = Allocate(...)
  61.132 @@ -1029,14 +1044,12 @@
  61.133        return st->in(MemNode::ValueIn);
  61.134      }
  61.135  
  61.136 -    intptr_t offset = 0;  // scratch
  61.137 -
  61.138      // A load from a freshly-created object always returns zero.
  61.139      // (This can happen after LoadNode::Ideal resets the load's memory input
  61.140      // to find_captured_store, which returned InitializeNode::zero_memory.)
  61.141      if (st->is_Proj() && st->in(0)->is_Allocate() &&
  61.142 -        st->in(0) == AllocateNode::Ideal_allocation(ld_adr, phase, offset) &&
  61.143 -        offset >= st->in(0)->as_Allocate()->minimum_header_size()) {
  61.144 +        (st->in(0) == ld_alloc) &&
  61.145 +        (ld_off >= st->in(0)->as_Allocate()->minimum_header_size())) {
  61.146        // return a zero value for the load's basic type
  61.147        // (This is one of the few places where a generic PhaseTransform
  61.148        // can create new nodes.  Think of it as lazily manifesting
  61.149 @@ -1048,15 +1061,27 @@
  61.150      if (st->is_Proj() && st->in(0)->is_Initialize()) {
  61.151        InitializeNode* init = st->in(0)->as_Initialize();
  61.152        AllocateNode* alloc = init->allocation();
  61.153 -      if (alloc != NULL &&
  61.154 -          alloc == AllocateNode::Ideal_allocation(ld_adr, phase, offset)) {
  61.155 +      if ((alloc != NULL) && (alloc == ld_alloc)) {
  61.156          // examine a captured store value
  61.157 -        st = init->find_captured_store(offset, memory_size(), phase);
  61.158 +        st = init->find_captured_store(ld_off, memory_size(), phase);
  61.159          if (st != NULL)
  61.160            continue;             // take one more trip around
  61.161        }
  61.162      }
  61.163  
  61.164 +    // Load boxed value from result of valueOf() call is input parameter.
  61.165 +    if (this->is_Load() && ld_adr->is_AddP() &&
  61.166 +        (tp != NULL) && tp->is_ptr_to_boxed_value()) {
  61.167 +      intptr_t ignore = 0;
  61.168 +      Node* base = AddPNode::Ideal_base_and_offset(ld_adr, phase, ignore);
  61.169 +      if (base != NULL && base->is_Proj() &&
  61.170 +          base->as_Proj()->_con == TypeFunc::Parms &&
  61.171 +          base->in(0)->is_CallStaticJava() &&
  61.172 +          base->in(0)->as_CallStaticJava()->is_boxing_method()) {
  61.173 +        return base->in(0)->in(TypeFunc::Parms);
  61.174 +      }
  61.175 +    }
  61.176 +
  61.177      break;
  61.178    }
  61.179  
  61.180 @@ -1065,11 +1090,13 @@
  61.181  
  61.182  //----------------------is_instance_field_load_with_local_phi------------------
  61.183  bool LoadNode::is_instance_field_load_with_local_phi(Node* ctrl) {
  61.184 -  if( in(MemNode::Memory)->is_Phi() && in(MemNode::Memory)->in(0) == ctrl &&
  61.185 -      in(MemNode::Address)->is_AddP() ) {
  61.186 -    const TypeOopPtr* t_oop = in(MemNode::Address)->bottom_type()->isa_oopptr();
  61.187 -    // Only instances.
  61.188 -    if( t_oop != NULL && t_oop->is_known_instance_field() &&
  61.189 +  if( in(Memory)->is_Phi() && in(Memory)->in(0) == ctrl &&
  61.190 +      in(Address)->is_AddP() ) {
  61.191 +    const TypeOopPtr* t_oop = in(Address)->bottom_type()->isa_oopptr();
  61.192 +    // Only instances and boxed values.
  61.193 +    if( t_oop != NULL &&
  61.194 +        (t_oop->is_ptr_to_boxed_value() ||
  61.195 +         t_oop->is_known_instance_field()) &&
  61.196          t_oop->offset() != Type::OffsetBot &&
  61.197          t_oop->offset() != Type::OffsetTop) {
  61.198        return true;
  61.199 @@ -1083,7 +1110,7 @@
  61.200  Node *LoadNode::Identity( PhaseTransform *phase ) {
  61.201    // If the previous store-maker is the right kind of Store, and the store is
  61.202    // to the same address, then we are equal to the value stored.
  61.203 -  Node* mem = in(MemNode::Memory);
  61.204 +  Node* mem = in(Memory);
  61.205    Node* value = can_see_stored_value(mem, phase);
  61.206    if( value ) {
  61.207      // byte, short & char stores truncate naturally.
  61.208 @@ -1105,15 +1132,22 @@
  61.209    // instance's field to avoid infinite generation of phis in a loop.
  61.210    Node *region = mem->in(0);
  61.211    if (is_instance_field_load_with_local_phi(region)) {
  61.212 -    const TypePtr *addr_t = in(MemNode::Address)->bottom_type()->isa_ptr();
  61.213 +    const TypeOopPtr *addr_t = in(Address)->bottom_type()->isa_oopptr();
  61.214      int this_index  = phase->C->get_alias_index(addr_t);
  61.215      int this_offset = addr_t->offset();
  61.216 -    int this_id    = addr_t->is_oopptr()->instance_id();
  61.217 +    int this_iid    = addr_t->instance_id();
  61.218 +    if (!addr_t->is_known_instance() &&
  61.219 +         addr_t->is_ptr_to_boxed_value()) {
  61.220 +      // Use _idx of address base (could be Phi node) for boxed values.
  61.221 +      intptr_t   ignore = 0;
  61.222 +      Node*      base = AddPNode::Ideal_base_and_offset(in(Address), phase, ignore);
  61.223 +      this_iid = base->_idx;
  61.224 +    }
  61.225      const Type* this_type = bottom_type();
  61.226      for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
  61.227        Node* phi = region->fast_out(i);
  61.228        if (phi->is_Phi() && phi != mem &&
  61.229 -          phi->as_Phi()->is_same_inst_field(this_type, this_id, this_index, this_offset)) {
  61.230 +          phi->as_Phi()->is_same_inst_field(this_type, this_iid, this_index, this_offset)) {
  61.231          return phi;
  61.232        }
  61.233      }
  61.234 @@ -1122,170 +1156,106 @@
  61.235    return this;
  61.236  }
  61.237  
  61.238 -
  61.239 -// Returns true if the AliasType refers to the field that holds the
  61.240 -// cached box array.  Currently only handles the IntegerCache case.
  61.241 -static bool is_autobox_cache(Compile::AliasType* atp) {
  61.242 -  if (atp != NULL && atp->field() != NULL) {
  61.243 -    ciField* field = atp->field();
  61.244 -    ciSymbol* klass = field->holder()->name();
  61.245 -    if (field->name() == ciSymbol::cache_field_name() &&
  61.246 -        field->holder()->uses_default_loader() &&
  61.247 -        klass == ciSymbol::java_lang_Integer_IntegerCache()) {
  61.248 -      return true;
  61.249 -    }
  61.250 -  }
  61.251 -  return false;
  61.252 -}
  61.253 -
  61.254 -// Fetch the base value in the autobox array
  61.255 -static bool fetch_autobox_base(Compile::AliasType* atp, int& cache_offset) {
  61.256 -  if (atp != NULL && atp->field() != NULL) {
  61.257 -    ciField* field = atp->field();
  61.258 -    ciSymbol* klass = field->holder()->name();
  61.259 -    if (field->name() == ciSymbol::cache_field_name() &&
  61.260 -        field->holder()->uses_default_loader() &&
  61.261 -        klass == ciSymbol::java_lang_Integer_IntegerCache()) {
  61.262 -      assert(field->is_constant(), "what?");
  61.263 -      ciObjArray* array = field->constant_value().as_object()->as_obj_array();
  61.264 -      // Fetch the box object at the base of the array and get its value
  61.265 -      ciInstance* box = array->obj_at(0)->as_instance();
  61.266 -      ciInstanceKlass* ik = box->klass()->as_instance_klass();
  61.267 -      if (ik->nof_nonstatic_fields() == 1) {
  61.268 -        // This should be true nonstatic_field_at requires calling
  61.269 -        // nof_nonstatic_fields so check it anyway
  61.270 -        ciConstant c = box->field_value(ik->nonstatic_field_at(0));
  61.271 -        cache_offset = c.as_int();
  61.272 -      }
  61.273 -      return true;
  61.274 -    }
  61.275 -  }
  61.276 -  return false;
  61.277 -}
  61.278 -
  61.279 -// Returns true if the AliasType refers to the value field of an
  61.280 -// autobox object.  Currently only handles Integer.
  61.281 -static bool is_autobox_object(Compile::AliasType* atp) {
  61.282 -  if (atp != NULL && atp->field() != NULL) {
  61.283 -    ciField* field = atp->field();
  61.284 -    ciSymbol* klass = field->holder()->name();
  61.285 -    if (field->name() == ciSymbol::value_name() &&
  61.286 -        field->holder()->uses_default_loader() &&
  61.287 -        klass == ciSymbol::java_lang_Integer()) {
  61.288 -      return true;
  61.289 -    }
  61.290 -  }
  61.291 -  return false;
  61.292 -}
  61.293 -
  61.294 -
  61.295  // We're loading from an object which has autobox behaviour.
  61.296  // If this object is result of a valueOf call we'll have a phi
  61.297  // merging a newly allocated object and a load from the cache.
  61.298  // We want to replace this load with the original incoming
  61.299  // argument to the valueOf call.
  61.300  Node* LoadNode::eliminate_autobox(PhaseGVN* phase) {
  61.301 -  Node* base = in(Address)->in(AddPNode::Base);
  61.302 -  if (base->is_Phi() && base->req() == 3) {
  61.303 -    AllocateNode* allocation = NULL;
  61.304 -    int allocation_index = -1;
  61.305 -    int load_index = -1;
  61.306 -    for (uint i = 1; i < base->req(); i++) {
  61.307 -      allocation = AllocateNode::Ideal_allocation(base->in(i), phase);
  61.308 -      if (allocation != NULL) {
  61.309 -        allocation_index = i;
  61.310 -        load_index = 3 - allocation_index;
  61.311 -        break;
  61.312 -      }
  61.313 -    }
  61.314 -    bool has_load = ( allocation != NULL &&
  61.315 -                      (base->in(load_index)->is_Load() ||
  61.316 -                       base->in(load_index)->is_DecodeN() &&
  61.317 -                       base->in(load_index)->in(1)->is_Load()) );
  61.318 -    if (has_load && in(Memory)->is_Phi() && in(Memory)->in(0) == base->in(0)) {
  61.319 -      // Push the loads from the phi that comes from valueOf up
  61.320 -      // through it to allow elimination of the loads and the recovery
  61.321 -      // of the original value.
  61.322 -      Node* mem_phi = in(Memory);
  61.323 -      Node* offset = in(Address)->in(AddPNode::Offset);
  61.324 -      Node* region = base->in(0);
  61.325 -
  61.326 -      Node* in1 = clone();
  61.327 -      Node* in1_addr = in1->in(Address)->clone();
  61.328 -      in1_addr->set_req(AddPNode::Base, base->in(allocation_index));
  61.329 -      in1_addr->set_req(AddPNode::Address, base->in(allocation_index));
  61.330 -      in1_addr->set_req(AddPNode::Offset, offset);
  61.331 -      in1->set_req(0, region->in(allocation_index));
  61.332 -      in1->set_req(Address, in1_addr);
  61.333 -      in1->set_req(Memory, mem_phi->in(allocation_index));
  61.334 -
  61.335 -      Node* in2 = clone();
  61.336 -      Node* in2_addr = in2->in(Address)->clone();
  61.337 -      in2_addr->set_req(AddPNode::Base, base->in(load_index));
  61.338 -      in2_addr->set_req(AddPNode::Address, base->in(load_index));
  61.339 -      in2_addr->set_req(AddPNode::Offset, offset);
  61.340 -      in2->set_req(0, region->in(load_index));
  61.341 -      in2->set_req(Address, in2_addr);
  61.342 -      in2->set_req(Memory, mem_phi->in(load_index));
  61.343 -
  61.344 -      in1_addr = phase->transform(in1_addr);
  61.345 -      in1 =      phase->transform(in1);
  61.346 -      in2_addr = phase->transform(in2_addr);
  61.347 -      in2 =      phase->transform(in2);
  61.348 -
  61.349 -      PhiNode* result = PhiNode::make_blank(region, this);
  61.350 -      result->set_req(allocation_index, in1);
  61.351 -      result->set_req(load_index, in2);
  61.352 -      return result;
  61.353 -    }
  61.354 +  assert(phase->C->eliminate_boxing(), "sanity");
  61.355 +  intptr_t ignore = 0;
  61.356 +  Node* base = AddPNode::Ideal_base_and_offset(in(Address), phase, ignore);
  61.357 +  if ((base == NULL) || base->is_Phi()) {
  61.358 +    // Push the loads from the phi that comes from valueOf up
  61.359 +    // through it to allow elimination of the loads and the recovery
  61.360 +    // of the original value. It is done in split_through_phi().
  61.361 +    return NULL;
  61.362    } else if (base->is_Load() ||
  61.363               base->is_DecodeN() && base->in(1)->is_Load()) {
  61.364 +    // Eliminate the load of boxed value for integer types from the cache
  61.365 +    // array by deriving the value from the index into the array.
  61.366 +    // Capture the offset of the load and then reverse the computation.
  61.367 +
  61.368 +    // Get LoadN node which loads a boxing object from 'cache' array.
  61.369      if (base->is_DecodeN()) {
  61.370 -      // Get LoadN node which loads cached Integer object
  61.371        base = base->in(1);
  61.372      }
  61.373 -    // Eliminate the load of Integer.value for integers from the cache
  61.374 -    // array by deriving the value from the index into the array.
  61.375 -    // Capture the offset of the load and then reverse the computation.
  61.376 -    Node* load_base = base->in(Address)->in(AddPNode::Base);
  61.377 -    if (load_base->is_DecodeN()) {
  61.378 -      // Get LoadN node which loads IntegerCache.cache field
  61.379 -      load_base = load_base->in(1);
  61.380 +    if (!base->in(Address)->is_AddP()) {
  61.381 +      return NULL; // Complex address
  61.382      }
  61.383 -    if (load_base != NULL) {
  61.384 -      Compile::AliasType* atp = phase->C->alias_type(load_base->adr_type());
  61.385 -      intptr_t cache_offset;
  61.386 -      int shift = -1;
  61.387 -      Node* cache = NULL;
  61.388 -      if (is_autobox_cache(atp)) {
  61.389 -        shift  = exact_log2(type2aelembytes(T_OBJECT));
  61.390 -        cache = AddPNode::Ideal_base_and_offset(load_base->in(Address), phase, cache_offset);
  61.391 -      }
  61.392 -      if (cache != NULL && base->in(Address)->is_AddP()) {
  61.393 +    AddPNode* address = base->in(Address)->as_AddP();
  61.394 +    Node* cache_base = address->in(AddPNode::Base);
  61.395 +    if ((cache_base != NULL) && cache_base->is_DecodeN()) {
  61.396 +      // Get ConP node which is static 'cache' field.
  61.397 +      cache_base = cache_base->in(1);
  61.398 +    }
  61.399 +    if ((cache_base != NULL) && cache_base->is_Con()) {
  61.400 +      const TypeAryPtr* base_type = cache_base->bottom_type()->isa_aryptr();
  61.401 +      if ((base_type != NULL) && base_type->is_autobox_cache()) {
  61.402          Node* elements[4];
  61.403 -        int count = base->in(Address)->as_AddP()->unpack_offsets(elements, ARRAY_SIZE(elements));
  61.404 -        int cache_low;
  61.405 -        if (count > 0 && fetch_autobox_base(atp, cache_low)) {
  61.406 -          int offset = arrayOopDesc::base_offset_in_bytes(memory_type()) - (cache_low << shift);
  61.407 -          // Add up all the offsets making of the address of the load
  61.408 -          Node* result = elements[0];
  61.409 -          for (int i = 1; i < count; i++) {
  61.410 -            result = phase->transform(new (phase->C) AddXNode(result, elements[i]));
  61.411 +        int shift = exact_log2(type2aelembytes(T_OBJECT));
  61.412 +        int count = address->unpack_offsets(elements, ARRAY_SIZE(elements));
  61.413 +        if ((count >  0) && elements[0]->is_Con() &&
  61.414 +            ((count == 1) ||
  61.415 +             (count == 2) && elements[1]->Opcode() == Op_LShiftX &&
  61.416 +                             elements[1]->in(2) == phase->intcon(shift))) {
  61.417 +          ciObjArray* array = base_type->const_oop()->as_obj_array();
  61.418 +          // Fetch the box object cache[0] at the base of the array and get its value
  61.419 +          ciInstance* box = array->obj_at(0)->as_instance();
  61.420 +          ciInstanceKlass* ik = box->klass()->as_instance_klass();
  61.421 +          assert(ik->is_box_klass(), "sanity");
  61.422 +          assert(ik->nof_nonstatic_fields() == 1, "change following code");
  61.423 +          if (ik->nof_nonstatic_fields() == 1) {
  61.424 +            // This should be true nonstatic_field_at requires calling
  61.425 +            // nof_nonstatic_fields so check it anyway
  61.426 +            ciConstant c = box->field_value(ik->nonstatic_field_at(0));
  61.427 +            BasicType bt = c.basic_type();
  61.428 +            // Only integer types have boxing cache.
  61.429 +            assert(bt == T_BOOLEAN || bt == T_CHAR  ||
  61.430 +                   bt == T_BYTE    || bt == T_SHORT ||
  61.431 +                   bt == T_INT     || bt == T_LONG, err_msg_res("wrong type = %s", type2name(bt)));
  61.432 +            jlong cache_low = (bt == T_LONG) ? c.as_long() : c.as_int();
  61.433 +            if (cache_low != (int)cache_low) {
  61.434 +              return NULL; // should not happen since cache is array indexed by value
  61.435 +            }
  61.436 +            jlong offset = arrayOopDesc::base_offset_in_bytes(T_OBJECT) - (cache_low << shift);
  61.437 +            if (offset != (int)offset) {
  61.438 +              return NULL; // should not happen since cache is array indexed by value
  61.439 +            }
  61.440 +           // Add up all the offsets making of the address of the load
  61.441 +            Node* result = elements[0];
  61.442 +            for (int i = 1; i < count; i++) {
  61.443 +              result = phase->transform(new (phase->C) AddXNode(result, elements[i]));
  61.444 +            }
  61.445 +            // Remove the constant offset from the address and then
  61.446 +            result = phase->transform(new (phase->C) AddXNode(result, phase->MakeConX(-(int)offset)));
  61.447 +            // remove the scaling of the offset to recover the original index.
  61.448 +            if (result->Opcode() == Op_LShiftX && result->in(2) == phase->intcon(shift)) {
  61.449 +              // Peel the shift off directly but wrap it in a dummy node
  61.450 +              // since Ideal can't return existing nodes
  61.451 +              result = new (phase->C) RShiftXNode(result->in(1), phase->intcon(0));
  61.452 +            } else if (result->is_Add() && result->in(2)->is_Con() &&
  61.453 +                       result->in(1)->Opcode() == Op_LShiftX &&
  61.454 +                       result->in(1)->in(2) == phase->intcon(shift)) {
  61.455 +              // We can't do general optimization: ((X<<Z) + Y) >> Z ==> X + (Y>>Z)
  61.456 +              // but for boxing cache access we know that X<<Z will not overflow
  61.457 +              // (there is range check) so we do this optimizatrion by hand here.
  61.458 +              Node* add_con = new (phase->C) RShiftXNode(result->in(2), phase->intcon(shift));
  61.459 +              result = new (phase->C) AddXNode(result->in(1)->in(1), phase->transform(add_con));
  61.460 +            } else {
  61.461 +              result = new (phase->C) RShiftXNode(result, phase->intcon(shift));
  61.462 +            }
  61.463 +#ifdef _LP64
  61.464 +            if (bt != T_LONG) {
  61.465 +              result = new (phase->C) ConvL2INode(phase->transform(result));
  61.466 +            }
  61.467 +#else
  61.468 +            if (bt == T_LONG) {
  61.469 +              result = new (phase->C) ConvI2LNode(phase->transform(result));
  61.470 +            }
  61.471 +#endif
  61.472 +            return result;
  61.473            }
  61.474 -          // Remove the constant offset from the address and then
  61.475 -          // remove the scaling of the offset to recover the original index.
  61.476 -          result = phase->transform(new (phase->C) AddXNode(result, phase->MakeConX(-offset)));
  61.477 -          if (result->Opcode() == Op_LShiftX && result->in(2) == phase->intcon(shift)) {
  61.478 -            // Peel the shift off directly but wrap it in a dummy node
  61.479 -            // since Ideal can't return existing nodes
  61.480 -            result = new (phase->C) RShiftXNode(result->in(1), phase->intcon(0));
  61.481 -          } else {
  61.482 -            result = new (phase->C) RShiftXNode(result, phase->intcon(shift));
  61.483 -          }
  61.484 -#ifdef _LP64
  61.485 -          result = new (phase->C) ConvL2INode(phase->transform(result));
  61.486 -#endif
  61.487 -          return result;
  61.488          }
  61.489        }
  61.490      }
  61.491 @@ -1293,65 +1263,131 @@
  61.492    return NULL;
  61.493  }
  61.494  
  61.495 -//------------------------------split_through_phi------------------------------
  61.496 -// Split instance field load through Phi.
  61.497 -Node *LoadNode::split_through_phi(PhaseGVN *phase) {
  61.498 -  Node* mem     = in(MemNode::Memory);
  61.499 -  Node* address = in(MemNode::Address);
  61.500 -  const TypePtr *addr_t = phase->type(address)->isa_ptr();
  61.501 -  const TypeOopPtr *t_oop = addr_t->isa_oopptr();
  61.502 -
  61.503 -  assert(mem->is_Phi() && (t_oop != NULL) &&
  61.504 -         t_oop->is_known_instance_field(), "invalide conditions");
  61.505 -
  61.506 -  Node *region = mem->in(0);
  61.507 +static bool stable_phi(PhiNode* phi, PhaseGVN *phase) {
  61.508 +  Node* region = phi->in(0);
  61.509    if (region == NULL) {
  61.510 -    return NULL; // Wait stable graph
  61.511 +    return false; // Wait stable graph
  61.512    }
  61.513 -  uint cnt = mem->req();
  61.514 +  uint cnt = phi->req();
  61.515    for (uint i = 1; i < cnt; i++) {
  61.516      Node* rc = region->in(i);
  61.517      if (rc == NULL || phase->type(rc) == Type::TOP)
  61.518 -      return NULL; // Wait stable graph
  61.519 -    Node *in = mem->in(i);
  61.520 -    if (in == NULL) {
  61.521 +      return false; // Wait stable graph
  61.522 +    Node* in = phi->in(i);
  61.523 +    if (in == NULL || phase->type(in) == Type::TOP)
  61.524 +      return false; // Wait stable graph
  61.525 +  }
  61.526 +  return true;
  61.527 +}
  61.528 +//------------------------------split_through_phi------------------------------
  61.529 +// Split instance or boxed field load through Phi.
  61.530 +Node *LoadNode::split_through_phi(PhaseGVN *phase) {
  61.531 +  Node* mem     = in(Memory);
  61.532 +  Node* address = in(Address);
  61.533 +  const TypeOopPtr *t_oop = phase->type(address)->isa_oopptr();
  61.534 +
  61.535 +  assert((t_oop != NULL) &&
  61.536 +         (t_oop->is_known_instance_field() ||
  61.537 +          t_oop->is_ptr_to_boxed_value()), "invalide conditions");
  61.538 +
  61.539 +  Compile* C = phase->C;
  61.540 +  intptr_t ignore = 0;
  61.541 +  Node*    base = AddPNode::Ideal_base_and_offset(address, phase, ignore);
  61.542 +  bool base_is_phi = (base != NULL) && base->is_Phi();
  61.543 +  bool load_boxed_values = t_oop->is_ptr_to_boxed_value() && C->aggressive_unboxing() &&
  61.544 +                           (base != NULL) && (base == address->in(AddPNode::Base)) &&
  61.545 +                           phase->type(base)->higher_equal(TypePtr::NOTNULL);
  61.546 +
  61.547 +  if (!((mem->is_Phi() || base_is_phi) &&
  61.548 +        (load_boxed_values || t_oop->is_known_instance_field()))) {
  61.549 +    return NULL; // memory is not Phi
  61.550 +  }
  61.551 +
  61.552 +  if (mem->is_Phi()) {
  61.553 +    if (!stable_phi(mem->as_Phi(), phase)) {
  61.554        return NULL; // Wait stable graph
  61.555      }
  61.556 -  }
  61.557 -  // Check for loop invariant.
  61.558 -  if (cnt == 3) {
  61.559 -    for (uint i = 1; i < cnt; i++) {
  61.560 -      Node *in = mem->in(i);
  61.561 -      Node* m = MemNode::optimize_memory_chain(in, addr_t, phase);
  61.562 -      if (m == mem) {
  61.563 -        set_req(MemNode::Memory, mem->in(cnt - i)); // Skip this phi.
  61.564 -        return this;
  61.565 +    uint cnt = mem->req();
  61.566 +    // Check for loop invariant memory.
  61.567 +    if (cnt == 3) {
  61.568 +      for (uint i = 1; i < cnt; i++) {
  61.569 +        Node* in = mem->in(i);
  61.570 +        Node*  m = optimize_memory_chain(in, t_oop, this, phase);
  61.571 +        if (m == mem) {
  61.572 +          set_req(Memory, mem->in(cnt - i));
  61.573 +          return this; // made change
  61.574 +        }
  61.575        }
  61.576      }
  61.577    }
  61.578 +  if (base_is_phi) {
  61.579 +    if (!stable_phi(base->as_Phi(), phase)) {
  61.580 +      return NULL; // Wait stable graph
  61.581 +    }
  61.582 +    uint cnt = base->req();
  61.583 +    // Check for loop invariant memory.
  61.584 +    if (cnt == 3) {
  61.585 +      for (uint i = 1; i < cnt; i++) {
  61.586 +        if (base->in(i) == base) {
  61.587 +          return NULL; // Wait stable graph
  61.588 +        }
  61.589 +      }
  61.590 +    }
  61.591 +  }
  61.592 +
  61.593 +  bool load_boxed_phi = load_boxed_values && base_is_phi && (base->in(0) == mem->in(0));
  61.594 +
  61.595    // Split through Phi (see original code in loopopts.cpp).
  61.596 -  assert(phase->C->have_alias_type(addr_t), "instance should have alias type");
  61.597 +  assert(C->have_alias_type(t_oop), "instance should have alias type");
  61.598  
  61.599    // Do nothing here if Identity will find a value
  61.600    // (to avoid infinite chain of value phis generation).
  61.601    if (!phase->eqv(this, this->Identity(phase)))
  61.602      return NULL;
  61.603  
  61.604 -  // Skip the split if the region dominates some control edge of the address.
  61.605 -  if (!MemNode::all_controls_dominate(address, region))
  61.606 -    return NULL;
  61.607 +  // Select Region to split through.
  61.608 +  Node* region;
  61.609 +  if (!base_is_phi) {
  61.610 +    assert(mem->is_Phi(), "sanity");
  61.611 +    region = mem->in(0);
  61.612 +    // Skip if the region dominates some control edge of the address.
  61.613 +    if (!MemNode::all_controls_dominate(address, region))
  61.614 +      return NULL;
  61.615 +  } else if (!mem->is_Phi()) {
  61.616 +    assert(base_is_phi, "sanity");
  61.617 +    region = base->in(0);
  61.618 +    // Skip if the region dominates some control edge of the memory.
  61.619 +    if (!MemNode::all_controls_dominate(mem, region))
  61.620 +      return NULL;
  61.621 +  } else if (base->in(0) != mem->in(0)) {
  61.622 +    assert(base_is_phi && mem->is_Phi(), "sanity");
  61.623 +    if (MemNode::all_controls_dominate(mem, base->in(0))) {
  61.624 +      region = base->in(0);
  61.625 +    } else if (MemNode::all_controls_dominate(address, mem->in(0))) {
  61.626 +      region = mem->in(0);
  61.627 +    } else {
  61.628 +      return NULL; // complex graph
  61.629 +    }
  61.630 +  } else {
  61.631 +    assert(base->in(0) == mem->in(0), "sanity");
  61.632 +    region = mem->in(0);
  61.633 +  }
  61.634  
  61.635    const Type* this_type = this->bottom_type();
  61.636 -  int this_index  = phase->C->get_alias_index(addr_t);
  61.637 -  int this_offset = addr_t->offset();
  61.638 -  int this_iid    = addr_t->is_oopptr()->instance_id();
  61.639 -  PhaseIterGVN *igvn = phase->is_IterGVN();
  61.640 -  Node *phi = new (igvn->C) PhiNode(region, this_type, NULL, this_iid, this_index, this_offset);
  61.641 +  int this_index  = C->get_alias_index(t_oop);
  61.642 +  int this_offset = t_oop->offset();
  61.643 +  int this_iid    = t_oop->instance_id();
  61.644 +  if (!t_oop->is_known_instance() && load_boxed_values) {
  61.645 +    // Use _idx of address base for boxed values.
  61.646 +    this_iid = base->_idx;
  61.647 +  }
  61.648 +  PhaseIterGVN* igvn = phase->is_IterGVN();
  61.649 +  Node* phi = new (C) PhiNode(region, this_type, NULL, this_iid, this_index, this_offset);
  61.650    for (uint i = 1; i < region->req(); i++) {
  61.651 -    Node *x;
  61.652 +    Node* x;
  61.653      Node* the_clone = NULL;
  61.654 -    if (region->in(i) == phase->C->top()) {
  61.655 -      x = phase->C->top();      // Dead path?  Use a dead data op
  61.656 +    if (region->in(i) == C->top()) {
  61.657 +      x = C->top();      // Dead path?  Use a dead data op
  61.658      } else {
  61.659        x = this->clone();        // Else clone up the data op
  61.660        the_clone = x;            // Remember for possible deletion.
  61.661 @@ -1361,10 +1397,16 @@
  61.662        } else {
  61.663          x->set_req(0, NULL);
  61.664        }
  61.665 -      for (uint j = 1; j < this->req(); j++) {
  61.666 -        Node *in = this->in(j);
  61.667 -        if (in->is_Phi() && in->in(0) == region)
  61.668 -          x->set_req(j, in->in(i)); // Use pre-Phi input for the clone
  61.669 +      if (mem->is_Phi() && (mem->in(0) == region)) {
  61.670 +        x->set_req(Memory, mem->in(i)); // Use pre-Phi input for the clone.
  61.671 +      }
  61.672 +      if (address->is_Phi() && address->in(0) == region) {
  61.673 +        x->set_req(Address, address->in(i)); // Use pre-Phi input for the clone
  61.674 +      }
  61.675 +      if (base_is_phi && (base->in(0) == region)) {
  61.676 +        Node* base_x = base->in(i); // Clone address for loads from boxed objects.
  61.677 +        Node* adr_x = phase->transform(new (C) AddPNode(base_x,base_x,address->in(AddPNode::Offset)));
  61.678 +        x->set_req(Address, adr_x);
  61.679        }
  61.680      }
  61.681      // Check for a 'win' on some paths
  61.682 @@ -1394,7 +1436,7 @@
  61.683        if (y != x) {
  61.684          x = y;
  61.685        } else {
  61.686 -        y = igvn->hash_find(x);
  61.687 +        y = igvn->hash_find_insert(x);
  61.688          if (y) {
  61.689            x = y;
  61.690          } else {
  61.691 @@ -1405,8 +1447,9 @@
  61.692          }
  61.693        }
  61.694      }
  61.695 -    if (x != the_clone && the_clone != NULL)
  61.696 +    if (x != the_clone && the_clone != NULL) {
  61.697        igvn->remove_dead_node(the_clone);
  61.698 +    }
  61.699      phi->set_req(i, x);
  61.700    }
  61.701    // Record Phi
  61.702 @@ -1445,31 +1488,23 @@
  61.703        // A method-invariant, non-null address (constant or 'this' argument).
  61.704        set_req(MemNode::Control, NULL);
  61.705      }
  61.706 -
  61.707 -    if (EliminateAutoBox && can_reshape) {
  61.708 -      assert(!phase->type(base)->higher_equal(TypePtr::NULL_PTR), "the autobox pointer should be non-null");
  61.709 -      Compile::AliasType* atp = phase->C->alias_type(adr_type());
  61.710 -      if (is_autobox_object(atp)) {
  61.711 -        Node* result = eliminate_autobox(phase);
  61.712 -        if (result != NULL) return result;
  61.713 -      }
  61.714 -    }
  61.715    }
  61.716  
  61.717    Node* mem = in(MemNode::Memory);
  61.718    const TypePtr *addr_t = phase->type(address)->isa_ptr();
  61.719  
  61.720 -  if (addr_t != NULL) {
  61.721 +  if (can_reshape && (addr_t != NULL)) {
  61.722      // try to optimize our memory input
  61.723 -    Node* opt_mem = MemNode::optimize_memory_chain(mem, addr_t, phase);
  61.724 +    Node* opt_mem = MemNode::optimize_memory_chain(mem, addr_t, this, phase);
  61.725      if (opt_mem != mem) {
  61.726        set_req(MemNode::Memory, opt_mem);
  61.727        if (phase->type( opt_mem ) == Type::TOP) return NULL;
  61.728        return this;
  61.729      }
  61.730      const TypeOopPtr *t_oop = addr_t->isa_oopptr();
  61.731 -    if (can_reshape && opt_mem->is_Phi() &&
  61.732 -        (t_oop != NULL) && t_oop->is_known_instance_field()) {
  61.733 +    if ((t_oop != NULL) &&
  61.734 +        (t_oop->is_known_instance_field() ||
  61.735 +         t_oop->is_ptr_to_boxed_value())) {
  61.736        PhaseIterGVN *igvn = phase->is_IterGVN();
  61.737        if (igvn != NULL && igvn->_worklist.member(opt_mem)) {
  61.738          // Delay this transformation until memory Phi is processed.
  61.739 @@ -1479,6 +1514,11 @@
  61.740        // Split instance field load through Phi.
  61.741        Node* result = split_through_phi(phase);
  61.742        if (result != NULL) return result;
  61.743 +
  61.744 +      if (t_oop->is_ptr_to_boxed_value()) {
  61.745 +        Node* result = eliminate_autobox(phase);
  61.746 +        if (result != NULL) return result;
  61.747 +      }
  61.748      }
  61.749    }
  61.750  
  61.751 @@ -1587,18 +1627,23 @@
  61.752            // This can happen if a interface-typed array narrows to a class type.
  61.753            jt = _type;
  61.754          }
  61.755 -
  61.756 -        if (EliminateAutoBox && adr->is_AddP()) {
  61.757 +#ifdef ASSERT
  61.758 +        if (phase->C->eliminate_boxing() && adr->is_AddP()) {
  61.759            // The pointers in the autobox arrays are always non-null
  61.760            Node* base = adr->in(AddPNode::Base);
  61.761 -          if (base != NULL &&
  61.762 -              !phase->type(base)->higher_equal(TypePtr::NULL_PTR)) {
  61.763 -            Compile::AliasType* atp = C->alias_type(base->adr_type());
  61.764 -            if (is_autobox_cache(atp)) {
  61.765 -              return jt->join(TypePtr::NOTNULL)->is_ptr();
  61.766 +          if ((base != NULL) && base->is_DecodeN()) {
  61.767 +            // Get LoadN node which loads IntegerCache.cache field
  61.768 +            base = base->in(1);
  61.769 +          }
  61.770 +          if ((base != NULL) && base->is_Con()) {
  61.771 +            const TypeAryPtr* base_type = base->bottom_type()->isa_aryptr();
  61.772 +            if ((base_type != NULL) && base_type->is_autobox_cache()) {
  61.773 +              // It could be narrow oop
  61.774 +              assert(jt->make_ptr()->ptr() == TypePtr::NotNull,"sanity");
  61.775              }
  61.776            }
  61.777          }
  61.778 +#endif
  61.779          return jt;
  61.780        }
  61.781      }
  61.782 @@ -1638,6 +1683,10 @@
  61.783      // Optimizations for constant objects
  61.784      ciObject* const_oop = tinst->const_oop();
  61.785      if (const_oop != NULL) {
  61.786 +      // For constant Boxed value treat the target field as a compile time constant.
  61.787 +      if (tinst->is_ptr_to_boxed_value()) {
  61.788 +        return tinst->get_const_boxed_value();
  61.789 +      } else
  61.790        // For constant CallSites treat the target field as a compile time constant.
  61.791        if (const_oop->is_call_site()) {
  61.792          ciCallSite* call_site = const_oop->as_call_site();
  61.793 @@ -1759,7 +1808,8 @@
  61.794    // (Also allow a variable load from a fresh array to produce zero.)
  61.795    const TypeOopPtr *tinst = tp->isa_oopptr();
  61.796    bool is_instance = (tinst != NULL) && tinst->is_known_instance_field();
  61.797 -  if (ReduceFieldZeroing || is_instance) {
  61.798 +  bool is_boxed_value = (tinst != NULL) && tinst->is_ptr_to_boxed_value();
  61.799 +  if (ReduceFieldZeroing || is_instance || is_boxed_value) {
  61.800      Node* value = can_see_stored_value(mem,phase);
  61.801      if (value != NULL && value->is_Con()) {
  61.802        assert(value->bottom_type()->higher_equal(_type),"sanity");
  61.803 @@ -2883,24 +2933,38 @@
  61.804    if (in(0) && in(0)->is_top())  return NULL;
  61.805  
  61.806    // Eliminate volatile MemBars for scalar replaced objects.
  61.807 -  if (can_reshape && req() == (Precedent+1) &&
  61.808 -      (Opcode() == Op_MemBarAcquire || Opcode() == Op_MemBarVolatile)) {
  61.809 -    // Volatile field loads and stores.
  61.810 -    Node* my_mem = in(MemBarNode::Precedent);
  61.811 -    if (my_mem != NULL && my_mem->is_Mem()) {
  61.812 -      const TypeOopPtr* t_oop = my_mem->in(MemNode::Address)->bottom_type()->isa_oopptr();
  61.813 -      // Check for scalar replaced object reference.
  61.814 -      if( t_oop != NULL && t_oop->is_known_instance_field() &&
  61.815 -          t_oop->offset() != Type::OffsetBot &&
  61.816 -          t_oop->offset() != Type::OffsetTop) {
  61.817 -        // Replace MemBar projections by its inputs.
  61.818 -        PhaseIterGVN* igvn = phase->is_IterGVN();
  61.819 -        igvn->replace_node(proj_out(TypeFunc::Memory), in(TypeFunc::Memory));
  61.820 -        igvn->replace_node(proj_out(TypeFunc::Control), in(TypeFunc::Control));
  61.821 -        // Must return either the original node (now dead) or a new node
  61.822 -        // (Do not return a top here, since that would break the uniqueness of top.)
  61.823 -        return new (phase->C) ConINode(TypeInt::ZERO);
  61.824 +  if (can_reshape && req() == (Precedent+1)) {
  61.825 +    bool eliminate = false;
  61.826 +    int opc = Opcode();
  61.827 +    if ((opc == Op_MemBarAcquire || opc == Op_MemBarVolatile)) {
  61.828 +      // Volatile field loads and stores.
  61.829 +      Node* my_mem = in(MemBarNode::Precedent);
  61.830 +      if (my_mem != NULL && my_mem->is_Mem()) {
  61.831 +        const TypeOopPtr* t_oop = my_mem->in(MemNode::Address)->bottom_type()->isa_oopptr();
  61.832 +        // Check for scalar replaced object reference.
  61.833 +        if( t_oop != NULL && t_oop->is_known_instance_field() &&
  61.834 +            t_oop->offset() != Type::OffsetBot &&
  61.835 +            t_oop->offset() != Type::OffsetTop) {
  61.836 +          eliminate = true;
  61.837 +        }
  61.838        }
  61.839 +    } else if (opc == Op_MemBarRelease) {
  61.840 +      // Final field stores.
  61.841 +      Node* alloc = AllocateNode::Ideal_allocation(in(MemBarNode::Precedent), phase);
  61.842 +      if ((alloc != NULL) && alloc->is_Allocate() &&
  61.843 +          alloc->as_Allocate()->_is_non_escaping) {
  61.844 +        // The allocated object does not escape.
  61.845 +        eliminate = true;
  61.846 +      }
  61.847 +    }
  61.848 +    if (eliminate) {
  61.849 +      // Replace MemBar projections by its inputs.
  61.850 +      PhaseIterGVN* igvn = phase->is_IterGVN();
  61.851 +      igvn->replace_node(proj_out(TypeFunc::Memory), in(TypeFunc::Memory));
  61.852 +      igvn->replace_node(proj_out(TypeFunc::Control), in(TypeFunc::Control));
  61.853 +      // Must return either the original node (now dead) or a new node
  61.854 +      // (Do not return a top here, since that would break the uniqueness of top.)
  61.855 +      return new (phase->C) ConINode(TypeInt::ZERO);
  61.856      }
  61.857    }
  61.858    return NULL;
  61.859 @@ -3113,9 +3177,7 @@
  61.860  // within the initialization without creating a vicious cycle, such as:
  61.861  //     { Foo p = new Foo(); p.next = p; }
  61.862  // True for constants and parameters and small combinations thereof.
  61.863 -bool InitializeNode::detect_init_independence(Node* n,
  61.864 -                                              bool st_is_pinned,
  61.865 -                                              int& count) {
  61.866 +bool InitializeNode::detect_init_independence(Node* n, int& count) {
  61.867    if (n == NULL)      return true;   // (can this really happen?)
  61.868    if (n->is_Proj())   n = n->in(0);
  61.869    if (n == this)      return false;  // found a cycle
  61.870 @@ -3135,7 +3197,6 @@
  61.871      // a store is never pinned *before* the availability of its inputs.
  61.872      if (!MemNode::all_controls_dominate(n, this))
  61.873        return false;                  // failed to prove a good control
  61.874 -
  61.875    }
  61.876  
  61.877    // Check data edges for possible dependencies on 'this'.
  61.878 @@ -3145,7 +3206,7 @@
  61.879      if (m == NULL || m == n || m->is_top())  continue;
  61.880      uint first_i = n->find_edge(m);
  61.881      if (i != first_i)  continue;  // process duplicate edge just once
  61.882 -    if (!detect_init_independence(m, st_is_pinned, count)) {
  61.883 +    if (!detect_init_independence(m, count)) {
  61.884        return false;
  61.885      }
  61.886    }
  61.887 @@ -3176,7 +3237,7 @@
  61.888      return FAIL;                // wrong allocation!  (store needs to float up)
  61.889    Node* val = st->in(MemNode::ValueIn);
  61.890    int complexity_count = 0;
  61.891 -  if (!detect_init_independence(val, true, complexity_count))
  61.892 +  if (!detect_init_independence(val, complexity_count))
  61.893      return FAIL;                // stored value must be 'simple enough'
  61.894  
  61.895    // The Store can be captured only if nothing after the allocation
    62.1 --- a/src/share/vm/opto/memnode.hpp	Tue May 14 17:33:07 2013 +0000
    62.2 +++ b/src/share/vm/opto/memnode.hpp	Thu May 16 13:47:55 2013 -0700
    62.3 @@ -75,8 +75,8 @@
    62.4                                        PhaseTransform* phase);
    62.5    static bool adr_phi_is_loop_invariant(Node* adr_phi, Node* cast);
    62.6  
    62.7 -  static Node *optimize_simple_memory_chain(Node *mchain, const TypePtr *t_adr, PhaseGVN *phase);
    62.8 -  static Node *optimize_memory_chain(Node *mchain, const TypePtr *t_adr, PhaseGVN *phase);
    62.9 +  static Node *optimize_simple_memory_chain(Node *mchain, const TypeOopPtr *t_oop, Node *load, PhaseGVN *phase);
   62.10 +  static Node *optimize_memory_chain(Node *mchain, const TypePtr *t_adr, Node *load, PhaseGVN *phase);
   62.11    // This one should probably be a phase-specific function:
   62.12    static bool all_controls_dominate(Node* dom, Node* sub);
   62.13  
   62.14 @@ -1099,7 +1099,7 @@
   62.15  
   62.16    Node* make_raw_address(intptr_t offset, PhaseTransform* phase);
   62.17  
   62.18 -  bool detect_init_independence(Node* n, bool st_is_pinned, int& count);
   62.19 +  bool detect_init_independence(Node* n, int& count);
   62.20  
   62.21    void coalesce_subword_stores(intptr_t header_size, Node* size_in_bytes,
   62.22                                 PhaseGVN* phase);
    63.1 --- a/src/share/vm/opto/multnode.cpp	Tue May 14 17:33:07 2013 +0000
    63.2 +++ b/src/share/vm/opto/multnode.cpp	Thu May 16 13:47:55 2013 -0700
    63.3 @@ -23,6 +23,7 @@
    63.4   */
    63.5  
    63.6  #include "precompiled.hpp"
    63.7 +#include "opto/callnode.hpp"
    63.8  #include "opto/matcher.hpp"
    63.9  #include "opto/multnode.hpp"
   63.10  #include "opto/opcodes.hpp"
   63.11 @@ -73,13 +74,26 @@
   63.12    return (_con == TypeFunc::Control && def->is_CFG());
   63.13  }
   63.14  
   63.15 +const Type* ProjNode::proj_type(const Type* t) const {
   63.16 +  if (t == Type::TOP) {
   63.17 +    return Type::TOP;
   63.18 +  }
   63.19 +  if (t == Type::BOTTOM) {
   63.20 +    return Type::BOTTOM;
   63.21 +  }
   63.22 +  t = t->is_tuple()->field_at(_con);
   63.23 +  Node* n = in(0);
   63.24 +  if ((_con == TypeFunc::Parms) &&
   63.25 +      n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method()) {
   63.26 +    // The result of autoboxing is always non-null on normal path.
   63.27 +    t = t->join(TypePtr::NOTNULL);
   63.28 +  }
   63.29 +  return t;
   63.30 +}
   63.31 +
   63.32  const Type *ProjNode::bottom_type() const {
   63.33 -  if (in(0) == NULL)  return Type::TOP;
   63.34 -  const Type *tb = in(0)->bottom_type();
   63.35 -  if( tb == Type::TOP ) return Type::TOP;
   63.36 -  if( tb == Type::BOTTOM ) return Type::BOTTOM;
   63.37 -  const TypeTuple *t = tb->is_tuple();
   63.38 -  return t->field_at(_con);
   63.39 +  if (in(0) == NULL) return Type::TOP;
   63.40 +  return proj_type(in(0)->bottom_type());
   63.41  }
   63.42  
   63.43  const TypePtr *ProjNode::adr_type() const {
   63.44 @@ -115,11 +129,8 @@
   63.45  
   63.46  //------------------------------Value------------------------------------------
   63.47  const Type *ProjNode::Value( PhaseTransform *phase ) const {
   63.48 -  if( !in(0) ) return Type::TOP;
   63.49 -  const Type *t = phase->type(in(0));
   63.50 -  if( t == Type::TOP ) return t;
   63.51 -  if( t == Type::BOTTOM ) return t;
   63.52 -  return t->is_tuple()->field_at(_con);
   63.53 +  if (in(0) == NULL) return Type::TOP;
   63.54 +  return proj_type(phase->type(in(0)));
   63.55  }
   63.56  
   63.57  //------------------------------out_RegMask------------------------------------
    64.1 --- a/src/share/vm/opto/multnode.hpp	Tue May 14 17:33:07 2013 +0000
    64.2 +++ b/src/share/vm/opto/multnode.hpp	Thu May 16 13:47:55 2013 -0700
    64.3 @@ -60,6 +60,7 @@
    64.4    virtual uint cmp( const Node &n ) const;
    64.5    virtual uint size_of() const;
    64.6    void check_con() const;       // Called from constructor.
    64.7 +  const Type* proj_type(const Type* t) const;
    64.8  
    64.9  public:
   64.10    ProjNode( Node *src, uint con, bool io_use = false )
   64.11 @@ -83,6 +84,7 @@
   64.12    virtual const Type *Value( PhaseTransform *phase ) const;
   64.13    virtual uint ideal_reg() const;
   64.14    virtual const RegMask &out_RegMask() const;
   64.15 +
   64.16  #ifndef PRODUCT
   64.17    virtual void dump_spec(outputStream *st) const;
   64.18  #endif
    65.1 --- a/src/share/vm/opto/node.cpp	Tue May 14 17:33:07 2013 +0000
    65.2 +++ b/src/share/vm/opto/node.cpp	Thu May 16 13:47:55 2013 -0700
    65.3 @@ -67,7 +67,8 @@
    65.4    }
    65.5    Compile::set_debug_idx(new_debug_idx);
    65.6    set_debug_idx( new_debug_idx );
    65.7 -  assert(Compile::current()->unique() < (UINT_MAX - 1), "Node limit exceeded UINT_MAX");
    65.8 +  assert(Compile::current()->unique() < (INT_MAX - 1), "Node limit exceeded INT_MAX");
    65.9 +  assert(Compile::current()->live_nodes() < (uint)MaxNodeLimit, "Live Node limit exceeded limit");
   65.10    if (BreakAtNode != 0 && (_debug_idx == BreakAtNode || (int)_idx == BreakAtNode)) {
   65.11      tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d", _idx, _debug_idx);
   65.12      BREAKPOINT;
   65.13 @@ -471,9 +472,9 @@
   65.14  //------------------------------clone------------------------------------------
   65.15  // Clone a Node.
   65.16  Node *Node::clone() const {
   65.17 -  Compile *compile = Compile::current();
   65.18 +  Compile* C = Compile::current();
   65.19    uint s = size_of();           // Size of inherited Node
   65.20 -  Node *n = (Node*)compile->node_arena()->Amalloc_D(size_of() + _max*sizeof(Node*));
   65.21 +  Node *n = (Node*)C->node_arena()->Amalloc_D(size_of() + _max*sizeof(Node*));
   65.22    Copy::conjoint_words_to_lower((HeapWord*)this, (HeapWord*)n, s);
   65.23    // Set the new input pointer array
   65.24    n->_in = (Node**)(((char*)n)+s);
   65.25 @@ -492,18 +493,18 @@
   65.26      if (x != NULL) x->add_out(n);
   65.27    }
   65.28    if (is_macro())
   65.29 -    compile->add_macro_node(n);
   65.30 +    C->add_macro_node(n);
   65.31    if (is_expensive())
   65.32 -    compile->add_expensive_node(n);
   65.33 +    C->add_expensive_node(n);
   65.34  
   65.35 -  n->set_idx(compile->next_unique()); // Get new unique index as well
   65.36 +  n->set_idx(C->next_unique()); // Get new unique index as well
   65.37    debug_only( n->verify_construction() );
   65.38    NOT_PRODUCT(nodes_created++);
   65.39    // Do not patch over the debug_idx of a clone, because it makes it
   65.40    // impossible to break on the clone's moment of creation.
   65.41    //debug_only( n->set_debug_idx( debug_idx() ) );
   65.42  
   65.43 -  compile->copy_node_notes_to(n, (Node*) this);
   65.44 +  C->copy_node_notes_to(n, (Node*) this);
   65.45  
   65.46    // MachNode clone
   65.47    uint nopnds;
   65.48 @@ -518,13 +519,12 @@
   65.49                                    (const void*)(&mthis->_opnds), 1));
   65.50      mach->_opnds = to;
   65.51      for ( uint i = 0; i < nopnds; ++i ) {
   65.52 -      to[i] = from[i]->clone(compile);
   65.53 +      to[i] = from[i]->clone(C);
   65.54      }
   65.55    }
   65.56    // cloning CallNode may need to clone JVMState
   65.57    if (n->is_Call()) {
   65.58 -    CallNode *call = n->as_Call();
   65.59 -    call->clone_jvms();
   65.60 +    n->as_Call()->clone_jvms(C);
   65.61    }
   65.62    return n;                     // Return the clone
   65.63  }
   65.64 @@ -811,6 +811,21 @@
   65.65    return nrep;
   65.66  }
   65.67  
   65.68 +/**
   65.69 + * Replace input edges in the range pointing to 'old' node.
   65.70 + */
   65.71 +int Node::replace_edges_in_range(Node* old, Node* neww, int start, int end) {
   65.72 +  if (old == neww)  return 0;  // nothing to do
   65.73 +  uint nrep = 0;
   65.74 +  for (int i = start; i < end; i++) {
   65.75 +    if (in(i) == old) {
   65.76 +      set_req(i, neww);
   65.77 +      nrep++;
   65.78 +    }
   65.79 +  }
   65.80 +  return nrep;
   65.81 +}
   65.82 +
   65.83  //-------------------------disconnect_inputs-----------------------------------
   65.84  // NULL out all inputs to eliminate incoming Def-Use edges.
   65.85  // Return the number of edges between 'n' and 'this'
   65.86 @@ -1383,6 +1398,21 @@
   65.87    return NULL;
   65.88  }
   65.89  
   65.90 +
   65.91 +/**
   65.92 + * Return a ptr type for nodes which should have it.
   65.93 + */
   65.94 +const TypePtr* Node::get_ptr_type() const {
   65.95 +  const TypePtr* tp = this->bottom_type()->make_ptr();
   65.96 +#ifdef ASSERT
   65.97 +  if (tp == NULL) {
   65.98 +    this->dump(1);
   65.99 +    assert((tp != NULL), "unexpected node type");
  65.100 +  }
  65.101 +#endif
  65.102 +  return tp;
  65.103 +}
  65.104 +
  65.105  // Get a double constant from a ConstNode.
  65.106  // Returns the constant if it is a double ConstNode
  65.107  jdouble Node::getd() const {
    66.1 --- a/src/share/vm/opto/node.hpp	Tue May 14 17:33:07 2013 +0000
    66.2 +++ b/src/share/vm/opto/node.hpp	Thu May 16 13:47:55 2013 -0700
    66.3 @@ -410,6 +410,7 @@
    66.4    // Find first occurrence of n among my edges:
    66.5    int find_edge(Node* n);
    66.6    int replace_edge(Node* old, Node* neww);
    66.7 +  int replace_edges_in_range(Node* old, Node* neww, int start, int end);
    66.8    // NULL out all inputs to eliminate incoming Def-Use edges.
    66.9    // Return the number of edges between 'n' and 'this'
   66.10    int  disconnect_inputs(Node *n, Compile *c);
   66.11 @@ -964,6 +965,8 @@
   66.12    }
   66.13    const TypeLong* find_long_type() const;
   66.14  
   66.15 +  const TypePtr* get_ptr_type() const;
   66.16 +
   66.17    // These guys are called by code generated by ADLC:
   66.18    intptr_t get_ptr() const;
   66.19    intptr_t get_narrowcon() const;
    67.1 --- a/src/share/vm/opto/output.cpp	Tue May 14 17:33:07 2013 +0000
    67.2 +++ b/src/share/vm/opto/output.cpp	Thu May 16 13:47:55 2013 -0700
    67.3 @@ -929,7 +929,7 @@
    67.4            scval = new_loc_value( _regalloc, obj_reg, Location::oop );
    67.5          }
    67.6        } else {
    67.7 -        const TypePtr *tp = obj_node->bottom_type()->make_ptr();
    67.8 +        const TypePtr *tp = obj_node->get_ptr_type();
    67.9          scval = new ConstantOopWriteValue(tp->is_oopptr()->const_oop()->constant_encoding());
   67.10        }
   67.11  
    68.1 --- a/src/share/vm/opto/parse.hpp	Tue May 14 17:33:07 2013 +0000
    68.2 +++ b/src/share/vm/opto/parse.hpp	Thu May 16 13:47:55 2013 -0700
    68.3 @@ -330,6 +330,7 @@
    68.4    bool          _wrote_final;   // Did we write a final field?
    68.5    bool          _count_invocations; // update and test invocation counter
    68.6    bool          _method_data_update; // update method data oop
    68.7 +  Node*         _alloc_with_final;   // An allocation node with final field
    68.8  
    68.9    // Variables which track Java semantics during bytecode parsing:
   68.10  
   68.11 @@ -370,6 +371,11 @@
   68.12    void      set_wrote_final(bool z)   { _wrote_final = z; }
   68.13    bool          count_invocations() const  { return _count_invocations; }
   68.14    bool          method_data_update() const { return _method_data_update; }
   68.15 +  Node*    alloc_with_final() const   { return _alloc_with_final; }
   68.16 +  void set_alloc_with_final(Node* n)  {
   68.17 +    assert((_alloc_with_final == NULL) || (_alloc_with_final == n), "different init objects?");
   68.18 +    _alloc_with_final = n;
   68.19 +  }
   68.20  
   68.21    Block*             block()    const { return _block; }
   68.22    ciBytecodeStream&  iter()           { return _iter; }
   68.23 @@ -512,7 +518,7 @@
   68.24  
   68.25    // loading from a constant field or the constant pool
   68.26    // returns false if push failed (non-perm field constants only, not ldcs)
   68.27 -  bool push_constant(ciConstant con, bool require_constant = false);
   68.28 +  bool push_constant(ciConstant con, bool require_constant = false, bool is_autobox_cache = false);
   68.29  
   68.30    // implementation of object creation bytecodes
   68.31    void emit_guard_for_new(ciInstanceKlass* klass);
    69.1 --- a/src/share/vm/opto/parse1.cpp	Tue May 14 17:33:07 2013 +0000
    69.2 +++ b/src/share/vm/opto/parse1.cpp	Thu May 16 13:47:55 2013 -0700
    69.3 @@ -390,6 +390,7 @@
    69.4    _expected_uses = expected_uses;
    69.5    _depth = 1 + (caller->has_method() ? caller->depth() : 0);
    69.6    _wrote_final = false;
    69.7 +  _alloc_with_final = NULL;
    69.8    _entry_bci = InvocationEntryBci;
    69.9    _tf = NULL;
   69.10    _block = NULL;
   69.11 @@ -723,6 +724,8 @@
   69.12    // Note:  iophi and memphi are not transformed until do_exits.
   69.13    Node* iophi  = new (C) PhiNode(region, Type::ABIO);
   69.14    Node* memphi = new (C) PhiNode(region, Type::MEMORY, TypePtr::BOTTOM);
   69.15 +  gvn().set_type_bottom(iophi);
   69.16 +  gvn().set_type_bottom(memphi);
   69.17    _exits.set_i_o(iophi);
   69.18    _exits.set_all_memory(memphi);
   69.19  
   69.20 @@ -738,6 +741,7 @@
   69.21      }
   69.22      int         ret_size = type2size[ret_type->basic_type()];
   69.23      Node*       ret_phi  = new (C) PhiNode(region, ret_type);
   69.24 +    gvn().set_type_bottom(ret_phi);
   69.25      _exits.ensure_stack(ret_size);
   69.26      assert((int)(tf()->range()->cnt() - TypeFunc::Parms) == ret_size, "good tf range");
   69.27      assert(method()->return_type()->size() == ret_size, "tf agrees w/ method");
   69.28 @@ -917,7 +921,7 @@
   69.29      // such unusual early publications.  But no barrier is needed on
   69.30      // exceptional returns, since they cannot publish normally.
   69.31      //
   69.32 -    _exits.insert_mem_bar(Op_MemBarRelease);
   69.33 +    _exits.insert_mem_bar(Op_MemBarRelease, alloc_with_final());
   69.34  #ifndef PRODUCT
   69.35      if (PrintOpto && (Verbose || WizardMode)) {
   69.36        method()->print_name();
    70.1 --- a/src/share/vm/opto/parse2.cpp	Tue May 14 17:33:07 2013 +0000
    70.2 +++ b/src/share/vm/opto/parse2.cpp	Thu May 16 13:47:55 2013 -0700
    70.3 @@ -987,7 +987,7 @@
    70.4      uncommon_trap(Deoptimization::Reason_unreached,
    70.5                    Deoptimization::Action_reinterpret,
    70.6                    NULL, "cold");
    70.7 -    if (EliminateAutoBox) {
    70.8 +    if (C->eliminate_boxing()) {
    70.9        // Mark the successor blocks as parsed
   70.10        branch_block->next_path_num();
   70.11        next_block->next_path_num();
   70.12 @@ -1012,7 +1012,7 @@
   70.13  
   70.14      if (stopped()) {            // Path is dead?
   70.15        explicit_null_checks_elided++;
   70.16 -      if (EliminateAutoBox) {
   70.17 +      if (C->eliminate_boxing()) {
   70.18          // Mark the successor block as parsed
   70.19          branch_block->next_path_num();
   70.20        }
   70.21 @@ -1032,7 +1032,7 @@
   70.22  
   70.23    if (stopped()) {              // Path is dead?
   70.24      explicit_null_checks_elided++;
   70.25 -    if (EliminateAutoBox) {
   70.26 +    if (C->eliminate_boxing()) {
   70.27        // Mark the successor block as parsed
   70.28        next_block->next_path_num();
   70.29      }
   70.30 @@ -1069,7 +1069,7 @@
   70.31      uncommon_trap(Deoptimization::Reason_unreached,
   70.32                    Deoptimization::Action_reinterpret,
   70.33                    NULL, "cold");
   70.34 -    if (EliminateAutoBox) {
   70.35 +    if (C->eliminate_boxing()) {
   70.36        // Mark the successor blocks as parsed
   70.37        branch_block->next_path_num();
   70.38        next_block->next_path_num();
   70.39 @@ -1135,7 +1135,7 @@
   70.40      set_control(taken_branch);
   70.41  
   70.42      if (stopped()) {
   70.43 -      if (EliminateAutoBox) {
   70.44 +      if (C->eliminate_boxing()) {
   70.45          // Mark the successor block as parsed
   70.46          branch_block->next_path_num();
   70.47        }
   70.48 @@ -1154,7 +1154,7 @@
   70.49  
   70.50    // Branch not taken.
   70.51    if (stopped()) {
   70.52 -    if (EliminateAutoBox) {
   70.53 +    if (C->eliminate_boxing()) {
   70.54        // Mark the successor block as parsed
   70.55        next_block->next_path_num();
   70.56      }
    71.1 --- a/src/share/vm/opto/parse3.cpp	Tue May 14 17:33:07 2013 +0000
    71.2 +++ b/src/share/vm/opto/parse3.cpp	Thu May 16 13:47:55 2013 -0700
    71.3 @@ -150,6 +150,23 @@
    71.4      // final field
    71.5      if (field->is_static()) {
    71.6        // final static field
    71.7 +      if (C->eliminate_boxing()) {
    71.8 +        // The pointers in the autobox arrays are always non-null.
    71.9 +        ciSymbol* klass_name = field->holder()->name();
   71.10 +        if (field->name() == ciSymbol::cache_field_name() &&
   71.11 +            field->holder()->uses_default_loader() &&
   71.12 +            (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
   71.13 +             klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
   71.14 +             klass_name == ciSymbol::java_lang_Short_ShortCache() ||
   71.15 +             klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
   71.16 +             klass_name == ciSymbol::java_lang_Long_LongCache())) {
   71.17 +          bool require_const = true;
   71.18 +          bool autobox_cache = true;
   71.19 +          if (push_constant(field->constant_value(), require_const, autobox_cache)) {
   71.20 +            return;
   71.21 +          }
   71.22 +        }
   71.23 +      }
   71.24        if (push_constant(field->constant_value()))
   71.25          return;
   71.26      }
   71.27 @@ -304,11 +321,18 @@
   71.28    // out of the constructor.
   71.29    if (is_field && field->is_final()) {
   71.30      set_wrote_final(true);
   71.31 +    // Preserve allocation ptr to create precedent edge to it in membar
   71.32 +    // generated on exit from constructor.
   71.33 +    if (C->eliminate_boxing() &&
   71.34 +        adr_type->isa_oopptr() && adr_type->is_oopptr()->is_ptr_to_boxed_value() &&
   71.35 +        AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
   71.36 +      set_alloc_with_final(obj);
   71.37 +    }
   71.38    }
   71.39  }
   71.40  
   71.41  
   71.42 -bool Parse::push_constant(ciConstant constant, bool require_constant) {
   71.43 +bool Parse::push_constant(ciConstant constant, bool require_constant, bool is_autobox_cache) {
   71.44    switch (constant.basic_type()) {
   71.45    case T_BOOLEAN:  push( intcon(constant.as_boolean()) ); break;
   71.46    case T_INT:      push( intcon(constant.as_int())     ); break;
   71.47 @@ -329,7 +353,7 @@
   71.48        push( zerocon(T_OBJECT) );
   71.49        break;
   71.50      } else if (require_constant || oop_constant->should_be_constant()) {
   71.51 -      push( makecon(TypeOopPtr::make_from_constant(oop_constant, require_constant)) );
   71.52 +      push( makecon(TypeOopPtr::make_from_constant(oop_constant, require_constant, is_autobox_cache)) );
   71.53        break;
   71.54      } else {
   71.55        // we cannot inline the oop, but we can use it later to narrow a type
    72.1 --- a/src/share/vm/opto/parseHelper.cpp	Tue May 14 17:33:07 2013 +0000
    72.2 +++ b/src/share/vm/opto/parseHelper.cpp	Thu May 16 13:47:55 2013 -0700
    72.3 @@ -284,6 +284,11 @@
    72.4         klass == C->env()->StringBuffer_klass())) {
    72.5      C->set_has_stringbuilder(true);
    72.6    }
    72.7 +
    72.8 +  // Keep track of boxed values for EliminateAutoBox optimizations.
    72.9 +  if (C->eliminate_boxing() && klass->is_box_klass()) {
   72.10 +    C->set_has_boxed_value(true);
   72.11 +  }
   72.12  }
   72.13  
   72.14  #ifndef PRODUCT
    73.1 --- a/src/share/vm/opto/phase.cpp	Tue May 14 17:33:07 2013 +0000
    73.2 +++ b/src/share/vm/opto/phase.cpp	Thu May 16 13:47:55 2013 -0700
    73.3 @@ -64,6 +64,7 @@
    73.4  // Subtimers for _t_optimizer
    73.5  elapsedTimer   Phase::_t_iterGVN;
    73.6  elapsedTimer   Phase::_t_iterGVN2;
    73.7 +elapsedTimer   Phase::_t_incrInline;
    73.8  
    73.9  // Subtimers for _t_registerAllocation
   73.10  elapsedTimer   Phase::_t_ctorChaitin;
   73.11 @@ -110,6 +111,7 @@
   73.12        tty->print_cr ("      macroEliminate : %3.3f sec", Phase::_t_macroEliminate.seconds());
   73.13      }
   73.14      tty->print_cr ("      iterGVN        : %3.3f sec", Phase::_t_iterGVN.seconds());
   73.15 +    tty->print_cr ("      incrInline     : %3.3f sec", Phase::_t_incrInline.seconds());
   73.16      tty->print_cr ("      idealLoop      : %3.3f sec", Phase::_t_idealLoop.seconds());
   73.17      tty->print_cr ("      idealLoopVerify: %3.3f sec", Phase::_t_idealLoopVerify.seconds());
   73.18      tty->print_cr ("      ccp            : %3.3f sec", Phase::_t_ccp.seconds());
    74.1 --- a/src/share/vm/opto/phase.hpp	Tue May 14 17:33:07 2013 +0000
    74.2 +++ b/src/share/vm/opto/phase.hpp	Thu May 16 13:47:55 2013 -0700
    74.3 @@ -100,6 +100,7 @@
    74.4  // Subtimers for _t_optimizer
    74.5    static elapsedTimer   _t_iterGVN;
    74.6    static elapsedTimer   _t_iterGVN2;
    74.7 +  static elapsedTimer   _t_incrInline;
    74.8  
    74.9  // Subtimers for _t_registerAllocation
   74.10    static elapsedTimer   _t_ctorChaitin;
    75.1 --- a/src/share/vm/opto/phaseX.cpp	Tue May 14 17:33:07 2013 +0000
    75.2 +++ b/src/share/vm/opto/phaseX.cpp	Thu May 16 13:47:55 2013 -0700
    75.3 @@ -882,7 +882,7 @@
    75.4        return;
    75.5      }
    75.6      Node *n  = _worklist.pop();
    75.7 -    if (++loop_count >= K * C->unique()) {
    75.8 +    if (++loop_count >= K * C->live_nodes()) {
    75.9        debug_only(n->dump(4);)
   75.10        assert(false, "infinite loop in PhaseIterGVN::optimize");
   75.11        C->record_method_not_compilable("infinite loop in PhaseIterGVN::optimize");
    76.1 --- a/src/share/vm/opto/runtime.cpp	Tue May 14 17:33:07 2013 +0000
    76.2 +++ b/src/share/vm/opto/runtime.cpp	Thu May 16 13:47:55 2013 -0700
    76.3 @@ -126,17 +126,15 @@
    76.4  
    76.5  // This should be called in an assertion at the start of OptoRuntime routines
    76.6  // which are entered from compiled code (all of them)
    76.7 -#ifndef PRODUCT
    76.8 +#ifdef ASSERT
    76.9  static bool check_compiled_frame(JavaThread* thread) {
   76.10    assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
   76.11 -#ifdef ASSERT
   76.12    RegisterMap map(thread, false);
   76.13    frame caller = thread->last_frame().sender(&map);
   76.14    assert(caller.is_compiled_frame(), "not being called from compiled like code");
   76.15 -#endif  /* ASSERT */
   76.16    return true;
   76.17  }
   76.18 -#endif
   76.19 +#endif // ASSERT
   76.20  
   76.21  
   76.22  #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \
    77.1 --- a/src/share/vm/opto/subnode.cpp	Tue May 14 17:33:07 2013 +0000
    77.2 +++ b/src/share/vm/opto/subnode.cpp	Thu May 16 13:47:55 2013 -0700
    77.3 @@ -863,10 +863,11 @@
    77.4    const TypePtr *r1 = t2->make_ptr();
    77.5  
    77.6    // Undefined inputs makes for an undefined result
    77.7 -  if( TypePtr::above_centerline(r0->_ptr) ||
    77.8 -      TypePtr::above_centerline(r1->_ptr) )
    77.9 +  if ((r0 == NULL) || (r1 == NULL) ||
   77.10 +      TypePtr::above_centerline(r0->_ptr) ||
   77.11 +      TypePtr::above_centerline(r1->_ptr)) {
   77.12      return Type::TOP;
   77.13 -
   77.14 +  }
   77.15    if (r0 == r1 && r0->singleton()) {
   77.16      // Equal pointer constants (klasses, nulls, etc.)
   77.17      return TypeInt::CC_EQ;
    78.1 --- a/src/share/vm/opto/type.cpp	Tue May 14 17:33:07 2013 +0000
    78.2 +++ b/src/share/vm/opto/type.cpp	Thu May 16 13:47:55 2013 -0700
    78.3 @@ -2372,7 +2372,12 @@
    78.4      _klass_is_exact(xk),
    78.5      _is_ptr_to_narrowoop(false),
    78.6      _is_ptr_to_narrowklass(false),
    78.7 +    _is_ptr_to_boxed_value(false),
    78.8      _instance_id(instance_id) {
    78.9 +  if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
   78.10 +      (offset > 0) && xk && (k != 0) && k->is_instance_klass()) {
   78.11 +    _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset);
   78.12 +  }
   78.13  #ifdef _LP64
   78.14    if (_offset != 0) {
   78.15      if (_offset == oopDesc::klass_offset_in_bytes()) {
   78.16 @@ -2613,44 +2618,50 @@
   78.17  
   78.18  //------------------------------make_from_constant-----------------------------
   78.19  // Make a java pointer from an oop constant
   78.20 -const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) {
   78.21 -    assert(!o->is_null_object(), "null object not yet handled here.");
   78.22 -    ciKlass* klass = o->klass();
   78.23 -    if (klass->is_instance_klass()) {
   78.24 -      // Element is an instance
   78.25 -      if (require_constant) {
   78.26 -        if (!o->can_be_constant())  return NULL;
   78.27 -      } else if (!o->should_be_constant()) {
   78.28 -        return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
   78.29 -      }
   78.30 -      return TypeInstPtr::make(o);
   78.31 -    } else if (klass->is_obj_array_klass()) {
   78.32 -      // Element is an object array. Recursively call ourself.
   78.33 -    const Type *etype =
   78.34 +const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o,
   78.35 +                                                 bool require_constant,
   78.36 +                                                 bool is_autobox_cache) {
   78.37 +  assert(!o->is_null_object(), "null object not yet handled here.");
   78.38 +  ciKlass* klass = o->klass();
   78.39 +  if (klass->is_instance_klass()) {
   78.40 +    // Element is an instance
   78.41 +    if (require_constant) {
   78.42 +      if (!o->can_be_constant())  return NULL;
   78.43 +    } else if (!o->should_be_constant()) {
   78.44 +      return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
   78.45 +    }
   78.46 +    return TypeInstPtr::make(o);
   78.47 +  } else if (klass->is_obj_array_klass()) {
   78.48 +    // Element is an object array. Recursively call ourself.
   78.49 +    const TypeOopPtr *etype =
   78.50        TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
   78.51 -      const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
   78.52 -      // We used to pass NotNull in here, asserting that the sub-arrays
   78.53 -      // are all not-null.  This is not true in generally, as code can
   78.54 -      // slam NULLs down in the subarrays.
   78.55 -      if (require_constant) {
   78.56 -        if (!o->can_be_constant())  return NULL;
   78.57 -      } else if (!o->should_be_constant()) {
   78.58 -        return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
   78.59 -      }
   78.60 -    const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
   78.61 +    if (is_autobox_cache) {
   78.62 +      // The pointers in the autobox arrays are always non-null.
   78.63 +      etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
   78.64 +    }
   78.65 +    const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
   78.66 +    // We used to pass NotNull in here, asserting that the sub-arrays
   78.67 +    // are all not-null.  This is not true in generally, as code can
   78.68 +    // slam NULLs down in the subarrays.
   78.69 +    if (require_constant) {
   78.70 +      if (!o->can_be_constant())  return NULL;
   78.71 +    } else if (!o->should_be_constant()) {
   78.72 +      return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
   78.73 +    }
   78.74 +    const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, is_autobox_cache);
   78.75      return arr;
   78.76 -    } else if (klass->is_type_array_klass()) {
   78.77 -      // Element is an typeArray
   78.78 +  } else if (klass->is_type_array_klass()) {
   78.79 +    // Element is an typeArray
   78.80      const Type* etype =
   78.81        (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
   78.82 -      const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
   78.83 -      // We used to pass NotNull in here, asserting that the array pointer
   78.84 -      // is not-null. That was not true in general.
   78.85 -      if (require_constant) {
   78.86 -        if (!o->can_be_constant())  return NULL;
   78.87 -      } else if (!o->should_be_constant()) {
   78.88 -        return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
   78.89 -      }
   78.90 +    const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
   78.91 +    // We used to pass NotNull in here, asserting that the array pointer
   78.92 +    // is not-null. That was not true in general.
   78.93 +    if (require_constant) {
   78.94 +      if (!o->can_be_constant())  return NULL;
   78.95 +    } else if (!o->should_be_constant()) {
   78.96 +      return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
   78.97 +    }
   78.98      const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
   78.99      return arr;
  78.100    }
  78.101 @@ -2856,6 +2867,28 @@
  78.102    return result;
  78.103  }
  78.104  
  78.105 +/**
  78.106 + *  Create constant type for a constant boxed value
  78.107 + */
  78.108 +const Type* TypeInstPtr::get_const_boxed_value() const {
  78.109 +  assert(is_ptr_to_boxed_value(), "should be called only for boxed value");
  78.110 +  assert((const_oop() != NULL), "should be called only for constant object");
  78.111 +  ciConstant constant = const_oop()->as_instance()->field_value_by_offset(offset());
  78.112 +  BasicType bt = constant.basic_type();
  78.113 +  switch (bt) {
  78.114 +    case T_BOOLEAN:  return TypeInt::make(constant.as_boolean());
  78.115 +    case T_INT:      return TypeInt::make(constant.as_int());
  78.116 +    case T_CHAR:     return TypeInt::make(constant.as_char());
  78.117 +    case T_BYTE:     return TypeInt::make(constant.as_byte());
  78.118 +    case T_SHORT:    return TypeInt::make(constant.as_short());
  78.119 +    case T_FLOAT:    return TypeF::make(constant.as_float());
  78.120 +    case T_DOUBLE:   return TypeD::make(constant.as_double());
  78.121 +    case T_LONG:     return TypeLong::make(constant.as_long());
  78.122 +    default:         break;
  78.123 +  }
  78.124 +  fatal(err_msg_res("Invalid boxed value type '%s'", type2name(bt)));
  78.125 +  return NULL;
  78.126 +}
  78.127  
  78.128  //------------------------------cast_to_ptr_type-------------------------------
  78.129  const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
  78.130 @@ -3330,18 +3363,18 @@
  78.131    if (!xk)  xk = ary->ary_must_be_exact();
  78.132    assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
  78.133    if (!UseExactTypes)  xk = (ptr == Constant);
  78.134 -  return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id))->hashcons();
  78.135 +  return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false))->hashcons();
  78.136  }
  78.137  
  78.138  //------------------------------make-------------------------------------------
  78.139 -const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) {
  78.140 +const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, bool is_autobox_cache) {
  78.141    assert(!(k == NULL && ary->_elem->isa_int()),
  78.142           "integral arrays must be pre-equipped with a class");
  78.143    assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
  78.144    if (!xk)  xk = (o != NULL) || ary->ary_must_be_exact();
  78.145    assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
  78.146    if (!UseExactTypes)  xk = (ptr == Constant);
  78.147 -  return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id))->hashcons();
  78.148 +  return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache))->hashcons();
  78.149  }
  78.150  
  78.151  //------------------------------cast_to_ptr_type-------------------------------
  78.152 @@ -3397,8 +3430,20 @@
  78.153    jint max_hi = max_array_length(elem()->basic_type());
  78.154    //if (index_not_size)  --max_hi;     // type of a valid array index, FTR
  78.155    bool chg = false;
  78.156 -  if (lo < min_lo) { lo = min_lo; chg = true; }
  78.157 -  if (hi > max_hi) { hi = max_hi; chg = true; }
  78.158 +  if (lo < min_lo) {
  78.159 +    lo = min_lo;
  78.160 +    if (size->is_con()) {
  78.161 +      hi = lo;
  78.162 +    }
  78.163 +    chg = true;
  78.164 +  }
  78.165 +  if (hi > max_hi) {
  78.166 +    hi = max_hi;
  78.167 +    if (size->is_con()) {
  78.168 +      lo = hi;
  78.169 +    }
  78.170 +    chg = true;
  78.171 +  }
  78.172    // Negative length arrays will produce weird intermediate dead fast-path code
  78.173    if (lo > hi)
  78.174      return TypeInt::ZERO;
  78.175 @@ -3630,7 +3675,7 @@
  78.176  //------------------------------xdual------------------------------------------
  78.177  // Dual: compute field-by-field dual
  78.178  const Type *TypeAryPtr::xdual() const {
  78.179 -  return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id() );
  78.180 +  return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache() );
  78.181  }
  78.182  
  78.183  //----------------------interface_vs_oop---------------------------------------
    79.1 --- a/src/share/vm/opto/type.hpp	Tue May 14 17:33:07 2013 +0000
    79.2 +++ b/src/share/vm/opto/type.hpp	Thu May 16 13:47:55 2013 -0700
    79.3 @@ -234,6 +234,9 @@
    79.4    bool is_ptr_to_narrowoop() const;
    79.5    bool is_ptr_to_narrowklass() const;
    79.6  
    79.7 +  bool is_ptr_to_boxing_obj() const;
    79.8 +
    79.9 +
   79.10    // Convenience access
   79.11    float getf() const;
   79.12    double getd() const;
   79.13 @@ -794,6 +797,7 @@
   79.14    bool          _klass_is_exact;
   79.15    bool          _is_ptr_to_narrowoop;
   79.16    bool          _is_ptr_to_narrowklass;
   79.17 +  bool          _is_ptr_to_boxed_value;
   79.18  
   79.19    // If not InstanceTop or InstanceBot, indicates that this is
   79.20    // a particular instance of this type which is distinct.
   79.21 @@ -826,7 +830,9 @@
   79.22    // If the object cannot be rendered as a constant,
   79.23    // may return a non-singleton type.
   79.24    // If require_constant, produce a NULL if a singleton is not possible.
   79.25 -  static const TypeOopPtr* make_from_constant(ciObject* o, bool require_constant = false);
   79.26 +  static const TypeOopPtr* make_from_constant(ciObject* o,
   79.27 +                                              bool require_constant = false,
   79.28 +                                              bool not_null_elements = false);
   79.29  
   79.30    // Make a generic (unclassed) pointer to an oop.
   79.31    static const TypeOopPtr* make(PTR ptr, int offset, int instance_id);
   79.32 @@ -839,7 +845,7 @@
   79.33    // compressed oop references.
   79.34    bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
   79.35    bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
   79.36 -
   79.37 +  bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
   79.38    bool is_known_instance()       const { return _instance_id > 0; }
   79.39    int  instance_id()             const { return _instance_id; }
   79.40    bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
   79.41 @@ -912,6 +918,9 @@
   79.42    // Make a pointer to an oop.
   79.43    static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot );
   79.44  
   79.45 +  /** Create constant type for a constant boxed value */
   79.46 +  const Type* get_const_boxed_value() const;
   79.47 +
   79.48    // If this is a java.lang.Class constant, return the type for it or NULL.
   79.49    // Pass to Type::get_const_type to turn it to a type, which will usually
   79.50    // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
   79.51 @@ -943,7 +952,12 @@
   79.52  //------------------------------TypeAryPtr-------------------------------------
   79.53  // Class of Java array pointers
   79.54  class TypeAryPtr : public TypeOopPtr {
   79.55 -  TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id), _ary(ary) {
   79.56 +  TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
   79.57 +              int offset, int instance_id, bool is_autobox_cache )
   79.58 +  : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id),
   79.59 +    _ary(ary),
   79.60 +    _is_autobox_cache(is_autobox_cache)
   79.61 + {
   79.62  #ifdef ASSERT
   79.63      if (k != NULL) {
   79.64        // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
   79.65 @@ -964,6 +978,7 @@
   79.66    virtual bool eq( const Type *t ) const;
   79.67    virtual int hash() const;     // Type specific hashing
   79.68    const TypeAry *_ary;          // Array we point into
   79.69 +  const bool     _is_autobox_cache;
   79.70  
   79.71    ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
   79.72  
   79.73 @@ -974,9 +989,11 @@
   79.74    const Type*    elem() const { return _ary->_elem; }
   79.75    const TypeInt* size() const { return _ary->_size; }
   79.76  
   79.77 +  bool is_autobox_cache() const { return _is_autobox_cache; }
   79.78 +
   79.79    static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
   79.80    // Constant pointer to array
   79.81 -  static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
   79.82 +  static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, bool is_autobox_cache = false);
   79.83  
   79.84    // Return a 'ptr' version of this type
   79.85    virtual const Type *cast_to_ptr_type(PTR ptr) const;
   79.86 @@ -1504,6 +1521,13 @@
   79.87    return false;
   79.88  }
   79.89  
   79.90 +inline bool Type::is_ptr_to_boxing_obj() const {
   79.91 +  const TypeInstPtr* tp = isa_instptr();
   79.92 +  return (tp != NULL) && (tp->offset() == 0) &&
   79.93 +         tp->klass()->is_instance_klass()  &&
   79.94 +         tp->klass()->as_instance_klass()->is_box_klass();
   79.95 +}
   79.96 +
   79.97  
   79.98  // ===============================================================
   79.99  // Things that need to be 64-bits in the 64-bit build but
    80.1 --- a/src/share/vm/prims/methodHandles.cpp	Tue May 14 17:33:07 2013 +0000
    80.2 +++ b/src/share/vm/prims/methodHandles.cpp	Thu May 16 13:47:55 2013 -0700
    80.3 @@ -1306,6 +1306,28 @@
    80.4  }
    80.5  JVM_END
    80.6  
    80.7 +/**
    80.8 + * Throws a java/lang/UnsupportedOperationException unconditionally.
    80.9 + * This is required by the specification of MethodHandle.invoke if
   80.10 + * invoked directly.
   80.11 + */
   80.12 +JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
   80.13 +  THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively");
   80.14 +  return NULL;
   80.15 +}
   80.16 +JVM_END
   80.17 +
   80.18 +/**
   80.19 + * Throws a java/lang/UnsupportedOperationException unconditionally.
   80.20 + * This is required by the specification of MethodHandle.invokeExact if
   80.21 + * invoked directly.
   80.22 + */
   80.23 +JVM_ENTRY(jobject, MH_invokeExact_UOE(JNIEnv* env, jobject mh, jobjectArray args)) {
   80.24 +  THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invokeExact cannot be invoked reflectively");
   80.25 +  return NULL;
   80.26 +}
   80.27 +JVM_END
   80.28 +
   80.29  /// JVM_RegisterMethodHandleMethods
   80.30  
   80.31  #undef CS  // Solaris builds complain
   80.32 @@ -1325,7 +1347,7 @@
   80.33  #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
   80.34  
   80.35  // These are the native methods on java.lang.invoke.MethodHandleNatives.
   80.36 -static JNINativeMethod required_methods_JDK8[] = {
   80.37 +static JNINativeMethod MHN_methods[] = {
   80.38    {CC"init",                      CC"("MEM""OBJ")V",                     FN_PTR(MHN_init_Mem)},
   80.39    {CC"expand",                    CC"("MEM")V",                          FN_PTR(MHN_expand_Mem)},
   80.40    {CC"resolve",                   CC"("MEM""CLS")"MEM,                   FN_PTR(MHN_resolve_Mem)},
   80.41 @@ -1343,8 +1365,28 @@
   80.42    {CC"getMemberVMInfo",           CC"("MEM")"OBJ,                        FN_PTR(MHN_getMemberVMInfo)}
   80.43  };
   80.44  
   80.45 -// This one function is exported, used by NativeLookup.
   80.46 +static JNINativeMethod MH_methods[] = {
   80.47 +  // UnsupportedOperationException throwers
   80.48 +  {CC"invoke",                    CC"(["OBJ")"OBJ,                       FN_PTR(MH_invoke_UOE)},
   80.49 +  {CC"invokeExact",               CC"(["OBJ")"OBJ,                       FN_PTR(MH_invokeExact_UOE)}
   80.50 +};
   80.51  
   80.52 +/**
   80.53 + * Helper method to register native methods.
   80.54 + */
   80.55 +static bool register_natives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) {
   80.56 +  int status = env->RegisterNatives(clazz, methods, nMethods);
   80.57 +  if (status != JNI_OK || env->ExceptionOccurred()) {
   80.58 +    warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
   80.59 +    env->ExceptionClear();
   80.60 +    return false;
   80.61 +  }
   80.62 +  return true;
   80.63 +}
   80.64 +
   80.65 +/**
   80.66 + * This one function is exported, used by NativeLookup.
   80.67 + */
   80.68  JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) {
   80.69    if (!EnableInvokeDynamic) {
   80.70      warning("JSR 292 is disabled in this JVM.  Use -XX:+UnlockDiagnosticVMOptions -XX:+EnableInvokeDynamic to enable.");
   80.71 @@ -1362,16 +1404,14 @@
   80.72      MH_class = (jclass) JNIHandles::make_local(env, mirror);
   80.73    }
   80.74  
   80.75 -  int status;
   80.76 -
   80.77    if (enable_MH) {
   80.78      ThreadToNativeFromVM ttnfv(thread);
   80.79  
   80.80 -    status = env->RegisterNatives(MHN_class, required_methods_JDK8, sizeof(required_methods_JDK8)/sizeof(JNINativeMethod));
   80.81 -    if (status != JNI_OK || env->ExceptionOccurred()) {
   80.82 -      warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
   80.83 -      enable_MH = false;
   80.84 -      env->ExceptionClear();
   80.85 +    if (enable_MH) {
   80.86 +      enable_MH = register_natives(env, MHN_class, MHN_methods, sizeof(MHN_methods)/sizeof(JNINativeMethod));
   80.87 +    }
   80.88 +    if (enable_MH) {
   80.89 +      enable_MH = register_natives(env, MH_class, MH_methods, sizeof(MH_methods)/sizeof(JNINativeMethod));
   80.90      }
   80.91    }
   80.92  
    81.1 --- a/src/share/vm/prims/nativeLookup.cpp	Tue May 14 17:33:07 2013 +0000
    81.2 +++ b/src/share/vm/prims/nativeLookup.cpp	Thu May 16 13:47:55 2013 -0700
    81.3 @@ -383,10 +383,7 @@
    81.4  
    81.5  address NativeLookup::lookup(methodHandle method, bool& in_base_library, TRAPS) {
    81.6    if (!method->has_native_function()) {
    81.7 -    address entry =
    81.8 -        method->intrinsic_id() == vmIntrinsics::_invokeGeneric ?
    81.9 -            SharedRuntime::native_method_throw_unsupported_operation_exception_entry() :
   81.10 -            lookup_base(method, in_base_library, CHECK_NULL);
   81.11 +    address entry = lookup_base(method, in_base_library, CHECK_NULL);
   81.12      method->set_native_function(entry,
   81.13        Method::native_bind_event_is_interesting);
   81.14      // -verbose:jni printing
    82.1 --- a/src/share/vm/runtime/arguments.cpp	Tue May 14 17:33:07 2013 +0000
    82.2 +++ b/src/share/vm/runtime/arguments.cpp	Thu May 16 13:47:55 2013 -0700
    82.3 @@ -1089,6 +1089,10 @@
    82.4    if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
    82.5      FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
    82.6    }
    82.7 +  if (!UseInterpreter) { // -Xcomp
    82.8 +    Tier3InvokeNotifyFreqLog = 0;
    82.9 +    Tier4InvocationThreshold = 0;
   82.10 +  }
   82.11  }
   82.12  
   82.13  #if INCLUDE_ALL_GCS
   82.14 @@ -1669,6 +1673,20 @@
   82.15  // Aggressive optimization flags  -XX:+AggressiveOpts
   82.16  void Arguments::set_aggressive_opts_flags() {
   82.17  #ifdef COMPILER2
   82.18 +  if (AggressiveUnboxing) {
   82.19 +    if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
   82.20 +      FLAG_SET_DEFAULT(EliminateAutoBox, true);
   82.21 +    } else if (!EliminateAutoBox) {
   82.22 +      // warning("AggressiveUnboxing is disabled because EliminateAutoBox is disabled");
   82.23 +      AggressiveUnboxing = false;
   82.24 +    }
   82.25 +    if (FLAG_IS_DEFAULT(DoEscapeAnalysis)) {
   82.26 +      FLAG_SET_DEFAULT(DoEscapeAnalysis, true);
   82.27 +    } else if (!DoEscapeAnalysis) {
   82.28 +      // warning("AggressiveUnboxing is disabled because DoEscapeAnalysis is disabled");
   82.29 +      AggressiveUnboxing = false;
   82.30 +    }
   82.31 +  }
   82.32    if (AggressiveOpts || !FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
   82.33      if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
   82.34        FLAG_SET_DEFAULT(EliminateAutoBox, true);
    83.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Tue May 14 17:33:07 2013 +0000
    83.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Thu May 16 13:47:55 2013 -0700
    83.3 @@ -883,26 +883,30 @@
    83.4  }
    83.5  
    83.6  
    83.7 -JNI_ENTRY(void, throw_unsatisfied_link_error(JNIEnv* env, ...))
    83.8 +/**
    83.9 + * Throws an java/lang/UnsatisfiedLinkError.  The address of this method is
   83.10 + * installed in the native function entry of all native Java methods before
   83.11 + * they get linked to their actual native methods.
   83.12 + *
   83.13 + * \note
   83.14 + * This method actually never gets called!  The reason is because
   83.15 + * the interpreter's native entries call NativeLookup::lookup() which
   83.16 + * throws the exception when the lookup fails.  The exception is then
   83.17 + * caught and forwarded on the return from NativeLookup::lookup() call
   83.18 + * before the call to the native function.  This might change in the future.
   83.19 + */
   83.20 +JNI_ENTRY(void*, throw_unsatisfied_link_error(JNIEnv* env, ...))
   83.21  {
   83.22 -  THROW(vmSymbols::java_lang_UnsatisfiedLinkError());
   83.23 +  // We return a bad value here to make sure that the exception is
   83.24 +  // forwarded before we look at the return value.
   83.25 +  THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badJNIHandle);
   83.26  }
   83.27  JNI_END
   83.28  
   83.29 -JNI_ENTRY(void, throw_unsupported_operation_exception(JNIEnv* env, ...))
   83.30 -{
   83.31 -  THROW(vmSymbols::java_lang_UnsupportedOperationException());
   83.32 -}
   83.33 -JNI_END
   83.34 -
   83.35  address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() {
   83.36    return CAST_FROM_FN_PTR(address, &throw_unsatisfied_link_error);
   83.37  }
   83.38  
   83.39 -address SharedRuntime::native_method_throw_unsupported_operation_exception_entry() {
   83.40 -  return CAST_FROM_FN_PTR(address, &throw_unsupported_operation_exception);
   83.41 -}
   83.42 -
   83.43  
   83.44  #ifndef PRODUCT
   83.45  JRT_ENTRY(intptr_t, SharedRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2))
    84.1 --- a/src/share/vm/runtime/vmStructs.cpp	Tue May 14 17:33:07 2013 +0000
    84.2 +++ b/src/share/vm/runtime/vmStructs.cpp	Thu May 16 13:47:55 2013 -0700
    84.3 @@ -1057,6 +1057,7 @@
    84.4    c2_nonstatic_field(Compile,            _save_argument_registers, const bool)                                                       \
    84.5    c2_nonstatic_field(Compile,            _subsume_loads,           const bool)                                                       \
    84.6    c2_nonstatic_field(Compile,            _do_escape_analysis,      const bool)                                                       \
    84.7 +  c2_nonstatic_field(Compile,            _eliminate_boxing,        const bool)                                                       \
    84.8    c2_nonstatic_field(Compile,            _ilt,                     InlineTree*)                                                      \
    84.9                                                                                                                                       \
   84.10    c2_nonstatic_field(InlineTree,         _caller_jvms,             JVMState*)                                                        \
    85.1 --- a/src/share/vm/utilities/quickSort.cpp	Tue May 14 17:33:07 2013 +0000
    85.2 +++ b/src/share/vm/utilities/quickSort.cpp	Thu May 16 13:47:55 2013 -0700
    85.3 @@ -34,6 +34,7 @@
    85.4  #include "memory/allocation.inline.hpp"
    85.5  #include <stdlib.h>
    85.6  
    85.7 +#ifdef ASSERT
    85.8  static int test_comparator(int a, int b) {
    85.9    if (a == b) {
   85.10      return 0;
   85.11 @@ -43,6 +44,7 @@
   85.12    }
   85.13    return 1;
   85.14  }
   85.15 +#endif // ASSERT
   85.16  
   85.17  static int test_even_odd_comparator(int a, int b) {
   85.18    bool a_is_odd = (a % 2) == 1;
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/test/compiler/6934604/TestByteBoxing.java	Thu May 16 13:47:55 2013 -0700
    86.3 @@ -0,0 +1,777 @@
    86.4 +/*
    86.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    86.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    86.7 + *
    86.8 + * This code is free software; you can redistribute it and/or modify it
    86.9 + * under the terms of the GNU General Public License version 2 only, as
   86.10 + * published by the Free Software Foundation.
   86.11 + *
   86.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   86.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   86.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   86.15 + * version 2 for more details (a copy is included in the LICENSE file that
   86.16 + * accompanied this code).
   86.17 + *
   86.18 + * You should have received a copy of the GNU General Public License version
   86.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   86.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   86.21 + *
   86.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   86.23 + * or visit www.oracle.com if you need additional information or have any
   86.24 + * questions.
   86.25 + */
   86.26 +
   86.27 +/*
   86.28 + * @test
   86.29 + * @bug 6934604
   86.30 + * @summary enable parts of EliminateAutoBox by default
   86.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestByteBoxing
   86.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
   86.33 + * -XX:CompileCommand=exclude,TestByteBoxing.dummy -XX:CompileCommand=exclude,TestByteBoxing.foo -XX:CompileCommand=exclude,TestByteBoxing.foob TestByteBoxing
   86.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
   86.35 + * -XX:CompileCommand=exclude,TestByteBoxing.dummy -XX:CompileCommand=exclude,TestByteBoxing.foo -XX:CompileCommand=exclude,TestByteBoxing.foob TestByteBoxing
   86.36 + *
   86.37 + */
   86.38 +
   86.39 +public class TestByteBoxing {
   86.40 +
   86.41 +  static final Byte ibc = new Byte((byte)1);
   86.42 +
   86.43 +  //===============================================
   86.44 +  // Non-inlined methods to test deoptimization info
   86.45 +  static void dummy()      { }
   86.46 +  static byte foo(byte i)  { return i; }
   86.47 +  static Byte foob(byte i) { return Byte.valueOf(i); }
   86.48 +
   86.49 +
   86.50 +  static byte simple(byte i) {
   86.51 +    Byte ib = new Byte(i);
   86.52 +    return ib;
   86.53 +  }
   86.54 +
   86.55 +  static byte simpleb(byte i) {
   86.56 +    Byte ib = Byte.valueOf(i);
   86.57 +    return ib;
   86.58 +  }
   86.59 +
   86.60 +  static byte simplec() {
   86.61 +    Byte ib = ibc;
   86.62 +    return ib;
   86.63 +  }
   86.64 +
   86.65 +  static byte simplef(byte i) {
   86.66 +    Byte ib = foob(i);
   86.67 +    return ib;
   86.68 +  }
   86.69 +
   86.70 +  static byte simplep(Byte ib) {
   86.71 +    return ib;
   86.72 +  }
   86.73 +
   86.74 +  static byte simple2(byte i) {
   86.75 +    Byte ib1 = new Byte(i);
   86.76 +    Byte ib2 = new Byte((byte)(i+1));
   86.77 +    return (byte)(ib1 + ib2);
   86.78 +  }
   86.79 +
   86.80 +  static byte simpleb2(byte i) {
   86.81 +    Byte ib1 = Byte.valueOf(i);
   86.82 +    Byte ib2 = Byte.valueOf((byte)(i+1));
   86.83 +    return (byte)(ib1 + ib2);
   86.84 +  }
   86.85 +
   86.86 +  static byte simplem2(byte i) {
   86.87 +    Byte ib1 = new Byte(i);
   86.88 +    Byte ib2 = Byte.valueOf((byte)(i+1));
   86.89 +    return (byte)(ib1 + ib2);
   86.90 +  }
   86.91 +
   86.92 +  static byte simplep2(byte i, Byte ib1) {
   86.93 +    Byte ib2 = Byte.valueOf((byte)(i+1));
   86.94 +    return (byte)(ib1 + ib2);
   86.95 +  }
   86.96 +
   86.97 +  static byte simplec2(byte i) {
   86.98 +    Byte ib1 = ibc;
   86.99 +    Byte ib2 = Byte.valueOf((byte)(i+1));
  86.100 +    return (byte)(ib1 + ib2);
  86.101 +  }
  86.102 +
  86.103 +  //===============================================
  86.104 +  static byte test(byte i) {
  86.105 +    Byte ib = new Byte(i);
  86.106 +    if ((i&1) == 0)
  86.107 +      ib = (byte)(i+1);
  86.108 +    return ib;
  86.109 +  }
  86.110 +
  86.111 +  static byte testb(byte i) {
  86.112 +    Byte ib = i;
  86.113 +    if ((i&1) == 0)
  86.114 +      ib = (byte)(i+1);
  86.115 +    return ib;
  86.116 +  }
  86.117 +
  86.118 +  static byte testm(byte i) {
  86.119 +    Byte ib = i;
  86.120 +    if ((i&1) == 0)
  86.121 +      ib = new Byte((byte)(i+1));
  86.122 +    return ib;
  86.123 +  }
  86.124 +
  86.125 +  static byte testp(byte i, Byte ib) {
  86.126 +    if ((i&1) == 0)
  86.127 +      ib = new Byte((byte)(i+1));
  86.128 +    return ib;
  86.129 +  }
  86.130 +
  86.131 +  static byte testc(byte i) {
  86.132 +    Byte ib = ibc;
  86.133 +    if ((i&1) == 0)
  86.134 +      ib = new Byte((byte)(i+1));
  86.135 +    return ib;
  86.136 +  }
  86.137 +
  86.138 +  static byte test2(byte i) {
  86.139 +    Byte ib1 = new Byte(i);
  86.140 +    Byte ib2 = new Byte((byte)(i+1));
  86.141 +    if ((i&1) == 0) {
  86.142 +      ib1 = new Byte((byte)(i+1));
  86.143 +      ib2 = new Byte((byte)(i+2));
  86.144 +    }
  86.145 +    return (byte)(ib1+ib2);
  86.146 +  }
  86.147 +
  86.148 +  static byte testb2(byte i) {
  86.149 +    Byte ib1 = i;
  86.150 +    Byte ib2 = (byte)(i+1);
  86.151 +    if ((i&1) == 0) {
  86.152 +      ib1 = (byte)(i+1);
  86.153 +      ib2 = (byte)(i+2);
  86.154 +    }
  86.155 +    return (byte)(ib1 + ib2);
  86.156 +  }
  86.157 +
  86.158 +  static byte testm2(byte i) {
  86.159 +    Byte ib1 = new Byte(i);
  86.160 +    Byte ib2 = (byte)(i+1);
  86.161 +    if ((i&1) == 0) {
  86.162 +      ib1 = new Byte((byte)(i+1));
  86.163 +      ib2 = (byte)(i+2);
  86.164 +    }
  86.165 +    return (byte)(ib1 + ib2);
  86.166 +  }
  86.167 +
  86.168 +  static byte testp2(byte i, Byte ib1) {
  86.169 +    Byte ib2 = (byte)(i+1);
  86.170 +    if ((i&1) == 0) {
  86.171 +      ib1 = new Byte((byte)(i+1));
  86.172 +      ib2 = (byte)(i+2);
  86.173 +    }
  86.174 +    return (byte)(ib1 + ib2);
  86.175 +  }
  86.176 +
  86.177 +  static byte testc2(byte i) {
  86.178 +    Byte ib1 = ibc;
  86.179 +    Byte ib2 = (byte)(i+1);
  86.180 +    if ((i&1) == 0) {
  86.181 +      ib1 = (byte)(ibc+1);
  86.182 +      ib2 = (byte)(i+2);
  86.183 +    }
  86.184 +    return (byte)(ib1 + ib2);
  86.185 +  }
  86.186 +
  86.187 +  //===============================================
  86.188 +  static byte sum(byte[] a) {
  86.189 +    byte result = 1;
  86.190 +    for (Byte i : a)
  86.191 +        result += i;
  86.192 +    return result;
  86.193 +  }
  86.194 +
  86.195 +  static byte sumb(byte[] a) {
  86.196 +    Byte result = 1;
  86.197 +    for (Byte i : a)
  86.198 +        result = (byte)(result + i);
  86.199 +    return result;
  86.200 +  }
  86.201 +
  86.202 +  static byte sumc(byte[] a) {
  86.203 +    Byte result = ibc;
  86.204 +    for (Byte i : a)
  86.205 +        result = (byte)(result + i);
  86.206 +    return result;
  86.207 +  }
  86.208 +
  86.209 +  static byte sumf(byte[] a) {
  86.210 +    Byte result = foob((byte)1);
  86.211 +    for (Byte i : a)
  86.212 +        result = (byte)(result + i);
  86.213 +    return result;
  86.214 +  }
  86.215 +
  86.216 +  static byte sump(byte[] a, Byte result) {
  86.217 +    for (Byte i : a)
  86.218 +        result = (byte)(result + i);
  86.219 +    return result;
  86.220 +  }
  86.221 +
  86.222 +  static byte sum2(byte[] a) {
  86.223 +    byte result1 = 1;
  86.224 +    byte result2 = 1;
  86.225 +    for (Byte i : a) {
  86.226 +        result1 += i;
  86.227 +        result2 += i + 1;
  86.228 +    }
  86.229 +    return (byte)(result1 + result2);
  86.230 +  }
  86.231 +
  86.232 +  static byte sumb2(byte[] a) {
  86.233 +    Byte result1 = 1;
  86.234 +    Byte result2 = 1;
  86.235 +    for (Byte i : a) {
  86.236 +        result1 = (byte)(result1 + i);
  86.237 +        result2 = (byte)(result2 + i + 1);
  86.238 +    }
  86.239 +    return (byte)(result1 + result2);
  86.240 +  }
  86.241 +
  86.242 +  static byte summ2(byte[] a) {
  86.243 +    Byte result1 = 1;
  86.244 +    Byte result2 = new Byte((byte)1);
  86.245 +    for (Byte i : a) {
  86.246 +        result1 = (byte)(result1 + i);
  86.247 +        result2 = (byte)(result2 + new Byte((byte)(i + 1)));
  86.248 +    }
  86.249 +    return (byte)(result1 + result2);
  86.250 +  }
  86.251 +
  86.252 +  static byte sump2(byte[] a, Byte result2) {
  86.253 +    Byte result1 = 1;
  86.254 +    for (Byte i : a) {
  86.255 +        result1 = (byte)(result1 + i);
  86.256 +        result2 = (byte)(result2 + i + 1);
  86.257 +    }
  86.258 +    return (byte)(result1 + result2);
  86.259 +  }
  86.260 +
  86.261 +  static byte sumc2(byte[] a) {
  86.262 +    Byte result1 = 1;
  86.263 +    Byte result2 = ibc;
  86.264 +    for (Byte i : a) {
  86.265 +        result1 = (byte)(result1 + i);
  86.266 +        result2 = (byte)(result2 + i + ibc);
  86.267 +    }
  86.268 +    return (byte)(result1 + result2);
  86.269 +  }
  86.270 +
  86.271 +  //===============================================
  86.272 +  static byte remi_sum() {
  86.273 +    Byte j = new Byte((byte)1);
  86.274 +    for (int i = 0; i< 1000; i++) {
  86.275 +      j = new Byte((byte)(j + 1));
  86.276 +    }
  86.277 +    return j;
  86.278 +  }
  86.279 +
  86.280 +  static byte remi_sumb() {
  86.281 +    Byte j = Byte.valueOf((byte)1);
  86.282 +    for (int i = 0; i< 1000; i++) {
  86.283 +      j = (byte)(j + 1);
  86.284 +    }
  86.285 +    return j;
  86.286 +  }
  86.287 +
  86.288 +  static byte remi_sumf() {
  86.289 +    Byte j = foob((byte)1);
  86.290 +    for (int i = 0; i< 1000; i++) {
  86.291 +      j = (byte)(j + 1);
  86.292 +    }
  86.293 +    return j;
  86.294 +  }
  86.295 +
  86.296 +  static byte remi_sump(Byte j) {
  86.297 +    for (int i = 0; i< 1000; i++) {
  86.298 +      j = new Byte((byte)(j + 1));
  86.299 +    }
  86.300 +    return j;
  86.301 +  }
  86.302 +
  86.303 +  static byte remi_sumc() {
  86.304 +    Byte j = ibc;
  86.305 +    for (int i = 0; i< 1000; i++) {
  86.306 +      j = (byte)(j + ibc);
  86.307 +    }
  86.308 +    return j;
  86.309 +  }
  86.310 +
  86.311 +  static byte remi_sum2() {
  86.312 +    Byte j1 = new Byte((byte)1);
  86.313 +    Byte j2 = new Byte((byte)1);
  86.314 +    for (int i = 0; i< 1000; i++) {
  86.315 +      j1 = new Byte((byte)(j1 + 1));
  86.316 +      j2 = new Byte((byte)(j2 + 2));
  86.317 +    }
  86.318 +    return (byte)(j1 + j2);
  86.319 +  }
  86.320 +
  86.321 +  static byte remi_sumb2() {
  86.322 +    Byte j1 = Byte.valueOf((byte)1);
  86.323 +    Byte j2 = Byte.valueOf((byte)1);
  86.324 +    for (int i = 0; i< 1000; i++) {
  86.325 +      j1 = (byte)(j1 + 1);
  86.326 +      j2 = (byte)(j2 + 2);
  86.327 +    }
  86.328 +    return (byte)(j1 + j2);
  86.329 +  }
  86.330 +
  86.331 +  static byte remi_summ2() {
  86.332 +    Byte j1 = new Byte((byte)1);
  86.333 +    Byte j2 = Byte.valueOf((byte)1);
  86.334 +    for (int i = 0; i< 1000; i++) {
  86.335 +      j1 = new Byte((byte)(j1 + 1));
  86.336 +      j2 = (byte)(j2 + 2);
  86.337 +    }
  86.338 +    return (byte)(j1 + j2);
  86.339 +  }
  86.340 +
  86.341 +  static byte remi_sump2(Byte j1) {
  86.342 +    Byte j2 = Byte.valueOf((byte)1);
  86.343 +    for (int i = 0; i< 1000; i++) {
  86.344 +      j1 = new Byte((byte)(j1 + 1));
  86.345 +      j2 = (byte)(j2 + 2);
  86.346 +    }
  86.347 +    return (byte)(j1 + j2);
  86.348 +  }
  86.349 +
  86.350 +  static byte remi_sumc2() {
  86.351 +    Byte j1 = ibc;
  86.352 +    Byte j2 = Byte.valueOf((byte)1);
  86.353 +    for (int i = 0; i< 1000; i++) {
  86.354 +      j1 = (byte)(j1 + ibc);
  86.355 +      j2 = (byte)(j2 + 2);
  86.356 +    }
  86.357 +    return (byte)(j1 + j2);
  86.358 +  }
  86.359 +
  86.360 +
  86.361 +  //===============================================
  86.362 +  // Safepointa and debug info for deoptimization
  86.363 +  static byte simple_deop(byte i) {
  86.364 +    Byte ib = new Byte(foo(i));
  86.365 +    dummy();
  86.366 +    return ib;
  86.367 +  }
  86.368 +
  86.369 +  static byte simpleb_deop(byte i) {
  86.370 +    Byte ib = Byte.valueOf(foo(i));
  86.371 +    dummy();
  86.372 +    return ib;
  86.373 +  }
  86.374 +
  86.375 +  static byte simplef_deop(byte i) {
  86.376 +    Byte ib = foob(i);
  86.377 +    dummy();
  86.378 +    return ib;
  86.379 +  }
  86.380 +
  86.381 +  static byte simplep_deop(Byte ib) {
  86.382 +    dummy();
  86.383 +    return ib;
  86.384 +  }
  86.385 +
  86.386 +  static byte simplec_deop(byte i) {
  86.387 +    Byte ib = ibc;
  86.388 +    dummy();
  86.389 +    return ib;
  86.390 +  }
  86.391 +
  86.392 +  static byte test_deop(byte i) {
  86.393 +    Byte ib = new Byte(foo(i));
  86.394 +    if ((i&1) == 0)
  86.395 +      ib = foo((byte)(i+1));
  86.396 +    dummy();
  86.397 +    return ib;
  86.398 +  }
  86.399 +
  86.400 +  static byte testb_deop(byte i) {
  86.401 +    Byte ib = foo(i);
  86.402 +    if ((i&1) == 0)
  86.403 +      ib = foo((byte)(i+1));
  86.404 +    dummy();
  86.405 +    return ib;
  86.406 +  }
  86.407 +
  86.408 +  static byte testf_deop(byte i) {
  86.409 +    Byte ib = foob(i);
  86.410 +    if ((i&1) == 0)
  86.411 +      ib = foo((byte)(i+1));
  86.412 +    dummy();
  86.413 +    return ib;
  86.414 +  }
  86.415 +
  86.416 +  static byte testp_deop(byte i, Byte ib) {
  86.417 +    if ((i&1) == 0)
  86.418 +      ib = foo((byte)(i+1));
  86.419 +    dummy();
  86.420 +    return ib;
  86.421 +  }
  86.422 +
  86.423 +  static byte testc_deop(byte i) {
  86.424 +    Byte ib = ibc;
  86.425 +    if ((i&1) == 0)
  86.426 +      ib = foo((byte)(i+1));
  86.427 +    dummy();
  86.428 +    return ib;
  86.429 +  }
  86.430 +
  86.431 +  static byte sum_deop(byte[] a) {
  86.432 +    byte result = 1;
  86.433 +    for (Byte i : a)
  86.434 +        result += foo(i);
  86.435 +    dummy();
  86.436 +    return result;
  86.437 +  }
  86.438 +
  86.439 +  static byte sumb_deop(byte[] a) {
  86.440 +    Byte result = 1;
  86.441 +    for (Byte i : a)
  86.442 +        result = (byte)(result + foo(i));
  86.443 +    dummy();
  86.444 +    return result;
  86.445 +  }
  86.446 +
  86.447 +  static byte sumf_deop(byte[] a) {
  86.448 +    Byte result = 1;
  86.449 +    for (Byte i : a)
  86.450 +        result = (byte)(result + foob(i));
  86.451 +    dummy();
  86.452 +    return result;
  86.453 +  }
  86.454 +
  86.455 +  static byte sump_deop(byte[] a, Byte result) {
  86.456 +    for (Byte i : a)
  86.457 +        result = (byte)(result + foob(i));
  86.458 +    dummy();
  86.459 +    return result;
  86.460 +  }
  86.461 +
  86.462 +  static byte sumc_deop(byte[] a) {
  86.463 +    Byte result = ibc;
  86.464 +    for (Byte i : a)
  86.465 +        result = (byte)(result + foo(i));
  86.466 +    dummy();
  86.467 +    return result;
  86.468 +  }
  86.469 +
  86.470 +  static byte remi_sum_deop() {
  86.471 +    Byte j = new Byte(foo((byte)1));
  86.472 +    for (int i = 0; i< 1000; i++) {
  86.473 +      j = new Byte(foo((byte)(j + 1)));
  86.474 +    }
  86.475 +    dummy();
  86.476 +    return j;
  86.477 +  }
  86.478 +
  86.479 +  static byte remi_sumb_deop() {
  86.480 +    Byte j = Byte.valueOf(foo((byte)1));
  86.481 +    for (int i = 0; i< 1000; i++) {
  86.482 +      j = foo((byte)(j + 1));
  86.483 +    }
  86.484 +    dummy();
  86.485 +    return j;
  86.486 +  }
  86.487 +
  86.488 +  static byte remi_sumf_deop() {
  86.489 +    Byte j = foob((byte)1);
  86.490 +    for (int i = 0; i< 1000; i++) {
  86.491 +      j = foo((byte)(j + 1));
  86.492 +    }
  86.493 +    dummy();
  86.494 +    return j;
  86.495 +  }
  86.496 +
  86.497 +  static byte remi_sump_deop(Byte j) {
  86.498 +    for (int i = 0; i< 1000; i++) {
  86.499 +      j = foo((byte)(j + 1));
  86.500 +    }
  86.501 +    dummy();
  86.502 +    return j;
  86.503 +  }
  86.504 +
  86.505 +  static byte remi_sumc_deop() {
  86.506 +    Byte j = ibc;
  86.507 +    for (int i = 0; i< 1000; i++) {
  86.508 +      j = foo((byte)(j + 1));
  86.509 +    }
  86.510 +    dummy();
  86.511 +    return j;
  86.512 +  }
  86.513 +
  86.514 +  //===============================================
  86.515 +  // Conditional increment
  86.516 +  static byte remi_sum_cond() {
  86.517 +    Byte j = new Byte((byte)1);
  86.518 +    for (int i = 0; i< 1000; i++) {
  86.519 +      if ((i&1) == 0) {
  86.520 +        j = new Byte((byte)(j + 1));
  86.521 +      }
  86.522 +    }
  86.523 +    return j;
  86.524 +  }
  86.525 +
  86.526 +  static byte remi_sumb_cond() {
  86.527 +    Byte j = Byte.valueOf((byte)1);
  86.528 +    for (int i = 0; i< 1000; i++) {
  86.529 +      if ((i&1) == 0) {
  86.530 +        j = (byte)(j + 1);
  86.531 +      }
  86.532 +    }
  86.533 +    return j;
  86.534 +  }
  86.535 +
  86.536 +  static byte remi_sumf_cond() {
  86.537 +    Byte j = foob((byte)1);
  86.538 +    for (int i = 0; i< 1000; i++) {
  86.539 +      if ((i&1) == 0) {
  86.540 +        j = (byte)(j + 1);
  86.541 +      }
  86.542 +    }
  86.543 +    return j;
  86.544 +  }
  86.545 +
  86.546 +  static byte remi_sump_cond(Byte j) {
  86.547 +    for (int i = 0; i< 1000; i++) {
  86.548 +      if ((i&1) == 0) {
  86.549 +        j = (byte)(j + 1);
  86.550 +      }
  86.551 +    }
  86.552 +    return j;
  86.553 +  }
  86.554 +
  86.555 +  static byte remi_sumc_cond() {
  86.556 +    Byte j = ibc;
  86.557 +    for (int i = 0; i< 1000; i++) {
  86.558 +      if ((i&1) == 0) {
  86.559 +        j = (byte)(j + ibc);
  86.560 +      }
  86.561 +    }
  86.562 +    return j;
  86.563 +  }
  86.564 +
  86.565 +  static byte remi_sum2_cond() {
  86.566 +    Byte j1 = new Byte((byte)1);
  86.567 +    Byte j2 = new Byte((byte)1);
  86.568 +    for (int i = 0; i< 1000; i++) {
  86.569 +      if ((i&1) == 0) {
  86.570 +        j1 = new Byte((byte)(j1 + 1));
  86.571 +      } else {
  86.572 +        j2 = new Byte((byte)(j2 + 2));
  86.573 +      }
  86.574 +    }
  86.575 +    return (byte)(j1 + j2);
  86.576 +  }
  86.577 +
  86.578 +  static byte remi_sumb2_cond() {
  86.579 +    Byte j1 = Byte.valueOf((byte)1);
  86.580 +    Byte j2 = Byte.valueOf((byte)1);
  86.581 +    for (int i = 0; i< 1000; i++) {
  86.582 +      if ((i&1) == 0) {
  86.583 +        j1 = (byte)(j1 + 1);
  86.584 +      } else {
  86.585 +        j2 = (byte)(j2 + 2);
  86.586 +      }
  86.587 +    }
  86.588 +    return (byte)(j1 + j2);
  86.589 +  }
  86.590 +
  86.591 +  static byte remi_summ2_cond() {
  86.592 +    Byte j1 = new Byte((byte)1);
  86.593 +    Byte j2 = Byte.valueOf((byte)1);
  86.594 +    for (int i = 0; i< 1000; i++) {
  86.595 +      if ((i&1) == 0) {
  86.596 +        j1 = new Byte((byte)(j1 + 1));
  86.597 +      } else {
  86.598 +        j2 = (byte)(j2 + 2);
  86.599 +      }
  86.600 +    }
  86.601 +    return (byte)(j1 + j2);
  86.602 +  }
  86.603 +
  86.604 +  static byte remi_sump2_cond(Byte j1) {
  86.605 +    Byte j2 = Byte.valueOf((byte)1);
  86.606 +    for (int i = 0; i< 1000; i++) {
  86.607 +      if ((i&1) == 0) {
  86.608 +        j1 = new Byte((byte)(j1 + 1));
  86.609 +      } else {
  86.610 +        j2 = (byte)(j2 + 2);
  86.611 +      }
  86.612 +    }
  86.613 +    return (byte)(j1 + j2);
  86.614 +  }
  86.615 +
  86.616 +  static byte remi_sumc2_cond() {
  86.617 +    Byte j1 = ibc;
  86.618 +    Byte j2 = Byte.valueOf((byte)1);
  86.619 +    for (int i = 0; i< 1000; i++) {
  86.620 +      if ((i&1) == 0) {
  86.621 +        j1 = (byte)(j1 + ibc);
  86.622 +      } else {
  86.623 +        j2 = (byte)(j2 + 2);
  86.624 +      }
  86.625 +    }
  86.626 +    return (byte)(j1 + j2);
  86.627 +  }
  86.628 +
  86.629 +
  86.630 +  public static void main(String[] args) {
  86.631 +    final int ntests = 70;
  86.632 +
  86.633 +    String[] test_name = new String[] {
  86.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
  86.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
  86.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
  86.637 +        "test",        "testb",        "testc",        "testm",        "testp",
  86.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
  86.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
  86.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
  86.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
  86.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
  86.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
  86.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
  86.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
  86.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
  86.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
  86.648 +    };
  86.649 +
  86.650 +    final int[] val = new int[] {
  86.651 +      -5488, -5488, 12000, -5488, -5488,
  86.652 +       1024,  1024, -5552,  1024,  1024,
  86.653 +      -5488, -5488, 12000, -5488, -5488,
  86.654 +        512,   512,  6256,   512,   512,
  86.655 +      13024, 13024, -5584, 13024, 13024,
  86.656 +        512,   512,  6256,   512,   512,
  86.657 +         45,    45,    45,    45,    45,
  86.658 +         66,    66,    66,    66,    66,
  86.659 +         45,    45,    45,    45,    45,
  86.660 +        -23,   -23,   -23,   -23,   -23,
  86.661 +        -70,   -70,   -70,   -70,   -70,
  86.662 +        -23,   -23,   -23,   -23,   -23,
  86.663 +        -11,   -11,   -11,   -11,   -11,
  86.664 +        -34,   -34,   -34,   -34,   -34
  86.665 +    };
  86.666 +
  86.667 +    int[] res = new int[ntests];
  86.668 +    for (int i = 0; i < ntests; i++) {
  86.669 +      res[i] = 0;
  86.670 +    }
  86.671 +
  86.672 +
  86.673 +    for (int i = 0; i < 12000; i++) {
  86.674 +      res[0] += simple((byte)i);
  86.675 +      res[1] += simpleb((byte)i);
  86.676 +      res[2] += simplec();
  86.677 +      res[3] += simplef((byte)i);
  86.678 +      res[4] += simplep((byte)i);
  86.679 +
  86.680 +      res[5] += simple2((byte)i);
  86.681 +      res[6] += simpleb2((byte)i);
  86.682 +      res[7] += simplec2((byte)i);
  86.683 +      res[8] += simplem2((byte)i);
  86.684 +      res[9] += simplep2((byte)i, (byte)i);
  86.685 +
  86.686 +      res[10] += simple_deop((byte)i);
  86.687 +      res[11] += simpleb_deop((byte)i);
  86.688 +      res[12] += simplec_deop((byte)i);
  86.689 +      res[13] += simplef_deop((byte)i);
  86.690 +      res[14] += simplep_deop((byte)i);
  86.691 +
  86.692 +      res[15] += test((byte)i);
  86.693 +      res[16] += testb((byte)i);
  86.694 +      res[17] += testc((byte)i);
  86.695 +      res[18] += testm((byte)i);
  86.696 +      res[19] += testp((byte)i, (byte)i);
  86.697 +
  86.698 +      res[20] += test2((byte)i);
  86.699 +      res[21] += testb2((byte)i);
  86.700 +      res[22] += testc2((byte)i);
  86.701 +      res[23] += testm2((byte)i);
  86.702 +      res[24] += testp2((byte)i, (byte)i);
  86.703 +
  86.704 +      res[25] += test_deop((byte)i);
  86.705 +      res[26] += testb_deop((byte)i);
  86.706 +      res[27] += testc_deop((byte)i);
  86.707 +      res[28] += testf_deop((byte)i);
  86.708 +      res[29] += testp_deop((byte)i, (byte)i);
  86.709 +    }
  86.710 +
  86.711 +    byte[] ia = new byte[1000];
  86.712 +    for (int i = 0; i < 1000; i++) {
  86.713 +      ia[i] = (byte)i;
  86.714 +    }
  86.715 +
  86.716 +    for (int i = 0; i < 100; i++) {
  86.717 +      res[30] = sum(ia);
  86.718 +      res[31] = sumb(ia);
  86.719 +      res[32] = sumc(ia);
  86.720 +      res[33] = sumf(ia);
  86.721 +      res[34] = sump(ia, (byte)1);
  86.722 +
  86.723 +      res[35] = sum2(ia);
  86.724 +      res[36] = sumb2(ia);
  86.725 +      res[37] = sumc2(ia);
  86.726 +      res[38] = summ2(ia);
  86.727 +      res[39] = sump2(ia, (byte)1);
  86.728 +
  86.729 +      res[40] = sum_deop(ia);
  86.730 +      res[41] = sumb_deop(ia);
  86.731 +      res[42] = sumc_deop(ia);
  86.732 +      res[43] = sumf_deop(ia);
  86.733 +      res[44] = sump_deop(ia, (byte)1);
  86.734 +
  86.735 +      res[45] = remi_sum();
  86.736 +      res[46] = remi_sumb();
  86.737 +      res[47] = remi_sumc();
  86.738 +      res[48] = remi_sumf();
  86.739 +      res[49] = remi_sump((byte)1);
  86.740 +
  86.741 +      res[50] = remi_sum2();
  86.742 +      res[51] = remi_sumb2();
  86.743 +      res[52] = remi_sumc2();
  86.744 +      res[53] = remi_summ2();
  86.745 +      res[54] = remi_sump2((byte)1);
  86.746 +
  86.747 +      res[55] = remi_sum_deop();
  86.748 +      res[56] = remi_sumb_deop();
  86.749 +      res[57] = remi_sumc_deop();
  86.750 +      res[58] = remi_sumf_deop();
  86.751 +      res[59] = remi_sump_deop((byte)1);
  86.752 +
  86.753 +      res[60] = remi_sum_cond();
  86.754 +      res[61] = remi_sumb_cond();
  86.755 +      res[62] = remi_sumc_cond();
  86.756 +      res[63] = remi_sumf_cond();
  86.757 +      res[64] = remi_sump_cond((byte)1);
  86.758 +
  86.759 +      res[65] = remi_sum2_cond();
  86.760 +      res[66] = remi_sumb2_cond();
  86.761 +      res[67] = remi_sumc2_cond();
  86.762 +      res[68] = remi_summ2_cond();
  86.763 +      res[69] = remi_sump2_cond((byte)1);
  86.764 +    }
  86.765 +
  86.766 +    int failed = 0;
  86.767 +    for (int i = 0; i < ntests; i++) {
  86.768 +      if (res[i] != val[i]) {
  86.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
  86.770 +        failed++;
  86.771 +      }
  86.772 +    }
  86.773 +    if (failed > 0) {
  86.774 +      System.err.println("Failed " + failed + " tests.");
  86.775 +      throw new InternalError();
  86.776 +    } else {
  86.777 +      System.out.println("Passed.");
  86.778 +    }
  86.779 +  }
  86.780 +}
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/test/compiler/6934604/TestDoubleBoxing.java	Thu May 16 13:47:55 2013 -0700
    87.3 @@ -0,0 +1,777 @@
    87.4 +/*
    87.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    87.7 + *
    87.8 + * This code is free software; you can redistribute it and/or modify it
    87.9 + * under the terms of the GNU General Public License version 2 only, as
   87.10 + * published by the Free Software Foundation.
   87.11 + *
   87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   87.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   87.15 + * version 2 for more details (a copy is included in the LICENSE file that
   87.16 + * accompanied this code).
   87.17 + *
   87.18 + * You should have received a copy of the GNU General Public License version
   87.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   87.21 + *
   87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   87.23 + * or visit www.oracle.com if you need additional information or have any
   87.24 + * questions.
   87.25 + */
   87.26 +
   87.27 +/*
   87.28 + * @test
   87.29 + * @bug 6934604
   87.30 + * @summary enable parts of EliminateAutoBox by default
   87.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestDoubleBoxing
   87.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
   87.33 + * -XX:CompileCommand=exclude,TestDoubleBoxing.dummy -XX:CompileCommand=exclude,TestDoubleBoxing.foo -XX:CompileCommand=exclude,TestDoubleBoxing.foob TestDoubleBoxing
   87.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
   87.35 + * -XX:CompileCommand=exclude,TestDoubleBoxing.dummy -XX:CompileCommand=exclude,TestDoubleBoxing.foo -XX:CompileCommand=exclude,TestDoubleBoxing.foob TestDoubleBoxing
   87.36 + *
   87.37 + */
   87.38 +
   87.39 +public class TestDoubleBoxing {
   87.40 +
   87.41 +  static final Double ibc = new Double(1.);
   87.42 +
   87.43 +  //===============================================
   87.44 +  // Non-inlined methods to test deoptimization info
   87.45 +  static void   dummy()        { }
   87.46 +  static double foo(double i)  { return i; }
   87.47 +  static Double foob(double i) { return Double.valueOf(i); }
   87.48 +
   87.49 +
   87.50 +  static double simple(double i) {
   87.51 +    Double ib = new Double(i);
   87.52 +    return ib;
   87.53 +  }
   87.54 +
   87.55 +  static double simpleb(double i) {
   87.56 +    Double ib = Double.valueOf(i);
   87.57 +    return ib;
   87.58 +  }
   87.59 +
   87.60 +  static double simplec() {
   87.61 +    Double ib = ibc;
   87.62 +    return ib;
   87.63 +  }
   87.64 +
   87.65 +  static double simplef(double i) {
   87.66 +    Double ib = foob(i);
   87.67 +    return ib;
   87.68 +  }
   87.69 +
   87.70 +  static double simplep(Double ib) {
   87.71 +    return ib;
   87.72 +  }
   87.73 +
   87.74 +  static double simple2(double i) {
   87.75 +    Double ib1 = new Double(i);
   87.76 +    Double ib2 = new Double(i+1.);
   87.77 +    return ib1 + ib2;
   87.78 +  }
   87.79 +
   87.80 +  static double simpleb2(double i) {
   87.81 +    Double ib1 = Double.valueOf(i);
   87.82 +    Double ib2 = Double.valueOf(i+1.);
   87.83 +    return ib1 + ib2;
   87.84 +  }
   87.85 +
   87.86 +  static double simplem2(double i) {
   87.87 +    Double ib1 = new Double(i);
   87.88 +    Double ib2 = Double.valueOf(i+1.);
   87.89 +    return ib1 + ib2;
   87.90 +  }
   87.91 +
   87.92 +  static double simplep2(double i, Double ib1) {
   87.93 +    Double ib2 = Double.valueOf(i+1.);
   87.94 +    return ib1 + ib2;
   87.95 +  }
   87.96 +
   87.97 +  static double simplec2(double i) {
   87.98 +    Double ib1 = ibc;
   87.99 +    Double ib2 = Double.valueOf(i+1.);
  87.100 +    return ib1 + ib2;
  87.101 +  }
  87.102 +
  87.103 +  //===============================================
  87.104 +  static double test(double f, int i) {
  87.105 +    Double ib = new Double(f);
  87.106 +    if ((i&1) == 0)
  87.107 +      ib = f+1.;
  87.108 +    return ib;
  87.109 +  }
  87.110 +
  87.111 +  static double testb(double f, int i) {
  87.112 +    Double ib = f;
  87.113 +    if ((i&1) == 0)
  87.114 +      ib = (f+1.);
  87.115 +    return ib;
  87.116 +  }
  87.117 +
  87.118 +  static double testm(double f, int i) {
  87.119 +    Double ib = f;
  87.120 +    if ((i&1) == 0)
  87.121 +      ib = new Double(f+1.);
  87.122 +    return ib;
  87.123 +  }
  87.124 +
  87.125 +  static double testp(double f, int i, Double ib) {
  87.126 +    if ((i&1) == 0)
  87.127 +      ib = new Double(f+1.);
  87.128 +    return ib;
  87.129 +  }
  87.130 +
  87.131 +  static double testc(double f, int i) {
  87.132 +    Double ib = ibc;
  87.133 +    if ((i&1) == 0)
  87.134 +      ib = new Double(f+1.);
  87.135 +    return ib;
  87.136 +  }
  87.137 +
  87.138 +  static double test2(double f, int i) {
  87.139 +    Double ib1 = new Double(f);
  87.140 +    Double ib2 = new Double(f+1.);
  87.141 +    if ((i&1) == 0) {
  87.142 +      ib1 = new Double(f+1.);
  87.143 +      ib2 = new Double(f+2.);
  87.144 +    }
  87.145 +    return ib1+ib2;
  87.146 +  }
  87.147 +
  87.148 +  static double testb2(double f, int i) {
  87.149 +    Double ib1 = f;
  87.150 +    Double ib2 = f+1.;
  87.151 +    if ((i&1) == 0) {
  87.152 +      ib1 = (f+1.);
  87.153 +      ib2 = (f+2.);
  87.154 +    }
  87.155 +    return ib1+ib2;
  87.156 +  }
  87.157 +
  87.158 +  static double testm2(double f, int i) {
  87.159 +    Double ib1 = new Double(f);
  87.160 +    Double ib2 = f+1.;
  87.161 +    if ((i&1) == 0) {
  87.162 +      ib1 = new Double(f+1.);
  87.163 +      ib2 = (f+2.);
  87.164 +    }
  87.165 +    return ib1+ib2;
  87.166 +  }
  87.167 +
  87.168 +  static double testp2(double f, int i, Double ib1) {
  87.169 +    Double ib2 = f+1.;
  87.170 +    if ((i&1) == 0) {
  87.171 +      ib1 = new Double(f+1.);
  87.172 +      ib2 = (f+2.);
  87.173 +    }
  87.174 +    return ib1+ib2;
  87.175 +  }
  87.176 +
  87.177 +  static double testc2(double f, int i) {
  87.178 +    Double ib1 = ibc;
  87.179 +    Double ib2 = f+1.;
  87.180 +    if ((i&1) == 0) {
  87.181 +      ib1 = (ibc+1.);
  87.182 +      ib2 = (f+2.);
  87.183 +    }
  87.184 +    return ib1+ib2;
  87.185 +  }
  87.186 +
  87.187 +  //===============================================
  87.188 +  static double sum(double[] a) {
  87.189 +    double result = 1.;
  87.190 +    for (Double i : a)
  87.191 +        result += i;
  87.192 +    return result;
  87.193 +  }
  87.194 +
  87.195 +  static double sumb(double[] a) {
  87.196 +    Double result = 1.;
  87.197 +    for (Double i : a)
  87.198 +        result += i;
  87.199 +    return result;
  87.200 +  }
  87.201 +
  87.202 +  static double sumc(double[] a) {
  87.203 +    Double result = ibc;
  87.204 +    for (Double i : a)
  87.205 +        result += i;
  87.206 +    return result;
  87.207 +  }
  87.208 +
  87.209 +  static double sumf(double[] a) {
  87.210 +    Double result = foob(1.);
  87.211 +    for (Double i : a)
  87.212 +        result += i;
  87.213 +    return result;
  87.214 +  }
  87.215 +
  87.216 +  static double sump(double[] a, Double result) {
  87.217 +    for (Double i : a)
  87.218 +        result += i;
  87.219 +    return result;
  87.220 +  }
  87.221 +
  87.222 +  static double sum2(double[] a) {
  87.223 +    double result1 = 1.;
  87.224 +    double result2 = 1.;
  87.225 +    for (Double i : a) {
  87.226 +        result1 += i;
  87.227 +        result2 += i + 1.;
  87.228 +    }
  87.229 +    return result1 + result2;
  87.230 +  }
  87.231 +
  87.232 +  static double sumb2(double[] a) {
  87.233 +    Double result1 = 1.;
  87.234 +    Double result2 = 1.;
  87.235 +    for (Double i : a) {
  87.236 +        result1 += i;
  87.237 +        result2 += i + 1.;
  87.238 +    }
  87.239 +    return result1 + result2;
  87.240 +  }
  87.241 +
  87.242 +  static double summ2(double[] a) {
  87.243 +    Double result1 = 1.;
  87.244 +    Double result2 = new Double(1.);
  87.245 +    for (Double i : a) {
  87.246 +        result1 += i;
  87.247 +        result2 += new Double(i + 1.);
  87.248 +    }
  87.249 +    return result1 + result2;
  87.250 +  }
  87.251 +
  87.252 +  static double sump2(double[] a, Double result2) {
  87.253 +    Double result1 = 1.;
  87.254 +    for (Double i : a) {
  87.255 +        result1 += i;
  87.256 +        result2 += i + 1.;
  87.257 +    }
  87.258 +    return result1 + result2;
  87.259 +  }
  87.260 +
  87.261 +  static double sumc2(double[] a) {
  87.262 +    Double result1 = 1.;
  87.263 +    Double result2 = ibc;
  87.264 +    for (Double i : a) {
  87.265 +        result1 += i;
  87.266 +        result2 += i + ibc;
  87.267 +    }
  87.268 +    return result1 + result2;
  87.269 +  }
  87.270 +
  87.271 +  //===============================================
  87.272 +  static double remi_sum() {
  87.273 +    Double j = new Double(1.);
  87.274 +    for (int i = 0; i< 1000; i++) {
  87.275 +      j = new Double(j + 1.);
  87.276 +    }
  87.277 +    return j;
  87.278 +  }
  87.279 +
  87.280 +  static double remi_sumb() {
  87.281 +    Double j = Double.valueOf(1.);
  87.282 +    for (int i = 0; i< 1000; i++) {
  87.283 +      j = j + 1.;
  87.284 +    }
  87.285 +    return j;
  87.286 +  }
  87.287 +
  87.288 +  static double remi_sumf() {
  87.289 +    Double j = foob(1.);
  87.290 +    for (int i = 0; i< 1000; i++) {
  87.291 +      j = j + 1.;
  87.292 +    }
  87.293 +    return j;
  87.294 +  }
  87.295 +
  87.296 +  static double remi_sump(Double j) {
  87.297 +    for (int i = 0; i< 1000; i++) {
  87.298 +      j = new Double(j + 1.);
  87.299 +    }
  87.300 +    return j;
  87.301 +  }
  87.302 +
  87.303 +  static double remi_sumc() {
  87.304 +    Double j = ibc;
  87.305 +    for (int i = 0; i< 1000; i++) {
  87.306 +      j = j + ibc;
  87.307 +    }
  87.308 +    return j;
  87.309 +  }
  87.310 +
  87.311 +  static double remi_sum2() {
  87.312 +    Double j1 = new Double(1.);
  87.313 +    Double j2 = new Double(1.);
  87.314 +    for (int i = 0; i< 1000; i++) {
  87.315 +      j1 = new Double(j1 + 1.);
  87.316 +      j2 = new Double(j2 + 2.);
  87.317 +    }
  87.318 +    return j1 + j2;
  87.319 +  }
  87.320 +
  87.321 +  static double remi_sumb2() {
  87.322 +    Double j1 = Double.valueOf(1.);
  87.323 +    Double j2 = Double.valueOf(1.);
  87.324 +    for (int i = 0; i< 1000; i++) {
  87.325 +      j1 = j1 + 1.;
  87.326 +      j2 = j2 + 2.;
  87.327 +    }
  87.328 +    return j1 + j2;
  87.329 +  }
  87.330 +
  87.331 +  static double remi_summ2() {
  87.332 +    Double j1 = new Double(1.);
  87.333 +    Double j2 = Double.valueOf(1.);
  87.334 +    for (int i = 0; i< 1000; i++) {
  87.335 +      j1 = new Double(j1 + 1.);
  87.336 +      j2 = j2 + 2.;
  87.337 +    }
  87.338 +    return j1 + j2;
  87.339 +  }
  87.340 +
  87.341 +  static double remi_sump2(Double j1) {
  87.342 +    Double j2 = Double.valueOf(1.);
  87.343 +    for (int i = 0; i< 1000; i++) {
  87.344 +      j1 = new Double(j1 + 1.);
  87.345 +      j2 = j2 + 2.;
  87.346 +    }
  87.347 +    return j1 + j2;
  87.348 +  }
  87.349 +
  87.350 +  static double remi_sumc2() {
  87.351 +    Double j1 = ibc;
  87.352 +    Double j2 = Double.valueOf(1.);
  87.353 +    for (int i = 0; i< 1000; i++) {
  87.354 +      j1 = j1 + ibc;
  87.355 +      j2 = j2 + 2.;
  87.356 +    }
  87.357 +    return j1 + j2;
  87.358 +  }
  87.359 +
  87.360 +
  87.361 +  //===============================================
  87.362 +  // Safepointa and debug info for deoptimization
  87.363 +  static double simple_deop(double i) {
  87.364 +    Double ib = new Double(foo(i));
  87.365 +    dummy();
  87.366 +    return ib;
  87.367 +  }
  87.368 +
  87.369 +  static double simpleb_deop(double i) {
  87.370 +    Double ib = Double.valueOf(foo(i));
  87.371 +    dummy();
  87.372 +    return ib;
  87.373 +  }
  87.374 +
  87.375 +  static double simplef_deop(double i) {
  87.376 +    Double ib = foob(i);
  87.377 +    dummy();
  87.378 +    return ib;
  87.379 +  }
  87.380 +
  87.381 +  static double simplep_deop(Double ib) {
  87.382 +    dummy();
  87.383 +    return ib;
  87.384 +  }
  87.385 +
  87.386 +  static double simplec_deop(double i) {
  87.387 +    Double ib = ibc;
  87.388 +    dummy();
  87.389 +    return ib;
  87.390 +  }
  87.391 +
  87.392 +  static double test_deop(double f, int i) {
  87.393 +    Double ib = new Double(foo(f));
  87.394 +    if ((i&1) == 0)
  87.395 +      ib = foo(f+1.);
  87.396 +    dummy();
  87.397 +    return ib;
  87.398 +  }
  87.399 +
  87.400 +  static double testb_deop(double f, int i) {
  87.401 +    Double ib = foo(f);
  87.402 +    if ((i&1) == 0)
  87.403 +      ib = foo(f+1.);
  87.404 +    dummy();
  87.405 +    return ib;
  87.406 +  }
  87.407 +
  87.408 +  static double testf_deop(double f, int i) {
  87.409 +    Double ib = foob(f);
  87.410 +    if ((i&1) == 0)
  87.411 +      ib = foo(f+1.);
  87.412 +    dummy();
  87.413 +    return ib;
  87.414 +  }
  87.415 +
  87.416 +  static double testp_deop(double f, int i, Double ib) {
  87.417 +    if ((i&1) == 0)
  87.418 +      ib = foo(f+1.);
  87.419 +    dummy();
  87.420 +    return ib;
  87.421 +  }
  87.422 +
  87.423 +  static double testc_deop(double f, int i) {
  87.424 +    Double ib = ibc;
  87.425 +    if ((i&1) == 0)
  87.426 +      ib = foo(f+1.);
  87.427 +    dummy();
  87.428 +    return ib;
  87.429 +  }
  87.430 +
  87.431 +  static double sum_deop(double[] a) {
  87.432 +    double result = 1.;
  87.433 +    for (Double i : a)
  87.434 +        result += foo(i);
  87.435 +    dummy();
  87.436 +    return result;
  87.437 +  }
  87.438 +
  87.439 +  static double sumb_deop(double[] a) {
  87.440 +    Double result = 1.;
  87.441 +    for (Double i : a)
  87.442 +        result += foo(i);
  87.443 +    dummy();
  87.444 +    return result;
  87.445 +  }
  87.446 +
  87.447 +  static double sumf_deop(double[] a) {
  87.448 +    Double result = 1.;
  87.449 +    for (Double i : a)
  87.450 +        result += foob(i);
  87.451 +    dummy();
  87.452 +    return result;
  87.453 +  }
  87.454 +
  87.455 +  static double sump_deop(double[] a, Double result) {
  87.456 +    for (Double i : a)
  87.457 +        result += foob(i);
  87.458 +    dummy();
  87.459 +    return result;
  87.460 +  }
  87.461 +
  87.462 +  static double sumc_deop(double[] a) {
  87.463 +    Double result = ibc;
  87.464 +    for (Double i : a)
  87.465 +        result += foo(i);
  87.466 +    dummy();
  87.467 +    return result;
  87.468 +  }
  87.469 +
  87.470 +  static double remi_sum_deop() {
  87.471 +    Double j = new Double(foo(1.));
  87.472 +    for (int i = 0; i< 1000; i++) {
  87.473 +      j = new Double(foo(j + 1.));
  87.474 +    }
  87.475 +    dummy();
  87.476 +    return j;
  87.477 +  }
  87.478 +
  87.479 +  static double remi_sumb_deop() {
  87.480 +    Double j = Double.valueOf(foo(1.));
  87.481 +    for (int i = 0; i< 1000; i++) {
  87.482 +      j = foo(j + 1.);
  87.483 +    }
  87.484 +    dummy();
  87.485 +    return j;
  87.486 +  }
  87.487 +
  87.488 +  static double remi_sumf_deop() {
  87.489 +    Double j = foob(1.);
  87.490 +    for (int i = 0; i< 1000; i++) {
  87.491 +      j = foo(j + 1.);
  87.492 +    }
  87.493 +    dummy();
  87.494 +    return j;
  87.495 +  }
  87.496 +
  87.497 +  static double remi_sump_deop(Double j) {
  87.498 +    for (int i = 0; i< 1000; i++) {
  87.499 +      j = foo(j + 1.);
  87.500 +    }
  87.501 +    dummy();
  87.502 +    return j;
  87.503 +  }
  87.504 +
  87.505 +  static double remi_sumc_deop() {
  87.506 +    Double j = ibc;
  87.507 +    for (int i = 0; i< 1000; i++) {
  87.508 +      j = foo(j + 1.);
  87.509 +    }
  87.510 +    dummy();
  87.511 +    return j;
  87.512 +  }
  87.513 +
  87.514 +  //===============================================
  87.515 +  // Conditional increment
  87.516 +  static double remi_sum_cond() {
  87.517 +    Double j = new Double(1.);
  87.518 +    for (int i = 0; i< 1000; i++) {
  87.519 +      if ((i&1) == 0) {
  87.520 +        j = new Double(j + 1.);
  87.521 +      }
  87.522 +    }
  87.523 +    return j;
  87.524 +  }
  87.525 +
  87.526 +  static double remi_sumb_cond() {
  87.527 +    Double j = Double.valueOf(1.);
  87.528 +    for (int i = 0; i< 1000; i++) {
  87.529 +      if ((i&1) == 0) {
  87.530 +        j = j + 1.;
  87.531 +      }
  87.532 +    }
  87.533 +    return j;
  87.534 +  }
  87.535 +
  87.536 +  static double remi_sumf_cond() {
  87.537 +    Double j = foob(1.);
  87.538 +    for (int i = 0; i< 1000; i++) {
  87.539 +      if ((i&1) == 0) {
  87.540 +        j = j + 1.;
  87.541 +      }
  87.542 +    }
  87.543 +    return j;
  87.544 +  }
  87.545 +
  87.546 +  static double remi_sump_cond(Double j) {
  87.547 +    for (int i = 0; i< 1000; i++) {
  87.548 +      if ((i&1) == 0) {
  87.549 +        j = j + 1.;
  87.550 +      }
  87.551 +    }
  87.552 +    return j;
  87.553 +  }
  87.554 +
  87.555 +  static double remi_sumc_cond() {
  87.556 +    Double j = ibc;
  87.557 +    for (int i = 0; i< 1000; i++) {
  87.558 +      if ((i&1) == 0) {
  87.559 +        j = j + ibc;
  87.560 +      }
  87.561 +    }
  87.562 +    return j;
  87.563 +  }
  87.564 +
  87.565 +  static double remi_sum2_cond() {
  87.566 +    Double j1 = new Double(1.);
  87.567 +    Double j2 = new Double(1.);
  87.568 +    for (int i = 0; i< 1000; i++) {
  87.569 +      if ((i&1) == 0) {
  87.570 +        j1 = new Double(j1 + 1.);
  87.571 +      } else {
  87.572 +        j2 = new Double(j2 + 2.);
  87.573 +      }
  87.574 +    }
  87.575 +    return j1 + j2;
  87.576 +  }
  87.577 +
  87.578 +  static double remi_sumb2_cond() {
  87.579 +    Double j1 = Double.valueOf(1.);
  87.580 +    Double j2 = Double.valueOf(1.);
  87.581 +    for (int i = 0; i< 1000; i++) {
  87.582 +      if ((i&1) == 0) {
  87.583 +        j1 = j1 + 1.;
  87.584 +      } else {
  87.585 +        j2 = j2 + 2.;
  87.586 +      }
  87.587 +    }
  87.588 +    return j1 + j2;
  87.589 +  }
  87.590 +
  87.591 +  static double remi_summ2_cond() {
  87.592 +    Double j1 = new Double(1.);
  87.593 +    Double j2 = Double.valueOf(1.);
  87.594 +    for (int i = 0; i< 1000; i++) {
  87.595 +      if ((i&1) == 0) {
  87.596 +        j1 = new Double(j1 + 1.);
  87.597 +      } else {
  87.598 +        j2 = j2 + 2.;
  87.599 +      }
  87.600 +    }
  87.601 +    return j1 + j2;
  87.602 +  }
  87.603 +
  87.604 +  static double remi_sump2_cond(Double j1) {
  87.605 +    Double j2 = Double.valueOf(1.);
  87.606 +    for (int i = 0; i< 1000; i++) {
  87.607 +      if ((i&1) == 0) {
  87.608 +        j1 = new Double(j1 + 1.);
  87.609 +      } else {
  87.610 +        j2 = j2 + 2.;
  87.611 +      }
  87.612 +    }
  87.613 +    return j1 + j2;
  87.614 +  }
  87.615 +
  87.616 +  static double remi_sumc2_cond() {
  87.617 +    Double j1 = ibc;
  87.618 +    Double j2 = Double.valueOf(1.);
  87.619 +    for (int i = 0; i< 1000; i++) {
  87.620 +      if ((i&1) == 0) {
  87.621 +        j1 = j1 + ibc;
  87.622 +      } else {
  87.623 +        j2 = j2 + 2;
  87.624 +      }
  87.625 +    }
  87.626 +    return j1 + j2;
  87.627 +  }
  87.628 +
  87.629 +
  87.630 +  public static void main(String[] args) {
  87.631 +    final int ntests = 70;
  87.632 +
  87.633 +    String[] test_name = new String[] {
  87.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
  87.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
  87.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
  87.637 +        "test",        "testb",        "testc",        "testm",        "testp",
  87.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
  87.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
  87.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
  87.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
  87.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
  87.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
  87.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
  87.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
  87.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
  87.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
  87.648 +    };
  87.649 +
  87.650 +    final double[] val = new double[] {
  87.651 +       71994000.,  71994000.,    12000.,  71994000.,  71994000.,
  87.652 +      144000000., 144000000., 72018000., 144000000., 144000000.,
  87.653 +       71994000.,  71994000.,    12000.,  71994000.,  71994000.,
  87.654 +       72000000.,  72000000., 36006000.,  72000000.,  72000000.,
  87.655 +      144012000., 144012000., 72030000., 144012000., 144012000.,
  87.656 +       72000000.,  72000000., 36006000.,  72000000.,  72000000.,
  87.657 +         499501.,    499501.,   499501.,    499501.,    499501.,
  87.658 +        1000002.,   1000002.,  1000002.,   1000002.,   1000002.,
  87.659 +         499501.,    499501.,   499501.,    499501.,    499501.,
  87.660 +           1001.,      1001.,     1001.,      1001.,      1001.,
  87.661 +           3002.,      3002.,     3002.,      3002.,      3002.,
  87.662 +           1001.,      1001.,     1001.,      1001.,      1001.,
  87.663 +            501.,       501.,      501.,       501.,       501.,
  87.664 +           1502.,      1502.,     1502.,      1502.,      1502.
  87.665 +    };
  87.666 +
  87.667 +    double[] res = new double[ntests];
  87.668 +    for (int i = 0; i < ntests; i++) {
  87.669 +      res[i] = 0.;
  87.670 +    }
  87.671 +
  87.672 +
  87.673 +    for (int i = 0; i < 12000; i++) {
  87.674 +      res[0] += simple(i);
  87.675 +      res[1] += simpleb(i);
  87.676 +      res[2] += simplec();
  87.677 +      res[3] += simplef(i);
  87.678 +      res[4] += simplep((double)i);
  87.679 +
  87.680 +      res[5] += simple2((double)i);
  87.681 +      res[6] += simpleb2((double)i);
  87.682 +      res[7] += simplec2((double)i);
  87.683 +      res[8] += simplem2((double)i);
  87.684 +      res[9] += simplep2((double)i, (double)i);
  87.685 +
  87.686 +      res[10] += simple_deop((double)i);
  87.687 +      res[11] += simpleb_deop((double)i);
  87.688 +      res[12] += simplec_deop((double)i);
  87.689 +      res[13] += simplef_deop((double)i);
  87.690 +      res[14] += simplep_deop((double)i);
  87.691 +
  87.692 +      res[15] += test((double)i, i);
  87.693 +      res[16] += testb((double)i, i);
  87.694 +      res[17] += testc((double)i, i);
  87.695 +      res[18] += testm((double)i, i);
  87.696 +      res[19] += testp((double)i, i, (double)i);
  87.697 +
  87.698 +      res[20] += test2((double)i, i);
  87.699 +      res[21] += testb2((double)i, i);
  87.700 +      res[22] += testc2((double)i, i);
  87.701 +      res[23] += testm2((double)i, i);
  87.702 +      res[24] += testp2((double)i, i, (double)i);
  87.703 +
  87.704 +      res[25] += test_deop((double)i, i);
  87.705 +      res[26] += testb_deop((double)i, i);
  87.706 +      res[27] += testc_deop((double)i, i);
  87.707 +      res[28] += testf_deop((double)i, i);
  87.708 +      res[29] += testp_deop((double)i, i, (double)i);
  87.709 +    }
  87.710 +
  87.711 +    double[] ia = new double[1000];
  87.712 +    for (int i = 0; i < 1000; i++) {
  87.713 +      ia[i] = i;
  87.714 +    }
  87.715 +
  87.716 +    for (int i = 0; i < 100; i++) {
  87.717 +      res[30] = sum(ia);
  87.718 +      res[31] = sumb(ia);
  87.719 +      res[32] = sumc(ia);
  87.720 +      res[33] = sumf(ia);
  87.721 +      res[34] = sump(ia, 1.);
  87.722 +
  87.723 +      res[35] = sum2(ia);
  87.724 +      res[36] = sumb2(ia);
  87.725 +      res[37] = sumc2(ia);
  87.726 +      res[38] = summ2(ia);
  87.727 +      res[39] = sump2(ia, 1.);
  87.728 +
  87.729 +      res[40] = sum_deop(ia);
  87.730 +      res[41] = sumb_deop(ia);
  87.731 +      res[42] = sumc_deop(ia);
  87.732 +      res[43] = sumf_deop(ia);
  87.733 +      res[44] = sump_deop(ia, 1.);
  87.734 +
  87.735 +      res[45] = remi_sum();
  87.736 +      res[46] = remi_sumb();
  87.737 +      res[47] = remi_sumc();
  87.738 +      res[48] = remi_sumf();
  87.739 +      res[49] = remi_sump(1.);
  87.740 +
  87.741 +      res[50] = remi_sum2();
  87.742 +      res[51] = remi_sumb2();
  87.743 +      res[52] = remi_sumc2();
  87.744 +      res[53] = remi_summ2();
  87.745 +      res[54] = remi_sump2(1.);
  87.746 +
  87.747 +      res[55] = remi_sum_deop();
  87.748 +      res[56] = remi_sumb_deop();
  87.749 +      res[57] = remi_sumc_deop();
  87.750 +      res[58] = remi_sumf_deop();
  87.751 +      res[59] = remi_sump_deop(1.);
  87.752 +
  87.753 +      res[60] = remi_sum_cond();
  87.754 +      res[61] = remi_sumb_cond();
  87.755 +      res[62] = remi_sumc_cond();
  87.756 +      res[63] = remi_sumf_cond();
  87.757 +      res[64] = remi_sump_cond(1.);
  87.758 +
  87.759 +      res[65] = remi_sum2_cond();
  87.760 +      res[66] = remi_sumb2_cond();
  87.761 +      res[67] = remi_sumc2_cond();
  87.762 +      res[68] = remi_summ2_cond();
  87.763 +      res[69] = remi_sump2_cond(1.);
  87.764 +    }
  87.765 +
  87.766 +    int failed = 0;
  87.767 +    for (int i = 0; i < ntests; i++) {
  87.768 +      if (res[i] != val[i]) {
  87.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
  87.770 +        failed++;
  87.771 +      }
  87.772 +    }
  87.773 +    if (failed > 0) {
  87.774 +      System.err.println("Failed " + failed + " tests.");
  87.775 +      throw new InternalError();
  87.776 +    } else {
  87.777 +      System.out.println("Passed.");
  87.778 +    }
  87.779 +  }
  87.780 +}
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/test/compiler/6934604/TestFloatBoxing.java	Thu May 16 13:47:55 2013 -0700
    88.3 @@ -0,0 +1,777 @@
    88.4 +/*
    88.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    88.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    88.7 + *
    88.8 + * This code is free software; you can redistribute it and/or modify it
    88.9 + * under the terms of the GNU General Public License version 2 only, as
   88.10 + * published by the Free Software Foundation.
   88.11 + *
   88.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   88.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   88.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   88.15 + * version 2 for more details (a copy is included in the LICENSE file that
   88.16 + * accompanied this code).
   88.17 + *
   88.18 + * You should have received a copy of the GNU General Public License version
   88.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   88.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   88.21 + *
   88.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   88.23 + * or visit www.oracle.com if you need additional information or have any
   88.24 + * questions.
   88.25 + */
   88.26 +
   88.27 +/*
   88.28 + * @test
   88.29 + * @bug 6934604
   88.30 + * @summary enable parts of EliminateAutoBox by default
   88.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestFloatBoxing
   88.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
   88.33 + * -XX:CompileCommand=exclude,TestFloatBoxing.dummy -XX:CompileCommand=exclude,TestFloatBoxing.foo -XX:CompileCommand=exclude,TestFloatBoxing.foob TestFloatBoxing
   88.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
   88.35 + * -XX:CompileCommand=exclude,TestFloatBoxing.dummy -XX:CompileCommand=exclude,TestFloatBoxing.foo -XX:CompileCommand=exclude,TestFloatBoxing.foob TestFloatBoxing
   88.36 + *
   88.37 + */
   88.38 +
   88.39 +public class TestFloatBoxing {
   88.40 +
   88.41 +  static final Float ibc = new Float(1.f);
   88.42 +
   88.43 +  //===============================================
   88.44 +  // Non-inlined methods to test deoptimization info
   88.45 +  static void  dummy()       { }
   88.46 +  static float foo(float i)  { return i; }
   88.47 +  static Float foob(float i) { return Float.valueOf(i); }
   88.48 +
   88.49 +
   88.50 +  static float simple(float i) {
   88.51 +    Float ib = new Float(i);
   88.52 +    return ib;
   88.53 +  }
   88.54 +
   88.55 +  static float simpleb(float i) {
   88.56 +    Float ib = Float.valueOf(i);
   88.57 +    return ib;
   88.58 +  }
   88.59 +
   88.60 +  static float simplec() {
   88.61 +    Float ib = ibc;
   88.62 +    return ib;
   88.63 +  }
   88.64 +
   88.65 +  static float simplef(float i) {
   88.66 +    Float ib = foob(i);
   88.67 +    return ib;
   88.68 +  }
   88.69 +
   88.70 +  static float simplep(Float ib) {
   88.71 +    return ib;
   88.72 +  }
   88.73 +
   88.74 +  static float simple2(float i) {
   88.75 +    Float ib1 = new Float(i);
   88.76 +    Float ib2 = new Float(i+1.f);
   88.77 +    return ib1 + ib2;
   88.78 +  }
   88.79 +
   88.80 +  static float simpleb2(float i) {
   88.81 +    Float ib1 = Float.valueOf(i);
   88.82 +    Float ib2 = Float.valueOf(i+1.f);
   88.83 +    return ib1 + ib2;
   88.84 +  }
   88.85 +
   88.86 +  static float simplem2(float i) {
   88.87 +    Float ib1 = new Float(i);
   88.88 +    Float ib2 = Float.valueOf(i+1.f);
   88.89 +    return ib1 + ib2;
   88.90 +  }
   88.91 +
   88.92 +  static float simplep2(float i, Float ib1) {
   88.93 +    Float ib2 = Float.valueOf(i+1.f);
   88.94 +    return ib1 + ib2;
   88.95 +  }
   88.96 +
   88.97 +  static float simplec2(float i) {
   88.98 +    Float ib1 = ibc;
   88.99 +    Float ib2 = Float.valueOf(i+1.f);
  88.100 +    return ib1 + ib2;
  88.101 +  }
  88.102 +
  88.103 +  //===============================================
  88.104 +  static float test(float f, int i) {
  88.105 +    Float ib = new Float(f);
  88.106 +    if ((i&1) == 0)
  88.107 +      ib = f+1.f;
  88.108 +    return ib;
  88.109 +  }
  88.110 +
  88.111 +  static float testb(float f, int i) {
  88.112 +    Float ib = f;
  88.113 +    if ((i&1) == 0)
  88.114 +      ib = (f+1.f);
  88.115 +    return ib;
  88.116 +  }
  88.117 +
  88.118 +  static float testm(float f, int i) {
  88.119 +    Float ib = f;
  88.120 +    if ((i&1) == 0)
  88.121 +      ib = new Float(f+1.f);
  88.122 +    return ib;
  88.123 +  }
  88.124 +
  88.125 +  static float testp(float f, int i, Float ib) {
  88.126 +    if ((i&1) == 0)
  88.127 +      ib = new Float(f+1.f);
  88.128 +    return ib;
  88.129 +  }
  88.130 +
  88.131 +  static float testc(float f, int i) {
  88.132 +    Float ib = ibc;
  88.133 +    if ((i&1) == 0)
  88.134 +      ib = new Float(f+1.f);
  88.135 +    return ib;
  88.136 +  }
  88.137 +
  88.138 +  static float test2(float f, int i) {
  88.139 +    Float ib1 = new Float(f);
  88.140 +    Float ib2 = new Float(f+1.f);
  88.141 +    if ((i&1) == 0) {
  88.142 +      ib1 = new Float(f+1.f);
  88.143 +      ib2 = new Float(f+2.f);
  88.144 +    }
  88.145 +    return ib1+ib2;
  88.146 +  }
  88.147 +
  88.148 +  static float testb2(float f, int i) {
  88.149 +    Float ib1 = f;
  88.150 +    Float ib2 = f+1.f;
  88.151 +    if ((i&1) == 0) {
  88.152 +      ib1 = (f+1.f);
  88.153 +      ib2 = (f+2.f);
  88.154 +    }
  88.155 +    return ib1+ib2;
  88.156 +  }
  88.157 +
  88.158 +  static float testm2(float f, int i) {
  88.159 +    Float ib1 = new Float(f);
  88.160 +    Float ib2 = f+1.f;
  88.161 +    if ((i&1) == 0) {
  88.162 +      ib1 = new Float(f+1.f);
  88.163 +      ib2 = (f+2.f);
  88.164 +    }
  88.165 +    return ib1+ib2;
  88.166 +  }
  88.167 +
  88.168 +  static float testp2(float f, int i, Float ib1) {
  88.169 +    Float ib2 = f+1.f;
  88.170 +    if ((i&1) == 0) {
  88.171 +      ib1 = new Float(f+1.f);
  88.172 +      ib2 = (f+2.f);
  88.173 +    }
  88.174 +    return ib1+ib2;
  88.175 +  }
  88.176 +
  88.177 +  static float testc2(float f, int i) {
  88.178 +    Float ib1 = ibc;
  88.179 +    Float ib2 = f+1.f;
  88.180 +    if ((i&1) == 0) {
  88.181 +      ib1 = (ibc+1.f);
  88.182 +      ib2 = (f+2.f);
  88.183 +    }
  88.184 +    return ib1+ib2;
  88.185 +  }
  88.186 +
  88.187 +  //===============================================
  88.188 +  static float sum(float[] a) {
  88.189 +    float result = 1.f;
  88.190 +    for (Float i : a)
  88.191 +        result += i;
  88.192 +    return result;
  88.193 +  }
  88.194 +
  88.195 +  static float sumb(float[] a) {
  88.196 +    Float result = 1.f;
  88.197 +    for (Float i : a)
  88.198 +        result += i;
  88.199 +    return result;
  88.200 +  }
  88.201 +
  88.202 +  static float sumc(float[] a) {
  88.203 +    Float result = ibc;
  88.204 +    for (Float i : a)
  88.205 +        result += i;
  88.206 +    return result;
  88.207 +  }
  88.208 +
  88.209 +  static float sumf(float[] a) {
  88.210 +    Float result = foob(1.f);
  88.211 +    for (Float i : a)
  88.212 +        result += i;
  88.213 +    return result;
  88.214 +  }
  88.215 +
  88.216 +  static float sump(float[] a, Float result) {
  88.217 +    for (Float i : a)
  88.218 +        result += i;
  88.219 +    return result;
  88.220 +  }
  88.221 +
  88.222 +  static float sum2(float[] a) {
  88.223 +    float result1 = 1.f;
  88.224 +    float result2 = 1.f;
  88.225 +    for (Float i : a) {
  88.226 +        result1 += i;
  88.227 +        result2 += i + 1.f;
  88.228 +    }
  88.229 +    return result1 + result2;
  88.230 +  }
  88.231 +
  88.232 +  static float sumb2(float[] a) {
  88.233 +    Float result1 = 1.f;
  88.234 +    Float result2 = 1.f;
  88.235 +    for (Float i : a) {
  88.236 +        result1 += i;
  88.237 +        result2 += i + 1.f;
  88.238 +    }
  88.239 +    return result1 + result2;
  88.240 +  }
  88.241 +
  88.242 +  static float summ2(float[] a) {
  88.243 +    Float result1 = 1.f;
  88.244 +    Float result2 = new Float(1.f);
  88.245 +    for (Float i : a) {
  88.246 +        result1 += i;
  88.247 +        result2 += new Float(i + 1.f);
  88.248 +    }
  88.249 +    return result1 + result2;
  88.250 +  }
  88.251 +
  88.252 +  static float sump2(float[] a, Float result2) {
  88.253 +    Float result1 = 1.f;
  88.254 +    for (Float i : a) {
  88.255 +        result1 += i;
  88.256 +        result2 += i + 1.f;
  88.257 +    }
  88.258 +    return result1 + result2;
  88.259 +  }
  88.260 +
  88.261 +  static float sumc2(float[] a) {
  88.262 +    Float result1 = 1.f;
  88.263 +    Float result2 = ibc;
  88.264 +    for (Float i : a) {
  88.265 +        result1 += i;
  88.266 +        result2 += i + ibc;
  88.267 +    }
  88.268 +    return result1 + result2;
  88.269 +  }
  88.270 +
  88.271 +  //===============================================
  88.272 +  static float remi_sum() {
  88.273 +    Float j = new Float(1.f);
  88.274 +    for (int i = 0; i< 1000; i++) {
  88.275 +      j = new Float(j + 1.f);
  88.276 +    }
  88.277 +    return j;
  88.278 +  }
  88.279 +
  88.280 +  static float remi_sumb() {
  88.281 +    Float j = Float.valueOf(1.f);
  88.282 +    for (int i = 0; i< 1000; i++) {
  88.283 +      j = j + 1.f;
  88.284 +    }
  88.285 +    return j;
  88.286 +  }
  88.287 +
  88.288 +  static float remi_sumf() {
  88.289 +    Float j = foob(1.f);
  88.290 +    for (int i = 0; i< 1000; i++) {
  88.291 +      j = j + 1.f;
  88.292 +    }
  88.293 +    return j;
  88.294 +  }
  88.295 +
  88.296 +  static float remi_sump(Float j) {
  88.297 +    for (int i = 0; i< 1000; i++) {
  88.298 +      j = new Float(j + 1.f);
  88.299 +    }
  88.300 +    return j;
  88.301 +  }
  88.302 +
  88.303 +  static float remi_sumc() {
  88.304 +    Float j = ibc;
  88.305 +    for (int i = 0; i< 1000; i++) {
  88.306 +      j = j + ibc;
  88.307 +    }
  88.308 +    return j;
  88.309 +  }
  88.310 +
  88.311 +  static float remi_sum2() {
  88.312 +    Float j1 = new Float(1.f);
  88.313 +    Float j2 = new Float(1.f);
  88.314 +    for (int i = 0; i< 1000; i++) {
  88.315 +      j1 = new Float(j1 + 1.f);
  88.316 +      j2 = new Float(j2 + 2.f);
  88.317 +    }
  88.318 +    return j1 + j2;
  88.319 +  }
  88.320 +
  88.321 +  static float remi_sumb2() {
  88.322 +    Float j1 = Float.valueOf(1.f);
  88.323 +    Float j2 = Float.valueOf(1.f);
  88.324 +    for (int i = 0; i< 1000; i++) {
  88.325 +      j1 = j1 + 1.f;
  88.326 +      j2 = j2 + 2.f;
  88.327 +    }
  88.328 +    return j1 + j2;
  88.329 +  }
  88.330 +
  88.331 +  static float remi_summ2() {
  88.332 +    Float j1 = new Float(1.f);
  88.333 +    Float j2 = Float.valueOf(1.f);
  88.334 +    for (int i = 0; i< 1000; i++) {
  88.335 +      j1 = new Float(j1 + 1.f);
  88.336 +      j2 = j2 + 2.f;
  88.337 +    }
  88.338 +    return j1 + j2;
  88.339 +  }
  88.340 +
  88.341 +  static float remi_sump2(Float j1) {
  88.342 +    Float j2 = Float.valueOf(1.f);
  88.343 +    for (int i = 0; i< 1000; i++) {
  88.344 +      j1 = new Float(j1 + 1.f);
  88.345 +      j2 = j2 + 2.f;
  88.346 +    }
  88.347 +    return j1 + j2;
  88.348 +  }
  88.349 +
  88.350 +  static float remi_sumc2() {
  88.351 +    Float j1 = ibc;
  88.352 +    Float j2 = Float.valueOf(1.f);
  88.353 +    for (int i = 0; i< 1000; i++) {
  88.354 +      j1 = j1 + ibc;
  88.355 +      j2 = j2 + 2.f;
  88.356 +    }
  88.357 +    return j1 + j2;
  88.358 +  }
  88.359 +
  88.360 +
  88.361 +  //===============================================
  88.362 +  // Safepointa and debug info for deoptimization
  88.363 +  static float simple_deop(float i) {
  88.364 +    Float ib = new Float(foo(i));
  88.365 +    dummy();
  88.366 +    return ib;
  88.367 +  }
  88.368 +
  88.369 +  static float simpleb_deop(float i) {
  88.370 +    Float ib = Float.valueOf(foo(i));
  88.371 +    dummy();
  88.372 +    return ib;
  88.373 +  }
  88.374 +
  88.375 +  static float simplef_deop(float i) {
  88.376 +    Float ib = foob(i);
  88.377 +    dummy();
  88.378 +    return ib;
  88.379 +  }
  88.380 +
  88.381 +  static float simplep_deop(Float ib) {
  88.382 +    dummy();
  88.383 +    return ib;
  88.384 +  }
  88.385 +
  88.386 +  static float simplec_deop(float i) {
  88.387 +    Float ib = ibc;
  88.388 +    dummy();
  88.389 +    return ib;
  88.390 +  }
  88.391 +
  88.392 +  static float test_deop(float f, int i) {
  88.393 +    Float ib = new Float(foo(f));
  88.394 +    if ((i&1) == 0)
  88.395 +      ib = foo(f+1.f);
  88.396 +    dummy();
  88.397 +    return ib;
  88.398 +  }
  88.399 +
  88.400 +  static float testb_deop(float f, int i) {
  88.401 +    Float ib = foo(f);
  88.402 +    if ((i&1) == 0)
  88.403 +      ib = foo(f+1.f);
  88.404 +    dummy();
  88.405 +    return ib;
  88.406 +  }
  88.407 +
  88.408 +  static float testf_deop(float f, int i) {
  88.409 +    Float ib = foob(f);
  88.410 +    if ((i&1) == 0)
  88.411 +      ib = foo(f+1.f);
  88.412 +    dummy();
  88.413 +    return ib;
  88.414 +  }
  88.415 +
  88.416 +  static float testp_deop(float f, int i, Float ib) {
  88.417 +    if ((i&1) == 0)
  88.418 +      ib = foo(f+1.f);
  88.419 +    dummy();
  88.420 +    return ib;
  88.421 +  }
  88.422 +
  88.423 +  static float testc_deop(float f, int i) {
  88.424 +    Float ib = ibc;
  88.425 +    if ((i&1) == 0)
  88.426 +      ib = foo(f+1.f);
  88.427 +    dummy();
  88.428 +    return ib;
  88.429 +  }
  88.430 +
  88.431 +  static float sum_deop(float[] a) {
  88.432 +    float result = 1.f;
  88.433 +    for (Float i : a)
  88.434 +        result += foo(i);
  88.435 +    dummy();
  88.436 +    return result;
  88.437 +  }
  88.438 +
  88.439 +  static float sumb_deop(float[] a) {
  88.440 +    Float result = 1.f;
  88.441 +    for (Float i : a)
  88.442 +        result += foo(i);
  88.443 +    dummy();
  88.444 +    return result;
  88.445 +  }
  88.446 +
  88.447 +  static float sumf_deop(float[] a) {
  88.448 +    Float result = 1.f;
  88.449 +    for (Float i : a)
  88.450 +        result += foob(i);
  88.451 +    dummy();
  88.452 +    return result;
  88.453 +  }
  88.454 +
  88.455 +  static float sump_deop(float[] a, Float result) {
  88.456 +    for (Float i : a)
  88.457 +        result += foob(i);
  88.458 +    dummy();
  88.459 +    return result;
  88.460 +  }
  88.461 +
  88.462 +  static float sumc_deop(float[] a) {
  88.463 +    Float result = ibc;
  88.464 +    for (Float i : a)
  88.465 +        result += foo(i);
  88.466 +    dummy();
  88.467 +    return result;
  88.468 +  }
  88.469 +
  88.470 +  static float remi_sum_deop() {
  88.471 +    Float j = new Float(foo(1.f));
  88.472 +    for (int i = 0; i< 1000; i++) {
  88.473 +      j = new Float(foo(j + 1.f));
  88.474 +    }
  88.475 +    dummy();
  88.476 +    return j;
  88.477 +  }
  88.478 +
  88.479 +  static float remi_sumb_deop() {
  88.480 +    Float j = Float.valueOf(foo(1.f));
  88.481 +    for (int i = 0; i< 1000; i++) {
  88.482 +      j = foo(j + 1.f);
  88.483 +    }
  88.484 +    dummy();
  88.485 +    return j;
  88.486 +  }
  88.487 +
  88.488 +  static float remi_sumf_deop() {
  88.489 +    Float j = foob(1.f);
  88.490 +    for (int i = 0; i< 1000; i++) {
  88.491 +      j = foo(j + 1.f);
  88.492 +    }
  88.493 +    dummy();
  88.494 +    return j;
  88.495 +  }
  88.496 +
  88.497 +  static float remi_sump_deop(Float j) {
  88.498 +    for (int i = 0; i< 1000; i++) {
  88.499 +      j = foo(j + 1.f);
  88.500 +    }
  88.501 +    dummy();
  88.502 +    return j;
  88.503 +  }
  88.504 +
  88.505 +  static float remi_sumc_deop() {
  88.506 +    Float j = ibc;
  88.507 +    for (int i = 0; i< 1000; i++) {
  88.508 +      j = foo(j + 1.f);
  88.509 +    }
  88.510 +    dummy();
  88.511 +    return j;
  88.512 +  }
  88.513 +
  88.514 +  //===============================================
  88.515 +  // Conditional increment
  88.516 +  static float remi_sum_cond() {
  88.517 +    Float j = new Float(1.f);
  88.518 +    for (int i = 0; i< 1000; i++) {
  88.519 +      if ((i&1) == 0) {
  88.520 +        j = new Float(j + 1.f);
  88.521 +      }
  88.522 +    }
  88.523 +    return j;
  88.524 +  }
  88.525 +
  88.526 +  static float remi_sumb_cond() {
  88.527 +    Float j = Float.valueOf(1.f);
  88.528 +    for (int i = 0; i< 1000; i++) {
  88.529 +      if ((i&1) == 0) {
  88.530 +        j = j + 1.f;
  88.531 +      }
  88.532 +    }
  88.533 +    return j;
  88.534 +  }
  88.535 +
  88.536 +  static float remi_sumf_cond() {
  88.537 +    Float j = foob(1.f);
  88.538 +    for (int i = 0; i< 1000; i++) {
  88.539 +      if ((i&1) == 0) {
  88.540 +        j = j + 1.f;
  88.541 +      }
  88.542 +    }
  88.543 +    return j;
  88.544 +  }
  88.545 +
  88.546 +  static float remi_sump_cond(Float j) {
  88.547 +    for (int i = 0; i< 1000; i++) {
  88.548 +      if ((i&1) == 0) {
  88.549 +        j = j + 1.f;
  88.550 +      }
  88.551 +    }
  88.552 +    return j;
  88.553 +  }
  88.554 +
  88.555 +  static float remi_sumc_cond() {
  88.556 +    Float j = ibc;
  88.557 +    for (int i = 0; i< 1000; i++) {
  88.558 +      if ((i&1) == 0) {
  88.559 +        j = j + ibc;
  88.560 +      }
  88.561 +    }
  88.562 +    return j;
  88.563 +  }
  88.564 +
  88.565 +  static float remi_sum2_cond() {
  88.566 +    Float j1 = new Float(1.f);
  88.567 +    Float j2 = new Float(1.f);
  88.568 +    for (int i = 0; i< 1000; i++) {
  88.569 +      if ((i&1) == 0) {
  88.570 +        j1 = new Float(j1 + 1.f);
  88.571 +      } else {
  88.572 +        j2 = new Float(j2 + 2.f);
  88.573 +      }
  88.574 +    }
  88.575 +    return j1 + j2;
  88.576 +  }
  88.577 +
  88.578 +  static float remi_sumb2_cond() {
  88.579 +    Float j1 = Float.valueOf(1.f);
  88.580 +    Float j2 = Float.valueOf(1.f);
  88.581 +    for (int i = 0; i< 1000; i++) {
  88.582 +      if ((i&1) == 0) {
  88.583 +        j1 = j1 + 1.f;
  88.584 +      } else {
  88.585 +        j2 = j2 + 2.f;
  88.586 +      }
  88.587 +    }
  88.588 +    return j1 + j2;
  88.589 +  }
  88.590 +
  88.591 +  static float remi_summ2_cond() {
  88.592 +    Float j1 = new Float(1.f);
  88.593 +    Float j2 = Float.valueOf(1.f);
  88.594 +    for (int i = 0; i< 1000; i++) {
  88.595 +      if ((i&1) == 0) {
  88.596 +        j1 = new Float(j1 + 1.f);
  88.597 +      } else {
  88.598 +        j2 = j2 + 2.f;
  88.599 +      }
  88.600 +    }
  88.601 +    return j1 + j2;
  88.602 +  }
  88.603 +
  88.604 +  static float remi_sump2_cond(Float j1) {
  88.605 +    Float j2 = Float.valueOf(1.f);
  88.606 +    for (int i = 0; i< 1000; i++) {
  88.607 +      if ((i&1) == 0) {
  88.608 +        j1 = new Float(j1 + 1.f);
  88.609 +      } else {
  88.610 +        j2 = j2 + 2.f;
  88.611 +      }
  88.612 +    }
  88.613 +    return j1 + j2;
  88.614 +  }
  88.615 +
  88.616 +  static float remi_sumc2_cond() {
  88.617 +    Float j1 = ibc;
  88.618 +    Float j2 = Float.valueOf(1.f);
  88.619 +    for (int i = 0; i< 1000; i++) {
  88.620 +      if ((i&1) == 0) {
  88.621 +        j1 = j1 + ibc;
  88.622 +      } else {
  88.623 +        j2 = j2 + 2;
  88.624 +      }
  88.625 +    }
  88.626 +    return j1 + j2;
  88.627 +  }
  88.628 +
  88.629 +
  88.630 +  public static void main(String[] args) {
  88.631 +    final int ntests = 70;
  88.632 +
  88.633 +    String[] test_name = new String[] {
  88.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
  88.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
  88.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
  88.637 +        "test",        "testb",        "testc",        "testm",        "testp",
  88.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
  88.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
  88.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
  88.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
  88.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
  88.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
  88.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
  88.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
  88.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
  88.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
  88.648 +    };
  88.649 +
  88.650 +    final float[] val = new float[] {
  88.651 +       71990896.f,  71990896.f,    12000.f,  71990896.f,  71990896.f,
  88.652 +      144000000.f, 144000000.f, 72014896.f, 144000000.f, 144000000.f,
  88.653 +       71990896.f,  71990896.f,    12000.f,  71990896.f,  71990896.f,
  88.654 +       72000000.f,  72000000.f, 36004096.f,  72000000.f,  72000000.f,
  88.655 +      144012288.f, 144012288.f, 72033096.f, 144012288.f, 144012288.f,
  88.656 +       72000000.f,  72000000.f, 36004096.f,  72000000.f,  72000000.f,
  88.657 +         499501.f,    499501.f,   499501.f,    499501.f,    499501.f,
  88.658 +        1000002.f,   1000002.f,  1000002.f,   1000002.f,   1000002.f,
  88.659 +         499501.f,    499501.f,   499501.f,    499501.f,    499501.f,
  88.660 +           1001.f,      1001.f,     1001.f,      1001.f,      1001.f,
  88.661 +           3002.f,      3002.f,     3002.f,      3002.f,      3002.f,
  88.662 +           1001.f,      1001.f,     1001.f,      1001.f,      1001.f,
  88.663 +            501.f,       501.f,      501.f,       501.f,       501.f,
  88.664 +           1502.f,      1502.f,     1502.f,      1502.f,      1502.f
  88.665 +    };
  88.666 +
  88.667 +    float[] res = new float[ntests];
  88.668 +    for (int i = 0; i < ntests; i++) {
  88.669 +      res[i] = 0.f;
  88.670 +    }
  88.671 +
  88.672 +
  88.673 +    for (int i = 0; i < 12000; i++) {
  88.674 +      res[0] += simple(i);
  88.675 +      res[1] += simpleb(i);
  88.676 +      res[2] += simplec();
  88.677 +      res[3] += simplef(i);
  88.678 +      res[4] += simplep((float)i);
  88.679 +
  88.680 +      res[5] += simple2((float)i);
  88.681 +      res[6] += simpleb2((float)i);
  88.682 +      res[7] += simplec2((float)i);
  88.683 +      res[8] += simplem2((float)i);
  88.684 +      res[9] += simplep2((float)i, (float)i);
  88.685 +
  88.686 +      res[10] += simple_deop((float)i);
  88.687 +      res[11] += simpleb_deop((float)i);
  88.688 +      res[12] += simplec_deop((float)i);
  88.689 +      res[13] += simplef_deop((float)i);
  88.690 +      res[14] += simplep_deop((float)i);
  88.691 +
  88.692 +      res[15] += test((float)i, i);
  88.693 +      res[16] += testb((float)i, i);
  88.694 +      res[17] += testc((float)i, i);
  88.695 +      res[18] += testm((float)i, i);
  88.696 +      res[19] += testp((float)i, i, (float)i);
  88.697 +
  88.698 +      res[20] += test2((float)i, i);
  88.699 +      res[21] += testb2((float)i, i);
  88.700 +      res[22] += testc2((float)i, i);
  88.701 +      res[23] += testm2((float)i, i);
  88.702 +      res[24] += testp2((float)i, i, (float)i);
  88.703 +
  88.704 +      res[25] += test_deop((float)i, i);
  88.705 +      res[26] += testb_deop((float)i, i);
  88.706 +      res[27] += testc_deop((float)i, i);
  88.707 +      res[28] += testf_deop((float)i, i);
  88.708 +      res[29] += testp_deop((float)i, i, (float)i);
  88.709 +    }
  88.710 +
  88.711 +    float[] ia = new float[1000];
  88.712 +    for (int i = 0; i < 1000; i++) {
  88.713 +      ia[i] = i;
  88.714 +    }
  88.715 +
  88.716 +    for (int i = 0; i < 100; i++) {
  88.717 +      res[30] = sum(ia);
  88.718 +      res[31] = sumb(ia);
  88.719 +      res[32] = sumc(ia);
  88.720 +      res[33] = sumf(ia);
  88.721 +      res[34] = sump(ia, 1.f);
  88.722 +
  88.723 +      res[35] = sum2(ia);
  88.724 +      res[36] = sumb2(ia);
  88.725 +      res[37] = sumc2(ia);
  88.726 +      res[38] = summ2(ia);
  88.727 +      res[39] = sump2(ia, 1.f);
  88.728 +
  88.729 +      res[40] = sum_deop(ia);
  88.730 +      res[41] = sumb_deop(ia);
  88.731 +      res[42] = sumc_deop(ia);
  88.732 +      res[43] = sumf_deop(ia);
  88.733 +      res[44] = sump_deop(ia, 1.f);
  88.734 +
  88.735 +      res[45] = remi_sum();
  88.736 +      res[46] = remi_sumb();
  88.737 +      res[47] = remi_sumc();
  88.738 +      res[48] = remi_sumf();
  88.739 +      res[49] = remi_sump(1.f);
  88.740 +
  88.741 +      res[50] = remi_sum2();
  88.742 +      res[51] = remi_sumb2();
  88.743 +      res[52] = remi_sumc2();
  88.744 +      res[53] = remi_summ2();
  88.745 +      res[54] = remi_sump2(1.f);
  88.746 +
  88.747 +      res[55] = remi_sum_deop();
  88.748 +      res[56] = remi_sumb_deop();
  88.749 +      res[57] = remi_sumc_deop();
  88.750 +      res[58] = remi_sumf_deop();
  88.751 +      res[59] = remi_sump_deop(1.f);
  88.752 +
  88.753 +      res[60] = remi_sum_cond();
  88.754 +      res[61] = remi_sumb_cond();
  88.755 +      res[62] = remi_sumc_cond();
  88.756 +      res[63] = remi_sumf_cond();
  88.757 +      res[64] = remi_sump_cond(1.f);
  88.758 +
  88.759 +      res[65] = remi_sum2_cond();
  88.760 +      res[66] = remi_sumb2_cond();
  88.761 +      res[67] = remi_sumc2_cond();
  88.762 +      res[68] = remi_summ2_cond();
  88.763 +      res[69] = remi_sump2_cond(1.f);
  88.764 +    }
  88.765 +
  88.766 +    int failed = 0;
  88.767 +    for (int i = 0; i < ntests; i++) {
  88.768 +      if (res[i] != val[i]) {
  88.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
  88.770 +        failed++;
  88.771 +      }
  88.772 +    }
  88.773 +    if (failed > 0) {
  88.774 +      System.err.println("Failed " + failed + " tests.");
  88.775 +      throw new InternalError();
  88.776 +    } else {
  88.777 +      System.out.println("Passed.");
  88.778 +    }
  88.779 +  }
  88.780 +}
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/test/compiler/6934604/TestIntBoxing.java	Thu May 16 13:47:55 2013 -0700
    89.3 @@ -0,0 +1,777 @@
    89.4 +/*
    89.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    89.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    89.7 + *
    89.8 + * This code is free software; you can redistribute it and/or modify it
    89.9 + * under the terms of the GNU General Public License version 2 only, as
   89.10 + * published by the Free Software Foundation.
   89.11 + *
   89.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   89.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   89.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   89.15 + * version 2 for more details (a copy is included in the LICENSE file that
   89.16 + * accompanied this code).
   89.17 + *
   89.18 + * You should have received a copy of the GNU General Public License version
   89.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   89.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   89.21 + *
   89.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   89.23 + * or visit www.oracle.com if you need additional information or have any
   89.24 + * questions.
   89.25 + */
   89.26 +
   89.27 +/*
   89.28 + * @test
   89.29 + * @bug 6934604
   89.30 + * @summary enable parts of EliminateAutoBox by default
   89.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestIntBoxing
   89.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
   89.33 + * -XX:CompileCommand=exclude,TestIntBoxing.dummy -XX:CompileCommand=exclude,TestIntBoxing.foo -XX:CompileCommand=exclude,TestIntBoxing.foob TestIntBoxing
   89.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
   89.35 + * -XX:CompileCommand=exclude,TestIntBoxing.dummy -XX:CompileCommand=exclude,TestIntBoxing.foo -XX:CompileCommand=exclude,TestIntBoxing.foob TestIntBoxing
   89.36 + *
   89.37 + */
   89.38 +
   89.39 +public class TestIntBoxing {
   89.40 +
   89.41 +  static final Integer ibc = new Integer(1);
   89.42 +
   89.43 +  //===============================================
   89.44 +  // Non-inlined methods to test deoptimization info
   89.45 +  static void    dummy()     { }
   89.46 +  static int     foo(int i)  { return i; }
   89.47 +  static Integer foob(int i) { return Integer.valueOf(i); }
   89.48 +
   89.49 +
   89.50 +  static int simple(int i) {
   89.51 +    Integer ib = new Integer(i);
   89.52 +    return ib;
   89.53 +  }
   89.54 +
   89.55 +  static int simpleb(int i) {
   89.56 +    Integer ib = Integer.valueOf(i);
   89.57 +    return ib;
   89.58 +  }
   89.59 +
   89.60 +  static int simplec() {
   89.61 +    Integer ib = ibc;
   89.62 +    return ib;
   89.63 +  }
   89.64 +
   89.65 +  static int simplef(int i) {
   89.66 +    Integer ib = foob(i);
   89.67 +    return ib;
   89.68 +  }
   89.69 +
   89.70 +  static int simplep(Integer ib) {
   89.71 +    return ib;
   89.72 +  }
   89.73 +
   89.74 +  static int simple2(int i) {
   89.75 +    Integer ib1 = new Integer(i);
   89.76 +    Integer ib2 = new Integer(i+1);
   89.77 +    return ib1 + ib2;
   89.78 +  }
   89.79 +
   89.80 +  static int simpleb2(int i) {
   89.81 +    Integer ib1 = Integer.valueOf(i);
   89.82 +    Integer ib2 = Integer.valueOf(i+1);
   89.83 +    return ib1 + ib2;
   89.84 +  }
   89.85 +
   89.86 +  static int simplem2(int i) {
   89.87 +    Integer ib1 = new Integer(i);
   89.88 +    Integer ib2 = Integer.valueOf(i+1);
   89.89 +    return ib1 + ib2;
   89.90 +  }
   89.91 +
   89.92 +  static int simplep2(int i, Integer ib1) {
   89.93 +    Integer ib2 = Integer.valueOf(i+1);
   89.94 +    return ib1 + ib2;
   89.95 +  }
   89.96 +
   89.97 +  static int simplec2(int i) {
   89.98 +    Integer ib1 = ibc;
   89.99 +    Integer ib2 = Integer.valueOf(i+1);
  89.100 +    return ib1 + ib2;
  89.101 +  }
  89.102 +
  89.103 +  //===============================================
  89.104 +  static int test(int i) {
  89.105 +    Integer ib = new Integer(i);
  89.106 +    if ((i&1) == 0)
  89.107 +      ib = i+1;
  89.108 +    return ib;
  89.109 +  }
  89.110 +
  89.111 +  static int testb(int i) {
  89.112 +    Integer ib = i;
  89.113 +    if ((i&1) == 0)
  89.114 +      ib = (i+1);
  89.115 +    return ib;
  89.116 +  }
  89.117 +
  89.118 +  static int testm(int i) {
  89.119 +    Integer ib = i;
  89.120 +    if ((i&1) == 0)
  89.121 +      ib = new Integer(i+1);
  89.122 +    return ib;
  89.123 +  }
  89.124 +
  89.125 +  static int testp(int i, Integer ib) {
  89.126 +    if ((i&1) == 0)
  89.127 +      ib = new Integer(i+1);
  89.128 +    return ib;
  89.129 +  }
  89.130 +
  89.131 +  static int testc(int i) {
  89.132 +    Integer ib = ibc;
  89.133 +    if ((i&1) == 0)
  89.134 +      ib = new Integer(i+1);
  89.135 +    return ib;
  89.136 +  }
  89.137 +
  89.138 +  static int test2(int i) {
  89.139 +    Integer ib1 = new Integer(i);
  89.140 +    Integer ib2 = new Integer(i+1);
  89.141 +    if ((i&1) == 0) {
  89.142 +      ib1 = new Integer(i+1);
  89.143 +      ib2 = new Integer(i+2);
  89.144 +    }
  89.145 +    return ib1+ib2;
  89.146 +  }
  89.147 +
  89.148 +  static int testb2(int i) {
  89.149 +    Integer ib1 = i;
  89.150 +    Integer ib2 = i+1;
  89.151 +    if ((i&1) == 0) {
  89.152 +      ib1 = (i+1);
  89.153 +      ib2 = (i+2);
  89.154 +    }
  89.155 +    return ib1+ib2;
  89.156 +  }
  89.157 +
  89.158 +  static int testm2(int i) {
  89.159 +    Integer ib1 = new Integer(i);
  89.160 +    Integer ib2 = i+1;
  89.161 +    if ((i&1) == 0) {
  89.162 +      ib1 = new Integer(i+1);
  89.163 +      ib2 = (i+2);
  89.164 +    }
  89.165 +    return ib1+ib2;
  89.166 +  }
  89.167 +
  89.168 +  static int testp2(int i, Integer ib1) {
  89.169 +    Integer ib2 = i+1;
  89.170 +    if ((i&1) == 0) {
  89.171 +      ib1 = new Integer(i+1);
  89.172 +      ib2 = (i+2);
  89.173 +    }
  89.174 +    return ib1+ib2;
  89.175 +  }
  89.176 +
  89.177 +  static int testc2(int i) {
  89.178 +    Integer ib1 = ibc;
  89.179 +    Integer ib2 = i+1;
  89.180 +    if ((i&1) == 0) {
  89.181 +      ib1 = (ibc+1);
  89.182 +      ib2 = (i+2);
  89.183 +    }
  89.184 +    return ib1+ib2;
  89.185 +  }
  89.186 +
  89.187 +  //===============================================
  89.188 +  static int sum(int[] a) {
  89.189 +    int result = 1;
  89.190 +    for (Integer i : a)
  89.191 +        result += i;
  89.192 +    return result;
  89.193 +  }
  89.194 +
  89.195 +  static int sumb(int[] a) {
  89.196 +    Integer result = 1;
  89.197 +    for (Integer i : a)
  89.198 +        result += i;
  89.199 +    return result;
  89.200 +  }
  89.201 +
  89.202 +  static int sumc(int[] a) {
  89.203 +    Integer result = ibc;
  89.204 +    for (Integer i : a)
  89.205 +        result += i;
  89.206 +    return result;
  89.207 +  }
  89.208 +
  89.209 +  static int sumf(int[] a) {
  89.210 +    Integer result = foob(1);
  89.211 +    for (Integer i : a)
  89.212 +        result += i;
  89.213 +    return result;
  89.214 +  }
  89.215 +
  89.216 +  static int sump(int[] a, Integer result) {
  89.217 +    for (Integer i : a)
  89.218 +        result += i;
  89.219 +    return result;
  89.220 +  }
  89.221 +
  89.222 +  static int sum2(int[] a) {
  89.223 +    int result1 = 1;
  89.224 +    int result2 = 1;
  89.225 +    for (Integer i : a) {
  89.226 +        result1 += i;
  89.227 +        result2 += i + 1;
  89.228 +    }
  89.229 +    return result1 + result2;
  89.230 +  }
  89.231 +
  89.232 +  static int sumb2(int[] a) {
  89.233 +    Integer result1 = 1;
  89.234 +    Integer result2 = 1;
  89.235 +    for (Integer i : a) {
  89.236 +        result1 += i;
  89.237 +        result2 += i + 1;
  89.238 +    }
  89.239 +    return result1 + result2;
  89.240 +  }
  89.241 +
  89.242 +  static int summ2(int[] a) {
  89.243 +    Integer result1 = 1;
  89.244 +    Integer result2 = new Integer(1);
  89.245 +    for (Integer i : a) {
  89.246 +        result1 += i;
  89.247 +        result2 += new Integer(i + 1);
  89.248 +    }
  89.249 +    return result1 + result2;
  89.250 +  }
  89.251 +
  89.252 +  static int sump2(int[] a, Integer result2) {
  89.253 +    Integer result1 = 1;
  89.254 +    for (Integer i : a) {
  89.255 +        result1 += i;
  89.256 +        result2 += i + 1;
  89.257 +    }
  89.258 +    return result1 + result2;
  89.259 +  }
  89.260 +
  89.261 +  static int sumc2(int[] a) {
  89.262 +    Integer result1 = 1;
  89.263 +    Integer result2 = ibc;
  89.264 +    for (Integer i : a) {
  89.265 +        result1 += i;
  89.266 +        result2 += i + ibc;
  89.267 +    }
  89.268 +    return result1 + result2;
  89.269 +  }
  89.270 +
  89.271 +  //===============================================
  89.272 +  static int remi_sum() {
  89.273 +    Integer j = new Integer(1);
  89.274 +    for (int i = 0; i< 1000; i++) {
  89.275 +      j = new Integer(j + 1);
  89.276 +    }
  89.277 +    return j;
  89.278 +  }
  89.279 +
  89.280 +  static int remi_sumb() {
  89.281 +    Integer j = Integer.valueOf(1);
  89.282 +    for (int i = 0; i< 1000; i++) {
  89.283 +      j = j + 1;
  89.284 +    }
  89.285 +    return j;
  89.286 +  }
  89.287 +
  89.288 +  static int remi_sumf() {
  89.289 +    Integer j = foob(1);
  89.290 +    for (int i = 0; i< 1000; i++) {
  89.291 +      j = j + 1;
  89.292 +    }
  89.293 +    return j;
  89.294 +  }
  89.295 +
  89.296 +  static int remi_sump(Integer j) {
  89.297 +    for (int i = 0; i< 1000; i++) {
  89.298 +      j = new Integer(j + 1);
  89.299 +    }
  89.300 +    return j;
  89.301 +  }
  89.302 +
  89.303 +  static int remi_sumc() {
  89.304 +    Integer j = ibc;
  89.305 +    for (int i = 0; i< 1000; i++) {
  89.306 +      j = j + ibc;
  89.307 +    }
  89.308 +    return j;
  89.309 +  }
  89.310 +
  89.311 +  static int remi_sum2() {
  89.312 +    Integer j1 = new Integer(1);
  89.313 +    Integer j2 = new Integer(1);
  89.314 +    for (int i = 0; i< 1000; i++) {
  89.315 +      j1 = new Integer(j1 + 1);
  89.316 +      j2 = new Integer(j2 + 2);
  89.317 +    }
  89.318 +    return j1 + j2;
  89.319 +  }
  89.320 +
  89.321 +  static int remi_sumb2() {
  89.322 +    Integer j1 = Integer.valueOf(1);
  89.323 +    Integer j2 = Integer.valueOf(1);
  89.324 +    for (int i = 0; i< 1000; i++) {
  89.325 +      j1 = j1 + 1;
  89.326 +      j2 = j2 + 2;
  89.327 +    }
  89.328 +    return j1 + j2;
  89.329 +  }
  89.330 +
  89.331 +  static int remi_summ2() {
  89.332 +    Integer j1 = new Integer(1);
  89.333 +    Integer j2 = Integer.valueOf(1);
  89.334 +    for (int i = 0; i< 1000; i++) {
  89.335 +      j1 = new Integer(j1 + 1);
  89.336 +      j2 = j2 + 2;
  89.337 +    }
  89.338 +    return j1 + j2;
  89.339 +  }
  89.340 +
  89.341 +  static int remi_sump2(Integer j1) {
  89.342 +    Integer j2 = Integer.valueOf(1);
  89.343 +    for (int i = 0; i< 1000; i++) {
  89.344 +      j1 = new Integer(j1 + 1);
  89.345 +      j2 = j2 + 2;
  89.346 +    }
  89.347 +    return j1 + j2;
  89.348 +  }
  89.349 +
  89.350 +  static int remi_sumc2() {
  89.351 +    Integer j1 = ibc;
  89.352 +    Integer j2 = Integer.valueOf(1);
  89.353 +    for (int i = 0; i< 1000; i++) {
  89.354 +      j1 = j1 + ibc;
  89.355 +      j2 = j2 + 2;
  89.356 +    }
  89.357 +    return j1 + j2;
  89.358 +  }
  89.359 +
  89.360 +
  89.361 +  //===============================================
  89.362 +  // Safepointa and debug info for deoptimization
  89.363 +  static int simple_deop(int i) {
  89.364 +    Integer ib = new Integer(foo(i));
  89.365 +    dummy();
  89.366 +    return ib;
  89.367 +  }
  89.368 +
  89.369 +  static int simpleb_deop(int i) {
  89.370 +    Integer ib = Integer.valueOf(foo(i));
  89.371 +    dummy();
  89.372 +    return ib;
  89.373 +  }
  89.374 +
  89.375 +  static int simplef_deop(int i) {
  89.376 +    Integer ib = foob(i);
  89.377 +    dummy();
  89.378 +    return ib;
  89.379 +  }
  89.380 +
  89.381 +  static int simplep_deop(Integer ib) {
  89.382 +    dummy();
  89.383 +    return ib;
  89.384 +  }
  89.385 +
  89.386 +  static int simplec_deop(int i) {
  89.387 +    Integer ib = ibc;
  89.388 +    dummy();
  89.389 +    return ib;
  89.390 +  }
  89.391 +
  89.392 +  static int test_deop(int i) {
  89.393 +    Integer ib = new Integer(foo(i));
  89.394 +    if ((i&1) == 0)
  89.395 +      ib = foo(i+1);
  89.396 +    dummy();
  89.397 +    return ib;
  89.398 +  }
  89.399 +
  89.400 +  static int testb_deop(int i) {
  89.401 +    Integer ib = foo(i);
  89.402 +    if ((i&1) == 0)
  89.403 +      ib = foo(i+1);
  89.404 +    dummy();
  89.405 +    return ib;
  89.406 +  }
  89.407 +
  89.408 +  static int testf_deop(int i) {
  89.409 +    Integer ib = foob(i);
  89.410 +    if ((i&1) == 0)
  89.411 +      ib = foo(i+1);
  89.412 +    dummy();
  89.413 +    return ib;
  89.414 +  }
  89.415 +
  89.416 +  static int testp_deop(int i, Integer ib) {
  89.417 +    if ((i&1) == 0)
  89.418 +      ib = foo(i+1);
  89.419 +    dummy();
  89.420 +    return ib;
  89.421 +  }
  89.422 +
  89.423 +  static int testc_deop(int i) {
  89.424 +    Integer ib = ibc;
  89.425 +    if ((i&1) == 0)
  89.426 +      ib = foo(i+1);
  89.427 +    dummy();
  89.428 +    return ib;
  89.429 +  }
  89.430 +
  89.431 +  static int sum_deop(int[] a) {
  89.432 +    int result = 1;
  89.433 +    for (Integer i : a)
  89.434 +        result += foo(i);
  89.435 +    dummy();
  89.436 +    return result;
  89.437 +  }
  89.438 +
  89.439 +  static int sumb_deop(int[] a) {
  89.440 +    Integer result = 1;
  89.441 +    for (Integer i : a)
  89.442 +        result += foo(i);
  89.443 +    dummy();
  89.444 +    return result;
  89.445 +  }
  89.446 +
  89.447 +  static int sumf_deop(int[] a) {
  89.448 +    Integer result = 1;
  89.449 +    for (Integer i : a)
  89.450 +        result += foob(i);
  89.451 +    dummy();
  89.452 +    return result;
  89.453 +  }
  89.454 +
  89.455 +  static int sump_deop(int[] a, Integer result) {
  89.456 +    for (Integer i : a)
  89.457 +        result += foob(i);
  89.458 +    dummy();
  89.459 +    return result;
  89.460 +  }
  89.461 +
  89.462 +  static int sumc_deop(int[] a) {
  89.463 +    Integer result = ibc;
  89.464 +    for (Integer i : a)
  89.465 +        result += foo(i);
  89.466 +    dummy();
  89.467 +    return result;
  89.468 +  }
  89.469 +
  89.470 +  static int remi_sum_deop() {
  89.471 +    Integer j = new Integer(foo(1));
  89.472 +    for (int i = 0; i< 1000; i++) {
  89.473 +      j = new Integer(foo(j + 1));
  89.474 +    }
  89.475 +    dummy();
  89.476 +    return j;
  89.477 +  }
  89.478 +
  89.479 +  static int remi_sumb_deop() {
  89.480 +    Integer j = Integer.valueOf(foo(1));
  89.481 +    for (int i = 0; i< 1000; i++) {
  89.482 +      j = foo(j + 1);
  89.483 +    }
  89.484 +    dummy();
  89.485 +    return j;
  89.486 +  }
  89.487 +
  89.488 +  static int remi_sumf_deop() {
  89.489 +    Integer j = foob(1);
  89.490 +    for (int i = 0; i< 1000; i++) {
  89.491 +      j = foo(j + 1);
  89.492 +    }
  89.493 +    dummy();
  89.494 +    return j;
  89.495 +  }
  89.496 +
  89.497 +  static int remi_sump_deop(Integer j) {
  89.498 +    for (int i = 0; i< 1000; i++) {
  89.499 +      j = foo(j + 1);
  89.500 +    }
  89.501 +    dummy();
  89.502 +    return j;
  89.503 +  }
  89.504 +
  89.505 +  static int remi_sumc_deop() {
  89.506 +    Integer j = ibc;
  89.507 +    for (int i = 0; i< 1000; i++) {
  89.508 +      j = foo(j + 1);
  89.509 +    }
  89.510 +    dummy();
  89.511 +    return j;
  89.512 +  }
  89.513 +
  89.514 +  //===============================================
  89.515 +  // Conditional increment
  89.516 +  static int remi_sum_cond() {
  89.517 +    Integer j = new Integer(1);
  89.518 +    for (int i = 0; i< 1000; i++) {
  89.519 +      if ((i&1) == 0) {
  89.520 +        j = new Integer(j + 1);
  89.521 +      }
  89.522 +    }
  89.523 +    return j;
  89.524 +  }
  89.525 +
  89.526 +  static int remi_sumb_cond() {
  89.527 +    Integer j = Integer.valueOf(1);
  89.528 +    for (int i = 0; i< 1000; i++) {
  89.529 +      if ((i&1) == 0) {
  89.530 +        j = j + 1;
  89.531 +      }
  89.532 +    }
  89.533 +    return j;
  89.534 +  }
  89.535 +
  89.536 +  static int remi_sumf_cond() {
  89.537 +    Integer j = foob(1);
  89.538 +    for (int i = 0; i< 1000; i++) {
  89.539 +      if ((i&1) == 0) {
  89.540 +        j = j + 1;
  89.541 +      }
  89.542 +    }
  89.543 +    return j;
  89.544 +  }
  89.545 +
  89.546 +  static int remi_sump_cond(Integer j) {
  89.547 +    for (int i = 0; i< 1000; i++) {
  89.548 +      if ((i&1) == 0) {
  89.549 +        j = j + 1;
  89.550 +      }
  89.551 +    }
  89.552 +    return j;
  89.553 +  }
  89.554 +
  89.555 +  static int remi_sumc_cond() {
  89.556 +    Integer j = ibc;
  89.557 +    for (int i = 0; i< 1000; i++) {
  89.558 +      if ((i&1) == 0) {
  89.559 +        j = j + ibc;
  89.560 +      }
  89.561 +    }
  89.562 +    return j;
  89.563 +  }
  89.564 +
  89.565 +  static int remi_sum2_cond() {
  89.566 +    Integer j1 = new Integer(1);
  89.567 +    Integer j2 = new Integer(1);
  89.568 +    for (int i = 0; i< 1000; i++) {
  89.569 +      if ((i&1) == 0) {
  89.570 +        j1 = new Integer(j1 + 1);
  89.571 +      } else {
  89.572 +        j2 = new Integer(j2 + 2);
  89.573 +      }
  89.574 +    }
  89.575 +    return j1 + j2;
  89.576 +  }
  89.577 +
  89.578 +  static int remi_sumb2_cond() {
  89.579 +    Integer j1 = Integer.valueOf(1);
  89.580 +    Integer j2 = Integer.valueOf(1);
  89.581 +    for (int i = 0; i< 1000; i++) {
  89.582 +      if ((i&1) == 0) {
  89.583 +        j1 = j1 + 1;
  89.584 +      } else {
  89.585 +        j2 = j2 + 2;
  89.586 +      }
  89.587 +    }
  89.588 +    return j1 + j2;
  89.589 +  }
  89.590 +
  89.591 +  static int remi_summ2_cond() {
  89.592 +    Integer j1 = new Integer(1);
  89.593 +    Integer j2 = Integer.valueOf(1);
  89.594 +    for (int i = 0; i< 1000; i++) {
  89.595 +      if ((i&1) == 0) {
  89.596 +        j1 = new Integer(j1 + 1);
  89.597 +      } else {
  89.598 +        j2 = j2 + 2;
  89.599 +      }
  89.600 +    }
  89.601 +    return j1 + j2;
  89.602 +  }
  89.603 +
  89.604 +  static int remi_sump2_cond(Integer j1) {
  89.605 +    Integer j2 = Integer.valueOf(1);
  89.606 +    for (int i = 0; i< 1000; i++) {
  89.607 +      if ((i&1) == 0) {
  89.608 +        j1 = new Integer(j1 + 1);
  89.609 +      } else {
  89.610 +        j2 = j2 + 2;
  89.611 +      }
  89.612 +    }
  89.613 +    return j1 + j2;
  89.614 +  }
  89.615 +
  89.616 +  static int remi_sumc2_cond() {
  89.617 +    Integer j1 = ibc;
  89.618 +    Integer j2 = Integer.valueOf(1);
  89.619 +    for (int i = 0; i< 1000; i++) {
  89.620 +      if ((i&1) == 0) {
  89.621 +        j1 = j1 + ibc;
  89.622 +      } else {
  89.623 +        j2 = j2 + 2;
  89.624 +      }
  89.625 +    }
  89.626 +    return j1 + j2;
  89.627 +  }
  89.628 +
  89.629 +
  89.630 +  public static void main(String[] args) {
  89.631 +    final int ntests = 70;
  89.632 +
  89.633 +    String[] test_name = new String[] {
  89.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
  89.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
  89.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
  89.637 +        "test",        "testb",        "testc",        "testm",        "testp",
  89.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
  89.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
  89.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
  89.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
  89.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
  89.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
  89.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
  89.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
  89.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
  89.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
  89.648 +    };
  89.649 +
  89.650 +    final int[] val = new int[] {
  89.651 +       71994000,  71994000,    12000,  71994000,  71994000,
  89.652 +      144000000, 144000000, 72018000, 144000000, 144000000,
  89.653 +       71994000,  71994000,    12000,  71994000,  71994000,
  89.654 +       72000000,  72000000, 36006000,  72000000,  72000000,
  89.655 +      144012000, 144012000, 72030000, 144012000, 144012000,
  89.656 +       72000000,  72000000, 36006000,  72000000,  72000000,
  89.657 +         499501,    499501,   499501,    499501,    499501,
  89.658 +        1000002,   1000002,  1000002,   1000002,   1000002,
  89.659 +         499501,    499501,   499501,    499501,    499501,
  89.660 +           1001,      1001,     1001,      1001,      1001,
  89.661 +           3002,      3002,     3002,      3002,      3002,
  89.662 +           1001,      1001,     1001,      1001,      1001,
  89.663 +            501,       501,      501,       501,       501,
  89.664 +           1502,      1502,     1502,      1502,      1502
  89.665 +    };
  89.666 +
  89.667 +    int[] res = new int[ntests];
  89.668 +    for (int i = 0; i < ntests; i++) {
  89.669 +      res[i] = 0;
  89.670 +    }
  89.671 +
  89.672 +
  89.673 +    for (int i = 0; i < 12000; i++) {
  89.674 +      res[0] += simple(i);
  89.675 +      res[1] += simpleb(i);
  89.676 +      res[2] += simplec();
  89.677 +      res[3] += simplef(i);
  89.678 +      res[4] += simplep(i);
  89.679 +
  89.680 +      res[5] += simple2(i);
  89.681 +      res[6] += simpleb2(i);
  89.682 +      res[7] += simplec2(i);
  89.683 +      res[8] += simplem2(i);
  89.684 +      res[9] += simplep2(i, i);
  89.685 +
  89.686 +      res[10] += simple_deop(i);
  89.687 +      res[11] += simpleb_deop(i);
  89.688 +      res[12] += simplec_deop(i);
  89.689 +      res[13] += simplef_deop(i);
  89.690 +      res[14] += simplep_deop(i);
  89.691 +
  89.692 +      res[15] += test(i);
  89.693 +      res[16] += testb(i);
  89.694 +      res[17] += testc(i);
  89.695 +      res[18] += testm(i);
  89.696 +      res[19] += testp(i, i);
  89.697 +
  89.698 +      res[20] += test2(i);
  89.699 +      res[21] += testb2(i);
  89.700 +      res[22] += testc2(i);
  89.701 +      res[23] += testm2(i);
  89.702 +      res[24] += testp2(i, i);
  89.703 +
  89.704 +      res[25] += test_deop(i);
  89.705 +      res[26] += testb_deop(i);
  89.706 +      res[27] += testc_deop(i);
  89.707 +      res[28] += testf_deop(i);
  89.708 +      res[29] += testp_deop(i, i);
  89.709 +    }
  89.710 +
  89.711 +    int[] ia = new int[1000];
  89.712 +    for (int i = 0; i < 1000; i++) {
  89.713 +      ia[i] = i;
  89.714 +    }
  89.715 +
  89.716 +    for (int i = 0; i < 100; i++) {
  89.717 +      res[30] = sum(ia);
  89.718 +      res[31] = sumb(ia);
  89.719 +      res[32] = sumc(ia);
  89.720 +      res[33] = sumf(ia);
  89.721 +      res[34] = sump(ia, 1);
  89.722 +
  89.723 +      res[35] = sum2(ia);
  89.724 +      res[36] = sumb2(ia);
  89.725 +      res[37] = sumc2(ia);
  89.726 +      res[38] = summ2(ia);
  89.727 +      res[39] = sump2(ia, 1);
  89.728 +
  89.729 +      res[40] = sum_deop(ia);
  89.730 +      res[41] = sumb_deop(ia);
  89.731 +      res[42] = sumc_deop(ia);
  89.732 +      res[43] = sumf_deop(ia);
  89.733 +      res[44] = sump_deop(ia, 1);
  89.734 +
  89.735 +      res[45] = remi_sum();
  89.736 +      res[46] = remi_sumb();
  89.737 +      res[47] = remi_sumc();
  89.738 +      res[48] = remi_sumf();
  89.739 +      res[49] = remi_sump(1);
  89.740 +
  89.741 +      res[50] = remi_sum2();
  89.742 +      res[51] = remi_sumb2();
  89.743 +      res[52] = remi_sumc2();
  89.744 +      res[53] = remi_summ2();
  89.745 +      res[54] = remi_sump2(1);
  89.746 +
  89.747 +      res[55] = remi_sum_deop();
  89.748 +      res[56] = remi_sumb_deop();
  89.749 +      res[57] = remi_sumc_deop();
  89.750 +      res[58] = remi_sumf_deop();
  89.751 +      res[59] = remi_sump_deop(1);
  89.752 +
  89.753 +      res[60] = remi_sum_cond();
  89.754 +      res[61] = remi_sumb_cond();
  89.755 +      res[62] = remi_sumc_cond();
  89.756 +      res[63] = remi_sumf_cond();
  89.757 +      res[64] = remi_sump_cond(1);
  89.758 +
  89.759 +      res[65] = remi_sum2_cond();
  89.760 +      res[66] = remi_sumb2_cond();
  89.761 +      res[67] = remi_sumc2_cond();
  89.762 +      res[68] = remi_summ2_cond();
  89.763 +      res[69] = remi_sump2_cond(1);
  89.764 +    }
  89.765 +
  89.766 +    int failed = 0;
  89.767 +    for (int i = 0; i < ntests; i++) {
  89.768 +      if (res[i] != val[i]) {
  89.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
  89.770 +        failed++;
  89.771 +      }
  89.772 +    }
  89.773 +    if (failed > 0) {
  89.774 +      System.err.println("Failed " + failed + " tests.");
  89.775 +      throw new InternalError();
  89.776 +    } else {
  89.777 +      System.out.println("Passed.");
  89.778 +    }
  89.779 +  }
  89.780 +}
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/test/compiler/6934604/TestLongBoxing.java	Thu May 16 13:47:55 2013 -0700
    90.3 @@ -0,0 +1,777 @@
    90.4 +/*
    90.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    90.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.7 + *
    90.8 + * This code is free software; you can redistribute it and/or modify it
    90.9 + * under the terms of the GNU General Public License version 2 only, as
   90.10 + * published by the Free Software Foundation.
   90.11 + *
   90.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   90.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   90.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   90.15 + * version 2 for more details (a copy is included in the LICENSE file that
   90.16 + * accompanied this code).
   90.17 + *
   90.18 + * You should have received a copy of the GNU General Public License version
   90.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   90.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   90.21 + *
   90.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   90.23 + * or visit www.oracle.com if you need additional information or have any
   90.24 + * questions.
   90.25 + */
   90.26 +
   90.27 +/*
   90.28 + * @test
   90.29 + * @bug 6934604
   90.30 + * @summary enable parts of EliminateAutoBox by default
   90.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestLongBoxing
   90.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
   90.33 + * -XX:CompileCommand=exclude,TestLongBoxing.dummy -XX:CompileCommand=exclude,TestLongBoxing.foo -XX:CompileCommand=exclude,TestLongBoxing.foob TestLongBoxing
   90.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
   90.35 + * -XX:CompileCommand=exclude,TestLongBoxing.dummy -XX:CompileCommand=exclude,TestLongBoxing.foo -XX:CompileCommand=exclude,TestLongBoxing.foob TestLongBoxing
   90.36 + *
   90.37 + */
   90.38 +
   90.39 +public class TestLongBoxing {
   90.40 +
   90.41 +  static final Long ibc = new Long(1);
   90.42 +
   90.43 +  //===============================================
   90.44 +  // Non-inlined methods to test deoptimization info
   90.45 +  static void dummy()     { }
   90.46 +  static long  foo(long i)  { return i; }
   90.47 +  static Long  foob(long i) { return Long.valueOf(i); }
   90.48 +
   90.49 +
   90.50 +  static long simple(long i) {
   90.51 +    Long ib = new Long(i);
   90.52 +    return ib;
   90.53 +  }
   90.54 +
   90.55 +  static long simpleb(long i) {
   90.56 +    Long ib = Long.valueOf(i);
   90.57 +    return ib;
   90.58 +  }
   90.59 +
   90.60 +  static long simplec() {
   90.61 +    Long ib = ibc;
   90.62 +    return ib;
   90.63 +  }
   90.64 +
   90.65 +  static long simplef(long i) {
   90.66 +    Long ib = foob(i);
   90.67 +    return ib;
   90.68 +  }
   90.69 +
   90.70 +  static long simplep(Long ib) {
   90.71 +    return ib;
   90.72 +  }
   90.73 +
   90.74 +  static long simple2(long i) {
   90.75 +    Long ib1 = new Long(i);
   90.76 +    Long ib2 = new Long(i+1);
   90.77 +    return ib1 + ib2;
   90.78 +  }
   90.79 +
   90.80 +  static long simpleb2(long i) {
   90.81 +    Long ib1 = Long.valueOf(i);
   90.82 +    Long ib2 = Long.valueOf(i+1);
   90.83 +    return ib1 + ib2;
   90.84 +  }
   90.85 +
   90.86 +  static long simplem2(long i) {
   90.87 +    Long ib1 = new Long(i);
   90.88 +    Long ib2 = Long.valueOf(i+1);
   90.89 +    return ib1 + ib2;
   90.90 +  }
   90.91 +
   90.92 +  static long simplep2(long i, Long ib1) {
   90.93 +    Long ib2 = Long.valueOf(i+1);
   90.94 +    return ib1 + ib2;
   90.95 +  }
   90.96 +
   90.97 +  static long simplec2(long i) {
   90.98 +    Long ib1 = ibc;
   90.99 +    Long ib2 = Long.valueOf(i+1);
  90.100 +    return ib1 + ib2;
  90.101 +  }
  90.102 +
  90.103 +  //===============================================
  90.104 +  static long test(long i) {
  90.105 +    Long ib = new Long(i);
  90.106 +    if ((i&1) == 0)
  90.107 +      ib = i+1;
  90.108 +    return ib;
  90.109 +  }
  90.110 +
  90.111 +  static long testb(long i) {
  90.112 +    Long ib = i;
  90.113 +    if ((i&1) == 0)
  90.114 +      ib = (i+1);
  90.115 +    return ib;
  90.116 +  }
  90.117 +
  90.118 +  static long testm(long i) {
  90.119 +    Long ib = i;
  90.120 +    if ((i&1) == 0)
  90.121 +      ib = new Long(i+1);
  90.122 +    return ib;
  90.123 +  }
  90.124 +
  90.125 +  static long testp(long i, Long ib) {
  90.126 +    if ((i&1) == 0)
  90.127 +      ib = new Long(i+1);
  90.128 +    return ib;
  90.129 +  }
  90.130 +
  90.131 +  static long testc(long i) {
  90.132 +    Long ib = ibc;
  90.133 +    if ((i&1) == 0)
  90.134 +      ib = new Long(i+1);
  90.135 +    return ib;
  90.136 +  }
  90.137 +
  90.138 +  static long test2(long i) {
  90.139 +    Long ib1 = new Long(i);
  90.140 +    Long ib2 = new Long(i+1);
  90.141 +    if ((i&1) == 0) {
  90.142 +      ib1 = new Long(i+1);
  90.143 +      ib2 = new Long(i+2);
  90.144 +    }
  90.145 +    return ib1+ib2;
  90.146 +  }
  90.147 +
  90.148 +  static long testb2(long i) {
  90.149 +    Long ib1 = i;
  90.150 +    Long ib2 = i+1;
  90.151 +    if ((i&1) == 0) {
  90.152 +      ib1 = (i+1);
  90.153 +      ib2 = (i+2);
  90.154 +    }
  90.155 +    return ib1+ib2;
  90.156 +  }
  90.157 +
  90.158 +  static long testm2(long i) {
  90.159 +    Long ib1 = new Long(i);
  90.160 +    Long ib2 = i+1;
  90.161 +    if ((i&1) == 0) {
  90.162 +      ib1 = new Long(i+1);
  90.163 +      ib2 = (i+2);
  90.164 +    }
  90.165 +    return ib1+ib2;
  90.166 +  }
  90.167 +
  90.168 +  static long testp2(long i, Long ib1) {
  90.169 +    Long ib2 = i+1;
  90.170 +    if ((i&1) == 0) {
  90.171 +      ib1 = new Long(i+1);
  90.172 +      ib2 = (i+2);
  90.173 +    }
  90.174 +    return ib1+ib2;
  90.175 +  }
  90.176 +
  90.177 +  static long testc2(long i) {
  90.178 +    Long ib1 = ibc;
  90.179 +    Long ib2 = i+1;
  90.180 +    if ((i&1) == 0) {
  90.181 +      ib1 = (ibc+1);
  90.182 +      ib2 = (i+2);
  90.183 +    }
  90.184 +    return ib1+ib2;
  90.185 +  }
  90.186 +
  90.187 +  //===============================================
  90.188 +  static long sum(long[] a) {
  90.189 +    long result = 1;
  90.190 +    for (Long i : a)
  90.191 +        result += i;
  90.192 +    return result;
  90.193 +  }
  90.194 +
  90.195 +  static long sumb(long[] a) {
  90.196 +    Long result = 1l;
  90.197 +    for (Long i : a)
  90.198 +        result += i;
  90.199 +    return result;
  90.200 +  }
  90.201 +
  90.202 +  static long sumc(long[] a) {
  90.203 +    Long result = ibc;
  90.204 +    for (Long i : a)
  90.205 +        result += i;
  90.206 +    return result;
  90.207 +  }
  90.208 +
  90.209 +  static long sumf(long[] a) {
  90.210 +    Long result = foob(1);
  90.211 +    for (Long i : a)
  90.212 +        result += i;
  90.213 +    return result;
  90.214 +  }
  90.215 +
  90.216 +  static long sump(long[] a, Long result) {
  90.217 +    for (Long i : a)
  90.218 +        result += i;
  90.219 +    return result;
  90.220 +  }
  90.221 +
  90.222 +  static long sum2(long[] a) {
  90.223 +    long result1 = 1;
  90.224 +    long result2 = 1;
  90.225 +    for (Long i : a) {
  90.226 +        result1 += i;
  90.227 +        result2 += i + 1;
  90.228 +    }
  90.229 +    return result1 + result2;
  90.230 +  }
  90.231 +
  90.232 +  static long sumb2(long[] a) {
  90.233 +    Long result1 = 1l;
  90.234 +    Long result2 = 1l;
  90.235 +    for (Long i : a) {
  90.236 +        result1 += i;
  90.237 +        result2 += i + 1;
  90.238 +    }
  90.239 +    return result1 + result2;
  90.240 +  }
  90.241 +
  90.242 +  static long summ2(long[] a) {
  90.243 +    Long result1 = 1l;
  90.244 +    Long result2 = new Long(1);
  90.245 +    for (Long i : a) {
  90.246 +        result1 += i;
  90.247 +        result2 += new Long(i + 1);
  90.248 +    }
  90.249 +    return result1 + result2;
  90.250 +  }
  90.251 +
  90.252 +  static long sump2(long[] a, Long result2) {
  90.253 +    Long result1 = 1l;
  90.254 +    for (Long i : a) {
  90.255 +        result1 += i;
  90.256 +        result2 += i + 1;
  90.257 +    }
  90.258 +    return result1 + result2;
  90.259 +  }
  90.260 +
  90.261 +  static long sumc2(long[] a) {
  90.262 +    Long result1 = 1l;
  90.263 +    Long result2 = ibc;
  90.264 +    for (Long i : a) {
  90.265 +        result1 += i;
  90.266 +        result2 += i + ibc;
  90.267 +    }
  90.268 +    return result1 + result2;
  90.269 +  }
  90.270 +
  90.271 +  //===============================================
  90.272 +  static long remi_sum() {
  90.273 +    Long j = new Long(1);
  90.274 +    for (int i = 0; i< 1000; i++) {
  90.275 +      j = new Long(j + 1);
  90.276 +    }
  90.277 +    return j;
  90.278 +  }
  90.279 +
  90.280 +  static long remi_sumb() {
  90.281 +    Long j = Long.valueOf(1);
  90.282 +    for (int i = 0; i< 1000; i++) {
  90.283 +      j = j + 1;
  90.284 +    }
  90.285 +    return j;
  90.286 +  }
  90.287 +
  90.288 +  static long remi_sumf() {
  90.289 +    Long j = foob(1);
  90.290 +    for (int i = 0; i< 1000; i++) {
  90.291 +      j = j + 1;
  90.292 +    }
  90.293 +    return j;
  90.294 +  }
  90.295 +
  90.296 +  static long remi_sump(Long j) {
  90.297 +    for (int i = 0; i< 1000; i++) {
  90.298 +      j = new Long(j + 1);
  90.299 +    }
  90.300 +    return j;
  90.301 +  }
  90.302 +
  90.303 +  static long remi_sumc() {
  90.304 +    Long j = ibc;
  90.305 +    for (int i = 0; i< 1000; i++) {
  90.306 +      j = j + ibc;
  90.307 +    }
  90.308 +    return j;
  90.309 +  }
  90.310 +
  90.311 +  static long remi_sum2() {
  90.312 +    Long j1 = new Long(1);
  90.313 +    Long j2 = new Long(1);
  90.314 +    for (int i = 0; i< 1000; i++) {
  90.315 +      j1 = new Long(j1 + 1);
  90.316 +      j2 = new Long(j2 + 2);
  90.317 +    }
  90.318 +    return j1 + j2;
  90.319 +  }
  90.320 +
  90.321 +  static long remi_sumb2() {
  90.322 +    Long j1 = Long.valueOf(1);
  90.323 +    Long j2 = Long.valueOf(1);
  90.324 +    for (int i = 0; i< 1000; i++) {
  90.325 +      j1 = j1 + 1;
  90.326 +      j2 = j2 + 2;
  90.327 +    }
  90.328 +    return j1 + j2;
  90.329 +  }
  90.330 +
  90.331 +  static long remi_summ2() {
  90.332 +    Long j1 = new Long(1);
  90.333 +    Long j2 = Long.valueOf(1);
  90.334 +    for (int i = 0; i< 1000; i++) {
  90.335 +      j1 = new Long(j1 + 1);
  90.336 +      j2 = j2 + 2;
  90.337 +    }
  90.338 +    return j1 + j2;
  90.339 +  }
  90.340 +
  90.341 +  static long remi_sump2(Long j1) {
  90.342 +    Long j2 = Long.valueOf(1);
  90.343 +    for (int i = 0; i< 1000; i++) {
  90.344 +      j1 = new Long(j1 + 1);
  90.345 +      j2 = j2 + 2;
  90.346 +    }
  90.347 +    return j1 + j2;
  90.348 +  }
  90.349 +
  90.350 +  static long remi_sumc2() {
  90.351 +    Long j1 = ibc;
  90.352 +    Long j2 = Long.valueOf(1);
  90.353 +    for (int i = 0; i< 1000; i++) {
  90.354 +      j1 = j1 + ibc;
  90.355 +      j2 = j2 + 2;
  90.356 +    }
  90.357 +    return j1 + j2;
  90.358 +  }
  90.359 +
  90.360 +
  90.361 +  //===============================================
  90.362 +  // Safepointa and debug info for deoptimization
  90.363 +  static long simple_deop(long i) {
  90.364 +    Long ib = new Long(foo(i));
  90.365 +    dummy();
  90.366 +    return ib;
  90.367 +  }
  90.368 +
  90.369 +  static long simpleb_deop(long i) {
  90.370 +    Long ib = Long.valueOf(foo(i));
  90.371 +    dummy();
  90.372 +    return ib;
  90.373 +  }
  90.374 +
  90.375 +  static long simplef_deop(long i) {
  90.376 +    Long ib = foob(i);
  90.377 +    dummy();
  90.378 +    return ib;
  90.379 +  }
  90.380 +
  90.381 +  static long simplep_deop(Long ib) {
  90.382 +    dummy();
  90.383 +    return ib;
  90.384 +  }
  90.385 +
  90.386 +  static long simplec_deop(long i) {
  90.387 +    Long ib = ibc;
  90.388 +    dummy();
  90.389 +    return ib;
  90.390 +  }
  90.391 +
  90.392 +  static long test_deop(long i) {
  90.393 +    Long ib = new Long(foo(i));
  90.394 +    if ((i&1) == 0)
  90.395 +      ib = foo(i+1);
  90.396 +    dummy();
  90.397 +    return ib;
  90.398 +  }
  90.399 +
  90.400 +  static long testb_deop(long i) {
  90.401 +    Long ib = foo(i);
  90.402 +    if ((i&1) == 0)
  90.403 +      ib = foo(i+1);
  90.404 +    dummy();
  90.405 +    return ib;
  90.406 +  }
  90.407 +
  90.408 +  static long testf_deop(long i) {
  90.409 +    Long ib = foob(i);
  90.410 +    if ((i&1) == 0)
  90.411 +      ib = foo(i+1);
  90.412 +    dummy();
  90.413 +    return ib;
  90.414 +  }
  90.415 +
  90.416 +  static long testp_deop(long i, Long ib) {
  90.417 +    if ((i&1) == 0)
  90.418 +      ib = foo(i+1);
  90.419 +    dummy();
  90.420 +    return ib;
  90.421 +  }
  90.422 +
  90.423 +  static long testc_deop(long i) {
  90.424 +    Long ib = ibc;
  90.425 +    if ((i&1) == 0)
  90.426 +      ib = foo(i+1);
  90.427 +    dummy();
  90.428 +    return ib;
  90.429 +  }
  90.430 +
  90.431 +  static long sum_deop(long[] a) {
  90.432 +    long result = 1;
  90.433 +    for (Long i : a)
  90.434 +        result += foo(i);
  90.435 +    dummy();
  90.436 +    return result;
  90.437 +  }
  90.438 +
  90.439 +  static long sumb_deop(long[] a) {
  90.440 +    Long result = 1l;
  90.441 +    for (Long i : a)
  90.442 +        result += foo(i);
  90.443 +    dummy();
  90.444 +    return result;
  90.445 +  }
  90.446 +
  90.447 +  static long sumf_deop(long[] a) {
  90.448 +    Long result = 1l;
  90.449 +    for (Long i : a)
  90.450 +        result += foob(i);
  90.451 +    dummy();
  90.452 +    return result;
  90.453 +  }
  90.454 +
  90.455 +  static long sump_deop(long[] a, Long result) {
  90.456 +    for (Long i : a)
  90.457 +        result += foob(i);
  90.458 +    dummy();
  90.459 +    return result;
  90.460 +  }
  90.461 +
  90.462 +  static long sumc_deop(long[] a) {
  90.463 +    Long result = ibc;
  90.464 +    for (Long i : a)
  90.465 +        result += foo(i);
  90.466 +    dummy();
  90.467 +    return result;
  90.468 +  }
  90.469 +
  90.470 +  static long remi_sum_deop() {
  90.471 +    Long j = new Long(foo(1));
  90.472 +    for (int i = 0; i< 1000; i++) {
  90.473 +      j = new Long(foo(j + 1));
  90.474 +    }
  90.475 +    dummy();
  90.476 +    return j;
  90.477 +  }
  90.478 +
  90.479 +  static long remi_sumb_deop() {
  90.480 +    Long j = Long.valueOf(foo(1));
  90.481 +    for (int i = 0; i< 1000; i++) {
  90.482 +      j = foo(j + 1);
  90.483 +    }
  90.484 +    dummy();
  90.485 +    return j;
  90.486 +  }
  90.487 +
  90.488 +  static long remi_sumf_deop() {
  90.489 +    Long j = foob(1);
  90.490 +    for (int i = 0; i< 1000; i++) {
  90.491 +      j = foo(j + 1);
  90.492 +    }
  90.493 +    dummy();
  90.494 +    return j;
  90.495 +  }
  90.496 +
  90.497 +  static long remi_sump_deop(Long j) {
  90.498 +    for (int i = 0; i< 1000; i++) {
  90.499 +      j = foo(j + 1);
  90.500 +    }
  90.501 +    dummy();
  90.502 +    return j;
  90.503 +  }
  90.504 +
  90.505 +  static long remi_sumc_deop() {
  90.506 +    Long j = ibc;
  90.507 +    for (int i = 0; i< 1000; i++) {
  90.508 +      j = foo(j + 1);
  90.509 +    }
  90.510 +    dummy();
  90.511 +    return j;
  90.512 +  }
  90.513 +
  90.514 +  //===============================================
  90.515 +  // Conditional increment
  90.516 +  static long remi_sum_cond() {
  90.517 +    Long j = new Long(1);
  90.518 +    for (int i = 0; i< 1000; i++) {
  90.519 +      if ((i&1) == 0) {
  90.520 +        j = new Long(j + 1);
  90.521 +      }
  90.522 +    }
  90.523 +    return j;
  90.524 +  }
  90.525 +
  90.526 +  static long remi_sumb_cond() {
  90.527 +    Long j = Long.valueOf(1);
  90.528 +    for (int i = 0; i< 1000; i++) {
  90.529 +      if ((i&1) == 0) {
  90.530 +        j = j + 1;
  90.531 +      }
  90.532 +    }
  90.533 +    return j;
  90.534 +  }
  90.535 +
  90.536 +  static long remi_sumf_cond() {
  90.537 +    Long j = foob(1);
  90.538 +    for (int i = 0; i< 1000; i++) {
  90.539 +      if ((i&1) == 0) {
  90.540 +        j = j + 1;
  90.541 +      }
  90.542 +    }
  90.543 +    return j;
  90.544 +  }
  90.545 +
  90.546 +  static long remi_sump_cond(Long j) {
  90.547 +    for (int i = 0; i< 1000; i++) {
  90.548 +      if ((i&1) == 0) {
  90.549 +        j = j + 1;
  90.550 +      }
  90.551 +    }
  90.552 +    return j;
  90.553 +  }
  90.554 +
  90.555 +  static long remi_sumc_cond() {
  90.556 +    Long j = ibc;
  90.557 +    for (int i = 0; i< 1000; i++) {
  90.558 +      if ((i&1) == 0) {
  90.559 +        j = j + ibc;
  90.560 +      }
  90.561 +    }
  90.562 +    return j;
  90.563 +  }
  90.564 +
  90.565 +  static long remi_sum2_cond() {
  90.566 +    Long j1 = new Long(1);
  90.567 +    Long j2 = new Long(1);
  90.568 +    for (int i = 0; i< 1000; i++) {
  90.569 +      if ((i&1) == 0) {
  90.570 +        j1 = new Long(j1 + 1);
  90.571 +      } else {
  90.572 +        j2 = new Long(j2 + 2);
  90.573 +      }
  90.574 +    }
  90.575 +    return j1 + j2;
  90.576 +  }
  90.577 +
  90.578 +  static long remi_sumb2_cond() {
  90.579 +    Long j1 = Long.valueOf(1);
  90.580 +    Long j2 = Long.valueOf(1);
  90.581 +    for (int i = 0; i< 1000; i++) {
  90.582 +      if ((i&1) == 0) {
  90.583 +        j1 = j1 + 1;
  90.584 +      } else {
  90.585 +        j2 = j2 + 2;
  90.586 +      }
  90.587 +    }
  90.588 +    return j1 + j2;
  90.589 +  }
  90.590 +
  90.591 +  static long remi_summ2_cond() {
  90.592 +    Long j1 = new Long(1);
  90.593 +    Long j2 = Long.valueOf(1);
  90.594 +    for (int i = 0; i< 1000; i++) {
  90.595 +      if ((i&1) == 0) {
  90.596 +        j1 = new Long(j1 + 1);
  90.597 +      } else {
  90.598 +        j2 = j2 + 2;
  90.599 +      }
  90.600 +    }
  90.601 +    return j1 + j2;
  90.602 +  }
  90.603 +
  90.604 +  static long remi_sump2_cond(Long j1) {
  90.605 +    Long j2 = Long.valueOf(1);
  90.606 +    for (int i = 0; i< 1000; i++) {
  90.607 +      if ((i&1) == 0) {
  90.608 +        j1 = new Long(j1 + 1);
  90.609 +      } else {
  90.610 +        j2 = j2 + 2;
  90.611 +      }
  90.612 +    }
  90.613 +    return j1 + j2;
  90.614 +  }
  90.615 +
  90.616 +  static long remi_sumc2_cond() {
  90.617 +    Long j1 = ibc;
  90.618 +    Long j2 = Long.valueOf(1);
  90.619 +    for (int i = 0; i< 1000; i++) {
  90.620 +      if ((i&1) == 0) {
  90.621 +        j1 = j1 + ibc;
  90.622 +      } else {
  90.623 +        j2 = j2 + 2;
  90.624 +      }
  90.625 +    }
  90.626 +    return j1 + j2;
  90.627 +  }
  90.628 +
  90.629 +
  90.630 +  public static void main(String[] args) {
  90.631 +    final int ntests = 70;
  90.632 +
  90.633 +    String[] test_name = new String[] {
  90.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
  90.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
  90.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
  90.637 +        "test",        "testb",        "testc",        "testm",        "testp",
  90.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
  90.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
  90.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
  90.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
  90.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
  90.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
  90.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
  90.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
  90.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
  90.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
  90.648 +    };
  90.649 +
  90.650 +    final long[] val = new long[] {
  90.651 +       71994000,  71994000,    12000,  71994000,  71994000,
  90.652 +      144000000, 144000000, 72018000, 144000000, 144000000,
  90.653 +       71994000,  71994000,    12000,  71994000,  71994000,
  90.654 +       72000000,  72000000, 36006000,  72000000,  72000000,
  90.655 +      144012000, 144012000, 72030000, 144012000, 144012000,
  90.656 +       72000000,  72000000, 36006000,  72000000,  72000000,
  90.657 +         499501,    499501,   499501,    499501,    499501,
  90.658 +        1000002,   1000002,  1000002,   1000002,   1000002,
  90.659 +         499501,    499501,   499501,    499501,    499501,
  90.660 +           1001,      1001,     1001,      1001,      1001,
  90.661 +           3002,      3002,     3002,      3002,      3002,
  90.662 +           1001,      1001,     1001,      1001,      1001,
  90.663 +            501,       501,      501,       501,       501,
  90.664 +           1502,      1502,     1502,      1502,      1502
  90.665 +    };
  90.666 +
  90.667 +    long[] res = new long[ntests];
  90.668 +    for (int i = 0; i < ntests; i++) {
  90.669 +      res[i] = 0;
  90.670 +    }
  90.671 +
  90.672 +
  90.673 +    for (long i = 0; i < 12000; i++) {
  90.674 +      res[0] += simple(i);
  90.675 +      res[1] += simpleb(i);
  90.676 +      res[2] += simplec();
  90.677 +      res[3] += simplef(i);
  90.678 +      res[4] += simplep(i);
  90.679 +
  90.680 +      res[5] += simple2(i);
  90.681 +      res[6] += simpleb2(i);
  90.682 +      res[7] += simplec2(i);
  90.683 +      res[8] += simplem2(i);
  90.684 +      res[9] += simplep2(i, i);
  90.685 +
  90.686 +      res[10] += simple_deop(i);
  90.687 +      res[11] += simpleb_deop(i);
  90.688 +      res[12] += simplec_deop(i);
  90.689 +      res[13] += simplef_deop(i);
  90.690 +      res[14] += simplep_deop(i);
  90.691 +
  90.692 +      res[15] += test(i);
  90.693 +      res[16] += testb(i);
  90.694 +      res[17] += testc(i);
  90.695 +      res[18] += testm(i);
  90.696 +      res[19] += testp(i, i);
  90.697 +
  90.698 +      res[20] += test2(i);
  90.699 +      res[21] += testb2(i);
  90.700 +      res[22] += testc2(i);
  90.701 +      res[23] += testm2(i);
  90.702 +      res[24] += testp2(i, i);
  90.703 +
  90.704 +      res[25] += test_deop(i);
  90.705 +      res[26] += testb_deop(i);
  90.706 +      res[27] += testc_deop(i);
  90.707 +      res[28] += testf_deop(i);
  90.708 +      res[29] += testp_deop(i, i);
  90.709 +    }
  90.710 +
  90.711 +    long[] ia = new long[1000];
  90.712 +    for (int i = 0; i < 1000; i++) {
  90.713 +      ia[i] = i;
  90.714 +    }
  90.715 +
  90.716 +    for (int i = 0; i < 100; i++) {
  90.717 +      res[30] = sum(ia);
  90.718 +      res[31] = sumb(ia);
  90.719 +      res[32] = sumc(ia);
  90.720 +      res[33] = sumf(ia);
  90.721 +      res[34] = sump(ia, (long)1);
  90.722 +
  90.723 +      res[35] = sum2(ia);
  90.724 +      res[36] = sumb2(ia);
  90.725 +      res[37] = sumc2(ia);
  90.726 +      res[38] = summ2(ia);
  90.727 +      res[39] = sump2(ia, (long)1);
  90.728 +
  90.729 +      res[40] = sum_deop(ia);
  90.730 +      res[41] = sumb_deop(ia);
  90.731 +      res[42] = sumc_deop(ia);
  90.732 +      res[43] = sumf_deop(ia);
  90.733 +      res[44] = sump_deop(ia, (long)1);
  90.734 +
  90.735 +      res[45] = remi_sum();
  90.736 +      res[46] = remi_sumb();
  90.737 +      res[47] = remi_sumc();
  90.738 +      res[48] = remi_sumf();
  90.739 +      res[49] = remi_sump((long)1);
  90.740 +
  90.741 +      res[50] = remi_sum2();
  90.742 +      res[51] = remi_sumb2();
  90.743 +      res[52] = remi_sumc2();
  90.744 +      res[53] = remi_summ2();
  90.745 +      res[54] = remi_sump2((long)1);
  90.746 +
  90.747 +      res[55] = remi_sum_deop();
  90.748 +      res[56] = remi_sumb_deop();
  90.749 +      res[57] = remi_sumc_deop();
  90.750 +      res[58] = remi_sumf_deop();
  90.751 +      res[59] = remi_sump_deop((long)1);
  90.752 +
  90.753 +      res[60] = remi_sum_cond();
  90.754 +      res[61] = remi_sumb_cond();
  90.755 +      res[62] = remi_sumc_cond();
  90.756 +      res[63] = remi_sumf_cond();
  90.757 +      res[64] = remi_sump_cond((long)1);
  90.758 +
  90.759 +      res[65] = remi_sum2_cond();
  90.760 +      res[66] = remi_sumb2_cond();
  90.761 +      res[67] = remi_sumc2_cond();
  90.762 +      res[68] = remi_summ2_cond();
  90.763 +      res[69] = remi_sump2_cond((long)1);
  90.764 +    }
  90.765 +
  90.766 +    int failed = 0;
  90.767 +    for (int i = 0; i < ntests; i++) {
  90.768 +      if (res[i] != val[i]) {
  90.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
  90.770 +        failed++;
  90.771 +      }
  90.772 +    }
  90.773 +    if (failed > 0) {
  90.774 +      System.err.println("Failed " + failed + " tests.");
  90.775 +      throw new InternalError();
  90.776 +    } else {
  90.777 +      System.out.println("Passed.");
  90.778 +    }
  90.779 +  }
  90.780 +}
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/test/compiler/6934604/TestShortBoxing.java	Thu May 16 13:47:55 2013 -0700
    91.3 @@ -0,0 +1,777 @@
    91.4 +/*
    91.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    91.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    91.7 + *
    91.8 + * This code is free software; you can redistribute it and/or modify it
    91.9 + * under the terms of the GNU General Public License version 2 only, as
   91.10 + * published by the Free Software Foundation.
   91.11 + *
   91.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   91.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   91.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   91.15 + * version 2 for more details (a copy is included in the LICENSE file that
   91.16 + * accompanied this code).
   91.17 + *
   91.18 + * You should have received a copy of the GNU General Public License version
   91.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   91.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   91.21 + *
   91.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   91.23 + * or visit www.oracle.com if you need additional information or have any
   91.24 + * questions.
   91.25 + */
   91.26 +
   91.27 +/*
   91.28 + * @test
   91.29 + * @bug 6934604
   91.30 + * @summary enable parts of EliminateAutoBox by default
   91.31 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox TestShortBoxing
   91.32 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
   91.33 + * -XX:CompileCommand=exclude,TestShortBoxing.dummy -XX:CompileCommand=exclude,TestShortBoxing.foo -XX:CompileCommand=exclude,TestShortBoxing.foob TestShortBoxing
   91.34 + * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-EliminateAutoBox
   91.35 + * -XX:CompileCommand=exclude,TestShortBoxing.dummy -XX:CompileCommand=exclude,TestShortBoxing.foo -XX:CompileCommand=exclude,TestShortBoxing.foob TestShortBoxing
   91.36 + *
   91.37 + */
   91.38 +
   91.39 +public class TestShortBoxing {
   91.40 +
   91.41 +  static final Short ibc = new Short((short)1);
   91.42 +
   91.43 +  //===============================================
   91.44 +  // Non-inlined methods to test deoptimization info
   91.45 +  static void dummy()      { }
   91.46 +  static short foo(short i)  { return i; }
   91.47 +  static Short foob(short i) { return Short.valueOf(i); }
   91.48 +
   91.49 +
   91.50 +  static short simple(short i) {
   91.51 +    Short ib = new Short(i);
   91.52 +    return ib;
   91.53 +  }
   91.54 +
   91.55 +  static short simpleb(short i) {
   91.56 +    Short ib = Short.valueOf(i);
   91.57 +    return ib;
   91.58 +  }
   91.59 +
   91.60 +  static short simplec() {
   91.61 +    Short ib = ibc;
   91.62 +    return ib;
   91.63 +  }
   91.64 +
   91.65 +  static short simplef(short i) {
   91.66 +    Short ib = foob(i);
   91.67 +    return ib;
   91.68 +  }
   91.69 +
   91.70 +  static short simplep(Short ib) {
   91.71 +    return ib;
   91.72 +  }
   91.73 +
   91.74 +  static short simple2(short i) {
   91.75 +    Short ib1 = new Short(i);
   91.76 +    Short ib2 = new Short((short)(i+1));
   91.77 +    return (short)(ib1 + ib2);
   91.78 +  }
   91.79 +
   91.80 +  static short simpleb2(short i) {
   91.81 +    Short ib1 = Short.valueOf(i);
   91.82 +    Short ib2 = Short.valueOf((short)(i+1));
   91.83 +    return (short)(ib1 + ib2);
   91.84 +  }
   91.85 +
   91.86 +  static short simplem2(short i) {
   91.87 +    Short ib1 = new Short(i);
   91.88 +    Short ib2 = Short.valueOf((short)(i+1));
   91.89 +    return (short)(ib1 + ib2);
   91.90 +  }
   91.91 +
   91.92 +  static short simplep2(short i, Short ib1) {
   91.93 +    Short ib2 = Short.valueOf((short)(i+1));
   91.94 +    return (short)(ib1 + ib2);
   91.95 +  }
   91.96 +
   91.97 +  static short simplec2(short i) {
   91.98 +    Short ib1 = ibc;
   91.99 +    Short ib2 = Short.valueOf((short)(i+1));
  91.100 +    return (short)(ib1 + ib2);
  91.101 +  }
  91.102 +
  91.103 +  //===============================================
  91.104 +  static short test(short i) {
  91.105 +    Short ib = new Short(i);
  91.106 +    if ((i&1) == 0)
  91.107 +      ib = (short)(i+1);
  91.108 +    return ib;
  91.109 +  }
  91.110 +
  91.111 +  static short testb(short i) {
  91.112 +    Short ib = i;
  91.113 +    if ((i&1) == 0)
  91.114 +      ib = (short)(i+1);
  91.115 +    return ib;
  91.116 +  }
  91.117 +
  91.118 +  static short testm(short i) {
  91.119 +    Short ib = i;
  91.120 +    if ((i&1) == 0)
  91.121 +      ib = new Short((short)(i+1));
  91.122 +    return ib;
  91.123 +  }
  91.124 +
  91.125 +  static short testp(short i, Short ib) {
  91.126 +    if ((i&1) == 0)
  91.127 +      ib = new Short((short)(i+1));
  91.128 +    return ib;
  91.129 +  }
  91.130 +
  91.131 +  static short testc(short i) {
  91.132 +    Short ib = ibc;
  91.133 +    if ((i&1) == 0)
  91.134 +      ib = new Short((short)(i+1));
  91.135 +    return ib;
  91.136 +  }
  91.137 +
  91.138 +  static short test2(short i) {
  91.139 +    Short ib1 = new Short(i);
  91.140 +    Short ib2 = new Short((short)(i+1));
  91.141 +    if ((i&1) == 0) {
  91.142 +      ib1 = new Short((short)(i+1));
  91.143 +      ib2 = new Short((short)(i+2));
  91.144 +    }
  91.145 +    return (short)(ib1+ib2);
  91.146 +  }
  91.147 +
  91.148 +  static short testb2(short i) {
  91.149 +    Short ib1 = i;
  91.150 +    Short ib2 = (short)(i+1);
  91.151 +    if ((i&1) == 0) {
  91.152 +      ib1 = (short)(i+1);
  91.153 +      ib2 = (short)(i+2);
  91.154 +    }
  91.155 +    return (short)(ib1 + ib2);
  91.156 +  }
  91.157 +
  91.158 +  static short testm2(short i) {
  91.159 +    Short ib1 = new Short(i);
  91.160 +    Short ib2 = (short)(i+1);
  91.161 +    if ((i&1) == 0) {
  91.162 +      ib1 = new Short((short)(i+1));
  91.163 +      ib2 = (short)(i+2);
  91.164 +    }
  91.165 +    return (short)(ib1 + ib2);
  91.166 +  }
  91.167 +
  91.168 +  static short testp2(short i, Short ib1) {
  91.169 +    Short ib2 = (short)(i+1);
  91.170 +    if ((i&1) == 0) {
  91.171 +      ib1 = new Short((short)(i+1));
  91.172 +      ib2 = (short)(i+2);
  91.173 +    }
  91.174 +    return (short)(ib1 + ib2);
  91.175 +  }
  91.176 +
  91.177 +  static short testc2(short i) {
  91.178 +    Short ib1 = ibc;
  91.179 +    Short ib2 = (short)(i+1);
  91.180 +    if ((i&1) == 0) {
  91.181 +      ib1 = (short)(ibc+1);
  91.182 +      ib2 = (short)(i+2);
  91.183 +    }
  91.184 +    return (short)(ib1 + ib2);
  91.185 +  }
  91.186 +
  91.187 +  //===============================================
  91.188 +  static short sum(short[] a) {
  91.189 +    short result = 1;
  91.190 +    for (Short i : a)
  91.191 +        result += i;
  91.192 +    return result;
  91.193 +  }
  91.194 +
  91.195 +  static short sumb(short[] a) {
  91.196 +    Short result = 1;
  91.197 +    for (Short i : a)
  91.198 +        result = (short)(result + i);
  91.199 +    return result;
  91.200 +  }
  91.201 +
  91.202 +  static short sumc(short[] a) {
  91.203 +    Short result = ibc;
  91.204 +    for (Short i : a)
  91.205 +        result = (short)(result + i);
  91.206 +    return result;
  91.207 +  }
  91.208 +
  91.209 +  static short sumf(short[] a) {
  91.210 +    Short result = foob((short)1);
  91.211 +    for (Short i : a)
  91.212 +        result = (short)(result + i);
  91.213 +    return result;
  91.214 +  }
  91.215 +
  91.216 +  static short sump(short[] a, Short result) {
  91.217 +    for (Short i : a)
  91.218 +        result = (short)(result + i);
  91.219 +    return result;
  91.220 +  }
  91.221 +
  91.222 +  static short sum2(short[] a) {
  91.223 +    short result1 = 1;
  91.224 +    short result2 = 1;
  91.225 +    for (Short i : a) {
  91.226 +        result1 += i;
  91.227 +        result2 += i + 1;
  91.228 +    }
  91.229 +    return (short)(result1 + result2);
  91.230 +  }
  91.231 +
  91.232 +  static short sumb2(short[] a) {
  91.233 +    Short result1 = 1;
  91.234 +    Short result2 = 1;
  91.235 +    for (Short i : a) {
  91.236 +        result1 = (short)(result1 + i);
  91.237 +        result2 = (short)(result2 + i + 1);
  91.238 +    }
  91.239 +    return (short)(result1 + result2);
  91.240 +  }
  91.241 +
  91.242 +  static short summ2(short[] a) {
  91.243 +    Short result1 = 1;
  91.244 +    Short result2 = new Short((short)1);
  91.245 +    for (Short i : a) {
  91.246 +        result1 = (short)(result1 + i);
  91.247 +        result2 = (short)(result2 + new Short((short)(i + 1)));
  91.248 +    }
  91.249 +    return (short)(result1 + result2);
  91.250 +  }
  91.251 +
  91.252 +  static short sump2(short[] a, Short result2) {
  91.253 +    Short result1 = 1;
  91.254 +    for (Short i : a) {
  91.255 +        result1 = (short)(result1 + i);
  91.256 +        result2 = (short)(result2 + i + 1);
  91.257 +    }
  91.258 +    return (short)(result1 + result2);
  91.259 +  }
  91.260 +
  91.261 +  static short sumc2(short[] a) {
  91.262 +    Short result1 = 1;
  91.263 +    Short result2 = ibc;
  91.264 +    for (Short i : a) {
  91.265 +        result1 = (short)(result1 + i);
  91.266 +        result2 = (short)(result2 + i + ibc);
  91.267 +    }
  91.268 +    return (short)(result1 + result2);
  91.269 +  }
  91.270 +
  91.271 +  //===============================================
  91.272 +  static short remi_sum() {
  91.273 +    Short j = new Short((short)1);
  91.274 +    for (int i = 0; i< 1000; i++) {
  91.275 +      j = new Short((short)(j + 1));
  91.276 +    }
  91.277 +    return j;
  91.278 +  }
  91.279 +
  91.280 +  static short remi_sumb() {
  91.281 +    Short j = Short.valueOf((short)1);
  91.282 +    for (int i = 0; i< 1000; i++) {
  91.283 +      j = (short)(j + 1);
  91.284 +    }
  91.285 +    return j;
  91.286 +  }
  91.287 +
  91.288 +  static short remi_sumf() {
  91.289 +    Short j = foob((short)1);
  91.290 +    for (int i = 0; i< 1000; i++) {
  91.291 +      j = (short)(j + 1);
  91.292 +    }
  91.293 +    return j;
  91.294 +  }
  91.295 +
  91.296 +  static short remi_sump(Short j) {
  91.297 +    for (int i = 0; i< 1000; i++) {
  91.298 +      j = new Short((short)(j + 1));
  91.299 +    }
  91.300 +    return j;
  91.301 +  }
  91.302 +
  91.303 +  static short remi_sumc() {
  91.304 +    Short j = ibc;
  91.305 +    for (int i = 0; i< 1000; i++) {
  91.306 +      j = (short)(j + ibc);
  91.307 +    }
  91.308 +    return j;
  91.309 +  }
  91.310 +
  91.311 +  static short remi_sum2() {
  91.312 +    Short j1 = new Short((short)1);
  91.313 +    Short j2 = new Short((short)1);
  91.314 +    for (int i = 0; i< 1000; i++) {
  91.315 +      j1 = new Short((short)(j1 + 1));
  91.316 +      j2 = new Short((short)(j2 + 2));
  91.317 +    }
  91.318 +    return (short)(j1 + j2);
  91.319 +  }
  91.320 +
  91.321 +  static short remi_sumb2() {
  91.322 +    Short j1 = Short.valueOf((short)1);
  91.323 +    Short j2 = Short.valueOf((short)1);
  91.324 +    for (int i = 0; i< 1000; i++) {
  91.325 +      j1 = (short)(j1 + 1);
  91.326 +      j2 = (short)(j2 + 2);
  91.327 +    }
  91.328 +    return (short)(j1 + j2);
  91.329 +  }
  91.330 +
  91.331 +  static short remi_summ2() {
  91.332 +    Short j1 = new Short((short)1);
  91.333 +    Short j2 = Short.valueOf((short)1);
  91.334 +    for (int i = 0; i< 1000; i++) {
  91.335 +      j1 = new Short((short)(j1 + 1));
  91.336 +      j2 = (short)(j2 + 2);
  91.337 +    }
  91.338 +    return (short)(j1 + j2);
  91.339 +  }
  91.340 +
  91.341 +  static short remi_sump2(Short j1) {
  91.342 +    Short j2 = Short.valueOf((short)1);
  91.343 +    for (int i = 0; i< 1000; i++) {
  91.344 +      j1 = new Short((short)(j1 + 1));
  91.345 +      j2 = (short)(j2 + 2);
  91.346 +    }
  91.347 +    return (short)(j1 + j2);
  91.348 +  }
  91.349 +
  91.350 +  static short remi_sumc2() {
  91.351 +    Short j1 = ibc;
  91.352 +    Short j2 = Short.valueOf((short)1);
  91.353 +    for (int i = 0; i< 1000; i++) {
  91.354 +      j1 = (short)(j1 + ibc);
  91.355 +      j2 = (short)(j2 + 2);
  91.356 +    }
  91.357 +    return (short)(j1 + j2);
  91.358 +  }
  91.359 +
  91.360 +
  91.361 +  //===============================================
  91.362 +  // Safepointa and debug info for deoptimization
  91.363 +  static short simple_deop(short i) {
  91.364 +    Short ib = new Short(foo(i));
  91.365 +    dummy();
  91.366 +    return ib;
  91.367 +  }
  91.368 +
  91.369 +  static short simpleb_deop(short i) {
  91.370 +    Short ib = Short.valueOf(foo(i));
  91.371 +    dummy();
  91.372 +    return ib;
  91.373 +  }
  91.374 +
  91.375 +  static short simplef_deop(short i) {
  91.376 +    Short ib = foob(i);
  91.377 +    dummy();
  91.378 +    return ib;
  91.379 +  }
  91.380 +
  91.381 +  static short simplep_deop(Short ib) {
  91.382 +    dummy();
  91.383 +    return ib;
  91.384 +  }
  91.385 +
  91.386 +  static short simplec_deop(short i) {
  91.387 +    Short ib = ibc;
  91.388 +    dummy();
  91.389 +    return ib;
  91.390 +  }
  91.391 +
  91.392 +  static short test_deop(short i) {
  91.393 +    Short ib = new Short(foo(i));
  91.394 +    if ((i&1) == 0)
  91.395 +      ib = foo((short)(i+1));
  91.396 +    dummy();
  91.397 +    return ib;
  91.398 +  }
  91.399 +
  91.400 +  static short testb_deop(short i) {
  91.401 +    Short ib = foo(i);
  91.402 +    if ((i&1) == 0)
  91.403 +      ib = foo((short)(i+1));
  91.404 +    dummy();
  91.405 +    return ib;
  91.406 +  }
  91.407 +
  91.408 +  static short testf_deop(short i) {
  91.409 +    Short ib = foob(i);
  91.410 +    if ((i&1) == 0)
  91.411 +      ib = foo((short)(i+1));
  91.412 +    dummy();
  91.413 +    return ib;
  91.414 +  }
  91.415 +
  91.416 +  static short testp_deop(short i, Short ib) {
  91.417 +    if ((i&1) == 0)
  91.418 +      ib = foo((short)(i+1));
  91.419 +    dummy();
  91.420 +    return ib;
  91.421 +  }
  91.422 +
  91.423 +  static short testc_deop(short i) {
  91.424 +    Short ib = ibc;
  91.425 +    if ((i&1) == 0)
  91.426 +      ib = foo((short)(i+1));
  91.427 +    dummy();
  91.428 +    return ib;
  91.429 +  }
  91.430 +
  91.431 +  static short sum_deop(short[] a) {
  91.432 +    short result = 1;
  91.433 +    for (Short i : a)
  91.434 +        result += foo(i);
  91.435 +    dummy();
  91.436 +    return result;
  91.437 +  }
  91.438 +
  91.439 +  static short sumb_deop(short[] a) {
  91.440 +    Short result = 1;
  91.441 +    for (Short i : a)
  91.442 +        result = (short)(result + foo(i));
  91.443 +    dummy();
  91.444 +    return result;
  91.445 +  }
  91.446 +
  91.447 +  static short sumf_deop(short[] a) {
  91.448 +    Short result = 1;
  91.449 +    for (Short i : a)
  91.450 +        result = (short)(result + foob(i));
  91.451 +    dummy();
  91.452 +    return result;
  91.453 +  }
  91.454 +
  91.455 +  static short sump_deop(short[] a, Short result) {
  91.456 +    for (Short i : a)
  91.457 +        result = (short)(result + foob(i));
  91.458 +    dummy();
  91.459 +    return result;
  91.460 +  }
  91.461 +
  91.462 +  static short sumc_deop(short[] a) {
  91.463 +    Short result = ibc;
  91.464 +    for (Short i : a)
  91.465 +        result = (short)(result + foo(i));
  91.466 +    dummy();
  91.467 +    return result;
  91.468 +  }
  91.469 +
  91.470 +  static short remi_sum_deop() {
  91.471 +    Short j = new Short(foo((short)1));
  91.472 +    for (int i = 0; i< 1000; i++) {
  91.473 +      j = new Short(foo((short)(j + 1)));
  91.474 +    }
  91.475 +    dummy();
  91.476 +    return j;
  91.477 +  }
  91.478 +
  91.479 +  static short remi_sumb_deop() {
  91.480 +    Short j = Short.valueOf(foo((short)1));
  91.481 +    for (int i = 0; i< 1000; i++) {
  91.482 +      j = foo((short)(j + 1));
  91.483 +    }
  91.484 +    dummy();
  91.485 +    return j;
  91.486 +  }
  91.487 +
  91.488 +  static short remi_sumf_deop() {
  91.489 +    Short j = foob((short)1);
  91.490 +    for (int i = 0; i< 1000; i++) {
  91.491 +      j = foo((short)(j + 1));
  91.492 +    }
  91.493 +    dummy();
  91.494 +    return j;
  91.495 +  }
  91.496 +
  91.497 +  static short remi_sump_deop(Short j) {
  91.498 +    for (int i = 0; i< 1000; i++) {
  91.499 +      j = foo((short)(j + 1));
  91.500 +    }
  91.501 +    dummy();
  91.502 +    return j;
  91.503 +  }
  91.504 +
  91.505 +  static short remi_sumc_deop() {
  91.506 +    Short j = ibc;
  91.507 +    for (int i = 0; i< 1000; i++) {
  91.508 +      j = foo((short)(j + 1));
  91.509 +    }
  91.510 +    dummy();
  91.511 +    return j;
  91.512 +  }
  91.513 +
  91.514 +  //===============================================
  91.515 +  // Conditional increment
  91.516 +  static short remi_sum_cond() {
  91.517 +    Short j = new Short((short)1);
  91.518 +    for (int i = 0; i< 1000; i++) {
  91.519 +      if ((i&1) == 0) {
  91.520 +        j = new Short((short)(j + 1));
  91.521 +      }
  91.522 +    }
  91.523 +    return j;
  91.524 +  }
  91.525 +
  91.526 +  static short remi_sumb_cond() {
  91.527 +    Short j = Short.valueOf((short)1);
  91.528 +    for (int i = 0; i< 1000; i++) {
  91.529 +      if ((i&1) == 0) {
  91.530 +        j = (short)(j + 1);
  91.531 +      }
  91.532 +    }
  91.533 +    return j;
  91.534 +  }
  91.535 +
  91.536 +  static short remi_sumf_cond() {
  91.537 +    Short j = foob((short)1);
  91.538 +    for (int i = 0; i< 1000; i++) {
  91.539 +      if ((i&1) == 0) {
  91.540 +        j = (short)(j + 1);
  91.541 +      }
  91.542 +    }
  91.543 +    return j;
  91.544 +  }
  91.545 +
  91.546 +  static short remi_sump_cond(Short j) {
  91.547 +    for (int i = 0; i< 1000; i++) {
  91.548 +      if ((i&1) == 0) {
  91.549 +        j = (short)(j + 1);
  91.550 +      }
  91.551 +    }
  91.552 +    return j;
  91.553 +  }
  91.554 +
  91.555 +  static short remi_sumc_cond() {
  91.556 +    Short j = ibc;
  91.557 +    for (int i = 0; i< 1000; i++) {
  91.558 +      if ((i&1) == 0) {
  91.559 +        j = (short)(j + ibc);
  91.560 +      }
  91.561 +    }
  91.562 +    return j;
  91.563 +  }
  91.564 +
  91.565 +  static short remi_sum2_cond() {
  91.566 +    Short j1 = new Short((short)1);
  91.567 +    Short j2 = new Short((short)1);
  91.568 +    for (int i = 0; i< 1000; i++) {
  91.569 +      if ((i&1) == 0) {
  91.570 +        j1 = new Short((short)(j1 + 1));
  91.571 +      } else {
  91.572 +        j2 = new Short((short)(j2 + 2));
  91.573 +      }
  91.574 +    }
  91.575 +    return (short)(j1 + j2);
  91.576 +  }
  91.577 +
  91.578 +  static short remi_sumb2_cond() {
  91.579 +    Short j1 = Short.valueOf((short)1);
  91.580 +    Short j2 = Short.valueOf((short)1);
  91.581 +    for (int i = 0; i< 1000; i++) {
  91.582 +      if ((i&1) == 0) {
  91.583 +        j1 = (short)(j1 + 1);
  91.584 +      } else {
  91.585 +        j2 = (short)(j2 + 2);
  91.586 +      }
  91.587 +    }
  91.588 +    return (short)(j1 + j2);
  91.589 +  }
  91.590 +
  91.591 +  static short remi_summ2_cond() {
  91.592 +    Short j1 = new Short((short)1);
  91.593 +    Short j2 = Short.valueOf((short)1);
  91.594 +    for (int i = 0; i< 1000; i++) {
  91.595 +      if ((i&1) == 0) {
  91.596 +        j1 = new Short((short)(j1 + 1));
  91.597 +      } else {
  91.598 +        j2 = (short)(j2 + 2);
  91.599 +      }
  91.600 +    }
  91.601 +    return (short)(j1 + j2);
  91.602 +  }
  91.603 +
  91.604 +  static short remi_sump2_cond(Short j1) {
  91.605 +    Short j2 = Short.valueOf((short)1);
  91.606 +    for (int i = 0; i< 1000; i++) {
  91.607 +      if ((i&1) == 0) {
  91.608 +        j1 = new Short((short)(j1 + 1));
  91.609 +      } else {
  91.610 +        j2 = (short)(j2 + 2);
  91.611 +      }
  91.612 +    }
  91.613 +    return (short)(j1 + j2);
  91.614 +  }
  91.615 +
  91.616 +  static short remi_sumc2_cond() {
  91.617 +    Short j1 = ibc;
  91.618 +    Short j2 = Short.valueOf((short)1);
  91.619 +    for (int i = 0; i< 1000; i++) {
  91.620 +      if ((i&1) == 0) {
  91.621 +        j1 = (short)(j1 + ibc);
  91.622 +      } else {
  91.623 +        j2 = (short)(j2 + 2);
  91.624 +      }
  91.625 +    }
  91.626 +    return (short)(j1 + j2);
  91.627 +  }
  91.628 +
  91.629 +
  91.630 +  public static void main(String[] args) {
  91.631 +    final int ntests = 70;
  91.632 +
  91.633 +    String[] test_name = new String[] {
  91.634 +        "simple",      "simpleb",      "simplec",      "simplef",      "simplep",
  91.635 +        "simple2",     "simpleb2",     "simplec2",     "simplem2",     "simplep2",
  91.636 +        "simple_deop", "simpleb_deop", "simplec_deop", "simplef_deop", "simplep_deop",
  91.637 +        "test",        "testb",        "testc",        "testm",        "testp",
  91.638 +        "test2",       "testb2",       "testc2",       "testm2",       "testp2",
  91.639 +        "test_deop",   "testb_deop",   "testc_deop",   "testf_deop",   "testp_deop",
  91.640 +        "sum",         "sumb",         "sumc",         "sumf",         "sump",
  91.641 +        "sum2",        "sumb2",        "sumc2",        "summ2",        "sump2",
  91.642 +        "sum_deop",    "sumb_deop",    "sumc_deop",    "sumf_deop",    "sump_deop",
  91.643 +        "remi_sum",       "remi_sumb",       "remi_sumc",       "remi_sumf",       "remi_sump",
  91.644 +        "remi_sum2",      "remi_sumb2",      "remi_sumc2",      "remi_summ2",      "remi_sump2",
  91.645 +        "remi_sum_deop",  "remi_sumb_deop",  "remi_sumc_deop",  "remi_sumf_deop",  "remi_sump_deop",
  91.646 +        "remi_sum_cond",  "remi_sumb_cond",  "remi_sumc_cond",  "remi_sumf_cond",  "remi_sump_cond",
  91.647 +        "remi_sum2_cond", "remi_sumb2_cond", "remi_sumc2_cond", "remi_summ2_cond", "remi_sump2_cond"
  91.648 +    };
  91.649 +
  91.650 +    final int[] val = new int[] {
  91.651 +       71994000,  71994000,    12000,  71994000,  71994000,
  91.652 +      144000000, 144000000, 72018000, 144000000, 144000000,
  91.653 +       71994000,  71994000,    12000,  71994000,  71994000,
  91.654 +       72000000,  72000000, 36006000,  72000000,  72000000,
  91.655 +      144012000, 144012000, 72030000, 144012000, 144012000,
  91.656 +       72000000,  72000000, 36006000,  72000000,  72000000,
  91.657 +         -24787,    -24787,   -24787,    -24787,    -24787,
  91.658 +          16962,     16962,    16962,     16962,     16962,
  91.659 +         -24787,    -24787,   -24787,    -24787,    -24787,
  91.660 +           1001,      1001,     1001,      1001,      1001,
  91.661 +           3002,      3002,     3002,      3002,      3002,
  91.662 +           1001,      1001,     1001,      1001,      1001,
  91.663 +            501,       501,      501,       501,       501,
  91.664 +           1502,      1502,     1502,      1502,      1502
  91.665 +    };
  91.666 +
  91.667 +    int[] res = new int[ntests];
  91.668 +    for (int i = 0; i < ntests; i++) {
  91.669 +      res[i] = 0;
  91.670 +    }
  91.671 +
  91.672 +
  91.673 +    for (int i = 0; i < 12000; i++) {
  91.674 +      res[0] += simple((short)i);
  91.675 +      res[1] += simpleb((short)i);
  91.676 +      res[2] += simplec();
  91.677 +      res[3] += simplef((short)i);
  91.678 +      res[4] += simplep((short)i);
  91.679 +
  91.680 +      res[5] += simple2((short)i);
  91.681 +      res[6] += simpleb2((short)i);
  91.682 +      res[7] += simplec2((short)i);
  91.683 +      res[8] += simplem2((short)i);
  91.684 +      res[9] += simplep2((short)i, (short)i);
  91.685 +
  91.686 +      res[10] += simple_deop((short)i);
  91.687 +      res[11] += simpleb_deop((short)i);
  91.688 +      res[12] += simplec_deop((short)i);
  91.689 +      res[13] += simplef_deop((short)i);
  91.690 +      res[14] += simplep_deop((short)i);
  91.691 +
  91.692 +      res[15] += test((short)i);
  91.693 +      res[16] += testb((short)i);
  91.694 +      res[17] += testc((short)i);
  91.695 +      res[18] += testm((short)i);
  91.696 +      res[19] += testp((short)i, (short)i);
  91.697 +
  91.698 +      res[20] += test2((short)i);
  91.699 +      res[21] += testb2((short)i);
  91.700 +      res[22] += testc2((short)i);
  91.701 +      res[23] += testm2((short)i);
  91.702 +      res[24] += testp2((short)i, (short)i);
  91.703 +
  91.704 +      res[25] += test_deop((short)i);
  91.705 +      res[26] += testb_deop((short)i);
  91.706 +      res[27] += testc_deop((short)i);
  91.707 +      res[28] += testf_deop((short)i);
  91.708 +      res[29] += testp_deop((short)i, (short)i);
  91.709 +    }
  91.710 +
  91.711 +    short[] ia = new short[1000];
  91.712 +    for (int i = 0; i < 1000; i++) {
  91.713 +      ia[i] = (short)i;
  91.714 +    }
  91.715 +
  91.716 +    for (int i = 0; i < 100; i++) {
  91.717 +      res[30] = sum(ia);
  91.718 +      res[31] = sumb(ia);
  91.719 +      res[32] = sumc(ia);
  91.720 +      res[33] = sumf(ia);
  91.721 +      res[34] = sump(ia, (short)1);
  91.722 +
  91.723 +      res[35] = sum2(ia);
  91.724 +      res[36] = sumb2(ia);
  91.725 +      res[37] = sumc2(ia);
  91.726 +      res[38] = summ2(ia);
  91.727 +      res[39] = sump2(ia, (short)1);
  91.728 +
  91.729 +      res[40] = sum_deop(ia);
  91.730 +      res[41] = sumb_deop(ia);
  91.731 +      res[42] = sumc_deop(ia);
  91.732 +      res[43] = sumf_deop(ia);
  91.733 +      res[44] = sump_deop(ia, (short)1);
  91.734 +
  91.735 +      res[45] = remi_sum();
  91.736 +      res[46] = remi_sumb();
  91.737 +      res[47] = remi_sumc();
  91.738 +      res[48] = remi_sumf();
  91.739 +      res[49] = remi_sump((short)1);
  91.740 +
  91.741 +      res[50] = remi_sum2();
  91.742 +      res[51] = remi_sumb2();
  91.743 +      res[52] = remi_sumc2();
  91.744 +      res[53] = remi_summ2();
  91.745 +      res[54] = remi_sump2((short)1);
  91.746 +
  91.747 +      res[55] = remi_sum_deop();
  91.748 +      res[56] = remi_sumb_deop();
  91.749 +      res[57] = remi_sumc_deop();
  91.750 +      res[58] = remi_sumf_deop();
  91.751 +      res[59] = remi_sump_deop((short)1);
  91.752 +
  91.753 +      res[60] = remi_sum_cond();
  91.754 +      res[61] = remi_sumb_cond();
  91.755 +      res[62] = remi_sumc_cond();
  91.756 +      res[63] = remi_sumf_cond();
  91.757 +      res[64] = remi_sump_cond((short)1);
  91.758 +
  91.759 +      res[65] = remi_sum2_cond();
  91.760 +      res[66] = remi_sumb2_cond();
  91.761 +      res[67] = remi_sumc2_cond();
  91.762 +      res[68] = remi_summ2_cond();
  91.763 +      res[69] = remi_sump2_cond((short)1);
  91.764 +    }
  91.765 +
  91.766 +    int failed = 0;
  91.767 +    for (int i = 0; i < ntests; i++) {
  91.768 +      if (res[i] != val[i]) {
  91.769 +        System.err.println(test_name[i] + ": " + res[i] + " != " + val[i]);
  91.770 +        failed++;
  91.771 +      }
  91.772 +    }
  91.773 +    if (failed > 0) {
  91.774 +      System.err.println("Failed " + failed + " tests.");
  91.775 +      throw new InternalError();
  91.776 +    } else {
  91.777 +      System.out.println("Passed.");
  91.778 +    }
  91.779 +  }
  91.780 +}
    92.1 --- a/test/compiler/8009761/Test8009761.java	Tue May 14 17:33:07 2013 +0000
    92.2 +++ b/test/compiler/8009761/Test8009761.java	Thu May 16 13:47:55 2013 -0700
    92.3 @@ -25,7 +25,7 @@
    92.4   * @test
    92.5   * @bug 8009761
    92.6   * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
    92.7 - * @run main/othervm -Xmixed -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8009761
    92.8 + * @run main/othervm -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
    92.9   *
   92.10   */
   92.11  
   92.12 @@ -249,7 +249,7 @@
   92.13              System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count);
   92.14              System.exit(97);
   92.15          } else {
   92.16 -            System.out.println("PASSED");
   92.17 +            System.out.println("PASSED " + c1);
   92.18          }
   92.19      }
   92.20  }
    93.1 --- a/test/compiler/ciReplay/TestSA.sh	Tue May 14 17:33:07 2013 +0000
    93.2 +++ b/test/compiler/ciReplay/TestSA.sh	Thu May 16 13:47:55 2013 -0700
    93.3 @@ -77,10 +77,11 @@
    93.4          "replay data wasn't generated by SA"
    93.5  fi
    93.6  
    93.7 -diff --brief ${replay_data} replay_vm.txt
    93.8 -if [ $? -ne 0 ]
    93.9 +diff ${replay_data} replay_vm.txt > replay.diff 2>&1
   93.10 +if [ -s replay.diff ]
   93.11  then
   93.12 -    echo WARNING: replay.txt from SA != replay.txt from VM
   93.13 +    echo WARNING: replay.txt from SA != replay.txt from VM:
   93.14 +    cat replay.diff
   93.15  fi
   93.16  
   93.17  common_tests 10 
    94.1 --- a/test/compiler/ciReplay/common.sh	Tue May 14 17:33:07 2013 +0000
    94.2 +++ b/test/compiler/ciReplay/common.sh	Thu May 16 13:47:55 2013 -0700
    94.3 @@ -182,8 +182,11 @@
    94.4  # crash vm in compiler thread with generation replay data and 'small' dump-file
    94.5  # $@ - additional vm opts
    94.6  generate_replay() {
    94.7 -    # enable core dump
    94.8 -    ulimit -c unlimited
    94.9 +    if [ $VM_OS != "windows" ]
   94.10 +    then
   94.11 +        # enable core dump
   94.12 +        ulimit -c unlimited
   94.13 +    fi
   94.14  
   94.15      cmd="${JAVA} ${TESTVMOPTS} $@ \
   94.16              -Xms8m \
   94.17 @@ -206,29 +209,24 @@
   94.18      echo GENERATION OF REPLAY.TXT:
   94.19      echo $cmd
   94.20  
   94.21 -    ${cmd} 2>&1 > crash.out
   94.22 +    ${cmd} > crash.out 2>&1
   94.23      
   94.24      core_locations=`grep -i core crash.out | grep "location:" | \
   94.25              sed -e 's/.*location: //'`
   94.26      rm crash.out 
   94.27      # processing core locations for *nix
   94.28 -    if [ $OS != "windows" ]
   94.29 +    if [ $VM_OS != "windows" ]
   94.30      then
   94.31          # remove 'or' between '/core.<pid>' and 'core'
   94.32          core_locations=`echo $core_locations | \
   94.33                  sed -e 's/\([^ ]*\) or \([^ ]*\)/\1 \2/'`
   94.34          # add <core_path>/core.<pid> core.<pid>
   94.35 -        core=`echo $core_locations | awk '{print $1}'`
   94.36 -        dir=`dirname $core`
   94.37 -        core=`basename $core`
   94.38 -        if [ -n ${core} ]
   94.39 +        core_with_dir=`echo $core_locations | awk '{print $1}'`
   94.40 +        dir=`dirname $core_with_dir`
   94.41 +        core_with_pid=`echo $core_locations | awk '{print $2}'`
   94.42 +        if [ -n ${core_with_pid} ]
   94.43          then
   94.44 -            core_locations="$core_locations $dir${FS}$core"
   94.45 -        fi
   94.46 -        core=`echo $core_locations | awk '{print $2}'`
   94.47 -        if [ -n ${core} ]
   94.48 -        then
   94.49 -            core_locations="$core_locations $dir${FS}$core"
   94.50 +            core_locations="$core_locations $dir${FS}$core_with_pid $core_with_pid"
   94.51          fi
   94.52      fi
   94.53  

mercurial