< prev index next >

make/modules/java.base/gensrc/GensrcVarHandles.gmk

Print this page

 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
 82   endif
 83 
 84   $$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_BYTEARRAY_$1, \
 85       SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandleByteArrayView.java.template, \
 86       OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandleByteArrayAs$$(VARHANDLE_BYTEARRAY_$1_Type)s.java, \
 87       INFO := Generating VarHandleByteArray class for $1, \
 88       SUBST_EMPTY_LINES := false, \
 89       KEYS := $$($1_KEYS), \
 90       REPLACEMENTS := \
 91           type=$1 \
 92           Type=$$(VARHANDLE_BYTEARRAY_$1_Type) \
 93           BoxType=$$(call Conv, $1, Fulltype) \
 94           rawType=$$(call Conv, $1, memtype) \
 95           RawType=$$(call Conv, $1, Memtype) \
 96           RawBoxType=$$(call Conv, $1, FullMemtype), \
 97   ))
 98   TARGETS += $$(GEN_VARHANDLE_BYTEARRAY_$1)






















































 99 endef
100 
101 ################################################################################
102 # Setup a rule for generating a VarHandleMemorySegment java class
103 #
104 # arg $1: type for this varhandle


105 define GenerateVarHandleMemorySegment
106   VARHANDLE_SEGMENT_$1_Type := $$(call Conv, $1, Type)
107 











108 
109   $1_KEYS := $1
110   ifneq ($$(filter int long float double, $1),)
111     $1_KEYS += CAS
112   endif
113   ifneq ($$(filter boolean byte, $1),)
114     $1_KEYS += byte









115   endif
116   ifneq ($$(filter float double, $1),)
117     $1_KEYS += floatingPoint








118   endif
119   ifneq ($$(filter boolean byte short char, $1),)
120     $1_KEYS += ShorterThanInt








121   endif
122   ifneq ($$(filter int long, $1),)
123     $1_KEYS += AtomicAdd Bitwise























124   endif
125 
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)
167 
168 TARGETS += $(GENSRC_VARHANDLEGUARDS)
169 
170 ################################################################################
171 
172 endif # include guard
173 include MakeIncludeEnd.gmk

 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 
 36 GENSRC_VARHANDLES :=
 37 
 38 VARHANDLES_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke
 39 VARHANDLES_SRC_DIR := $(MODULE_SRC)/share/classes/java/lang/invoke
 40 
 41 ################################################################################
 42 # Setup a rule for generating a VarHandle java class
 43 # Param 1 - Variable declaration prefix
 44 # Param 2 - Type with first letter capitalized
 45 define GenerateVarHandle
 46 
 47   $1_InputType := $2
 48   $1_type := $$(call lowercase, $2)
 49   $1_Type := $2
 50 
 51   $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandle$$($1_InputType)s.java
 52 
 53   $1_ARGS += -KCAS
 54 
 55   ifneq ($$(findstring $$($1_InputType), Byte Short Char Int Long Float Double), )
 56     $1_ARGS += -KAtomicAdd
 57     $1_ARGS += -KNonPlainAccess
 58     $1_ARGS += -KStatic
 59     $1_ARGS += -KArray
 60   endif
 61 
 62   ifneq ($$(findstring $$($1_InputType), Byte Short Char Int Long), )
 63     $1_ARGS += -KBitwise
 64   endif
 65 
 66   ifeq ($$($1_InputType), Boolean)
 67     $1_ARGS += -KBitwise
 68     $1_ARGS += -KNonPlainAccess
 69     $1_ARGS += -KStatic
 70     $1_ARGS += -KArray
 71   endif
 72 
 73   ifneq ($$(findstring $$($1_InputType), Byte Short Char), )
 74     $1_ARGS += -KShorterThanInt
 75   endif
 76 
 77   ifeq ($$($1_InputType), Reference)
 78     $1_ARGS += -KReference
 79     $1_ARGS += -KNonPlainAccess
 80     $1_ARGS += -KStatic
 81     $1_type := Object
 82   endif
 83 
 84   ifeq ($$($1_InputType), NonAtomicReference)
 85       $1_ARGS += -KReference
 86       $1_ARGS += -KStatic
 87       $1_type := Object
 88       $1_Type := Reference
 89   endif
 90 
 91   ifeq ($$($1_InputType), FlatValue)
 92     $1_ARGS += -KFlatValue
 93     $1_ARGS += -KNonPlainAccess
 94     $1_type := Object
 95     $1_Type := FlatValue
 96   endif
 97 
 98   ifeq ($$($1_InputType), NonAtomicFlatValue)
 99     $1_ARGS += -KFlatValue
100     $1_type := Object
101     $1_Type := FlatValue
102   endif
103 
104   $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandle.java.template $(BUILD_TOOLS_JDK)
105         ifeq ($$($1_InputType), Reference)
106 	  $$(eval $1_type := Object)
107 	  $$(eval $1_Type := Reference)
108         else ifeq ($$($1_InputType), NonAtomicReference)
109 	  $$(eval $1_type := Object)
110 	  $$(eval $1_Type := Reference)
111         else ifeq ($$($1_InputType), FlatValue)
112 	  $$(eval $1_type := Object)
113 	  $$(eval $1_Type := FlatValue)
114         else ifeq ($$($1_InputType), NonAtomicFlatValue)
115 	  $$(eval $1_type := Object)
116 	  $$(eval $1_Type := FlatValue)
117         else
118 	  $$(eval $1_type := $$$$($1_type))
119 	  $$(eval $1_Type := $$$$($1_InputType))
120         endif
121 	$$(call MakeDir, $$(@D))
122 	$(RM) $$@
123 	$(TOOL_SPP) -nel -K$$($1_type) -Dtype=$$($1_type) -DType=$$($1_Type) -DInputType=$$($1_InputType) \
124 	    $$($1_ARGS) -i$$< -o$$@
125 
126   GENSRC_VARHANDLES += $$($1_FILENAME)
127 endef
128 
129 ################################################################################
130 
131 ################################################################################
132 # Setup a rule for generating a VarHandleByteArray java class
133 # Param 1 - Variable declaration prefix
134 # Param 2 - Type with first letter capitalized
135 define GenerateVarHandleByteArray
136 
137   $1_Type := $2
138 
139   $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleByteArrayAs$$($1_Type)s.java
140 
141   ifeq ($$($1_Type), Short)
142     $1_type := short
143     $1_BoxType := $$($1_Type)
144 
145     $1_rawType := $$($1_type)
146     $1_RawType := $$($1_Type)
147     $1_RawBoxType := $$($1_BoxType)
148   endif
149 
150   ifeq ($$($1_Type), Char)
151     $1_type := char
152     $1_BoxType := Character
153 
154     $1_rawType := $$($1_type)
155     $1_RawType := $$($1_Type)
156     $1_RawBoxType := $$($1_BoxType)
157   endif
158 
159   ifeq ($$($1_Type), Int)
160     $1_type := int
161     $1_BoxType := Integer
162 
163     $1_rawType := $$($1_type)
164     $1_RawType := $$($1_Type)
165     $1_RawBoxType := $$($1_BoxType)
166 
167     $1_ARGS += -KCAS
168     $1_ARGS += -KAtomicAdd
169     $1_ARGS += -KBitwise
170   endif
171 
172   ifeq ($$($1_Type), Long)
173     $1_type := long
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 += -KCAS
181     $1_ARGS += -KAtomicAdd
182     $1_ARGS += -KBitwise
183   endif
184 
185   ifeq ($$($1_Type), Float)
186     $1_type := float
187     $1_BoxType := $$($1_Type)
188 
189     $1_rawType := int
190     $1_RawType := Int
191     $1_RawBoxType := Integer
192 
193     $1_ARGS += -KCAS
194     $1_ARGS += -KfloatingPoint
195   endif
196 
197   ifeq ($$($1_Type), Double)
198     $1_type := double
199     $1_BoxType := $$($1_Type)
200 
201     $1_rawType := long
202     $1_RawType := Long
203     $1_RawBoxType := Long
204 
205     $1_ARGS += -KCAS
206     $1_ARGS += -KfloatingPoint
207   endif
208 
209   $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleByteArrayView.java.template $(BUILD_TOOLS_JDK)
210 	$$(call MakeDir, $$(@D))
211 	$(RM) $$@
212 	$(TOOL_SPP) -nel -K$$($1_type) \
213 	    -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \
214 	    -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \
215 	    $$($1_ARGS) -i$$< -o$$@
216 
217   GENSRC_VARHANDLES += $$($1_FILENAME)
218 endef
219 
220 ################################################################################
221 
222 ################################################################################
223 # Setup a rule for generating a memory segment var handle view class
224 # Param 1 - Variable declaration prefix
225 # Param 2 - Type with first letter capitalized
226 define GenerateVarHandleMemorySegment

227 
228   $1_Type := $2
229 
230   $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleSegmentAs$$($1_Type)s.java
231 
232   ifeq ($$($1_Type), Boolean)
233     $1_type := boolean
234     $1_BoxType := $$($1_Type)
235 
236     $1_rawType := $$($1_type)
237     $1_RawType := $$($1_Type)
238     $1_RawBoxType := $$($1_BoxType)
239 
240     $1_ARGS += -Kbyte
241     $1_ARGS += -KShorterThanInt

242   endif
243 
244   ifeq ($$($1_Type), Byte)
245     $1_type := byte
246     $1_BoxType := $$($1_Type)
247 
248     $1_rawType := $$($1_type)
249     $1_RawType := $$($1_Type)
250     $1_RawBoxType := $$($1_BoxType)
251 
252     $1_ARGS += -Kbyte
253     $1_ARGS += -KShorterThanInt
254   endif
255 
256   ifeq ($$($1_Type), Short)
257     $1_type := short
258     $1_BoxType := $$($1_Type)
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), Char)
268     $1_type := char
269     $1_BoxType := Character
270 
271     $1_rawType := $$($1_type)
272     $1_RawType := $$($1_Type)
273     $1_RawBoxType := $$($1_BoxType)
274 
275     $1_ARGS += -KShorterThanInt
276   endif
277 
278   ifeq ($$($1_Type), Int)
279     $1_type := int
280     $1_BoxType := Integer
281 
282     $1_rawType := $$($1_type)
283     $1_RawType := $$($1_Type)
284     $1_RawBoxType := $$($1_BoxType)
285 
286     $1_ARGS += -KCAS
287     $1_ARGS += -KAtomicAdd
288     $1_ARGS += -KBitwise
289   endif
290 
291   ifeq ($$($1_Type), Long)
292     $1_type := long
293     $1_BoxType := $$($1_Type)
294 
295     $1_rawType := $$($1_type)
296     $1_RawType := $$($1_Type)
297     $1_RawBoxType := $$($1_BoxType)
298 
299     $1_ARGS += -KCAS
300     $1_ARGS += -KAtomicAdd
301     $1_ARGS += -KBitwise
302   endif
303 
304   ifeq ($$($1_Type), Float)
305     $1_type := float
306     $1_BoxType := $$($1_Type)
307 
308     $1_rawType := int
309     $1_RawType := Int
310     $1_RawBoxType := Integer
311 
312     $1_ARGS += -KCAS
313     $1_ARGS += -KfloatingPoint
314   endif
315 
316   ifeq ($$($1_Type), Double)
317     $1_type := double
318     $1_BoxType := $$($1_Type)
319 
320     $1_rawType := long
321     $1_RawType := Long
322     $1_RawBoxType := Long
323 
324     $1_ARGS += -KCAS
325     $1_ARGS += -KfloatingPoint
326   endif
327 
328   $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleSegmentView.java.template $(BUILD_TOOLS_JDK)
329 	$$(call MakeDir, $$(@D))
330 	$(RM) $$@
331 	$(TOOL_SPP) -nel -K$$($1_type) \
332 	    -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \
333 	    -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \
334 	    $$($1_ARGS) -i$$< -o$$@
335 
336   GENSRC_VARHANDLES += $$($1_FILENAME)
337 endef
338 
339 ################################################################################

340 
341 # List the types to generate source for, with capitalized first letter
342 VARHANDLES_TYPES := Boolean Byte Short Char Int Long Float Double Reference FlatValue NonAtomicReference NonAtomicFlatValue
343 $(foreach t, $(VARHANDLES_TYPES), \
344   $(eval $(call GenerateVarHandle,VAR_HANDLE_$t,$t)))
345 
346 # List the types to generate source for, with capitalized first letter
347 VARHANDLES_BYTE_ARRAY_TYPES := Short Char Int Long Float Double
348 $(foreach t, $(VARHANDLES_BYTE_ARRAY_TYPES), \
349   $(eval $(call GenerateVarHandleByteArray,VAR_HANDLE_BYTE_ARRAY_$t,$t)))
350 
351 # List the types to generate source for, with capitalized first letter
352 VARHANDLES_MEMORY_SEGMENT_TYPES := Boolean Byte Short Char Int Long Float Double
353 $(foreach t, $(VARHANDLES_MEMORY_SEGMENT_TYPES), \
354   $(eval $(call GenerateVarHandleMemorySegment,VAR_HANDLE_MEMORY_SEGMENT_$t,$t)))
355 
356 TARGETS += $(GENSRC_VARHANDLES)


357 
358 ################################################################################
359 
360 GENSRC_VARHANDLEGUARDS := $(VARHANDLES_OUTPUT_DIR)/VarHandleGuards.java
361 
362 $(GENSRC_VARHANDLEGUARDS): $(BUILD_TOOLS_JDK)
363 	$(call LogInfo, Generating $@)
364 	$(call MakeTargetDir)
365 	$(TOOL_VARHANDLEGUARDMETHODGENERATOR) \
366 	    $(GENSRC_VARHANDLEGUARDS)
367 
368 TARGETS += $(GENSRC_VARHANDLEGUARDS)
369 
370 ################################################################################
371 
372 endif # include guard
373 include MakeIncludeEnd.gmk
< prev index next >