make/data/characterdata/CharacterDataLatin1.java.template
author zgu
Tue, 26 Nov 2019 14:33:56 -0500
changeset 59283 78aa7484c722
parent 58028 7ac4273bb49b
permissions -rw-r--r--
8233500: Shenandoah: Shenandoah load barrier should save registers before calling keep alive barrier on x86 Reviewed-by: rkennke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58028
7ac4273bb49b 8229831: Upgrade Character.isUnicodeIdentifierStart/Part() methods to the latest standard
naoto
parents: 52979
diff changeset
     2
 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
52979
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    28
import jdk.internal.HotSpotIntrinsicCandidate;
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/** The CharacterData class encapsulates the large tables found in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
    Java.lang.Character. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
class CharacterDataLatin1 extends CharacterData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    /* The character properties are currently encoded into 32 bits in the following manner:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
        1 bit   mirrored property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        4 bits  directionality property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        9 bits  signed offset used for converting case
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        1 bit   if 1, adding the signed offset converts the character to lowercase
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        1 bit   if 1, subtracting the signed offset converts the character to uppercase
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        1 bit   if 1, this character has a titlecase equivalent (possibly itself)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        3 bits  0  may not be part of an identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                1  ignorable control; may continue a Unicode identifier or Java identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                2  may continue a Java identifier but not a Unicode identifier (unused)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
                3  may continue a Unicode identifier or Java identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                4  is a Java whitespace character
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                5  may start or continue a Java identifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                   may continue but not start a Unicode identifier (underscores)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                6  may start or continue a Java identifier but not a Unicode identifier ($)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                7  may start or continue a Unicode identifier or Java identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                Thus:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                   5, 6, 7 may start a Java identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                   1, 2, 3, 5, 6, 7 may continue a Java identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                   7 may start a Unicode identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                   1, 3, 5, 7 may continue a Unicode identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                   1 is ignorable within an identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                   4 is Java whitespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        2 bits  0  this character has no numeric property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                1  adding the digit offset to the character code and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                   masking with 0x1F will produce the desired numeric value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                2  this character has a "strange" numeric value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                3  a Java supradecimal digit: adding the digit offset to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                   character code, then masking with 0x1F, then adding 10
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                   will produce the desired numeric value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        5 bits  digit offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        5 bits  character type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        The encoding of character properties is subject to change at any time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    int getProperties(int ch) {
9535
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    72
        char offset = (char)ch;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        int props = $$Lookup(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        return props;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
9535
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    77
    int getPropertiesEx(int ch) {
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    78
        char offset = (char)ch;
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    79
        int props = $$LookupEx(offset);
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    80
        return props;
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    81
    }
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
    82
52979
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    83
    @HotSpotIntrinsicCandidate
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    84
    boolean isDigit(int ch) {
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    85
        return '0' <= ch && ch <= '9';
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    86
    }
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    87
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    88
    @HotSpotIntrinsicCandidate
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    89
    boolean isLowerCase(int ch) {
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    90
        int props = getProperties(ch);
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    91
        return (props & $$maskType) == Character.LOWERCASE_LETTER;
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    92
    }
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    93
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    94
    @HotSpotIntrinsicCandidate
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    95
    boolean isUpperCase(int ch) {
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    96
        int props = getProperties(ch);
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    97
        return (props & $$maskType) == Character.UPPERCASE_LETTER;
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    98
    }
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
    99
9535
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   100
    boolean isOtherLowercase(int ch) {
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   101
        int props = getPropertiesEx(ch);
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   102
        return (props & $$maskOtherLowercase) != 0;
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   103
    }
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   104
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   105
    boolean isOtherUppercase(int ch) {
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   106
        int props = getPropertiesEx(ch);
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   107
        return (props & $$maskOtherUppercase) != 0;
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   108
    }
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   109
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   110
    boolean isOtherAlphabetic(int ch) {
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   111
        int props = getPropertiesEx(ch);
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   112
        return (props & $$maskOtherAlphabetic) != 0;
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   113
    }
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   114
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   115
    boolean isIdeographic(int ch) {
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   116
        int props = getPropertiesEx(ch);
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   117
        return (props & $$maskIdeographic) != 0;
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   118
    }
d930011fd275 7037261: j.l.Character.isLowerCase/isUpperCase need to match the Unicode Standard
sherman
parents: 5506
diff changeset
   119
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    int getType(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        int props = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return (props & $$maskType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    boolean isJavaIdentifierStart(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        int props = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        return ((props & $$maskIdentifierInfo) >= $$lowJavaStart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    boolean isJavaIdentifierPart(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        int props = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return ((props & $$nonzeroJavaPart) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    boolean isUnicodeIdentifierStart(int ch) {
58028
7ac4273bb49b 8229831: Upgrade Character.isUnicodeIdentifierStart/Part() methods to the latest standard
naoto
parents: 52979
diff changeset
   136
        return (getPropertiesEx(ch) & $$maskIDStart) != 0 ||
7ac4273bb49b 8229831: Upgrade Character.isUnicodeIdentifierStart/Part() methods to the latest standard
naoto
parents: 52979
diff changeset
   137
               ch == 0x2E2F;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    boolean isUnicodeIdentifierPart(int ch) {
58028
7ac4273bb49b 8229831: Upgrade Character.isUnicodeIdentifierStart/Part() methods to the latest standard
naoto
parents: 52979
diff changeset
   141
        return (getPropertiesEx(ch) & $$maskIDContinue) != 0 ||
7ac4273bb49b 8229831: Upgrade Character.isUnicodeIdentifierStart/Part() methods to the latest standard
naoto
parents: 52979
diff changeset
   142
               isIdentifierIgnorable(ch) ||
7ac4273bb49b 8229831: Upgrade Character.isUnicodeIdentifierStart/Part() methods to the latest standard
naoto
parents: 52979
diff changeset
   143
               ch == 0x2E2F;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    boolean isIdentifierIgnorable(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        int props = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        return ((props & $$maskIdentifierInfo) == $$valueIgnorable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    int toLowerCase(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        int mapChar = ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        int val = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        if (((val & $$maskLowerCase) != 0) && 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                ((val & $$maskCaseOffset) != $$maskCaseOffset)) { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            int offset = val << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            mapChar = ch + offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return mapChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    int toUpperCase(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        int mapChar = ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        int val = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if ((val & $$maskUpperCase) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            if ((val & $$maskCaseOffset) != $$maskCaseOffset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                int offset = val  << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                mapChar =  ch - offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            } else if (ch == 0x00B5) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                mapChar = 0x039C;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        return mapChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    int toTitleCase(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return toUpperCase(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
48684
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   182
    // Digit values for codePoints in the 0-255 range. Contents generated using:
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   183
    // for (char i = 0; i < 256; i++) {
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   184
    //     int v = -1;
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   185
    //     if (i >= '0' && i <= '9') { v = i - '0'; } 
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   186
    //     else if (i >= 'A' && i <= 'Z') { v = i - 'A' + 10; }
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   187
    //     else if (i >= 'a' && i <= 'z') { v = i - 'a' + 10; }
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   188
    //     if (i % 20 == 0) System.out.println();
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   189
    //     System.out.printf("%2d, ", v);
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   190
    // }
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   191
    //
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   192
    // Analysis has shown that generating the whole array allows the JIT to generate
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   193
    // better code compared to a slimmed down array, such as one cutting off after 'z'
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   194
    private static final byte[] DIGITS = new byte[] {
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   195
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   196
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   197
        -1, -1, -1, -1, -1, -1, -1, -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   198
        -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   199
        25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, 10, 11, 12,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   200
        13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   201
        33, 34, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   202
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   203
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   204
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   205
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   206
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   207
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   208
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    int digit(int ch, int radix) {
48684
29c1fede33a6 8196331: Optimize Character.digit for latin1 input
redestad
parents: 47216
diff changeset
   210
        int value = DIGITS[ch];
48740
7d5826282e8d 8196740: Character.digit(int,int) returns wrong value for out of range radix
igerasim
parents: 48684
diff changeset
   211
        return (value >= 0 && value < radix && radix >= Character.MIN_RADIX
7d5826282e8d 8196740: Character.digit(int,int) returns wrong value for out of range radix
igerasim
parents: 48684
diff changeset
   212
                && radix <= Character.MAX_RADIX) ? value : -1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    int getNumericValue(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        int val = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        int retval = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        switch (val & $$maskNumericType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            default: // cannot occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            case ($$valueNotNumeric):         // not numeric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                retval = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            case ($$valueDigit):              // simple numeric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                retval = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            case ($$valueStrangeNumeric)      :       // "strange" numeric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                 retval = -2; 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            case ($$valueJavaSupradecimal):           // Java supradecimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                retval = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
52979
7384e00d5860 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
mhorie
parents: 48740
diff changeset
   237
    @HotSpotIntrinsicCandidate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    boolean isWhitespace(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        int props = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return ((props & $$maskIdentifierInfo) == $$valueJavaWhitespace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    byte getDirectionality(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        int val = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        byte directionality = (byte)((val & $$maskBidi) >> $$shiftBidi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        if (directionality == 0xF ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            directionality = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return directionality;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    boolean isMirrored(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        int props = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return ((props & $$maskMirrored) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    int toUpperCaseEx(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        int mapChar = ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        int val = getProperties(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        if ((val & $$maskUpperCase) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            if ((val & $$maskCaseOffset) != $$maskCaseOffset) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                int offset = val  << $$shiftCaseOffsetSign >> ($$shiftCaseOffsetSign+$$shiftCaseOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                mapChar =  ch - offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                switch(ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                    // map overflow characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                    case 0x00B5 : mapChar = 0x039C; break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                    default       : mapChar = Character.ERROR; break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return mapChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    static char[] sharpsMap = new char[] {'S', 'S'};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    char[] toUpperCaseCharArray(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        char[] upperMap = {(char)ch};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (ch == 0x00DF) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            upperMap = sharpsMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        return upperMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    static final CharacterDataLatin1 instance = new CharacterDataLatin1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    private CharacterDataLatin1() {};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    $$Tables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        $$Initializers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }        
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297