author | lfoltan |
Mon, 21 Oct 2019 13:13:16 -0400 | |
changeset 58722 | cba8afa5cfed |
parent 54847 | 59ea39bb2809 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
54847
59ea39bb2809
8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents:
54786
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
54786 | 26 |
#include "classfile/symbolTable.hpp" |
7397 | 27 |
#include "classfile/systemDictionary.hpp" |
28 |
#include "memory/oopFactory.hpp" |
|
37248 | 29 |
#include "memory/resourceArea.hpp" |
7397 | 30 |
#include "oops/oop.inline.hpp" |
31 |
#include "oops/typeArrayKlass.hpp" |
|
32 |
#include "runtime/fieldType.hpp" |
|
33 |
#include "runtime/signature.hpp" |
|
1 | 34 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
35 |
BasicType FieldType::basic_type(Symbol* signature) { |
51997
9ce37fa2e179
8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents:
49354
diff
changeset
|
36 |
return char2type(signature->char_at(0)); |
1 | 37 |
} |
38 |
||
39 |
// Check if it is a valid array signature |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
40 |
bool FieldType::is_valid_array_signature(Symbol* sig) { |
1 | 41 |
assert(sig->utf8_length() > 1, "this should already have been checked"); |
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
42 |
assert(sig->char_at(0) == JVM_SIGNATURE_ARRAY, "this should already have been checked"); |
1 | 43 |
// The first character is already checked |
44 |
int i = 1; |
|
45 |
int len = sig->utf8_length(); |
|
46 |
// First skip all '['s |
|
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
47 |
while(i < len - 1 && sig->char_at(i) == JVM_SIGNATURE_ARRAY) i++; |
1 | 48 |
|
49 |
// Check type |
|
51997
9ce37fa2e179
8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents:
49354
diff
changeset
|
50 |
switch(sig->char_at(i)) { |
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
51 |
case JVM_SIGNATURE_BYTE: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
52 |
case JVM_SIGNATURE_CHAR: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
53 |
case JVM_SIGNATURE_DOUBLE: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
54 |
case JVM_SIGNATURE_FLOAT: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
55 |
case JVM_SIGNATURE_INT: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
56 |
case JVM_SIGNATURE_LONG: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
57 |
case JVM_SIGNATURE_SHORT: |
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
58 |
case JVM_SIGNATURE_BOOLEAN: |
1 | 59 |
// If it is an array, the type is the last character |
60 |
return (i + 1 == len); |
|
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
61 |
case JVM_SIGNATURE_CLASS: |
1 | 62 |
// If it is an object, the last character must be a ';' |
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
63 |
return sig->char_at(len - 1) == JVM_SIGNATURE_ENDCLASS; |
1 | 64 |
} |
65 |
||
66 |
return false; |
|
67 |
} |
|
68 |
||
69 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
70 |
BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) { |
1 | 71 |
assert(basic_type(signature) == T_ARRAY, "must be array"); |
72 |
int index = 1; |
|
73 |
int dim = 1; |
|
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
74 |
while (signature->char_at(index) == JVM_SIGNATURE_ARRAY) { |
1 | 75 |
index++; |
76 |
dim++; |
|
77 |
} |
|
78 |
ResourceMark rm; |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
79 |
char *element = signature->as_C_string() + index; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
80 |
BasicType element_type = char2type(element[0]); |
1 | 81 |
if (element_type == T_OBJECT) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
82 |
int len = (int)strlen(element); |
58722
cba8afa5cfed
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents:
54847
diff
changeset
|
83 |
assert(element[len-1] == JVM_SIGNATURE_ENDCLASS, "last char should be a semicolon"); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
84 |
element[len-1] = '\0'; // chop off semicolon |
54847
59ea39bb2809
8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents:
54786
diff
changeset
|
85 |
fd._object_key = SymbolTable::new_symbol(element + 1); |
1 | 86 |
} |
87 |
// Pass dimension back to caller |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
88 |
fd._dimension = dim; |
1 | 89 |
return element_type; |
90 |
} |