8366837: Clean up gensrc by spp.Spp

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2025-09-08 16:48:14 +00:00
parent 323b02016e
commit 55af9d8380
9 changed files with 752 additions and 791 deletions

View File

@ -55,6 +55,42 @@ uppercase = \
$(uppercase_result) \
)
lowercase_table := A,a B,b C,c D,d E,e F,f G,g H,h I,i J,j K,k L,l M,m N,n O,o \
P,p Q,q R,r S,s T,t U,u V,v W,w X,x Y,y Z,z
lowercase_internal = \
$(if $(strip $1), $$(subst $(firstword $1), $(call lowercase_internal, \
$(wordlist 2, $(words $1), $1), $2)), $2)
# Convert a string to lower case. Works only on a-z.
# $1 - The string to convert
lowercase = \
$(strip \
$(eval lowercase_result := $(call lowercase_internal, $(lowercase_table), $1)) \
$(lowercase_result) \
)
lowercase_letters := a b c d e f g h i j k l m n o p q r s t u v w x y z
uppercase_letters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
titlecase_internal = \
$(strip $(or \
$(strip $(foreach l, $(lowercase_letters) $(uppercase_letters), \
$(if $(filter $l%, $1), \
$(call uppercase, $l)$(call lowercase, $(patsubst $l%,%,$1))))), \
$1))
# Convert a string to Title Case. Works only on a-z.
# $1 - The string to convert
titlecase = \
$(strip $(foreach w, $1, $(call titlecase_internal, $w)))
# Returns the first character of a string. Works only on a-z.
# $1 - The string to extract the first character from
firstchar = \
$(strip $(foreach l, $(lowercase_letters) $(uppercase_letters), \
$(if $(filter $l%, $(firstword $1)), $l)))
################################################################################
# Creates a sequence of increasing numbers (inclusive).
# Param 1 - starting number

View File

@ -0,0 +1,228 @@
#
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include MakeIncludeStart.gmk
ifeq ($(INCLUDE), true)
################################################################################
# This file defines macros that sets up rules for running the spp.Spp build tool
################################################################################
include Execute.gmk
include $(TOPDIR)/make/ToolsJdk.gmk
NON_BYTE_NUMBER_TYPES := char short int long float double
NUMBER_TYPES := byte $(NON_BYTE_NUMBER_TYPES)
PRIMITIVE_TYPES := boolean $(NUMBER_TYPES)
################################################################################
# The Conv function converts a type given as first argument (as a normal Java
# native type name), into one of several corresponding strings, depending on
# the aspect given in the second argument
#
# The implementation dispatches the call to one of several Conv_<aspect> macros.
#
# arg $1: the type to convert
# arg $2: the aspect to convert for
# arg $3: byte order (only needed for certain aspects)
#
Conv = \
$(strip $(call Conv_$(strip $2),$(strip $1),$(strip $3)))
################################################################################
# Conv_<aspect> implementations
# Return a single letter representing the type (lowercase first letter)
Conv_x = \
$(call firstchar, $1)
# Return capitalized type name
Conv_Type = \
$(call titlecase, $1)
# Return the full descriptive name of the type, e.g. int -> integer
Conv_fulltype = \
$(if $(filter char, $1), \
character, \
$(if $(filter int, $1), \
integer, \
$1 \
) \
)
# Return the capitalized full descriptive name of the type, e.g. int -> Integer
Conv_Fulltype = \
$(call titlecase, $(call Conv_fulltype, $1))
# Return log2 bits per value (0-3)
Conv_LBPV = \
$(if $(filter byte, $1), \
0, \
$(if $(filter char short, $1), \
1, \
$(if $(filter int float, $1), \
2, \
$(if $(filter long double, $1), \
3))))
# Return float or int category
Conv_category = \
$(if $(filter float double, $1), \
floatingPointType, \
integralType \
)
# Return stream information for char
Conv_streams = \
$(if $(filter char, $1), streamableType)
# Return stream type information for char
Conv_streamtype = \
$(if $(filter char, $1), int)
# Return capitalized stream type information for char
Conv_Streamtype = \
$(if $(filter char, $1), Int)
# Return article to use for type in English text
Conv_a = \
$(if $(filter int, $1), an, a)
# Return capitalized article to use for type in English text
Conv_A = \
$(if $(filter int, $1), An, A)
# Return integer type with same size as the type
Conv_memtype = \
$(if $(filter float, $1), int, $(if $(filter double, $1), long, $1))
# Return capitalized integer type with same size as the type
Conv_Memtype = \
$(call titlecase, $(call Conv, $1, memtype))
# Return capitalized full descriptive name for integer type with same size as the type
Conv_FullMemtype = \
$(call Conv, $(call Conv, $1, memtype), Fulltype)
# Return Type or Memtype depending on byte order
# arg $2: BYTE_ORDER
Conv_Swaptype = \
$(if $(filter U, $2), \
$(call Conv, $1, Type), \
$(call Conv, $1, Memtype))
# Return fromBits method name for floating types, depending on byte order
# arg $2: BYTE_ORDER
Conv_fromBits = \
$(if $(filter float double, $1), \
$(if $(filter U, $2), , \
$(call Conv, $1, Type).$(call Conv, $1, memtype)BitsTo$(call Conv, $1, Type)))
# Return toBits method name for floating types, depending on byte order
# arg $2: BYTE_ORDER
Conv_toBits = \
$(if $(filter float double, $1), \
$(if $(filter U, $2), , \
$(call Conv, $1, Type).$1ToRaw$(call Conv, $(call Conv, $1, memtype), Type)Bits))
# Return swap method name, depending on byte order
# arg $2: BYTE_ORDER
Conv_swap = \
$(if $(filter S, $2), Bits.swap)
# Return word describing the number of bytes required by type
Conv_nbytes = \
$(if $(filter 0, $(call Conv, $1, LBPV)), one, \
$(if $(filter 1, $(call Conv, $1, LBPV)), two, \
$(if $(filter 2, $(call Conv, $1, LBPV)), four, \
$(if $(filter 3, $(call Conv, $1, LBPV)), eight))))
# Return word describing the number of bytes required by type, minus one
Conv_nbytesButOne = \
$(if $(filter 0, $(call Conv, $1, LBPV)), zero, \
$(if $(filter 1, $(call Conv, $1, LBPV)), one, \
$(if $(filter 2, $(call Conv, $1, LBPV)), three, \
$(if $(filter 3, $(call Conv, $1, LBPV)), seven))))
################################################################################
# Setup make rules that runs the spp.Spp build tool on an input file.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These include:
# BEGIN_END Set to true to exclude everything outside #begin/#end (default: false)
# SUBST_EMPTY_LINES Set to false to not generate empty lines for removed lines (default: true)
# SOURCE_FILE The input file to process (required)
# OUTPUT_FILE The output file (required)
# INFO Override default message to print (optional)
# KEYS One or more keys to control the generation (optional)
# REPLACEMENTS one or more text replacement patterns, using the syntax:
# VAR=VALUE [VAR=VALUE] ...
#
SetupStreamPreProcessing = $(NamedParamsMacroTemplate)
define SetupStreamPreProcessingBody
# Verify arguments
ifeq ($$($1_SOURCE_FILE), )
$$(error Must specify SOURCE_FILE (in $1))
endif
ifeq ($$($1_OUTPUT_FILE), )
$$(error Must specify OUTPUT_FILE (in $1))
endif
$1_COMMAND_LINE :=
ifeq ($$($1_BEGIN_END), true)
$1_COMMAND_LINE += -be
endif
ifeq ($$($1_SUBST_EMPTY_LINES), false)
$1_COMMAND_LINE += -nel
endif
$1_COMMAND_LINE += $$(foreach k, $$($1_KEYS), -K$$k)
$1_COMMAND_LINE += $$(subst $$$$(SPACE), ,$$(foreach d, $$($1_REPLACEMENTS), -D$$d))
$1_COMMAND_LINE += -i$$($1_SOURCE_FILE) -o$$($1_OUTPUT_FILE).tmp
ifeq ($$($1_INFO), )
$1_INFO := Preprocessing $$(notdir $$($1_SOURCE_FILE)) for $(MODULE)
endif
$$(eval $$(call SetupExecute, RUN_SPP_$1, \
INFO := $$($1_INFO), \
DEPS := $$($1_SOURCE_FILE) $$(BUILD_TOOLS_JDK), \
OUTPUT_FILE := $$($1_OUTPUT_FILE), \
COMMAND := $$(TOOL_SPP) $$($1_COMMAND_LINE), \
PRE_COMMAND := $$(RM) $$($1_OUTPUT_FILE).tmp $$($1_OUTPUT_FILE), \
POST_COMMAND := $$(MV) $$($1_OUTPUT_FILE).tmp $$($1_OUTPUT_FILE), \
))
$1 += $$(RUN_SPP_$1)
endef
################################################################################
endif # include guard
include MakeIncludeEnd.gmk

View File

@ -26,6 +26,8 @@
################################################################################
include GensrcCommon.gmk
include GensrcProperties.gmk
include GensrcStreamPreProcessing.gmk
include gensrc/GensrcBuffer.gmk
include gensrc/GensrcCharacterData.gmk
@ -71,8 +73,6 @@ TARGETS += $(CLDR_GEN_DONE)
################################################################################
include GensrcProperties.gmk
$(eval $(call SetupCompileProperties, LIST_RESOURCE_BUNDLE, \
SRC_DIRS := $(MODULE_SRC)/share/classes/sun/launcher/resources, \
CLASS := ListResourceBundle, \

View File

@ -28,363 +28,222 @@ ifeq ($(INCLUDE), true)
################################################################################
GENSRC_BUFFER :=
BUFFER_INPUT_DIR := $(MODULE_SRC)/share/classes/java/nio
BUFFER_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio
GENSRC_BUFFER_DST := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio
################################################################################
# Helper method to setup generation of bin snippets.
# Will add the generated snippet file name to $1_BIN_SNIPPET_FILES.
#
# arg $1: $1 as passed into SetupGenBuffer
# arg $2: type for this bin snippet
define SetupGenBufferBinSnippets
$1_$2_TMP := $$(BUFFER_OUTPUT_DIR)/$1.java.bin-snippet.$2
GENSRC_BUFFER_SRC := $(MODULE_SRC)/share/classes/java/nio
###
$(GENSRC_BUFFER_DST)/_the.buffer.dir:
$(call LogInfo, Generating buffer classes)
$(call MakeDir, $(@D))
$(TOUCH) $@
define fixRw
$1_RW := $2
$1_rwkey := rw
ifeq (R, $2)
$1_rwkey := ro
endif
endef
define typesAndBits
# param 1 target
# param 2 type
# param 3 BO
$1_a := a
$1_A := A
$1_type := $2
ifeq ($2, byte)
$1_x := b
$1_Type := Byte
$1_fulltype := byte
$1_Fulltype := Byte
$1_category := integralType
$1_LBPV := 0
endif
ifeq ($2, char)
$1_x := c
$1_Type := Char
$1_fulltype := character
$1_Fulltype := Character
$1_category := integralType
$1_streams := streamableType
$1_streamtype := int
$1_Streamtype := Int
$1_LBPV := 1
endif
ifeq ($2, short)
$1_x := s
$1_Type := Short
$1_fulltype := short
$1_Fulltype := Short
$1_category := integralType
$1_LBPV := 1
endif
ifeq ($2, int)
$1_a := an
$1_A := An
$1_x := i
$1_Type := Int
$1_fulltype := integer
$1_Fulltype := Integer
$1_category := integralType
$1_LBPV := 2
endif
ifeq ($2, long)
$1_x := l
$1_Type := Long
$1_fulltype := long
$1_Fulltype := Long
$1_category := integralType
$1_LBPV := 3
endif
ifeq ($2, float)
$1_x := f
$1_Type := Float
$1_fulltype := float
$1_Fulltype := Float
$1_category := floatingPointType
$1_LBPV := 2
endif
ifeq ($2, double)
$1_x := d
$1_Type := Double
$1_fulltype := double
$1_Fulltype := Double
$1_category := floatingPointType
$1_LBPV := 3
endif
$1_Swaptype := $$($1_Type)
$1_memtype := $2
$1_Memtype := $$($1_Type)
ifeq ($2, float)
$1_memtype := int
$1_Memtype := Int
ifneq ($3, U)
$1_Swaptype := Int
$1_fromBits := Float.intBitsToFloat
$1_toBits := Float.floatToRawIntBits
endif
endif
ifeq ($2, double)
$1_memtype := long
$1_Memtype := Long
ifneq ($3, U)
$1_Swaptype := Long
$1_fromBits := Double.longBitsToDouble
$1_toBits := Double.doubleToRawLongBits
endif
endif
ifeq ($3, S)
$1_swap := Bits.swap
endif
endef
define genBinOps
# param 1 target
# param 2 type
# param 3 BO
# param 4 RW
# param 5 nbytes
# param 6 nbytesButOne
$(call typesAndBits,$1,$2,$3)
$(call fixRw,$1,$4)
$1_nbytes := $5
$1_nbytesButOne := $6
$1_CMD := $(TOOL_SPP) \
-Dtype=$$($1_type) \
-DType=$$($1_Type) \
-Dfulltype=$$($1_fulltype) \
-Dmemtype=$$($1_memtype) \
-DMemtype=$$($1_Memtype) \
-DfromBits=$$($1_fromBits) \
-DtoBits=$$($1_toBits) \
-DLG_BYTES_PER_VALUE=$$($1_LBPV) \
-DBYTES_PER_VALUE="(1 << $$($1_LBPV))" \
-Dnbytes=$$($1_nbytes) \
-DnbytesButOne=$$($1_nbytesButOne) \
-DRW=$$($1_RW) \
-K$$($1_rwkey) \
-Da=$$($1_a) \
-be
endef
define SetupGenBuffer
# param 1 is for output file
# param 2 is template dependency
# param 3-9 are named args.
# type :=
# BIN :=
# RW := Mutability (R)ead-only (W)ritable
# BO := (U)nswapped/(S)wapped/(L)ittle/(B)ig
#
$(if $3,$1_$(strip $3))
$(if $4,$1_$(strip $4))
$(if $5,$1_$(strip $5))
$(if $6,$1_$(strip $6))
$(if $7,$1_$(strip $7))
$(if $8,$1_$(strip $8))
$(if $9,$1_$(strip $9))
$(if $(10),$1_$(strip $(10)))
$(if $(11),$1_$(strip $(11)))
$(if $(12),$1_$(strip $(12)))
$(if $(13),$1_$(strip $(13)))
$(if $(14),$1_$(strip $(14)))
$(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15,$(if $($i),$1_$(strip $($i)))$(NEWLINE))
$(call LogSetupMacroEntry,SetupGenBuffer($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
$(if $(16),$(error Internal makefile error: Too many arguments to SetupGenBuffer, please update GensrcBuffer.gmk))
$(call fixRw,$1,$$($1_RW))
$(call typesAndBits,$1,$$($1_type),$$($1_BO))
$1_DST := $(GENSRC_BUFFER_DST)/$1.java
$1_SRC := $(GENSRC_BUFFER_SRC)/$(strip $2).java.template
$1_SRC_BIN := $(GENSRC_BUFFER_SRC)/$(strip $2)-bin.java.template
$1_DEP := $$($1_SRC)
ifneq ($$($1_BIN), 1)
$1_DEP := $$($1_SRC)
$1_OUT := $$($1_DST)
$1_$2_LBPV := $$(call Conv, $2, LBPV)
ifeq ($$($1_READ_ONLY), true)
$1_$2_RW_KEYS := ro
$1_$2_RW_REPLACEMENT := R
else
$1_DEP += $$($1_SRC) $$($1_SRC_BIN)
$1_OUT := $(GENSRC_BUFFER_DST)/$1.binop.0.java
$1_$2_RW_KEYS := rw
$1_$2_RW_REPLACEMENT :=
endif
ifeq ($$($1_BIN), 1)
$(call genBinOps,$1_char,char,$$($1_BO),$$($1_RW),two,one)
$(call genBinOps,$1_short,short,$$($1_BO),$$($1_RW),two,one)
$(call genBinOps,$1_int,int,$$($1_BO),$$($1_RW),four,three)
$(call genBinOps,$1_long,long,$$($1_BO),$$($1_RW),eight,seven)
$(call genBinOps,$1_float,float,$$($1_BO),$$($1_RW),four,three)
$(call genBinOps,$1_double,double,$$($1_BO),$$($1_RW),eight,seven)
endif
$$($1_DST): $$($1_DEP) $(GENSRC_BUFFER_DST)/_the.buffer.dir
$(RM) $$($1_OUT).tmp
$(TOOL_SPP) -i$$($1_SRC) -o$$($1_OUT).tmp \
-K$$($1_type) \
-K$$($1_category) \
-K$$($1_streams) \
-Dtype=$$($1_type) \
-DType=$$($1_Type) \
-Dfulltype=$$($1_fulltype) \
-DFulltype=$$($1_Fulltype) \
-Dstreamtype=$$($1_streamtype) \
-DStreamtype=$$($1_Streamtype) \
-Dx=$$($1_x) \
-Dmemtype=$$($1_memtype) \
-DMemtype=$$($1_Memtype) \
-DSwaptype=$$($1_Swaptype) \
-DfromBits=$$($1_fromBits) \
-DtoBits=$$($1_toBits) \
-DLG_BYTES_PER_VALUE=$$($1_LBPV) \
-DBYTES_PER_VALUE="(1 << $$($1_LBPV))" \
-DBO=$$($1_BO) \
-Dswap=$$($1_swap) \
-DRW=$$($1_RW) \
-K$$($1_rwkey) \
-Da=$$($1_a) \
-DA=$$($1_A) \
-Kbo$$($1_BO)
$(MV) $$($1_OUT).tmp $$($1_OUT)
# Do the extra bin thing
ifeq ($$($1_BIN), 1)
$(SED) -e '/#BIN/,$$$$d' < $$($1_OUT) > $$($1_DST).tmp
$(RM) $$($1_OUT)
$$($1_char_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
$$($1_short_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
$$($1_int_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
$$($1_long_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
$$($1_float_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
$$($1_double_CMD) -i$$($1_SRC_BIN) -o$$($1_DST).tmp
$(ECHO) "}" >> $$($1_DST).tmp
mv $$($1_DST).tmp $$($1_DST)
endif
GENSRC_BUFFER += $$($1_DST)
$$(eval $$(call SetupStreamPreProcessing, GEN_BUFFER_BIN_$1_$2, \
SOURCE_FILE := $$(BUFFER_INPUT_DIR)/$$($1_TEMPLATE)-bin.java.template, \
OUTPUT_FILE := $$($1_$2_TMP), \
INFO := Generating buffer class bin snippets for $1 ($2), \
BEGIN_END := true, \
KEYS := \
$$($1_$2_RW_KEYS), \
REPLACEMENTS := \
type=$2 \
RW=$$($1_$2_RW_REPLACEMENT) \
LG_BYTES_PER_VALUE=$$($1_$2_LBPV) \
BYTES_PER_VALUE="(1$$$$(SPACE)<<$$$$(SPACE)$$($1_$2_LBPV))" \
a=$$(call Conv, $2, a) \
fulltype=$$(call Conv, $2, fulltype) \
memtype=$$(call Conv, $2, memtype) \
Memtype=$$(call Conv, $2, Memtype) \
nbytes=$$(call Conv, $2, nbytes) \
nbytesButOne=$$(call Conv, $2, nbytesButOne) \
Type=$$(call Conv, $2, Type) \
fromBits=$$(call Conv, $2, fromBits, $$($1_BYTE_ORDER)) \
toBits=$$(call Conv, $2, toBits, $$($1_BYTE_ORDER)), \
))
TARGETS += $$(GEN_BUFFER_$1_$2)
$1_BIN_SNIPPET_FILES += $$($1_$2_TMP)
endef
###
X_BUF := X-Buffer
$(eval $(call SetupGenBuffer,ByteBuffer, $(X_BUF), type := byte, BIN := 1))
$(eval $(call SetupGenBuffer,CharBuffer, $(X_BUF), type := char))
$(eval $(call SetupGenBuffer,ShortBuffer, $(X_BUF), type := short))
$(eval $(call SetupGenBuffer,IntBuffer, $(X_BUF), type := int))
$(eval $(call SetupGenBuffer,LongBuffer, $(X_BUF), type := long))
$(eval $(call SetupGenBuffer,FloatBuffer, $(X_BUF), type := float))
$(eval $(call SetupGenBuffer,DoubleBuffer,$(X_BUF), type := double))
# Buffers whose contents are heap-allocated
################################################################################
# Setup make rules that creates a generated buffer class java source file,
# according to specifications provided.
#
HEAP_X_BUF := Heap-X-Buffer
$(eval $(call SetupGenBuffer,HeapByteBuffer, $(HEAP_X_BUF), type := byte))
$(eval $(call SetupGenBuffer,HeapByteBufferR, $(HEAP_X_BUF), type := byte, RW := R))
$(eval $(call SetupGenBuffer,HeapCharBuffer, $(HEAP_X_BUF), type := char))
$(eval $(call SetupGenBuffer,HeapCharBufferR, $(HEAP_X_BUF), type := char, RW := R))
$(eval $(call SetupGenBuffer,HeapShortBuffer, $(HEAP_X_BUF), type := short))
$(eval $(call SetupGenBuffer,HeapShortBufferR, $(HEAP_X_BUF), type := short, RW := R))
$(eval $(call SetupGenBuffer,HeapIntBuffer, $(HEAP_X_BUF), type := int))
$(eval $(call SetupGenBuffer,HeapIntBufferR, $(HEAP_X_BUF), type := int, RW := R))
$(eval $(call SetupGenBuffer,HeapLongBuffer, $(HEAP_X_BUF), type := long))
$(eval $(call SetupGenBuffer,HeapLongBufferR, $(HEAP_X_BUF), type := long, RW := R))
$(eval $(call SetupGenBuffer,HeapFloatBuffer, $(HEAP_X_BUF), type := float))
$(eval $(call SetupGenBuffer,HeapFloatBufferR, $(HEAP_X_BUF), type := float, RW := R))
$(eval $(call SetupGenBuffer,HeapDoubleBuffer, $(HEAP_X_BUF), type := double))
$(eval $(call SetupGenBuffer,HeapDoubleBufferR,$(HEAP_X_BUF), type := double, RW := R))
# Direct byte buffer
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name. The output
# file name is also based on this.
#
DIRECT_X_BUF := Direct-X-Buffer
$(eval $(call SetupGenBuffer,DirectByteBuffer, $(DIRECT_X_BUF), type := byte, BIN := 1))
$(eval $(call SetupGenBuffer,DirectByteBufferR,$(DIRECT_X_BUF), type := byte, BIN := 1, RW := R))
# Unswapped views of direct byte buffers
# Remaining parameters are named arguments. These include:
# TYPE The native type
# TEMPLATE The base file name of the template to use
# BYTE_ORDER (U)nswapped/(S)wapped/(L)ittle/(B)ig
# READ_ONLY Set to true to generate read-only buffers (default: false)
# GENERATE_BIN Set to true to generate bin snippets (default: false)
#
$(eval $(call SetupGenBuffer,DirectCharBufferU, $(DIRECT_X_BUF), type := char, BO := U))
$(eval $(call SetupGenBuffer,DirectCharBufferRU, $(DIRECT_X_BUF), type := char, RW := R, BO := U))
$(eval $(call SetupGenBuffer,DirectShortBufferU, $(DIRECT_X_BUF), type := short, BO := U))
$(eval $(call SetupGenBuffer,DirectShortBufferRU, $(DIRECT_X_BUF), type := short, RW := R, BO := U))
$(eval $(call SetupGenBuffer,DirectIntBufferU, $(DIRECT_X_BUF), type := int, BO := U))
$(eval $(call SetupGenBuffer,DirectIntBufferRU, $(DIRECT_X_BUF), type := int, RW := R, BO := U))
$(eval $(call SetupGenBuffer,DirectLongBufferU, $(DIRECT_X_BUF), type := long, BO := U))
$(eval $(call SetupGenBuffer,DirectLongBufferRU, $(DIRECT_X_BUF), type := long, RW := R, BO := U))
$(eval $(call SetupGenBuffer,DirectFloatBufferU, $(DIRECT_X_BUF), type := float, BO := U))
$(eval $(call SetupGenBuffer,DirectFloatBufferRU, $(DIRECT_X_BUF), type := float, RW := R, BO := U))
$(eval $(call SetupGenBuffer,DirectDoubleBufferU, $(DIRECT_X_BUF), type := double, BO := U))
$(eval $(call SetupGenBuffer,DirectDoubleBufferRU,$(DIRECT_X_BUF), type := double, RW := R, BO := U))
SetupGenBuffer = $(NamedParamsMacroTemplate)
define SetupGenBufferBody
$1_OUTPUT := $$(BUFFER_OUTPUT_DIR)/$1.java
ifeq ($$($1_GENERATE_BIN), true)
# After generating the buffer class, we need to do further post processing,
# so output to a temporary file
$1_REAL_OUTPUT := $$($1_OUTPUT)
$1_OUTPUT := $$($1_OUTPUT).bin-snippet.tmp
endif
# Swapped views of direct byte buffers
$1_LBPV := $$(call Conv, $$($1_TYPE), LBPV)
ifeq ($$($1_READ_ONLY), true)
$1_RW_KEYS := ro
$1_RW_REPLACEMENT := R
else
$1_RW_KEYS := rw
$1_RW_REPLACEMENT :=
endif
$$(eval $$(call SetupStreamPreProcessing, GEN_BUFFER_$1, \
SOURCE_FILE := $$(BUFFER_INPUT_DIR)/$$($1_TEMPLATE).java.template, \
OUTPUT_FILE := $$($1_OUTPUT), \
INFO := Generating buffer class $1.java, \
KEYS := \
$$($1_TYPE) \
$$($1_RW_KEYS) \
bo$$($1_BYTE_ORDER) \
$$(call Conv, $$($1_TYPE), category) \
$$(call Conv, $$($1_TYPE), streams), \
REPLACEMENTS := \
type=$$($1_TYPE) \
BO=$$($1_BYTE_ORDER) \
RW=$$($1_RW_REPLACEMENT) \
LG_BYTES_PER_VALUE=$$($1_LBPV) \
BYTES_PER_VALUE="(1$$$$(SPACE)<<$$$$(SPACE)$$($1_$2_LBPV))" \
a=$$(call Conv, $$($1_TYPE), a) \
A=$$(call Conv, $$($1_TYPE), A) \
fulltype=$$(call Conv, $$($1_TYPE), fulltype) \
Fulltype=$$(call Conv, $$($1_TYPE), Fulltype) \
memtype=$$(call Conv, $$($1_TYPE), memtype) \
Memtype=$$(call Conv, $$($1_TYPE), Memtype) \
streamtype=$$(call Conv, $$($1_TYPE), streamtype) \
Streamtype=$$(call Conv, $$($1_TYPE), Streamtype) \
Type=$$(call Conv, $$($1_TYPE), Type) \
x=$$(call Conv, $$($1_TYPE), x) \
fromBits=$$(call Conv, $$($1_TYPE), fromBits, $$($1_BYTE_ORDER)) \
toBits=$$(call Conv, $$($1_TYPE), toBits, $$($1_BYTE_ORDER)) \
swap=$$(call Conv, $$($1_TYPE), swap, $$($1_BYTE_ORDER)) \
Swaptype=$$(call Conv, $$($1_TYPE), Swaptype, $$($1_BYTE_ORDER)), \
))
TARGETS += $$(GEN_BUFFER_$1)
$1 += $$(GEN_BUFFER_$1)
ifeq ($$($1_GENERATE_BIN), true)
# Setup generation of snippet files, one for each non-byte type. This will
# populate $1_BIN_SNIPPET_FILES.
$1_BIN_SNIPPET_FILES :=
$$(foreach t, $$(NON_BYTE_NUMBER_TYPES), \
$$(eval $$(call SetupGenBufferBinSnippets,$1,$$t)) \
)
# Inject these snippets in the file generated by GEN_BUFFER_$1
$$($1_REAL_OUTPUT): $$($1_OUTPUT) $$($1_BIN_SNIPPET_FILES)
$$(call LogInfo, Concatenating buffer class bin snippets for $1)
# Delete everything from the line containing #BIN and below
$$(SED) -e '/#BIN/,$$$$d' < $$($1_OUTPUT) > $$($1_REAL_OUTPUT).tmp
$$(CAT) $$($1_BIN_SNIPPET_FILES) >> $$($1_REAL_OUTPUT).tmp
$$(ECHO) "}" >> $$($1_REAL_OUTPUT).tmp
$$(MV) $$($1_REAL_OUTPUT).tmp $$($1_REAL_OUTPUT)
TARGETS += $$($1_REAL_OUTPUT)
$1 += $$($1_REAL_OUTPUT)
endif
endef
################################################################################
# Helper method to setup generation of all buffer classes, for a given
# modifiability state (read-only or not)
#
$(eval $(call SetupGenBuffer,DirectCharBufferS, $(DIRECT_X_BUF), type := char, BO := S))
$(eval $(call SetupGenBuffer,DirectCharBufferRS, $(DIRECT_X_BUF), type := char, RW := R, BO := S))
$(eval $(call SetupGenBuffer,DirectShortBufferS, $(DIRECT_X_BUF), type := short, BO := S))
$(eval $(call SetupGenBuffer,DirectShortBufferRS, $(DIRECT_X_BUF), type := short, RW := R, BO := S))
$(eval $(call SetupGenBuffer,DirectIntBufferS, $(DIRECT_X_BUF), type := int, BO := S))
$(eval $(call SetupGenBuffer,DirectIntBufferRS, $(DIRECT_X_BUF), type := int, RW := R, BO := S))
$(eval $(call SetupGenBuffer,DirectLongBufferS, $(DIRECT_X_BUF), type := long, BO := S))
$(eval $(call SetupGenBuffer,DirectLongBufferRS, $(DIRECT_X_BUF), type := long, RW := R, BO := S))
$(eval $(call SetupGenBuffer,DirectFloatBufferS, $(DIRECT_X_BUF), type := float, BO := S))
$(eval $(call SetupGenBuffer,DirectFloatBufferRS, $(DIRECT_X_BUF), type := float, RW := R, BO := S))
$(eval $(call SetupGenBuffer,DirectDoubleBufferS, $(DIRECT_X_BUF), type := double, BO := S))
$(eval $(call SetupGenBuffer,DirectDoubleBufferRS,$(DIRECT_X_BUF), type := double, RW := R, BO := S))
# arg $1: READ_ONLY argument, true or false
# arg $2: Modifiability marker for class name (R or empty)
define SetupGenerateBuffersWithRO
ifeq ($1, false)
# The basic buffer classes are not generated in READ_ONLY versions
$$(eval $$(call SetupGenBuffer, ByteBuffer, \
TYPE := byte, \
TEMPLATE := X-Buffer, \
GENERATE_BIN := true, \
))
TARGETS += $$(ByteBuffer)
# Big-endian views of byte buffers
#
BYTE_X_BUF := ByteBufferAs-X-Buffer
$$(foreach t, $$(NON_BYTE_NUMBER_TYPES), \
$$(eval $$(call SetupGenBuffer, $$(call titlecase, $$t)Buffer, \
TYPE := $$t, \
TEMPLATE := X-Buffer, \
)) \
$$(eval TARGETS += $$($$(call titlecase, $$t)Buffer)) \
)
endif
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferB, $(BYTE_X_BUF), type := char, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferRB, $(BYTE_X_BUF), type := char, RW := R, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferB, $(BYTE_X_BUF), type := short, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferRB, $(BYTE_X_BUF), type := short, RW := R, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferB, $(BYTE_X_BUF), type := int, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferRB, $(BYTE_X_BUF), type := int, RW := R, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferB, $(BYTE_X_BUF), type := long, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferRB, $(BYTE_X_BUF), type := long, RW := R, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferB, $(BYTE_X_BUF), type := float, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferRB, $(BYTE_X_BUF), type := float, RW := R, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferB, $(BYTE_X_BUF), type := double, BO := B))
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferRB,$(BYTE_X_BUF), type := double, RW := R, BO := B))
# Buffers whose contents are heap-allocated, one for every type
$$(foreach t, $$(NUMBER_TYPES), \
$$(eval $$(call SetupGenBuffer, Heap$$(call titlecase, $$t)Buffer$2, \
TYPE := $$t, \
TEMPLATE := Heap-X-Buffer, \
READ_ONLY := $1, \
)) \
$$(eval TARGETS += $$(Heap$$(call titlecase, $$t)Buffer$2)) \
)
# Little-endian views of byte buffers
#
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferL, $(BYTE_X_BUF), type := char, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsCharBufferRL, $(BYTE_X_BUF), type := char, RW := R, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferL, $(BYTE_X_BUF), type := short, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsShortBufferRL, $(BYTE_X_BUF), type := short, RW := R, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferL, $(BYTE_X_BUF), type := int, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsIntBufferRL, $(BYTE_X_BUF), type := int, RW := R, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferL, $(BYTE_X_BUF), type := long, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsLongBufferRL, $(BYTE_X_BUF), type := long, RW := R, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferL, $(BYTE_X_BUF), type := float, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsFloatBufferRL, $(BYTE_X_BUF), type := float, RW := R, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferL, $(BYTE_X_BUF), type := double, BO := L))
$(eval $(call SetupGenBuffer,ByteBufferAsDoubleBufferRL,$(BYTE_X_BUF), type := double, RW := R, BO := L))
# Treat byte special for DirectByteBuffer classes
$$(eval $$(call SetupGenBuffer, DirectByteBuffer$2, \
TEMPLATE := Direct-X-Buffer, \
TYPE := byte, \
GENERATE_BIN := true, \
READ_ONLY := $1, \
))
TARGETS += $$(DirectByteBuffer$2)
###
# Generate Swapped and Unswapped views of the direct byte buffers, each for
# every non-byte type
$$(foreach b, U S, \
$$(foreach t, $$(NON_BYTE_NUMBER_TYPES), \
$$(eval $$(call SetupGenBuffer, Direct$$(call titlecase, $$t)Buffer$2$$b, \
TYPE := $$t, \
TEMPLATE := Direct-X-Buffer, \
BYTE_ORDER := $$b, \
READ_ONLY := $1, \
)) \
$$(eval TARGETS += $$(Direct$$(call titlecase, $$t)Buffer$2$$b)) \
) \
)
$(GENSRC_BUFFER): $(BUILD_TOOLS_JDK)
# Generate Big and Little endian views of the direct byte buffers, each for
# every non-byte type
$$(foreach b, B L, \
$$(foreach t, $$(NON_BYTE_NUMBER_TYPES), \
$$(eval $$(call SetupGenBuffer, ByteBufferAs$$(call titlecase, $$t)Buffer$2$$b, \
TYPE := $$t, \
TEMPLATE := ByteBufferAs-X-Buffer, \
BYTE_ORDER := $$b, \
READ_ONLY := $1, \
)) \
$$(eval TARGETS += $$(ByteBufferAs$$(call titlecase, $$t)Buffer$2$$b)) \
) \
)
endef
TARGETS += $(GENSRC_BUFFER)
################################################################################
# Generate buffers in both read-write and read-only variants for all buffers
$(eval $(call SetupGenerateBuffersWithRO,false,))
$(eval $(call SetupGenerateBuffersWithRO,true,R))
################################################################################

View File

@ -28,91 +28,74 @@ ifeq ($(INCLUDE), true)
################################################################################
GENSRC_CHARSETCODER :=
GENSRC_CHARSETCODER_DST := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio/charset
GENSRC_CHARSETCODER_SRC := $(MODULE_SRC)/share/classes/java/nio
GENSRC_CHARSETCODER_TEMPLATE := $(GENSRC_CHARSETCODER_SRC)/charset/Charset-X-Coder.java.template
CHARSETCODER_INPUT := $(MODULE_SRC)/share/classes/java/nio/charset/Charset-X-Coder.java.template
CHARSETCODER_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio/charset
################################################################################
$(GENSRC_CHARSETCODER_DST)/CharsetDecoder.java: $(GENSRC_CHARSETCODER_TEMPLATE)
$(call MakeTargetDir)
$(RM) $@.tmp
$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/gensrc/java.base/_charset_decoder, \
$(TOOL_SPP) -i$< -o$@.tmp \
-Kdecoder \
-DA='A' \
-Da='a' \
-DCode='Decode' \
-Dcode='decode' \
-DitypesPhrase='bytes in a specific charset' \
-DotypesPhrase='sixteen-bit Unicode characters' \
-Ditype='byte' \
-Dotype='character' \
-DItype='Byte' \
-DOtype='Char' \
-Dcoder='decoder' \
-DCoder='Decoder' \
-Dcoding='decoding' \
-DOtherCoder='Encoder' \
-DreplTypeName='string' \
-DdefaultRepl='"\\uFFFD"' \
-DdefaultReplName='<code>"\&#92;uFFFD"<\/code>' \
-DreplType='String' \
-DreplFQType='java.lang.String' \
-DreplLength='length()' \
-DItypesPerOtype='CharsPerByte' \
-DnotLegal='not legal for this charset' \
-Dotypes-per-itype='chars-per-byte' \
-DoutSequence='Unicode character')
$(MV) $@.tmp $@
$(eval $(call SetupStreamPreProcessing, GEN_CHARSETDECODER, \
SOURCE_FILE := $(CHARSETCODER_INPUT), \
OUTPUT_FILE := $(CHARSETCODER_OUTPUT_DIR)/CharsetDecoder.java, \
INFO := Generating CharsetDecoder.java, \
KEYS := decoder, \
REPLACEMENTS := \
A='A' \
a='a' \
Code='Decode' \
code='decode' \
itypesPhrase='bytes$$(SPACE)in$$(SPACE)a$$(SPACE)specific$$(SPACE)charset' \
otypesPhrase='sixteen-bit$$(SPACE)Unicode$$(SPACE)characters' \
itype='byte' \
otype='character' \
Itype='Byte' \
Otype='Char' \
coder='decoder' \
Coder='Decoder' \
coding='decoding' \
OtherCoder='Encoder' \
replTypeName='string' \
replType='String' \
replFQType='java.lang.String' \
replLength='length()' \
ItypesPerOtype='CharsPerByte' \
notLegal='not$$(SPACE)legal$$(SPACE)for$$(SPACE)this$$(SPACE)charset' \
otypes-per-itype='chars-per-byte' \
outSequence='Unicode$$(SPACE)character', \
))
GENSRC_CHARSETCODER += $(GENSRC_CHARSETCODER_DST)/CharsetDecoder.java
TARGETS += $(GEN_CHARSETDECODER)
################################################################################
$(eval $(call SetupStreamPreProcessing, GEN_CHARSETENCODER, \
SOURCE_FILE := $(CHARSETCODER_INPUT), \
OUTPUT_FILE := $(CHARSETCODER_OUTPUT_DIR)/CharsetEncoder.java, \
INFO := Generating CharsetEncoder.java, \
KEYS := encoder, \
REPLACEMENTS := \
A='An' \
a='an' \
Code='Encode' \
code='encode' \
itypesPhrase='sixteen-bit$$(SPACE)Unicode$$(SPACE)characters' \
otypesPhrase='bytes$$(SPACE)in$$(SPACE)a$$(SPACE)specific$$(SPACE)charset' \
itype='character' \
otype='byte' \
Itype='Char' \
Otype='Byte' \
coder='encoder' \
Coder='Encoder' \
coding='encoding' \
OtherCoder='Decoder' \
replTypeName='byte$$(SPACE)array' \
replType='byte[]' \
replFQType='byte[]' \
replLength='length' \
ItypesPerOtype='BytesPerChar' \
notLegal='not$$(SPACE)a$$(SPACE)legal$$(SPACE)sixteen-bit$$(SPACE)Unicode$$(SPACE)sequence' \
otypes-per-itype='bytes-per-char' \
outSequence='byte$$(SPACE)sequence$$(SPACE)in$$(SPACE)the$$(SPACE)given$$(SPACE)charset', \
))
$(GENSRC_CHARSETCODER_DST)/CharsetEncoder.java: $(GENSRC_CHARSETCODER_TEMPLATE)
$(call MakeTargetDir)
$(RM) $@.tmp
$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/gensrc/java.base/_charset_encoder, \
$(TOOL_SPP) -i$< -o$@.tmp \
-Kencoder \
-DA='An' \
-Da='an' \
-DCode='Encode' \
-Dcode='encode' \
-DitypesPhrase='sixteen-bit Unicode characters' \
-DotypesPhrase='bytes in a specific charset' \
-Ditype='character' \
-Dotype='byte' \
-DItype='Char' \
-DOtype='Byte' \
-Dcoder='encoder' \
-DCoder='Encoder' \
-Dcoding='encoding' \
-DOtherCoder='Decoder' \
-DreplTypeName='byte array' \
-DdefaultRepl='new byte[] { (byte)'"'"\\?"'"' }' \
-DdefaultReplName='<code>{<\/code>\&nbsp;<code>(byte)'"'"\\?"'"'<\/code>\&nbsp;<code>}<\/code>' \
-DreplType='byte[]' \
-DreplFQType='byte[]' \
-DreplLength='length' \
-DItypesPerOtype='BytesPerChar' \
-DnotLegal='not a legal sixteen-bit Unicode sequence' \
-Dotypes-per-itype='bytes-per-char' \
-DoutSequence='byte sequence in the given charset')
$(MV) $@.tmp $@
GENSRC_CHARSETCODER += $(GENSRC_CHARSETCODER_DST)/CharsetEncoder.java
################################################################################
$(GENSRC_CHARSETCODER): $(BUILD_TOOLS_JDK)
TARGETS += $(GENSRC_CHARSETCODER)
TARGETS += $(GEN_CHARSETENCODER)
################################################################################

View File

@ -28,144 +28,77 @@ ifeq ($(INCLUDE), true)
################################################################################
SCOPED_MEMORY_ACCESS_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/jdk/internal/misc
SCOPED_MEMORY_ACCESS_SRC_DIR := $(MODULE_SRC)/share/classes/jdk/internal/misc
SCOPED_MEMORY_ACCESS_TEMPLATE := $(SCOPED_MEMORY_ACCESS_SRC_DIR)/X-ScopedMemoryAccess.java.template
SCOPED_MEMORY_ACCESS_BIN_TEMPLATE := $(SCOPED_MEMORY_ACCESS_SRC_DIR)/X-ScopedMemoryAccess-bin.java.template
SCOPED_MEMORY_ACCESS_DEST := $(SCOPED_MEMORY_ACCESS_GENSRC_DIR)/ScopedMemoryAccess.java
SCOPED_INPUT_DIR := $(MODULE_SRC)/share/classes/jdk/internal/misc
SCOPED_INPUT := $(SCOPED_INPUT_DIR)/X-ScopedMemoryAccess.java.template
SCOPED_OUTPUT := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/jdk/internal/misc/ScopedMemoryAccess.java
################################################################################
# Setup a rule for generating the ScopedMemoryAccess java class
# Param 1 - Variable declaration prefix
# Param 2 - Type with first letter capitalized
define GenerateScopedOp
# Helper method to setup generation of scoped snippets.
# Will add the generated snippet file name to SCOPED_SNIPPET_FILES.
#
# arg $1: type for this snippet
define SetupGenScopedSnippets
$1_SCOPED_SNIPPET_FILE := $$(SCOPED_OUTPUT).snippet.$1
$1_Type := $2
ifeq ($$($1_Type), Boolean)
$1_type := boolean
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_KEYS := $1 CAS
ifneq ($$(filter byte, $1),)
$1_KEYS += byte
endif
ifneq ($$(filter float double, $1),)
$1_KEYS += floatingPoint
endif
ifneq ($$(filter char short int long, $1),)
$1_KEYS += Unaligned
endif
ifneq ($$(filter boolean byte char short, $1),)
$1_KEYS += ShorterThanInt
endif
ifeq ($$(filter boolean, $1),)
$1_KEYS += AtomicAdd
endif
ifeq ($$(filter float double, $1),)
$1_KEYS += Bitwise
endif
ifeq ($$($1_Type), Byte)
$1_type := byte
$1_BoxType := $$($1_Type)
$$(eval $$(call SetupStreamPreProcessing, GEN_SCOPED_SNIPPET_$1, \
SOURCE_FILE := $$(SCOPED_INPUT_DIR)/X-ScopedMemoryAccess-bin.java.template, \
OUTPUT_FILE := $$($1_SCOPED_SNIPPET_FILE), \
INFO := Generating snippets for ScopedMemoryAccess ($1), \
SUBST_EMPTY_LINES := false, \
KEYS := $$($1_KEYS), \
REPLACEMENTS := \
type=$1 \
Type=$$(call Conv, $1, Type), \
))
TARGETS += $$(GEN_SCOPED_SNIPPET_$1)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -Kbyte
endif
ifeq ($$($1_Type), Short)
$1_type := short
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KUnaligned
endif
ifeq ($$($1_Type), Char)
$1_type := char
$1_BoxType := Character
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KUnaligned
endif
ifeq ($$($1_Type), Int)
$1_type := int
$1_BoxType := Integer
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KUnaligned
endif
ifeq ($$($1_Type), Long)
$1_type := long
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KUnaligned
endif
ifeq ($$($1_Type), Float)
$1_type := float
$1_BoxType := $$($1_Type)
$1_rawType := int
$1_RawType := Int
$1_RawBoxType := Integer
$1_ARGS += -KCAS
$1_ARGS += -KfloatingPoint
endif
ifeq ($$($1_Type), Double)
$1_type := double
$1_BoxType := $$($1_Type)
$1_rawType := long
$1_RawType := Long
$1_RawBoxType := Long
$1_ARGS += -KCAS
$1_ARGS += -KfloatingPoint
endif
ifneq ($$(findstring $$($1_Type), Byte Short Char Int Long Float Double), )
$1_ARGS += -KAtomicAdd
endif
ifneq ($$(findstring $$($1_Type), Boolean Byte Short Char Int Long), )
$1_ARGS += -KBitwise
endif
ifneq ($$(findstring $$($1_Type), Boolean Byte Short Char), )
$1_ARGS += -KShorterThanInt
endif
SCOPED_SNIPPET_FILES += $$($1_SCOPED_SNIPPET_FILE)
endef
################################################################################
# Setup a rule for generating the ScopedMemoryAccess java class
# Setup generation of snippet files, one for each primitive type. This will
# populate SCOPED_SNIPPET_FILES.
SCOPE_MEMORY_ACCESS_TYPES := Boolean Byte Short Char Int Long Float Double
$(foreach t, $(SCOPE_MEMORY_ACCESS_TYPES), \
$(eval $(call GenerateScopedOp,BIN_$t,$t)))
# SCOPED_TYPES is identical to PRIMITIVE_TYPES, but with a slightly different
# order. Keep the original SCOPED_TYPES order for now to not change the
# generated file.
SCOPED_TYPES := boolean byte short char int long float double
$(SCOPED_MEMORY_ACCESS_DEST): $(BUILD_TOOLS_JDK) $(SCOPED_MEMORY_ACCESS_TEMPLATE) $(SCOPED_MEMORY_ACCESS_BIN_TEMPLATE)
$(call MakeDir, $(SCOPED_MEMORY_ACCESS_GENSRC_DIR))
$(CAT) $(SCOPED_MEMORY_ACCESS_TEMPLATE) > $(SCOPED_MEMORY_ACCESS_DEST)
$(foreach t, $(SCOPE_MEMORY_ACCESS_TYPES), \
$(TOOL_SPP) -nel -K$(BIN_$t_type) -Dtype=$(BIN_$t_type) -DType=$(BIN_$t_Type) $(BIN_$t_ARGS) \
-i$(SCOPED_MEMORY_ACCESS_BIN_TEMPLATE) -o$(SCOPED_MEMORY_ACCESS_DEST) ;)
$(ECHO) "}" >> $(SCOPED_MEMORY_ACCESS_DEST)
SCOPED_SNIPPET_FILES :=
$(foreach t, $(SCOPED_TYPES), \
$(eval $(call SetupGenScopedSnippets,$t)) \
)
TARGETS += $(SCOPED_MEMORY_ACCESS_DEST)
# Setup a rule for generating the ScopedMemoryAccess java class by incorporating
# those snippets
$(SCOPED_OUTPUT): $(SCOPED_INPUT) $(SCOPED_SNIPPET_FILES)
$(call LogInfo, Concatenating snippets for ScopedMemoryAccess.java)
$(CAT) $(SCOPED_INPUT) > $(SCOPED_OUTPUT).tmp
$(CAT) $(SCOPED_SNIPPET_FILES) >> $(SCOPED_OUTPUT).tmp
$(ECHO) "}" >> $(SCOPED_OUTPUT).tmp
$(MV) $(SCOPED_OUTPUT).tmp $(SCOPED_OUTPUT)
TARGETS += $(SCOPED_OUTPUT)
################################################################################

View File

@ -28,277 +28,132 @@ ifeq ($(INCLUDE), true)
################################################################################
GENSRC_VARHANDLES :=
VARHANDLES_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke
VARHANDLES_SRC_DIR := $(MODULE_SRC)/share/classes/java/lang/invoke
VARHANDLES_INPUT_DIR := $(MODULE_SRC)/share/classes/java/lang/invoke
VARHANDLES_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/invoke
################################################################################
# Setup a rule for generating a VarHandle java class
# Param 1 - Variable declaration prefix
# Param 2 - Type with first letter capitalized
#
# arg $1: type for this varhandle
define GenerateVarHandle
VARHANDLE_$1_type := $$(strip $$(if $$(filter reference, $1), Object, $1))
VARHANDLE_$1_Type := $$(call Conv, $1, Type)
$1_Type := $2
$1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandle$$($1_Type)s.java
$1_ARGS += -KCAS
ifneq ($$(findstring $$($1_Type), Byte Short Char Int Long Float Double), )
$1_ARGS += -KAtomicAdd
$1_KEYS := $$(VARHANDLE_$1_type) CAS
ifneq ($$(filter byte short char, $1),)
$1_KEYS += ShorterThanInt
endif
ifeq ($$(filter boolean reference, $1),)
$1_KEYS += AtomicAdd
endif
ifeq ($$(filter float double reference, $1),)
$1_KEYS += Bitwise
endif
ifneq ($$(findstring $$($1_Type), Boolean Byte Short Char Int Long), )
$1_ARGS += -KBitwise
endif
ifneq ($$(findstring $$($1_Type), Byte Short Char), )
$1_ARGS += -KShorterThanInt
endif
$$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandle.java.template $(BUILD_TOOLS_JDK)
ifeq ($$($1_Type), Reference)
$$(eval $1_type := Object)
else
$$(eval $1_type := $$$$(shell $(TR) '[:upper:]' '[:lower:]' <<< $$$$($1_Type)))
endif
$$(call MakeDir, $$(@D))
$(RM) $$@
$(TOOL_SPP) -nel -K$$($1_type) -Dtype=$$($1_type) -DType=$$($1_Type) \
$$($1_ARGS) -i$$< -o$$@
GENSRC_VARHANDLES += $$($1_FILENAME)
$$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_$1, \
SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandle.java.template, \
OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandle$$(VARHANDLE_$1_Type)s.java, \
INFO := Generating VarHandle class for $1, \
SUBST_EMPTY_LINES := false, \
KEYS := $$($1_KEYS), \
REPLACEMENTS := \
type=$$(VARHANDLE_$1_type) \
Type=$$(VARHANDLE_$1_Type), \
))
TARGETS += $$(GEN_VARHANDLE_$1)
endef
################################################################################
################################################################################
# Setup a rule for generating a VarHandleByteArray java class
# Param 1 - Variable declaration prefix
# Param 2 - Type with first letter capitalized
#
# arg $1: type for this varhandle
define GenerateVarHandleByteArray
VARHANDLE_BYTEARRAY_$1_Type := $$(call Conv, $1, Type)
$1_Type := $2
$1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleByteArrayAs$$($1_Type)s.java
ifeq ($$($1_Type), Short)
$1_type := short
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_KEYS := $1
ifneq ($$(filter int long float double, $1),)
$1_KEYS += CAS
endif
ifneq ($$(filter float double, $1),)
$1_KEYS += floatingPoint
endif
ifneq ($$(filter int long, $1),)
$1_KEYS += AtomicAdd Bitwise
endif
ifeq ($$($1_Type), Char)
$1_type := char
$1_BoxType := Character
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
endif
ifeq ($$($1_Type), Int)
$1_type := int
$1_BoxType := Integer
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KAtomicAdd
$1_ARGS += -KBitwise
endif
ifeq ($$($1_Type), Long)
$1_type := long
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KAtomicAdd
$1_ARGS += -KBitwise
endif
ifeq ($$($1_Type), Float)
$1_type := float
$1_BoxType := $$($1_Type)
$1_rawType := int
$1_RawType := Int
$1_RawBoxType := Integer
$1_ARGS += -KCAS
$1_ARGS += -KfloatingPoint
endif
ifeq ($$($1_Type), Double)
$1_type := double
$1_BoxType := $$($1_Type)
$1_rawType := long
$1_RawType := Long
$1_RawBoxType := Long
$1_ARGS += -KCAS
$1_ARGS += -KfloatingPoint
endif
$$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleByteArrayView.java.template $(BUILD_TOOLS_JDK)
$$(call MakeDir, $$(@D))
$(RM) $$@
$(TOOL_SPP) -nel -K$$($1_type) \
-Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \
-DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \
$$($1_ARGS) -i$$< -o$$@
GENSRC_VARHANDLES += $$($1_FILENAME)
$$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_BYTEARRAY_$1, \
SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandleByteArrayView.java.template, \
OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandleByteArrayAs$$(VARHANDLE_BYTEARRAY_$1_Type)s.java, \
INFO := Generating VarHandleByteArray class for $1, \
SUBST_EMPTY_LINES := false, \
KEYS := $$($1_KEYS), \
REPLACEMENTS := \
type=$1 \
Type=$$(VARHANDLE_BYTEARRAY_$1_Type) \
BoxType=$$(call Conv, $1, Fulltype) \
rawType=$$(call Conv, $1, memtype) \
RawType=$$(call Conv, $1, Memtype) \
RawBoxType=$$(call Conv, $1, FullMemtype), \
))
TARGETS += $$(GEN_VARHANDLE_BYTEARRAY_$1)
endef
################################################################################
################################################################################
# Setup a rule for generating a memory segment var handle view class
# Param 1 - Variable declaration prefix
# Param 2 - Type with first letter capitalized
# Setup a rule for generating a VarHandleMemorySegment java class
#
# arg $1: type for this varhandle
define GenerateVarHandleMemorySegment
VARHANDLE_SEGMENT_$1_Type := $$(call Conv, $1, Type)
$1_Type := $2
$1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandleSegmentAs$$($1_Type)s.java
ifeq ($$($1_Type), Boolean)
$1_type := boolean
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -Kbyte
$1_ARGS += -KShorterThanInt
$1_KEYS := $1
ifneq ($$(filter int long float double, $1),)
$1_KEYS += CAS
endif
ifneq ($$(filter boolean byte, $1),)
$1_KEYS += byte
endif
ifneq ($$(filter float double, $1),)
$1_KEYS += floatingPoint
endif
ifneq ($$(filter boolean byte short char, $1),)
$1_KEYS += ShorterThanInt
endif
ifneq ($$(filter int long, $1),)
$1_KEYS += AtomicAdd Bitwise
endif
ifeq ($$($1_Type), Byte)
$1_type := byte
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -Kbyte
$1_ARGS += -KShorterThanInt
endif
ifeq ($$($1_Type), Short)
$1_type := short
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KShorterThanInt
endif
ifeq ($$($1_Type), Char)
$1_type := char
$1_BoxType := Character
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KShorterThanInt
endif
ifeq ($$($1_Type), Int)
$1_type := int
$1_BoxType := Integer
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KAtomicAdd
$1_ARGS += -KBitwise
endif
ifeq ($$($1_Type), Long)
$1_type := long
$1_BoxType := $$($1_Type)
$1_rawType := $$($1_type)
$1_RawType := $$($1_Type)
$1_RawBoxType := $$($1_BoxType)
$1_ARGS += -KCAS
$1_ARGS += -KAtomicAdd
$1_ARGS += -KBitwise
endif
ifeq ($$($1_Type), Float)
$1_type := float
$1_BoxType := $$($1_Type)
$1_rawType := int
$1_RawType := Int
$1_RawBoxType := Integer
$1_ARGS += -KCAS
$1_ARGS += -KfloatingPoint
endif
ifeq ($$($1_Type), Double)
$1_type := double
$1_BoxType := $$($1_Type)
$1_rawType := long
$1_RawType := Long
$1_RawBoxType := Long
$1_ARGS += -KCAS
$1_ARGS += -KfloatingPoint
endif
$$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandleSegmentView.java.template $(BUILD_TOOLS_JDK)
$$(call MakeDir, $$(@D))
$(RM) $$@
$(TOOL_SPP) -nel -K$$($1_type) \
-Dtype=$$($1_type) -DType=$$($1_Type) -DBoxType=$$($1_BoxType) \
-DrawType=$$($1_rawType) -DRawType=$$($1_RawType) -DRawBoxType=$$($1_RawBoxType) \
$$($1_ARGS) -i$$< -o$$@
GENSRC_VARHANDLES += $$($1_FILENAME)
$$(eval $$(call SetupStreamPreProcessing, GEN_VARHANDLE_SEGMENT_$1, \
SOURCE_FILE := $$(VARHANDLES_INPUT_DIR)/X-VarHandleSegmentView.java.template, \
OUTPUT_FILE := $$(VARHANDLES_OUTPUT_DIR)/VarHandleSegmentAs$$(VARHANDLE_SEGMENT_$1_Type)s.java, \
INFO := Generating VarHandleSegment class for $1, \
SUBST_EMPTY_LINES := false, \
KEYS := $$($1_KEYS), \
REPLACEMENTS := \
type=$1 \
Type=$$(VARHANDLE_SEGMENT_$1_Type) \
BoxType=$$(call Conv, $1, Fulltype) \
rawType=$$(call Conv, $1, memtype) \
RawType=$$(call Conv, $1, Memtype) \
RawBoxType=$$(call Conv, $1, FullMemtype), \
))
TARGETS += $$(GEN_VARHANDLE_SEGMENT_$1)
endef
################################################################################
# Generate all VarHandle related classes
# List the types to generate source for, with capitalized first letter
VARHANDLES_TYPES := Boolean Byte Short Char Int Long Float Double Reference
$(foreach t, $(VARHANDLES_TYPES), \
$(eval $(call GenerateVarHandle,VAR_HANDLE_$t,$t)))
$(foreach t, $(PRIMITIVE_TYPES) reference, \
$(eval $(call GenerateVarHandle,$t)) \
)
# List the types to generate source for, with capitalized first letter
VARHANDLES_BYTE_ARRAY_TYPES := Short Char Int Long Float Double
$(foreach t, $(VARHANDLES_BYTE_ARRAY_TYPES), \
$(eval $(call GenerateVarHandleByteArray,VAR_HANDLE_BYTE_ARRAY_$t,$t)))
$(foreach t, $(NON_BYTE_NUMBER_TYPES), \
$(eval $(call GenerateVarHandleByteArray,$t)) \
)
# List the types to generate source for, with capitalized first letter
VARHANDLES_MEMORY_SEGMENT_TYPES := Boolean Byte Short Char Int Long Float Double
$(foreach t, $(VARHANDLES_MEMORY_SEGMENT_TYPES), \
$(eval $(call GenerateVarHandleMemorySegment,VAR_HANDLE_MEMORY_SEGMENT_$t,$t)))
TARGETS += $(GENSRC_VARHANDLES)
$(foreach t, $(PRIMITIVE_TYPES), \
$(eval $(call GenerateVarHandleMemorySegment,$t)) \
)
################################################################################

View File

@ -97,10 +97,10 @@ import jdk.internal.util.ArraysSupport;
*
#if[encoder]
* is initially set to the $coder$'s default replacement, which often
* (but not always) has the initial value&nbsp;$defaultReplName$;
* (but not always) has the initial value&nbsp;<code>{</code>&nbsp;<code>(byte)'?'</code>&nbsp;<code>}</code>;
#end[encoder]
#if[decoder]
* has the initial value $defaultReplName$;
* has the initial value <code>"&#92;uFFFD"</code>;
#end[decoder]
*
* its value may be changed via the {@link #replaceWith($replFQType$)
@ -212,7 +212,12 @@ public abstract class Charset$Coder$ {
/**
* Initializes a new $coder$. The new $coder$ will have the given
* $otypes-per-itype$ values and its replacement will be the
* $replTypeName$ $defaultReplName$.
#if[encoder]
* byte array <code>{</code>&nbsp;<code>(byte)'?'</code>&nbsp;<code>}</code>.
#end[encoder]
#if[decoder]
* string <code>"&#92;uFFFD"</code>.
#end[decoder]
*
* @param cs
* The charset that created this $coder$
@ -234,7 +239,12 @@ public abstract class Charset$Coder$ {
{
this(cs,
average$ItypesPerOtype$, max$ItypesPerOtype$,
$defaultRepl$);
#if[encoder]
new byte[] { (byte)'?' });
#end[encoder]
#if[decoder]
"\uFFFD");
#end[decoder]
}
/**

View File

@ -113,6 +113,63 @@ ifneq ($(call equals, $(EQUALS_VALUE2), $(EQUALS_EMPTY)), )
$(error The strings >$(EQUALS_VALUE2)< and >$(EQUALS_EMPTY)< are equal)
endif
################################################################################
# Test string manipulation
$(call AssertEquals, \
$(call uppercase, foo bar), \
FOO BAR, \
uppercase "foo bar" failed, \
)
$(call AssertEquals, \
$(call uppercase, Foo BaR 123), \
FOO BAR 123, \
uppercase "Foo BaR 123" failed, \
)
$(call AssertEquals, \
$(call lowercase, FOO BAR), \
foo bar, \
lowercase "FOO BAR" failed, \
)
$(call AssertEquals, \
$(call lowercase, Foo BaR 123), \
foo bar 123, \
lowercase "Foo BaR 123" failed, \
)
$(call AssertEquals, \
$(call titlecase, foo bar), \
Foo Bar, \
titlecase "foo bar" failed, \
)
$(call AssertEquals, \
$(call titlecase, FOO BAR), \
Foo Bar, \
titlecase "FOO BAR" failed, \
)
$(call AssertEquals, \
$(call titlecase, Foo BaR 123), \
Foo Bar 123, \
titlecase "Foo BaR 123" failed, \
)
$(call AssertEquals, \
$(call firstchar, foo bar), \
f, \
firstchar "foo bar" failed, \
)
$(call AssertEquals, \
$(call firstchar, Foo Bar), \
F, \
firstchar "Foo Bar" failed, \
)
################################################################################
# Test boolean operators