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 GENSRC_VARHANDLES := 32 33 VARHANDLES_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke 34 VARHANDLES_SRC_DIR := $(MODULE_SRC)/share/classes/java/lang/invoke 35 36 ################################################################################ 37 # Setup a rule for generating a VarHandle java class 38 # Param 1 - Variable declaration prefix 39 # Param 2 - Type with first letter capitalized 40 define GenerateVarHandle 41 42 $1_InputType := $2 43 44 $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandle$$($1_InputType)s.java 45 46 $1_ARGS += -KCAS 47 48 ifneq ($$(findstring $$($1_InputType), Byte Short Char Int Long Float Double), ) 49 $1_ARGS += -KAtomicAdd 50 $1_ARGS += -KNonPlainAccess 51 $1_ARGS += -KStatic 52 $1_ARGS += -KArray 53 endif 54 55 ifneq ($$(findstring $$($1_InputType), Byte Short Char Int Long), ) 56 $1_ARGS += -KBitwise 57 endif 58 59 ifeq ($$($1_InputType), Boolean) 60 $1_ARGS += -KBitwise 61 $1_ARGS += -KNonPlainAccess 62 $1_ARGS += -KStatic 63 $1_ARGS += -KArray 64 endif 65 66 ifneq ($$(findstring $$($1_InputType), Byte Short Char), ) 67 $1_ARGS += -KShorterThanInt 68 endif 69 70 ifeq ($$($1_InputType), Reference) 71 $1_ARGS += -KReference 72 $1_ARGS += -KNonPlainAccess 73 $1_ARGS += -KStatic 74 $1_ARGS += -KArray 75 endif 76 77 ifeq ($$($1_InputType), NonAtomicReference) 78 $1_ARGS += -KReference 79 $1_ARGS += -KStatic 80 $1_Type := Reference 81 $1_ARGS += -KArray 82 endif 83 84 ifeq ($$($1_InputType), FlatValue) 85 $1_ARGS += -KFlatValue 86 $1_ARGS += -KNonPlainAccess 87 endif 88 89 ifeq ($$($1_InputType), NonAtomicFlatValue) 90 $1_ARGS += -KFlatValue 91 endif 92 93 $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandle.java.template $(BUILD_TOOLS_JDK) 94 ifeq ($$($1_InputType), Reference) 95 $$(eval $1_type := Object) 96 $$(eval $1_Type := Reference) 97 else ifeq ($$($1_InputType), NonAtomicReference) 98 $$(eval $1_type := Object) 99 $$(eval $1_Type := Reference) 100 else ifeq ($$($1_InputType), FlatValue) 101 $$(eval $1_type := Object) 102 $$(eval $1_Type := FlatValue) 103 else ifeq ($$($1_InputType), NonAtomicFlatValue) 104 $$(eval $1_type := Object) 105 $$(eval $1_Type := FlatValue) 106 else 107 $$(eval $1_type := $$$$(shell $(TR) '[:upper:]' '[:lower:]' <<< $$$$($1_InputType))) 108 $$(eval $1_Type := $$$$($1_InputType)) 109 endif 110 $$(call MakeDir, $$(@D)) 111 $(RM) $$@ 112 $(TOOL_SPP) -nel -K$$($1_type) -Dtype=$$($1_type) -DType=$$($1_Type) -DInputType=$$($1_InputType) \ 113 $$($1_ARGS) -i$$< -o$$@ 114 115 GENSRC_VARHANDLES += $$($1_FILENAME) 116 endef 117 118 ################################################################################ 119 120 ################################################################################ 121 # Setup a rule for generating a VarHandleByteArray java class 122 # Param 1 - Variable declaration prefix 123 # Param 2 - Type with first letter capitalized 124 define GenerateVarHandleByteArray 125 126 $1_Type := $2 127 128 $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleByteArrayAs$$($1_Type)s.java 129 130 ifeq ($$($1_Type), Short) 131 $1_type := short 132 $1_BoxType := $$($1_Type) 133 134 $1_rawType := $$($1_type) 135 $1_RawType := $$($1_Type) 136 $1_RawBoxType := $$($1_BoxType) 137 endif 138 139 ifeq ($$($1_Type), Char) 140 $1_type := char 141 $1_BoxType := Character 142 143 $1_rawType := $$($1_type) 144 $1_RawType := $$($1_Type) 145 $1_RawBoxType := $$($1_BoxType) 146 endif 147 148 ifeq ($$($1_Type), Int) 149 $1_type := int 150 $1_BoxType := Integer 151 152 $1_rawType := $$($1_type) 153 $1_RawType := $$($1_Type) 154 $1_RawBoxType := $$($1_BoxType) 155 156 $1_ARGS += -KCAS 157 $1_ARGS += -KAtomicAdd 158 $1_ARGS += -KBitwise 159 endif 160 161 ifeq ($$($1_Type), Long) 162 $1_type := long 163 $1_BoxType := $$($1_Type) 164 165 $1_rawType := $$($1_type) 166 $1_RawType := $$($1_Type) 167 $1_RawBoxType := $$($1_BoxType) 168 169 $1_ARGS += -KCAS 170 $1_ARGS += -KAtomicAdd 171 $1_ARGS += -KBitwise 172 endif 173 174 ifeq ($$($1_Type), Float) 175 $1_type := float 176 $1_BoxType := $$($1_Type) 177 178 $1_rawType := int 179 $1_RawType := Int 180 $1_RawBoxType := Integer 181 182 $1_ARGS += -KCAS 183 $1_ARGS += -KfloatingPoint 184 endif 185 186 ifeq ($$($1_Type), Double) 187 $1_type := double 188 $1_BoxType := $$($1_Type) 189 190 $1_rawType := long 191 $1_RawType := Long 192 $1_RawBoxType := Long 193 194 $1_ARGS += -KCAS 195 $1_ARGS += -KfloatingPoint 196 endif 197 198 $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleByteArrayView.java.template $(BUILD_TOOLS_JDK) 199 $$(call MakeDir, $$(@D)) 200 $(RM) $$@ 201 $(TOOL_SPP) -nel -K$$($1_type) \ 202 -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \ 203 -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \ 204 $$($1_ARGS) -i$$< -o$$@ 205 206 GENSRC_VARHANDLES += $$($1_FILENAME) 207 endef 208 209 ################################################################################ 210 211 ################################################################################ 212 # Setup a rule for generating a memory segment var handle view class 213 # Param 1 - Variable declaration prefix 214 # Param 2 - Type with first letter capitalized 215 define GenerateVarHandleMemorySegment 216 217 $1_Type := $2 218 219 $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleSegmentAs$$($1_Type)s.java 220 221 ifeq ($$($1_Type), Boolean) 222 $1_type := boolean 223 $1_BoxType := $$($1_Type) 224 225 $1_rawType := $$($1_type) 226 $1_RawType := $$($1_Type) 227 $1_RawBoxType := $$($1_BoxType) 228 229 $1_ARGS += -Kbyte 230 $1_ARGS += -KShorterThanInt 231 endif 232 233 ifeq ($$($1_Type), Byte) 234 $1_type := byte 235 $1_BoxType := $$($1_Type) 236 237 $1_rawType := $$($1_type) 238 $1_RawType := $$($1_Type) 239 $1_RawBoxType := $$($1_BoxType) 240 241 $1_ARGS += -Kbyte 242 $1_ARGS += -KShorterThanInt 243 endif 244 245 ifeq ($$($1_Type), Short) 246 $1_type := short 247 $1_BoxType := $$($1_Type) 248 249 $1_rawType := $$($1_type) 250 $1_RawType := $$($1_Type) 251 $1_RawBoxType := $$($1_BoxType) 252 253 $1_ARGS += -KShorterThanInt 254 endif 255 256 ifeq ($$($1_Type), Char) 257 $1_type := char 258 $1_BoxType := Character 259 260 $1_rawType := $$($1_type) 261 $1_RawType := $$($1_Type) 262 $1_RawBoxType := $$($1_BoxType) 263 264 $1_ARGS += -KShorterThanInt 265 endif 266 267 ifeq ($$($1_Type), Int) 268 $1_type := int 269 $1_BoxType := Integer 270 271 $1_rawType := $$($1_type) 272 $1_RawType := $$($1_Type) 273 $1_RawBoxType := $$($1_BoxType) 274 275 $1_ARGS += -KCAS 276 $1_ARGS += -KAtomicAdd 277 $1_ARGS += -KBitwise 278 endif 279 280 ifeq ($$($1_Type), Long) 281 $1_type := long 282 $1_BoxType := $$($1_Type) 283 284 $1_rawType := $$($1_type) 285 $1_RawType := $$($1_Type) 286 $1_RawBoxType := $$($1_BoxType) 287 288 $1_ARGS += -KCAS 289 $1_ARGS += -KAtomicAdd 290 $1_ARGS += -KBitwise 291 endif 292 293 ifeq ($$($1_Type), Float) 294 $1_type := float 295 $1_BoxType := $$($1_Type) 296 297 $1_rawType := int 298 $1_RawType := Int 299 $1_RawBoxType := Integer 300 301 $1_ARGS += -KCAS 302 $1_ARGS += -KfloatingPoint 303 endif 304 305 ifeq ($$($1_Type), Double) 306 $1_type := double 307 $1_BoxType := $$($1_Type) 308 309 $1_rawType := long 310 $1_RawType := Long 311 $1_RawBoxType := Long 312 313 $1_ARGS += -KCAS 314 $1_ARGS += -KfloatingPoint 315 endif 316 317 $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleSegmentView.java.template $(BUILD_TOOLS_JDK) 318 $$(call MakeDir, $$(@D)) 319 $(RM) $$@ 320 $(TOOL_SPP) -nel -K$$($1_type) \ 321 -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \ 322 -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \ 323 $$($1_ARGS) -i$$< -o$$@ 324 325 GENSRC_VARHANDLES += $$($1_FILENAME) 326 endef 327 328 ################################################################################ 329 330 # List the types to generate source for, with capitalized first letter 331 VARHANDLES_TYPES := Boolean Byte Short Char Int Long Float Double Reference FlatValue NonAtomicReference NonAtomicFlatValue 332 $(foreach t, $(VARHANDLES_TYPES), \ 333 $(eval $(call GenerateVarHandle,VAR_HANDLE_$t,$t))) 334 335 # List the types to generate source for, with capitalized first letter 336 VARHANDLES_BYTE_ARRAY_TYPES := Short Char Int Long Float Double 337 $(foreach t, $(VARHANDLES_BYTE_ARRAY_TYPES), \ 338 $(eval $(call GenerateVarHandleByteArray,VAR_HANDLE_BYTE_ARRAY_$t,$t))) 339 340 # List the types to generate source for, with capitalized first letter 341 VARHANDLES_MEMORY_SEGMENT_TYPES := Boolean Byte Short Char Int Long Float Double 342 $(foreach t, $(VARHANDLES_MEMORY_SEGMENT_TYPES), \ 343 $(eval $(call GenerateVarHandleMemorySegment,VAR_HANDLE_MEMORY_SEGMENT_$t,$t))) 344 345 TARGETS += $(GENSRC_VARHANDLES) 346 347 ################################################################################ 348 349 endif # include guard 350 include MakeIncludeEnd.gmk