Mercurial > hg > openjdk > bsd-port > hotspot
changeset 2997:fc76ef829cd3
. Changes to BSD specific files to match changes to the Linux specific files
plus additional BSD support for some altered files it was missing from.
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java Sun Mar 04 16:11:11 2012 -0800 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java Sun Mar 04 16:13:13 2012 -0800 @@ -30,6 +30,7 @@ import sun.jvm.hotspot.debugger.amd64.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.amd64.*; +import sun.jvm.hotspot.runtime.x86.*; import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; @@ -80,11 +81,11 @@ if (fp == null) { return null; // no information } - return new AMD64Frame(thread.getLastJavaSP(), fp); + return new X86Frame(thread.getLastJavaSP(), fp); } public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { - return new AMD64RegisterMap(thread, updateMap); + return new X86RegisterMap(thread, updateMap); } public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { @@ -95,9 +96,9 @@ return null; } if (guesser.getPC() == null) { - return new AMD64Frame(guesser.getSP(), guesser.getFP()); + return new X86Frame(guesser.getSP(), guesser.getFP()); } else { - return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); + return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); } }
--- a/make/bsd/Makefile Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/Makefile Sun Mar 04 16:13:13 2012 -0800 @@ -210,6 +210,7 @@ BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION) JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) +BUILDTREE_VARS += OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) BUILDTREE = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS) @@ -230,7 +231,7 @@ # Solaris 2.5.1, 2.6). # Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok. -#SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7% +#SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% DISABLE_HOTSPOT_OS_VERSION_CHECK = ok OS_VERSION := $(shell uname -r) EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
--- a/make/bsd/makefiles/build_vm_def.sh Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/build_vm_def.sh Sun Mar 04 16:13:13 2012 -0800 @@ -7,6 +7,10 @@ NM=nm fi -$NM --defined-only $* | awk ' - { if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";" } - ' +$NM --defined-only $* \ + | awk '{ + if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";" + if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";" + if ($3 ~ /^_ZN9Arguments17SharedArchivePathE$/) print "\t" $3 ";" + }' \ + | sort -u
--- a/make/bsd/makefiles/buildtree.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/buildtree.make Sun Mar 04 16:13:13 2012 -0800 @@ -233,6 +233,10 @@ echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ [ -n "$(CFLAGS_BROWSE)" ] && \ echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \ + [ -n "$(OBJCOPY)" ] && \ + echo && echo "OBJCOPY = $(OBJCOPY)"; \ + [ -n "$(STRIP_POLICY)" ] && \ + echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \ [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \ echo && \ echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
--- a/make/bsd/makefiles/defs.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/defs.make Sun Mar 04 16:13:13 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -124,6 +124,67 @@ HS_ARCH = ppc endif +# determine if HotSpot is being built in JDK6 or earlier version +JDK6_OR_EARLIER=0 +ifeq "$(shell expr \( '$(JDK_MAJOR_VERSION)' != '' \& '$(JDK_MINOR_VERSION)' != '' \& '$(JDK_MICRO_VERSION)' != '' \))" "1" + # if the longer variable names (newer build style) are set, then check those + ifeq "$(shell expr \( $(JDK_MAJOR_VERSION) = 1 \& $(JDK_MINOR_VERSION) \< 7 \))" "1" + JDK6_OR_EARLIER=1 + endif +else + # the longer variables aren't set so check the shorter variable names + ifeq "$(shell expr \( '$(JDK_MAJOR_VER)' = 1 \& '$(JDK_MINOR_VER)' \< 7 \))" "1" + JDK6_OR_EARLIER=1 + endif +endif + +ifeq ($(JDK6_OR_EARLIER),0) + # Full Debug Symbols is supported on JDK7 or newer + + # Default OBJCOPY comes from GNU Binutils on Bsd: + DEF_OBJCOPY=/usr/bin/objcopy + ifdef CROSS_COMPILE_ARCH + # don't try to generate .debuginfo files when cross compiling + _JUNK_ := $(shell \ + echo >&2 "INFO: cross compiling for ARCH $(CROSS_COMPILE_ARCH)," \ + "skipping .debuginfo generation.") + OBJCOPY= + else + OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) + ifneq ($(ALT_OBJCOPY),) + _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)") + # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path + OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) + endif + endif + + ifeq ($(OBJCOPY),) + _JUNK_ := $(shell \ + echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.") + else + _JUNK_ := $(shell \ + echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.") + + # Library stripping policies for .debuginfo configs: + # all_strip - strips everything from the library + # min_strip - strips most stuff from the library; leaves minimum symbols + # no_strip - does not strip the library at all + # + # Oracle security policy requires "all_strip". A waiver was granted on + # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. + # + DEF_STRIP_POLICY="min_strip" + ifeq ($(ALT_STRIP_POLICY),) + STRIP_POLICY=$(DEF_STRIP_POLICY) + else + STRIP_POLICY=$(ALT_STRIP_POLICY) + endif + + _JUNK_ := $(shell \ + echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)") + endif +endif + JDK_INCLUDE_SUBDIR=bsd # Library suffix @@ -141,18 +202,28 @@ # client and server subdirectories have symbolic links to ../libjsig.so EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX) +ifneq ($(OBJCOPY),) + EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.debuginfo +endif + EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server +EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client ifndef BUILD_CLIENT_ONLY EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX) + ifneq ($(OBJCOPY),) + EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo + endif endif ifneq ($(ZERO_BUILD), true) ifeq ($(ARCH_DATA_MODEL), 32) - EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) + ifneq ($(OBJCOPY),) + EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo + endif endif endif @@ -162,6 +233,10 @@ $(EXPORT_LIB_DIR)/sa-jdi.jar ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \ $(EXPORT_LIB_DIR)/sa-jdi.jar +ifneq ($(OBJCOPY),) + ADD_SA_BINARIES/x86 += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo + ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo +endif ADD_SA_BINARIES/ppc = ADD_SA_BINARIES/ia64 = ADD_SA_BINARIES/arm =
--- a/make/bsd/makefiles/gcc.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/gcc.make Sun Mar 04 16:13:13 2012 -0800 @@ -248,6 +248,26 @@ DEBUG_CFLAGS += -gstabs endif +ifneq ($(OBJCOPY),) + FASTDEBUG_CFLAGS/ia64 = -g + FASTDEBUG_CFLAGS/amd64 = -g + FASTDEBUG_CFLAGS/arm = -g + FASTDEBUG_CFLAGS/ppc = -g + FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) + ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),) + FASTDEBUG_CFLAGS += -gstabs + endif + + OPT_CFLAGS/ia64 = -g + OPT_CFLAGS/amd64 = -g + OPT_CFLAGS/arm = -g + OPT_CFLAGS/ppc = -g + OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH)) + ifeq ($(OPT_CFLAGS/$(BUILDARCH)),) + OPT_CFLAGS += -gstabs + endif +endif + # DEBUG_BINARIES overrides everything, use full -g debug information ifeq ($(DEBUG_BINARIES), true) DEBUG_CFLAGS = -g @@ -265,3 +285,9 @@ ifdef MINIMIZE_RAM_USAGE CFLAGS += -DMINIMIZE_RAM_USAGE endif + +ifdef CROSS_COMPILE_ARCH + STRIP = $(ALT_COMPILER_PATH)/strip +else + STRIP = strip +endif
--- a/make/bsd/makefiles/jsig.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/jsig.make Sun Mar 04 16:13:13 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -36,9 +36,13 @@ LIBJSIG_G = lib$(JSIG_G).so endif +LIBJSIG_DEBUGINFO = lib$(JSIG).debuginfo +LIBJSIG_G_DEBUGINFO = lib$(JSIG_G).debuginfo + JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm -DEST_JSIG = $(JDK_LIBDIR)/$(LIBJSIG) +DEST_JSIG = $(JDK_LIBDIR)/$(LIBJSIG) +DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO) LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig @@ -59,9 +63,24 @@ $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $< $(QUIETLY) [ -f $(LIBJSIG_G) ] || { ln -s $@ $(LIBJSIG_G); } +ifneq ($(OBJCOPY),) + $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO) + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ + ifeq ($(STRIP_POLICY),all_strip) + $(QUIETLY) $(STRIP) $@ + else + ifeq ($(STRIP_POLICY),min_strip) + $(QUIETLY) $(STRIP) -g $@ + # implied else here is no stripping at all + endif + endif + [ -f $(LIBJSIG_G_DEBUGINFO) ] || { ln -s $(LIBJSIG_DEBUGINFO) $(LIBJSIG_G_DEBUGINFO); } +endif install_jsig: $(LIBJSIG) @echo "Copying $(LIBJSIG) to $(DEST_JSIG)" + $(QUIETLY) test -f $(LIBJSIG_DEBUGINFO) && \ + cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO) $(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done" .PHONY: install_jsig
--- a/make/bsd/makefiles/mapfile-vers-debug Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/mapfile-vers-debug Sun Mar 04 16:13:13 2012 -0800 @@ -244,24 +244,6 @@ JVM_Yield; JVM_handle_bsd_signal; - # Old reflection routines - # These do not need to be present in the product build in JDK 1.4 - # but their code has not been removed yet because there will not - # be a substantial code savings until JVM_InvokeMethod and - # JVM_NewInstanceFromConstructor can also be removed; see - # reflectionCompat.hpp. - JVM_GetClassConstructor; - JVM_GetClassConstructors; - JVM_GetClassField; - JVM_GetClassFields; - JVM_GetClassMethod; - JVM_GetClassMethods; - JVM_GetField; - JVM_GetPrimitiveField; - JVM_NewInstance; - JVM_SetField; - JVM_SetPrimitiveField; - # debug JVM JVM_AccessVMBooleanFlag; JVM_AccessVMIntFlag;
--- a/make/bsd/makefiles/mapfile-vers-product Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/mapfile-vers-product Sun Mar 04 16:13:13 2012 -0800 @@ -244,24 +244,6 @@ JVM_Yield; JVM_handle_bsd_signal; - # Old reflection routines - # These do not need to be present in the product build in JDK 1.4 - # but their code has not been removed yet because there will not - # be a substantial code savings until JVM_InvokeMethod and - # JVM_NewInstanceFromConstructor can also be removed; see - # reflectionCompat.hpp. - JVM_GetClassConstructor; - JVM_GetClassConstructors; - JVM_GetClassField; - JVM_GetClassFields; - JVM_GetClassMethod; - JVM_GetClassMethods; - JVM_GetField; - JVM_GetPrimitiveField; - JVM_NewInstance; - JVM_SetField; - JVM_SetPrimitiveField; - # miscellaneous functions jio_fprintf; jio_printf;
--- a/make/bsd/makefiles/product.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/product.make Sun Mar 04 16:13:13 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -46,13 +46,10 @@ # use -g to strip library as -x will discard its symbol table; -x is fine for # executables. -ifdef CROSS_COMPILE_ARCH - STRIP = $(ALT_COMPILER_PATH)/strip -else - STRIP = strip -endif +# Note: these macros are not used in .debuginfo configs STRIP_LIBJVM = $(STRIP) -g $@ || exit 1; STRIP_AOUT = $(STRIP) -x $@ || exit 1; -# Don't strip in VM build; JDK build will strip libraries later +# If we can create .debuginfo files, then the VM is stripped in vm.make +# and this macro is not used. # LINK_LIB.CC/POST_HOOK += $(STRIP_$(LINK_INTO))
--- a/make/bsd/makefiles/saproc.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/saproc.make Sun Mar 04 16:13:13 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,9 @@ LIBSAPROC_G = lib$(SAPROC_G).so endif +LIBSAPROC_DEBUGINFO = lib$(SAPROC).debuginfo +LIBSAPROC_G_DEBUGINFO = lib$(SAPROC_G).debuginfo + AGENT_DIR = $(GAMMADIR)/agent SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family) @@ -55,7 +58,8 @@ SAMAPFILE = $(SASRCDIR)/mapfile -DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC) +DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC) +DEST_SAPROC_DEBUGINFO = $(JDK_LIBDIR)/$(LIBSAPROC_DEBUGINFO) # DEBUG_BINARIES overrides everything, use full -g debug information ifeq ($(DEBUG_BINARIES), true) @@ -95,10 +99,25 @@ -o $@ \ $(SALIBS) $(QUIETLY) [ -f $(LIBSAPROC_G) ] || { ln -s $@ $(LIBSAPROC_G); } +ifneq ($(OBJCOPY),) + $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO) + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@ + ifeq ($(STRIP_POLICY),all_strip) + $(QUIETLY) $(STRIP) $@ + else + ifeq ($(STRIP_POLICY),min_strip) + $(QUIETLY) $(STRIP) -g $@ + # implied else here is no stripping at all + endif + endif + [ -f $(LIBSAPROC_G_DEBUGINFO) ] || { ln -s $(LIBSAPROC_DEBUGINFO) $(LIBSAPROC_G_DEBUGINFO); } +endif install_saproc: $(BUILDLIBSAPROC) $(QUIETLY) if [ -e $(LIBSAPROC) ] ; then \ echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)"; \ + test -f $(LIBSAPROC_DEBUGINFO) && \ + cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \ cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done"; \ fi
--- a/make/bsd/makefiles/vm.make Sun Mar 04 16:11:11 2012 -0800 +++ b/make/bsd/makefiles/vm.make Sun Mar 04 16:13:13 2012 -0800 @@ -60,10 +60,16 @@ # The order is important for the precompiled headers to work. INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%) -ifeq (${VERSION}, debug) +# SYMFLAG is used by {jsig,saproc}.make +ifneq ($(OBJCOPY),) + # always build with debug info when we can create .debuginfo files SYMFLAG = -g else - SYMFLAG = + ifeq (${VERSION}, debug) + SYMFLAG = -g + else + SYMFLAG = + endif endif # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined @@ -136,6 +142,9 @@ LIBJVM_G = lib$(JVM)$(G_SUFFIX).so endif +LIBJVM_DEBUGINFO = lib$(JVM).debuginfo +LIBJVM_G_DEBUGINFO = lib$(JVM)$(G_SUFFIX).debuginfo + SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt SOURCE_PATHS=\ @@ -301,11 +310,30 @@ rm -f $@.1; ln -s $@ $@.1; \ [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \ } +ifeq ($(CROSS_COMPILE_ARCH),) + ifneq ($(OBJCOPY),) + $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) + $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ + ifeq ($(STRIP_POLICY),all_strip) + $(QUIETLY) $(STRIP) $@ + else + ifeq ($(STRIP_POLICY),min_strip) + $(QUIETLY) $(STRIP) -g $@ + # implied else here is no stripping at all + endif + endif + $(QUIETLY) [ -f $(LIBJVM_G_DEBUGINFO) ] || ln -s $(LIBJVM_DEBUGINFO) $(LIBJVM_G_DEBUGINFO) + endif +endif -DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM) +DEST_SUBDIR = $(JDK_LIBDIR)/$(VM_SUBDIR) +DEST_JVM = $(DEST_SUBDIR)/$(LIBJVM) +DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO) install_jvm: $(LIBJVM) @echo "Copying $(LIBJVM) to $(DEST_JVM)" + $(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \ + cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) $(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done" #----------------------------------------------------------------------
--- a/src/os/bsd/vm/os_bsd.cpp Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os/bsd/vm/os_bsd.cpp Sun Mar 04 16:13:13 2012 -0800 @@ -192,7 +192,35 @@ sigset_t SR_sigset; -//////////////////////////////////////////////////////////////////////////////// +#ifdef JAVASE_EMBEDDED +class MemNotifyThread: public Thread { + friend class VMStructs; + public: + virtual void run(); + + private: + static MemNotifyThread* _memnotify_thread; + int _fd; + + public: + + // Constructor + MemNotifyThread(int fd); + + // Tester + bool is_memnotify_thread() const { return true; } + + // Printing + char* name() const { return (char*)"Bsd MemNotify Thread"; } + + // Returns the single instance of the MemNotifyThread + static MemNotifyThread* memnotify_thread() { return _memnotify_thread; } + + // Create and start the single instance of MemNotifyThread + static void start(); +}; +#endif // JAVASE_EMBEDDED + // utility functions static int SR_initialize(); @@ -2303,6 +2331,14 @@ #endif } +void os::pd_print_cpu_info(outputStream* st) { + st->print("\n/proc/cpuinfo:\n"); + if (!_print_ascii_file("/proc/cpuinfo", st)) { + st->print(" <Not Available>"); + } + st->cr(); +} + void os::print_memory_info(outputStream* st) { st->print("Memory:"); @@ -2703,7 +2739,13 @@ #else uintptr_t res = (uintptr_t) ::mmap(addr, size, prot, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0); - return res != (uintptr_t) MAP_FAILED; + if (res != (uintptr_t) MAP_FAILED) { + if (UseNUMAInterleaving) { + numa_make_global(addr, size); + } + return true; + } + return false; #endif } @@ -2728,11 +2770,21 @@ (uintptr_t) ::mmap(addr, size, prot, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB, -1, 0); - return res != (uintptr_t) MAP_FAILED; + if (res != (uintptr_t) MAP_FAILED) { + if (UseNUMAInterleaving) { + numa_make_global(addr, size); + } + return true; + } + // Fall through and try to use small pages } #endif - return commit_memory(addr, size, exec); + if (commit_memory(addr, size, exec)) { + realign_memory(addr, size, alignment_hint); + return true; + } + return false; } void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { @@ -2746,7 +2798,7 @@ } void os::free_memory(char *addr, size_t bytes) { - ::madvise(addr, bytes, MADV_DONTNEED); + commit_memory(addr, bytes, false); } void os::numa_make_global(char *addr, size_t bytes) { @@ -2782,6 +2834,31 @@ } #ifndef _ALLBSD_SOURCE +int os::Bsd::sched_getcpu_syscall(void) { + unsigned int cpu; + int retval = -1; + +#if defined(IA32) +# ifndef SYS_getcpu +# define SYS_getcpu 318 +# endif + retval = syscall(SYS_getcpu, &cpu, NULL, NULL); +#elif defined(AMD64) +// Unfortunately we have to bring all these macros here from vsyscall.h +// to be able to compile on old bsdes. +# define __NR_vgetcpu 2 +# define VSYSCALL_START (-10UL << 20) +# define VSYSCALL_SIZE 1024 +# define VSYSCALL_ADDR(vsyscall_nr) +(VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr)) + typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache); + vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu); + retval = vgetcpu(&cpu, NULL, NULL); +#endif + + return (retval == -1) ? retval : cpu; +} + // Something to do with the numa-aware allocator needs these symbols extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } extern "C" JNIEXPORT void numa_error(char *where) { } @@ -2805,6 +2882,10 @@ set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, dlsym(RTLD_DEFAULT, "sched_getcpu"))); + // If it's not, try a direct syscall. + if (sched_getcpu() == -1) + set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, (void*)&sched_getcpu_syscall)); + if (sched_getcpu() != -1) { // Does it work? void *handle = dlopen("libnuma.so.1", RTLD_LAZY); if (handle != NULL) { @@ -3233,6 +3314,10 @@ return NULL; } + if ((addr != NULL) && UseNUMAInterleaving) { + numa_make_global(addr, bytes); + } + return addr; } @@ -4531,7 +4616,16 @@ } // this is called at the end of vm_initialization -void os::init_3(void) { } +void os::init_3(void) +{ +#ifdef JAVASE_EMBEDDED + // Start the MemNotifyThread + if (LowMemoryProtection) { + MemNotifyThread::start(); + } + return; +#endif +} // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { @@ -5704,3 +5798,78 @@ return true; } + +#ifdef JAVASE_EMBEDDED +// +// A thread to watch the '/dev/mem_notify' device, which will tell us when the OS is running low on memory. +// +MemNotifyThread* MemNotifyThread::_memnotify_thread = NULL; + +// ctor +// +MemNotifyThread::MemNotifyThread(int fd): Thread() { + assert(memnotify_thread() == NULL, "we can only allocate one MemNotifyThread"); + _fd = fd; + + if (os::create_thread(this, os::os_thread)) { + _memnotify_thread = this; + os::set_priority(this, NearMaxPriority); + os::start_thread(this); + } +} + +// Where all the work gets done +// +void MemNotifyThread::run() { + assert(this == memnotify_thread(), "expected the singleton MemNotifyThread"); + + // Set up the select arguments + fd_set rfds; + if (_fd != -1) { + FD_ZERO(&rfds); + FD_SET(_fd, &rfds); + } + + // Now wait for the mem_notify device to wake up + while (1) { + // Wait for the mem_notify device to signal us.. + int rc = select(_fd+1, _fd != -1 ? &rfds : NULL, NULL, NULL, NULL); + if (rc == -1) { + perror("select!\n"); + break; + } else if (rc) { + //ssize_t free_before = os::available_memory(); + //tty->print ("Notified: Free: %dK \n",os::available_memory()/1024); + + // The kernel is telling us there is not much memory left... + // try to do something about that + + // If we are not already in a GC, try one. + if (!Universe::heap()->is_gc_active()) { + Universe::heap()->collect(GCCause::_allocation_failure); + + //ssize_t free_after = os::available_memory(); + //tty->print ("Post-Notify: Free: %dK\n",free_after/1024); + //tty->print ("GC freed: %dK\n", (free_after - free_before)/1024); + } + // We might want to do something like the following if we find the GC's are not helping... + // Universe::heap()->size_policy()->set_gc_time_limit_exceeded(true); + } + } +} + +// +// See if the /dev/mem_notify device exists, and if so, start a thread to monitor it. +// +void MemNotifyThread::start() { + int fd; + fd = open ("/dev/mem_notify", O_RDONLY, 0); + if (fd < 0) { + return; + } + + if (memnotify_thread() == NULL) { + new MemNotifyThread(fd); + } +} +#endif // JAVASE_EMBEDDED
--- a/src/os/bsd/vm/os_bsd.hpp Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os/bsd/vm/os_bsd.hpp Sun Mar 04 16:13:13 2012 -0800 @@ -293,6 +293,7 @@ static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; } static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; } static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; } + static int sched_getcpu_syscall(void); public: static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; } static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
--- a/src/os_cpu/bsd_x86/vm/assembler_bsd_x86.cpp Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os_cpu/bsd_x86/vm/assembler_bsd_x86.cpp Sun Mar 04 16:13:13 2012 -0800 @@ -33,6 +33,28 @@ call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); } +#ifdef MINIMIZE_RAM_USAGE + +void MacroAssembler::get_thread(Register thread) { + // call pthread_getspecific + // void * pthread_getspecific(pthread_key_t key); + if (thread != rax) push(rax); + push(rcx); + push(rdx); + + push(ThreadLocalStorage::thread_index()); + call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific))); + increment(rsp, wordSize); + + pop(rdx); + pop(rcx); + if (thread != rax) { + mov(thread, rax); + pop(rax); + } +} + +#else void MacroAssembler::get_thread(Register thread) { movl(thread, rsp); shrl(thread, PAGE_SHIFT); @@ -43,6 +65,7 @@ movptr(thread, tls); } +#endif // MINIMIZE_RAM_USAGE #else void MacroAssembler::int3() { call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
--- a/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad Sun Mar 04 16:13:13 2012 -0800 @@ -154,7 +154,7 @@ uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { - return 5; + return MachNode::size(ra_); } %}
--- a/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad Sun Mar 04 16:13:13 2012 -0800 @@ -167,7 +167,8 @@ } uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const { - return 5; + // distance could be far and requires load and call through register + return MachNode::size(ra_); } %}
--- a/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp Sun Mar 04 16:13:13 2012 -0800 @@ -52,25 +52,20 @@ // MADV_DONTNEED on Bsd keeps the virtual memory mapping, but zaps the // physical memory page (i.e. similar to MADV_FREE on Solaris). -#ifndef AMD64 +#if !defined(AMD64) && !defined(MINIMIZE_RAM_USAGE) Thread* ThreadLocalStorage::_sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)]; -#endif // !AMD64 void ThreadLocalStorage::generate_code_for_get_thread() { // nothing we can do here for user-level thread } void ThreadLocalStorage::pd_init() { -#ifndef AMD64 assert(align_size_down(os::vm_page_size(), PAGE_SIZE) == os::vm_page_size(), "page size must be multiple of PAGE_SIZE"); -#endif // !AMD64 } void ThreadLocalStorage::pd_set_thread(Thread* thread) { os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); - -#ifndef AMD64 address stack_top = os::current_stack_base(); size_t stack_size = os::current_stack_size(); @@ -88,5 +83,17 @@ "thread exited without detaching from VM??"); _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread; } -#endif // !AMD64 +} +#else + +void ThreadLocalStorage::generate_code_for_get_thread() { + // nothing we can do here for user-level thread } + +void ThreadLocalStorage::pd_init() { +} + +void ThreadLocalStorage::pd_set_thread(Thread* thread) { + os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); +} +#endif // !AMD64 && !MINIMIZE_RAM_USAGE
--- a/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.hpp Sun Mar 04 16:11:11 2012 -0800 +++ b/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.hpp Sun Mar 04 16:13:13 2012 -0800 @@ -27,7 +27,8 @@ // Processor dependent parts of ThreadLocalStorage -#ifndef AMD64 +#if !defined(AMD64) && !defined(MINIMIZE_RAM_USAGE) + // map stack pointer to thread pointer - see notes in threadLS_bsd_x86.cpp #define SP_BITLENGTH 32 #ifndef PAGE_SHIFT @@ -35,22 +36,25 @@ #define PAGE_SIZE (1UL << PAGE_SHIFT) #endif static Thread* _sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)]; -#endif // !AMD64 public: -#ifndef AMD64 static Thread** sp_map_addr() { return _sp_map; } -#endif // !AMD64 static Thread* thread() { -#ifdef AMD64 - return (Thread*) os::thread_local_storage_at(thread_index()); -#else uintptr_t sp; __asm__ volatile ("movl %%esp, %0" : "=r" (sp)); return _sp_map[sp >> PAGE_SHIFT]; -#endif // AMD64 } +#else + +public: + + static Thread* thread() { + return (Thread*) os::thread_local_storage_at(thread_index()); + } + +#endif // AMD64 || MINIMIZE_RAM_USAGE + #endif // OS_CPU_BSD_X86_VM_THREADLS_BSD_X86_HPP
--- a/test/compiler/5091921/Test7005594.sh Sun Mar 04 16:11:11 2012 -0800 +++ b/test/compiler/5091921/Test7005594.sh Sun Mar 04 16:13:13 2012 -0800 @@ -71,6 +71,9 @@ # Windows/MKS MEM=`"$ROOTDIR/mksnt/sysinf" memory -v | grep "Total Physical Memory: " | sed 's/Total Physical Memory: *//g'` MEM="$(($machine_memory / 1024))" +elif [ -n `sysctl -n hw.physmem64 2> /dev/null` -o -n `sysctl -n hw.physmem 2> /dev/null` ]; + # BSD + MEM=`sysctl -n hw.physmem64 2> /dev/null || sysctl -n hw.physmem) | awk '{print int($$NF / 1048576); }'` else echo "Unable to determine amount of physical memory on the machine" fi