make/hotspot/gensrc/GensrcJvmti.gmk
changeset 47216 71c04702a3d5
parent 42145 11d01e02d9c1
child 47217 72e3ae9a25eb
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 #
       
     2 # Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4 #
       
     5 # This code is free software; you can redistribute it and/or modify it
       
     6 # under the terms of the GNU General Public License version 2 only, as
       
     7 # published by the Free Software Foundation.  Oracle designates this
       
     8 # particular file as subject to the "Classpath" exception as provided
       
     9 # by Oracle in the LICENSE file that accompanied this code.
       
    10 #
       
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14 # version 2 for more details (a copy is included in the LICENSE file that
       
    15 # accompanied this code).
       
    16 #
       
    17 # You should have received a copy of the GNU General Public License version
       
    18 # 2 along with this work; if not, write to the Free Software Foundation,
       
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20 #
       
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22 # or visit www.oracle.com if you need additional information or have any
       
    23 # questions.
       
    24 #
       
    25 
       
    26 $(eval $(call IncludeCustomExtension, hotspot, gensrc/GensrcJvmti.gmk))
       
    27 
       
    28 ################################################################################
       
    29 # Build tools needed for the JVMTI source code generation
       
    30 
       
    31 JVMTI_TOOLS_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/prims
       
    32 JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti
       
    33 
       
    34 $(eval $(call SetupJavaCompiler, GENERATE_OLDBYTECODE, \
       
    35     JAVAC := $(JAVAC), \
       
    36     FLAGS := $(DISABLE_WARNINGS), \
       
    37     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
       
    38     SERVER_JVM := $(SJAVAC_SERVER_JAVA), \
       
    39     DISABLE_SJAVAC := true, \
       
    40 ))
       
    41 
       
    42 $(eval $(call SetupJavaCompilation, BUILD_JVMTI_TOOLS, \
       
    43     SETUP := GENERATE_OLDBYTECODE, \
       
    44     SRC := $(JVMTI_TOOLS_SRCDIR), \
       
    45     INCLUDE_FILES := jvmtiGen.java jvmtiEnvFill.java, \
       
    46     BIN := $(JVMTI_TOOLS_OUTPUTDIR), \
       
    47 ))
       
    48 
       
    49 TOOL_JVMTI_GEN := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiGen
       
    50 TOOL_JVMTI_ENV_FILL := $(JAVA_SMALL) -cp $(JVMTI_TOOLS_OUTPUTDIR) jvmtiEnvFill
       
    51 
       
    52 ################################################################################
       
    53 # Setup make rules for an xml transform for jvmti/trace file generation.
       
    54 #
       
    55 # Parameter 1 is the name of the rule. This name is used as variable prefix,
       
    56 # and the targets generated are listed in a variable by that name. This name is
       
    57 # also used as the name of the output file.
       
    58 #
       
    59 # Remaining parameters are named arguments. These include:
       
    60 #   XML_FILE -- The input source file to use
       
    61 #   XSL_FILE -- The xsl file to use
       
    62 #   OUTPUT_DIR -- The directory to put the generated file in
       
    63 #   ARGS -- Additional arguments to the jvmtiGen tool
       
    64 #   DEPS -- Additional dependencies
       
    65 SetupXslTransform = $(NamedParamsMacroTemplate)
       
    66 define SetupXslTransformBody
       
    67   $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
       
    68 	$$(call LogInfo, Generating $$(@F))
       
    69 	$$(call MakeDir, $$(@D))
       
    70 	$$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
       
    71 	    -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
       
    72         # jvmtiGen does not return error code properly on fail.
       
    73         # NOTE: We should really fix jvmtiGen.java instead.
       
    74 	test -f $$@
       
    75 
       
    76   TARGETS += $$($1_OUTPUT_DIR)/$1
       
    77 endef
       
    78 
       
    79 ################################################################################
       
    80 # Create JVMTI files in gensrc/jvmtifiles
       
    81 
       
    82 JVMTI_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/prims
       
    83 JVMTI_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles
       
    84 
       
    85 # Setup rule for generating a jvmti file
       
    86 #
       
    87 # $1 is generated source file name in $(JVMTI_OUTPUTDIR)
       
    88 # $2 is XSL file to use in $(JVMTI_SRCDIR)
       
    89 # $3 is optional extra arguments to jvmtiGen
       
    90 define SetupJvmtiGeneration
       
    91   $$(eval $$(call SetupXslTransform, $1, \
       
    92       XML_FILE := $$(JVMTI_SRCDIR)/jvmti.xml, \
       
    93       XSL_FILE := $$(JVMTI_SRCDIR)/$(strip $2), \
       
    94       OUTPUT_DIR := $$(JVMTI_OUTPUTDIR), \
       
    95       ARGS := $3, \
       
    96       DEPS := $$(JVMTI_SRCDIR)/jvmtiLib.xsl, \
       
    97   ))
       
    98 endef
       
    99 
       
   100 $(eval $(call SetupJvmtiGeneration, jvmtiEnter.cpp, jvmtiEnter.xsl, \
       
   101     -PARAM interface jvmti))
       
   102 $(eval $(call SetupJvmtiGeneration, jvmtiEnterTrace.cpp, jvmtiEnter.xsl, \
       
   103     -PARAM interface jvmti -PARAM trace Trace))
       
   104 $(eval $(call SetupJvmtiGeneration, jvmtiEnv.hpp, jvmtiHpp.xsl))
       
   105 $(eval $(call SetupJvmtiGeneration, jvmti.h, jvmtiH.xsl))
       
   106 $(eval $(call SetupJvmtiGeneration, jvmti.html, jvmti.xsl))
       
   107 $(eval $(call SetupJvmtiGeneration, jvmtiEnvStub.cpp, jvmtiEnv.xsl))
       
   108 
       
   109 JVMTI_BC_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/interpreter
       
   110 
       
   111 $(eval $(call SetupXslTransform, bytecodeInterpreterWithChecks.cpp, \
       
   112     XML_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xml, \
       
   113     XSL_FILE := $(JVMTI_BC_SRCDIR)/bytecodeInterpreterWithChecks.xsl, \
       
   114     OUTPUT_DIR := $(JVMTI_OUTPUTDIR), \
       
   115     DEPS := $(JVMTI_BC_SRCDIR)/bytecodeInterpreter.cpp, \
       
   116 ))
       
   117 
       
   118 # We need $(JVMTI_OUTPUTDIR)/jvmtiEnvStub.cpp (generated above) as input
       
   119 $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp: $(JVMTI_SRCDIR)/jvmtiEnv.cpp \
       
   120     $(JVMTI_OUTPUTDIR)/jvmtiEnvStub.cpp $(BUILD_JVMTI_TOOLS)
       
   121 	$(call LogInfo, Generating $(@F))
       
   122 	$(call MakeDir, $(@D))
       
   123 	$(call ExecuteWithLog, $@, $(TOOL_JVMTI_ENV_FILL) $(JVMTI_SRCDIR)/jvmtiEnv.cpp \
       
   124 	    $(JVMTI_OUTPUTDIR)/jvmtiEnvStub.cpp \
       
   125 	    $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp)
       
   126         # jvmtiEnvFill does not necessarily return an error code on failure.
       
   127         # NOTE: We should really fix jvmtiEnvFill.java instead.
       
   128 	test -f $@
       
   129 
       
   130 TARGETS += $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp
       
   131 
       
   132 ################################################################################
       
   133 # Copy jvmti.h to include dir
       
   134 
       
   135 # The file is the same regardless of jvm variant. Only let one do the copy.
       
   136 ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS)))
       
   137   $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \
       
   138       DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \
       
   139       FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \
       
   140   ))
       
   141 
       
   142   TARGETS += $(COPY_JVMTI_H)
       
   143 endif
       
   144 
       
   145 ################################################################################
       
   146 # Create trace files in gensrc/tracefiles
       
   147 
       
   148 TRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles
       
   149 TRACE_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/trace
       
   150 
       
   151 # Append list of XSL files to search (might have been set by custom extensions)
       
   152 TRACE_XSL_FILES += $(wildcard $(TRACE_SRCDIR)/*.xsl)
       
   153 
       
   154 TRACE_XML ?= $(TRACE_SRCDIR)/trace.xml
       
   155 
       
   156 # Changing these will trigger a rebuild of generated trace files.
       
   157 TRACE_DEPS += \
       
   158     $(TRACE_XML) \
       
   159     $(TRACE_SRCDIR)/tracetypes.xml \
       
   160     $(TRACE_SRCDIR)/tracerelationdecls.xml \
       
   161     $(TRACE_SRCDIR)/traceevents.xml \
       
   162     $(TRACE_SRCDIR)/trace.dtd \
       
   163     $(TRACE_SRCDIR)/xinclude.mod \
       
   164     #
       
   165 
       
   166 # Setup rule for generating a trace file
       
   167 #
       
   168 # $1 is generated source file name in $(TRACE_OUTPUTDIR)
       
   169 define SetupTraceGeneration
       
   170   $$(eval $$(call SetupXslTransform, $1, \
       
   171       XML_FILE := $$(TRACE_XML), \
       
   172       XSL_FILE := $$(firstword $$(filter %/$$(basename $1).xsl, $$(TRACE_XSL_FILES))), \
       
   173       OUTPUT_DIR := $$(TRACE_OUTPUTDIR), \
       
   174       DEPS := $$(TRACE_DEPS), \
       
   175   ))
       
   176 endef
       
   177 
       
   178 # Append files to generated (might have been set by custom extensions)
       
   179 TRACE_GENSRC_FILES += \
       
   180     traceEventClasses.hpp \
       
   181     traceEventIds.hpp \
       
   182     traceTypes.hpp \
       
   183     #
       
   184 
       
   185 # Call SetupTraceGeneration for all trace gensrc files
       
   186 $(foreach tracefile, $(TRACE_GENSRC_FILES), \
       
   187   $(eval $(call SetupTraceGeneration, $(tracefile))) \
       
   188 )