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