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