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 := \
43 $$(strip $$(if $$(filter $(VARHANDLE_OBJECT_TYPES), $1), Object, $1))
44 VARHANDLE_$1_InputType := \
45 $$(strip $$(if $$(filter $(VARHANDLE_OBJECT_TYPES), $1), $1, \
46 $$(call Conv, $1, Type)))
47 VARHANDLE_$1_Type := \
48 $$(strip $$(subst NonAtomicReference, Reference, \
49 $$(subst NonAtomicFlatValue, FlatValue, $$(VARHANDLE_$1_InputType))))
50
51 $1_KEYS := $$(VARHANDLE_$1_type) CAS
52 ifneq ($$(filter $(PRIMITIVE_TYPES), $1),)
53 # Reference types use ArrayVarHandle class
54 $1_KEYS += Array Static
55 else ifneq ($$(filter Reference NonAtomicReference, $1),)
56 $1_KEYS += Reference Static
57 else ifneq ($$(filter FlatValue NonAtomicFlatValue, $1),)
58 # No static field is flat in Hotspot
59 $1_KEYS += FlatValue
60 endif
61
62 ifneq ($$(filter byte short char, $1),)
63 $1_KEYS += ShorterThanInt
64 endif
65 ifneq ($$(filter $(NUMBER_TYPES), $1),)
66 $1_KEYS += AtomicAdd
67 endif
68 ifneq ($$(filter $(BITWISE_PRIMITIVE_TYPES), $1),)
69 $1_KEYS += Bitwise
70 endif
71 ifeq ($$(filter NonAtomicReference NonAtomicFlatValue, $1),)
72 # Everyone except NonAtomicXxx have non-plain access
73 $1_KEYS += NonPlainAccess
74 endif
75
76 $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_$1, \
77 SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandle.java.template, \
78 OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandle$$(VARHANDLE_$1_InputType)s.java, \
79 INFO := Generating VarHandle class for $1, \
80 SUBST_EMPTY_LINES := false, \
81 KEYS := $$($1_KEYS), \
82 REPLACEMENTS := \
83 type=$$(VARHANDLE_$1_type) \
84 Type=$$(VARHANDLE_$1_Type) \
85 InputType=$$(VARHANDLE_$1_InputType), \
86 ))
87 TARGETS += $$(GEN_VARHANDLE_$1)
88 endef
89
90 ################################################################################
91 # Setup a rule for generating a VarHandleByteArray java class
92 #
93 # arg $1: type for this varhandle
94 define GenerateVarHandleByteArray
95 VARHANDLE_BYTEARRAY_$1_Type := $$(call Conv, $1, Type)
96
97 $1_KEYS := $1
98 ifneq ($$(filter int long float double, $1),)
99 $1_KEYS += CAS
100 endif
101 ifneq ($$(filter float double, $1),)
102 $1_KEYS += floatingPoint
103 endif
104 ifneq ($$(filter int long, $1),)
105 $1_KEYS += AtomicAdd Bitwise
150 $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_SEGMENT_$1, \
151 SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandleSegmentView.java.template, \
152 OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandleSegmentAs$$(VARHANDLE_SEGMENT_$1_Type)s.java, \
153 INFO := Generating VarHandleSegment class for $1, \
154 SUBST_EMPTY_LINES := false, \
155 KEYS := $$($1_KEYS), \
156 REPLACEMENTS := \
157 type=$1 \
158 Type=$$(VARHANDLE_SEGMENT_$1_Type) \
159 BoxType=$$(call Conv, $1, Fulltype) \
160 rawType=$$(call Conv, $1, memtype) \
161 RawType=$$(call Conv, $1, Memtype) \
162 RawBoxType=$$(call Conv, $1, FullMemtype), \
163 ))
164 TARGETS += $$(GEN_VARHANDLE_SEGMENT_$1)
165 endef
166
167 ################################################################################
168 # Generate all VarHandle related classes
169
170 $(foreach t, $(PRIMITIVE_TYPES) $(VARHANDLE_OBJECT_TYPES), \
171 $(eval $(call GenerateVarHandle,$t)) \
172 )
173
174 $(foreach t, $(NON_BYTE_NUMBER_TYPES), \
175 $(eval $(call GenerateVarHandleByteArray,$t)) \
176 )
177
178 $(foreach t, $(PRIMITIVE_TYPES), \
179 $(eval $(call GenerateVarHandleMemorySegment,$t)) \
180 )
181
182 ################################################################################
183
184 GENSRC_VARHANDLEGUARDS := $(VARHANDLES_OUTPUT_DIR)/VarHandleGuards.java
185
186 $(GENSRC_VARHANDLEGUARDS): $(BUILD_TOOLS_JDK)
187 $(call LogInfo, Generating $@)
188 $(call MakeTargetDir)
189 $(TOOL_VARHANDLEGUARDMETHODGENERATOR) \
190 $(GENSRC_VARHANDLEGUARDS)
|