make/hotspot/lib/JvmDtraceObjects.gmk
author tschatzl
Thu, 06 Dec 2018 15:44:13 +0100
changeset 52876 2d17750d41e7
parent 49982 9042ffe5b7fe
child 53683 48ff68e2fe5c
permissions -rw-r--r--
8214791: Consistently name gc files containing VM operations Summary: Name all gc files containing VM operations according to a <gc>VMOperations.?pp. Reviewed-by: coleenp, dholmes

#
# Copyright (c) 2013, 2018, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

ifeq ($(call check-jvm-feature, dtrace), true)
  ifeq ($(OPENJDK_TARGET_OS), solaris)

    ############################################################################
    # Integrate with libjvm. Here we generate two object files which are
    # linked with libjvm.so. This step is complicated from a dependency
    # perspective. We add these two files to the linking of libjvm using
    # EXTRA_OBJECT_FILES, but they need to be created outside the call to
    # SetupNativeCompilation. Also, one of the files is dependent on compiled
    # object files from the libjvm compilation, so this generation must happen
    # as a part of the libjvm compilation.

    DTRACE_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace.o
    DTRACE_JHELPER_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace_jhelper.o

    DTRACE_EXTRA_OBJECT_FILES := $(DTRACE_OBJ) $(DTRACE_JHELPER_OBJ)

    ############################################################################
    # Generate DTRACE_OBJ which is linked with libjvm.so. It depends on a set of
    # object files from the compilation.

    # Concatenate all *.d files into a single file
    DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \
        hotspot_jni.d \
        hotspot.d \
        hs_private.d \
    )

    $(JVM_OUTPUTDIR)/objs/dtrace.d: $(DTRACE_SOURCE_FILES)
	$(call LogInfo, Generating $(@F))
	$(call MakeDir, $(@D))
	$(CAT) $^ > $@

    DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \
        ciEnv.o \
        classLoadingService.o \
        compileBroker.o \
        gcVMOperations.o \
        hashtable.o \
        instanceKlass.o \
        java.o \
        jni.o \
        jvm.o \
        memoryManager.o \
        nmethod.o \
        objectMonitor.o \
        runtimeService.o \
        sharedRuntime.o \
        synchronizer.o \
        thread.o \
        unsafe.o \
        vmThread.o \
    )

    ifeq ($(call check-jvm-feature, cmsgc), true)
      DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
          cmsVMOperations.o \
      )
    endif

    ifeq ($(call check-jvm-feature, parallelgc), true)
      DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
          psVMOperations.o \
      )
    endif

    DTRACE_FLAGS := -64 -G
    DTRACE_CPP_FLAGS := -D_LP64

    # Make sure we run our selected compiler for preprocessing instead of letting
    # the dtrace tool pick it on it's own.
    $(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
	$(call LogInfo, Generating $(@F) from $(<F) and object files)
	$(call MakeDir, $(DTRACE_SUPPORT_DIR))
	$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
	    ($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
	$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
	    -s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))

    ############################################################################
    # Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so.

    JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d

    # jhelper.d includes JvmOffsetsIndex.h which was created by the gensrc step.
    DTRACE_GENSRC_DIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/dtracefiles
    JVM_OFFSETS_INDEX_H := $(DTRACE_GENSRC_DIR)/JvmOffsetsIndex.h

    # Unfortunately dtrace generates incorrect types for some symbols in
    # dtrace_jhelper.o, resulting in "warning: symbol X has differing types"
    # See JDK-6890703 for details.
    # We work around this by fixing the types for these symbols using elfedit,
    # after dtrace has generated the .o file.
    GetElfeditCommands = \
      $(foreach symbol, \
          $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }'), \
          -e 'sym:st_type $(symbol) 1')

    # Make sure we run our selected compiler for preprocessing instead of letting
    # the dtrace tool pick it on it's own.
    $(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
	$(call LogInfo, Running dtrace for $(<F))
	$(call MakeDir, $(DTRACE_SUPPORT_DIR))
	$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
	    ($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_GENSRC_DIR) $^ \
	    > $(DTRACE_SUPPORT_DIR)/$(@F).d))
	$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
	    -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
        ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc)
	  $(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
        endif

  endif
endif