make/hotspot/gensrc/GensrcJvmti.gmk
author egahlin
Tue, 15 May 2018 20:24:34 +0200
changeset 50113 caf115bb98ad
parent 48009 9fe60f7e366f
child 53995 ecc2bcc3beb0
child 57155 ba61956ea598
permissions -rw-r--r--
8199712: Flight Recorder Reviewed-by: coleenp, ihse, erikj, dsamersoff, mseledtsov, egahlin, mgronlun Contributed-by: erik.gahlin@oracle.com, markus.gronlund@oracle.com

#
# 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.
#

$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcJvmti.gmk))

################################################################################
# Build tools needed for the JVMTI source code generation

JVMTI_TOOLS_SRCDIR := $(TOPDIR)/src/hotspot/share/prims
JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti

$(eval $(call SetupJavaCompiler, GENERATE_OLDBYTECODE, \
    JAVAC := $(JAVAC), \
    FLAGS := $(DISABLE_WARNINGS), \
    SERVER_DIR := $(SJAVAC_SERVER_DIR), \
    SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
    DISABLE_SJAVAC := true, \
))

$(eval $(call SetupJavaCompilation, BUILD_JVMTI_TOOLS, \
    SETUP := GENERATE_OLDBYTECODE, \
    SRC := $(JVMTI_TOOLS_SRCDIR), \
    INCLUDE_FILES := jvmtiGen.java jvmtiEnvFill.java, \
    BIN := $(JVMTI_TOOLS_OUTPUTDIR), \
))

TOOL_JVMTI_GEN := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiGen
TOOL_JVMTI_ENV_FILL := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiEnvFill

################################################################################
# Setup make rules for an xml transform for jvmti file generation.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name. This name is
# also used as the name of the output file.
#
# Remaining parameters are named arguments. These include:
#   XML_FILE -- The input source file to use
#   XSL_FILE -- The xsl file to use
#   OUTPUT_DIR -- The directory to put the generated file in
#   ARGS -- Additional arguments to the jvmtiGen tool
#   DEPS -- Additional dependencies
SetupXslTransform = $(NamedParamsMacroTemplate)
define SetupXslTransformBody
  $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
	$$(call LogInfo, Generating $$(@F))
	$$(call MakeDir, $$(@D))
	$$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
	    -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
        # jvmtiGen does not return error code properly on fail.
        # NOTE: We should really fix jvmtiGen.java instead.
	test -f $$@

  TARGETS += $$($1_OUTPUT_DIR)/$1
endef

################################################################################
# Create JVMTI files in gensrc/jvmtifiles

JVMTI_SRCDIR := $(TOPDIR)/src/hotspot/share/prims
JVMTI_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles

# Setup rule for generating a jvmti file
#
# $1 is generated source file name in $(JVMTI_OUTPUTDIR)
# $2 is XSL file to use in $(JVMTI_SRCDIR)
# $3 is optional extra arguments to jvmtiGen
define SetupJvmtiGeneration
  $$(eval $$(call SetupXslTransform, $1, \
      XML_FILE := $$(JVMTI_SRCDIR)/jvmti.xml, \
      XSL_FILE := $$(JVMTI_SRCDIR)/$(strip $2), \
      OUTPUT_DIR := $$(JVMTI_OUTPUTDIR), \
      ARGS := $3, \
      DEPS := $$(JVMTI_SRCDIR)/jvmtiLib.xsl, \
  ))
endef

$(eval $(call SetupJvmtiGeneration, jvmtiEnter.cpp, jvmtiEnter.xsl, \
    -PARAM interface jvmti))
$(eval $(call SetupJvmtiGeneration, jvmtiEnterTrace.cpp, jvmtiEnter.xsl, \
    -PARAM interface jvmti -PARAM trace Trace))
$(eval $(call SetupJvmtiGeneration, jvmtiEnv.hpp, jvmtiHpp.xsl))
$(eval $(call SetupJvmtiGeneration, jvmti.h, jvmtiH.xsl))
$(eval $(call SetupJvmtiGeneration, jvmti.html, jvmti.xsl))

JVMTI_BC_SRCDIR := $(TOPDIR)/src/hotspot/share/interpreter

$(eval $(call SetupXslTransform, bytecodeInterpreterWithChecks.cpp, \
    XML_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xml, \
    XSL_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xsl, \
    OUTPUT_DIR := $(JVMTI_OUTPUTDIR), \
    DEPS := $(JVMTI_BC_SRCDIR)/bytecodeInterpreter.cpp, \
))

################################################################################
# Copy jvmti.h to include dir

# The file is the same regardless of jvm variant. Only let one do the copy.
ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
  $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
      DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
      FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
  ))

  TARGETS += $(COPY_JVMTI_H)
endif