Mercurial > hg > truffle
comparison src/share/vm/runtime/fieldType.cpp @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | f95d63e2154a |
children | 1d1603768966 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
28 #include "oops/oop.inline.hpp" | 28 #include "oops/oop.inline.hpp" |
29 #include "oops/typeArrayKlass.hpp" | 29 #include "oops/typeArrayKlass.hpp" |
30 #include "runtime/fieldType.hpp" | 30 #include "runtime/fieldType.hpp" |
31 #include "runtime/signature.hpp" | 31 #include "runtime/signature.hpp" |
32 | 32 |
33 void FieldType::skip_optional_size(symbolOop signature, int* index) { | 33 void FieldType::skip_optional_size(Symbol* signature, int* index) { |
34 jchar c = signature->byte_at(*index); | 34 jchar c = signature->byte_at(*index); |
35 while (c >= '0' && c <= '9') { | 35 while (c >= '0' && c <= '9') { |
36 *index = *index + 1; | 36 *index = *index + 1; |
37 c = signature->byte_at(*index); | 37 c = signature->byte_at(*index); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 BasicType FieldType::basic_type(symbolOop signature) { | 41 BasicType FieldType::basic_type(Symbol* signature) { |
42 return char2type(signature->byte_at(0)); | 42 return char2type(signature->byte_at(0)); |
43 } | 43 } |
44 | 44 |
45 // Check if it is a valid array signature | 45 // Check if it is a valid array signature |
46 bool FieldType::is_valid_array_signature(symbolOop sig) { | 46 bool FieldType::is_valid_array_signature(Symbol* sig) { |
47 assert(sig->utf8_length() > 1, "this should already have been checked"); | 47 assert(sig->utf8_length() > 1, "this should already have been checked"); |
48 assert(sig->byte_at(0) == '[', "this should already have been checked"); | 48 assert(sig->byte_at(0) == '[', "this should already have been checked"); |
49 // The first character is already checked | 49 // The first character is already checked |
50 int i = 1; | 50 int i = 1; |
51 int len = sig->utf8_length(); | 51 int len = sig->utf8_length(); |
71 | 71 |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 BasicType FieldType::get_array_info(symbolOop signature, jint* dimension, symbolOop* object_key, TRAPS) { | 76 BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) { |
77 assert(basic_type(signature) == T_ARRAY, "must be array"); | 77 assert(basic_type(signature) == T_ARRAY, "must be array"); |
78 int index = 1; | 78 int index = 1; |
79 int dim = 1; | 79 int dim = 1; |
80 skip_optional_size(signature, &index); | 80 skip_optional_size(signature, &index); |
81 while (signature->byte_at(index) == '[') { | 81 while (signature->byte_at(index) == '[') { |
82 index++; | 82 index++; |
83 dim++; | 83 dim++; |
84 skip_optional_size(signature, &index); | 84 skip_optional_size(signature, &index); |
85 } | 85 } |
86 ResourceMark rm; | 86 ResourceMark rm; |
87 symbolOop element = oopFactory::new_symbol(signature->as_C_string() + index, CHECK_(T_BYTE)); | 87 char *element = signature->as_C_string() + index; |
88 BasicType element_type = FieldType::basic_type(element); | 88 BasicType element_type = char2type(element[0]); |
89 if (element_type == T_OBJECT) { | 89 if (element_type == T_OBJECT) { |
90 char* object_type = element->as_C_string(); | 90 int len = (int)strlen(element); |
91 object_type[element->utf8_length() - 1] = '\0'; | 91 assert(element[len-1] == ';', "last char should be a semicolon"); |
92 *object_key = oopFactory::new_symbol(object_type + 1, CHECK_(T_BYTE)); | 92 element[len-1] = '\0'; // chop off semicolon |
93 fd._object_key = SymbolTable::new_symbol(element + 1, CHECK_(T_BYTE)); | |
93 } | 94 } |
94 // Pass dimension back to caller | 95 // Pass dimension back to caller |
95 *dimension = dim; | 96 fd._dimension = dim; |
96 return element_type; | 97 return element_type; |
97 } | 98 } |