1 # 2 # Copyright (c) 2015, 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 := $(JDK_TOPDIR)/src/java.base/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 ifneq ($$(findstring $$($1_Type), Object Boolean Byte Short Char Int Long), ) 42 $1_ARGS += -KCAS 43 endif 44 45 ifneq ($$(findstring $$($1_Type), Byte Short Char Int Long), ) 46 $1_ARGS += -KAtomicAdd 47 endif 48 49 ifneq ($$(findstring $$($1_Type), Byte Short Char), ) 50 $1_ARGS += -KShorterThanInt 51 endif 52 53 $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandle.java.template $(BUILD_TOOLS_JDK) 54 ifeq ($$($1_Type), Object) 55 $$(eval $1_type := $$($1_Type)) 56 else 57 $$(eval $1_type := $$$$(shell $(TR) '[:upper:]' '[:lower:]' <<< $$$$($1_Type))) 58 endif 59 $$(call MakeDir, $$(@D)) 60 $(TOOL_SPP) -nel -K$$($1_type) -Dtype=$$($1_type) -DType=$$($1_Type) \ 61 $$($1_ARGS) < $$< > $$@ 62 63 GENSRC_VARHANDLES += $$($1_FILENAME) 64 endef 65 66 ################################################################################ 67 68 ################################################################################ 69 # Setup a rule for generating a VarHandleByteArray java class 70 # Param 1 - Variable declaration prefix 71 # Param 2 - Type with first letter capitalized 72 define GenerateVarHandleByteArray 73 74 $1_Type := $2 75 76 $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleByteArrayAs$$($1_Type)s.java 77 78 ifeq ($$($1_Type), Short) 79 $1_type := short 80 $1_BoxType := $$($1_Type) 81 82 $1_rawType := $$($1_type) 83 $1_RawType := $$($1_Type) 84 $1_RawBoxType := $$($1_BoxType) 85 endif 86 87 ifeq ($$($1_Type), Char) 88 $1_type := char 89 $1_BoxType := Character 90 91 $1_rawType := $$($1_type) 92 $1_RawType := $$($1_Type) 93 $1_RawBoxType := $$($1_BoxType) 94 endif 95 96 ifeq ($$($1_Type), Int) 97 $1_type := int 98 $1_BoxType := Integer 99 100 $1_rawType := $$($1_type) 101 $1_RawType := $$($1_Type) 102 $1_RawBoxType := $$($1_BoxType) 103 104 $1_ARGS += -KCAS 105 $1_ARGS += -KAtomicAdd 106 endif 107 108 ifeq ($$($1_Type), Long) 109 $1_type := long 110 $1_BoxType := $$($1_Type) 111 112 $1_rawType := $$($1_type) 113 $1_RawType := $$($1_Type) 114 $1_RawBoxType := $$($1_BoxType) 115 116 $1_ARGS += -KCAS 117 $1_ARGS += -KAtomicAdd 118 endif 119 120 ifeq ($$($1_Type), Float) 121 $1_type := float 122 $1_BoxType := $$($1_Type) 123 124 $1_rawType := int 125 $1_RawType := Int 126 $1_RawBoxType := Integer 127 128 $1_ARGS += -KCAS 129 $1_ARGS += -KfloatingPoint 130 endif 131 132 ifeq ($$($1_Type), Double) 133 $1_type := double 134 $1_BoxType := $$($1_Type) 135 136 $1_rawType := long 137 $1_RawType := Long 138 $1_RawBoxType := Long 139 140 $1_ARGS += -KCAS 141 $1_ARGS += -KfloatingPoint 142 endif 143 144 $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleByteArrayView.java.template $(BUILD_TOOLS_JDK) 145 $$(call MakeDir, $$(@D)) 146 $(TOOL_SPP) -nel -K$$($1_type) \ 147 -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \ 148 -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \ 149 $$($1_ARGS) < $$< > $$@ 150 151 GENSRC_VARHANDLES += $$($1_FILENAME) 152 endef 153 154 ################################################################################ 155 156 # List the types to generate source for, with capitalized first letter 157 VARHANDLES_TYPES := Boolean Byte Short Char Int Long Float Double Object 158 $(foreach t, $(VARHANDLES_TYPES), \ 159 $(eval $(call GenerateVarHandle,VAR_HANDLE_$t,$t))) 160 161 # List the types to generate source for, with capitalized first letter 162 VARHANDLES_BYTE_ARRAY_TYPES := Short Char Int Long Float Double 163 $(foreach t, $(VARHANDLES_BYTE_ARRAY_TYPES), \ 164 $(eval $(call GenerateVarHandleByteArray,VAR_HANDLE_BYTE_ARRAY_$t,$t))) 165 166 GENSRC_JAVA_BASE += $(GENSRC_VARHANDLES)