1 #
2 # Copyright (c) 2015, 2025, 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 include MakeIncludeStart.gmk
27 ifeq ($(INCLUDE), true)
28
29 ################################################################################
30
31 VARHANDLES_INPUT_DIR := $(MODULE_SRC)/share/classes/java/lang/invoke
32 VARHANDLES_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke
33
34 ################################################################################
35 # Setup a rule for generating a VarHandle java class
36 #
37 # arg $1: type for this varhandle
38 define GenerateVarHandle
39 VARHANDLE_$1_type := $$(strip $$(if $$(filter reference, $1), Object, $1))
40 VARHANDLE_$1_Type := $$(call Conv, $1, Type)
41
42 $1_KEYS := $$(VARHANDLE_$1_type) CAS
43 ifneq ($$(filter byte short char, $1),)
44 $1_KEYS += ShorterThanInt
45 endif
46 ifeq ($$(filter boolean reference, $1),)
47 $1_KEYS += AtomicAdd
48 endif
49 ifeq ($$(filter float double reference, $1),)
50 $1_KEYS += Bitwise
51 endif
52
53 $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_$1, \
54 SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandle.java.template, \
55 OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandle$$(VARHANDLE_$1_Type)s.java, \
56 INFO := Generating VarHandle class for $1, \
57 SUBST_EMPTY_LINES := false, \
58 KEYS := $$($1_KEYS), \
59 REPLACEMENTS := \
60 type=$$(VARHANDLE_$1_type) \
61 Type=$$(VARHANDLE_$1_Type), \
62 ))
63 TARGETS += $$(GEN_VARHANDLE_$1)
64 endef
65
66 ################################################################################
67 # Setup a rule for generating a VarHandleByteArray java class
68 #
69 # arg $1: type for this varhandle
70 define GenerateVarHandleByteArray
71 VARHANDLE_BYTEARRAY_$1_Type := $$(call Conv, $1, Type)
72
73 $1_KEYS := $1
74 ifneq ($$(filter int long float double, $1),)
75 $1_KEYS += CAS
76 endif
77 ifneq ($$(filter float double, $1),)
78 $1_KEYS += floatingPoint
79 endif
80 ifneq ($$(filter int long, $1),)
81 $1_KEYS += AtomicAdd Bitwise
126 $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_SEGMENT_$1, \
127 SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandleSegmentView.java.template, \
128 OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandleSegmentAs$$(VARHANDLE_SEGMENT_$1_Type)s.java, \
129 INFO := Generating VarHandleSegment class for $1, \
130 SUBST_EMPTY_LINES := false, \
131 KEYS := $$($1_KEYS), \
132 REPLACEMENTS := \
133 type=$1 \
134 Type=$$(VARHANDLE_SEGMENT_$1_Type) \
135 BoxType=$$(call Conv, $1, Fulltype) \
136 rawType=$$(call Conv, $1, memtype) \
137 RawType=$$(call Conv, $1, Memtype) \
138 RawBoxType=$$(call Conv, $1, FullMemtype), \
139 ))
140 TARGETS += $$(GEN_VARHANDLE_SEGMENT_$1)
141 endef
142
143 ################################################################################
144 # Generate all VarHandle related classes
145
146 $(foreach t, $(PRIMITIVE_TYPES) reference, \
147 $(eval $(call GenerateVarHandle,$t)) \
148 )
149
150 $(foreach t, $(NON_BYTE_NUMBER_TYPES), \
151 $(eval $(call GenerateVarHandleByteArray,$t)) \
152 )
153
154 $(foreach t, $(PRIMITIVE_TYPES), \
155 $(eval $(call GenerateVarHandleMemorySegment,$t)) \
156 )
157
158 ################################################################################
159
160 GENSRC_VARHANDLEGUARDS := $(VARHANDLES_OUTPUT_DIR)/VarHandleGuards.java
161
162 $(GENSRC_VARHANDLEGUARDS): $(BUILD_TOOLS_JDK)
163 $(call LogInfo, Generating $@)
164 $(call MakeTargetDir)
165 $(TOOL_VARHANDLEGUARDMETHODGENERATOR) \
166 $(GENSRC_VARHANDLEGUARDS)
|
1 #
2 # Copyright (c) 2015, 2026, 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 include MakeIncludeStart.gmk
27 ifeq ($(INCLUDE), true)
28
29 ################################################################################
30
31 VARHANDLES_INPUT_DIR := $(MODULE_SRC)/share/classes/java/lang/invoke
32 VARHANDLES_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke
33 # These guys are cased because make cannot preserve case...
34 VARHANDLE_OBJECT_TYPES := Reference FlatValue NonAtomicReference NonAtomicFlatValue
35
36 ################################################################################
37 # Setup a rule for generating a VarHandle java class
38 #
39 # arg $1: type for this varhandle
40 define GenerateVarHandle
41 # Underlying erased signature type, Object or a primitive type
42 VARHANDLE_$1_type := $$(strip $$(if $$(filter $(VARHANDLE_OBJECT_TYPES), $1), Object, $1))
43 VARHANDLE_$1_InputType := $$(strip $$(if $$(filter $(VARHANDLE_OBJECT_TYPES), $1), $1, $$(call Conv, $1, Type)))
44 VARHANDLE_$1_Type := $$(strip $$(subst NonAtomicReference, Reference, $$(subst NonAtomicFlatValue, FlatValue, $$(VARHANDLE_$1_InputType))))
45
46 $1_KEYS := $$(VARHANDLE_$1_type) CAS
47 ifneq ($$(filter $(PRIMITIVE_TYPES), $1),)
48 # Reference types use ArrayVarHandle class
49 $1_KEYS += Array Static
50 else ifneq ($$(filter Reference NonAtomicReference, $1),)
51 $1_KEYS += Reference Static
52 else ifneq ($$(filter FlatValue NonAtomicFlatValue, $1),)
53 # No static field is flat in Hotspot
54 $1_KEYS += FlatValue
55 endif
56
57 ifneq ($$(filter byte short char, $1),)
58 $1_KEYS += ShorterThanInt
59 endif
60 ifneq ($$(filter $(NUMBER_TYPES), $1),)
61 $1_KEYS += AtomicAdd
62 endif
63 ifneq ($$(filter $(BITWISE_PRIMITIVE_TYPES), $1),)
64 $1_KEYS += Bitwise
65 endif
66 ifeq ($$(filter NonAtomicReference NonAtomicFlatValue, $1),)
67 # Everyone except NonAtomicXxx have non-plain access
68 $1_KEYS += NonPlainAccess
69 endif
70
71 $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_$1, \
72 SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandle.java.template, \
73 OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandle$$(VARHANDLE_$1_InputType)s.java, \
74 INFO := Generating VarHandle class for $1, \
75 SUBST_EMPTY_LINES := false, \
76 KEYS := $$($1_KEYS), \
77 REPLACEMENTS := \
78 type=$$(VARHANDLE_$1_type) \
79 Type=$$(VARHANDLE_$1_Type) \
80 InputType=$$(VARHANDLE_$1_InputType), \
81 ))
82 TARGETS += $$(GEN_VARHANDLE_$1)
83 endef
84
85 ################################################################################
86 # Setup a rule for generating a VarHandleByteArray java class
87 #
88 # arg $1: type for this varhandle
89 define GenerateVarHandleByteArray
90 VARHANDLE_BYTEARRAY_$1_Type := $$(call Conv, $1, Type)
91
92 $1_KEYS := $1
93 ifneq ($$(filter int long float double, $1),)
94 $1_KEYS += CAS
95 endif
96 ifneq ($$(filter float double, $1),)
97 $1_KEYS += floatingPoint
98 endif
99 ifneq ($$(filter int long, $1),)
100 $1_KEYS += AtomicAdd Bitwise
145 $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_SEGMENT_$1, \
146 SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandleSegmentView.java.template, \
147 OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandleSegmentAs$$(VARHANDLE_SEGMENT_$1_Type)s.java, \
148 INFO := Generating VarHandleSegment class for $1, \
149 SUBST_EMPTY_LINES := false, \
150 KEYS := $$($1_KEYS), \
151 REPLACEMENTS := \
152 type=$1 \
153 Type=$$(VARHANDLE_SEGMENT_$1_Type) \
154 BoxType=$$(call Conv, $1, Fulltype) \
155 rawType=$$(call Conv, $1, memtype) \
156 RawType=$$(call Conv, $1, Memtype) \
157 RawBoxType=$$(call Conv, $1, FullMemtype), \
158 ))
159 TARGETS += $$(GEN_VARHANDLE_SEGMENT_$1)
160 endef
161
162 ################################################################################
163 # Generate all VarHandle related classes
164
165 $(foreach t, $(PRIMITIVE_TYPES) $(VARHANDLE_OBJECT_TYPES), \
166 $(eval $(call GenerateVarHandle,$t)) \
167 )
168
169 $(foreach t, $(NON_BYTE_NUMBER_TYPES), \
170 $(eval $(call GenerateVarHandleByteArray,$t)) \
171 )
172
173 $(foreach t, $(PRIMITIVE_TYPES), \
174 $(eval $(call GenerateVarHandleMemorySegment,$t)) \
175 )
176
177 ################################################################################
178
179 GENSRC_VARHANDLEGUARDS := $(VARHANDLES_OUTPUT_DIR)/VarHandleGuards.java
180
181 $(GENSRC_VARHANDLEGUARDS): $(BUILD_TOOLS_JDK)
182 $(call LogInfo, Generating $@)
183 $(call MakeTargetDir)
184 $(TOOL_VARHANDLEGUARDMETHODGENERATOR) \
185 $(GENSRC_VARHANDLEGUARDS)
|