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