jdk/make/gensrc/GensrcVarHandles.gmk
author shade
Wed, 15 Jun 2016 11:20:15 +0300
changeset 39470 d6f8b4a85fb0
parent 36938 b43bd5279f4e
child 39471 6622892a347a
permissions -rw-r--r--
8157726: VarHandles/Unsafe should support sub-word atomic ops Reviewed-by: psandoz, vlivanov, lagergren
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     1
#
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     2
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     4
#
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    10
#
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    15
# accompanied this code).
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    16
#
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    20
#
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    23
# questions.
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    24
#
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    25
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    26
GENSRC_VARHANDLES :=
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    27
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    28
VARHANDLES_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    29
VARHANDLES_SRC_DIR := $(JDK_TOPDIR)/src/java.base/share/classes/java/lang/invoke
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    30
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    31
################################################################################
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    32
# Setup a rule for generating a VarHandle java class
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    33
# Param 1 - Variable declaration prefix
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    34
# Param 2 - Type with first letter capitalized
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    35
define GenerateVarHandle
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    36
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    37
  $1_Type := $2
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    38
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    39
  $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandle$$($1_Type)s.java
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    40
39470
d6f8b4a85fb0 8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents: 36938
diff changeset
    41
  ifneq ($$(findstring $$($1_Type), Object Boolean Byte Short Char Int Long), )
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    42
    $1_ARGS += -KCAS
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    43
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    44
39470
d6f8b4a85fb0 8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents: 36938
diff changeset
    45
  ifneq ($$(findstring $$($1_Type), Byte Short Char Int Long), )
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    46
    $1_ARGS += -KAtomicAdd
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    47
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    48
39470
d6f8b4a85fb0 8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents: 36938
diff changeset
    49
  ifneq ($$(findstring $$($1_Type), Byte Short Char), )
d6f8b4a85fb0 8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents: 36938
diff changeset
    50
    $1_ARGS += -KShorterThanInt
d6f8b4a85fb0 8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents: 36938
diff changeset
    51
  endif
d6f8b4a85fb0 8157726: VarHandles/Unsafe should support sub-word atomic ops
shade
parents: 36938
diff changeset
    52
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    53
  $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandle.java.template $(BUILD_TOOLS_JDK)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    54
        ifeq ($$($1_Type), Object)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    55
	  $$(eval $1_type := $$($1_Type))
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    56
        else
36938
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
    57
	  $$(eval $1_type := $$$$(shell $(TR) '[:upper:]' '[:lower:]' <<< $$$$($1_Type)))
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    58
        endif
36938
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
    59
	$$(call MakeDir, $$(@D))
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    60
	$(TOOL_SPP) -nel -K$$($1_type) -Dtype=$$($1_type) -DType=$$($1_Type) \
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    61
	    $$($1_ARGS) < $$< > $$@
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    62
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    63
  GENSRC_VARHANDLES += $$($1_FILENAME)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    64
endef
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    65
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    66
################################################################################
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    67
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    68
################################################################################
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    69
# Setup a rule for generating a VarHandleByteArray java class
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    70
# Param 1 - Variable declaration prefix
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    71
# Param 2 - Type with first letter capitalized
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    72
define GenerateVarHandleByteArray
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    73
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    74
  $1_Type := $2
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    75
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    76
  $1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleByteArrayAs$$($1_Type)s.java
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    77
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    78
  ifeq ($$($1_Type), Short)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    79
    $1_type := short
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    80
    $1_BoxType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    81
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    82
    $1_rawType := $$($1_type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    83
    $1_RawType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    84
    $1_RawBoxType := $$($1_BoxType)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    85
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    86
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    87
  ifeq ($$($1_Type), Char)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    88
    $1_type := char
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    89
    $1_BoxType := Character
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    90
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    91
    $1_rawType := $$($1_type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    92
    $1_RawType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    93
    $1_RawBoxType := $$($1_BoxType)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    94
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    95
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    96
  ifeq ($$($1_Type), Int)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    97
    $1_type := int
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    98
    $1_BoxType := Integer
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
    99
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   100
    $1_rawType := $$($1_type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   101
    $1_RawType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   102
    $1_RawBoxType := $$($1_BoxType)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   103
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   104
    $1_ARGS += -KCAS
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   105
    $1_ARGS += -KAtomicAdd
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   106
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   107
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   108
  ifeq ($$($1_Type), Long)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   109
    $1_type := long
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   110
    $1_BoxType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   111
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   112
    $1_rawType := $$($1_type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   113
    $1_RawType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   114
    $1_RawBoxType := $$($1_BoxType)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   115
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   116
    $1_ARGS += -KCAS
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   117
    $1_ARGS += -KAtomicAdd
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   118
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   119
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   120
  ifeq ($$($1_Type), Float)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   121
    $1_type := float
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   122
    $1_BoxType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   123
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   124
    $1_rawType := int
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   125
    $1_RawType := Int
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   126
    $1_RawBoxType := Integer
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   127
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   128
    $1_ARGS += -KCAS
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   129
    $1_ARGS += -KfloatingPoint
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   130
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   131
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   132
  ifeq ($$($1_Type), Double)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   133
    $1_type := double
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   134
    $1_BoxType := $$($1_Type)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   135
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   136
    $1_rawType := long
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   137
    $1_RawType := Long
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   138
    $1_RawBoxType := Long
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   139
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   140
    $1_ARGS += -KCAS
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   141
    $1_ARGS += -KfloatingPoint
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   142
  endif
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   143
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   144
  $$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleByteArrayView.java.template $(BUILD_TOOLS_JDK)
36938
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
   145
	$$(call MakeDir, $$(@D))
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   146
	$(TOOL_SPP) -nel -K$$($1_type) \
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   147
	    -Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   148
	    -DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   149
	    $$($1_ARGS) < $$< > $$@
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   150
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   151
  GENSRC_VARHANDLES += $$($1_FILENAME)
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   152
endef
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   153
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   154
################################################################################
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   155
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   156
# List the types to generate source for, with capitalized first letter
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   157
VARHANDLES_TYPES := Boolean Byte Short Char Int Long Float Double Object
36938
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
   158
$(foreach t, $(VARHANDLES_TYPES), \
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
   159
  $(eval $(call GenerateVarHandle,VAR_HANDLE_$t,$t)))
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   160
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   161
# List the types to generate source for, with capitalized first letter
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   162
VARHANDLES_BYTE_ARRAY_TYPES := Short Char Int Long Float Double
36938
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
   163
$(foreach t, $(VARHANDLES_BYTE_ARRAY_TYPES), \
b43bd5279f4e 8152959: Build crashes in jdk9-hs-comp on Linux with gnumake 3.81
erikj
parents: 36934
diff changeset
   164
  $(eval $(call GenerateVarHandleByteArray,VAR_HANDLE_BYTE_ARRAY_$t,$t)))
36934
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   165
590fc47a0aeb 8149644: Integrate VarHandles
psandoz
parents:
diff changeset
   166
GENSRC_JAVA_BASE += $(GENSRC_VARHANDLES)