Mercurial > hg > truffle
comparison src/share/vm/classfile/vmSymbols.hpp @ 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 | 8f8dfba37802 |
children | d25d4ca69222 f36c9fe788b8 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #ifndef SHARE_VM_CLASSFILE_VMSYMBOLS_HPP | 25 #ifndef SHARE_VM_CLASSFILE_VMSYMBOLS_HPP |
26 #define SHARE_VM_CLASSFILE_VMSYMBOLS_HPP | 26 #define SHARE_VM_CLASSFILE_VMSYMBOLS_HPP |
27 | 27 |
28 #include "oops/symbolOop.hpp" | 28 #include "oops/symbol.hpp" |
29 | 29 #include "memory/iterator.hpp" |
30 // The classes vmSymbols and vmSymbolHandles are a name spaces for fast lookup of | 30 |
31 // symbols commonly used in the VM. The first class return a symbolOop, while the | 31 // The class vmSymbols is a name space for fast lookup of |
32 // second class returns a SymbolHandle. The underlying data structure is shared | 32 // symbols commonly used in the VM. |
33 // between the two classes. | |
34 // | 33 // |
35 // Sample usage: | 34 // Sample usage: |
36 // | 35 // |
37 // symbolOop obj = vmSymbols::java_lang_Object()(); | 36 // Symbol* obj = vmSymbols::java_lang_Object(); |
38 // SymbolHandle handle = vmSymbolHandles::java_lang_Object(); | |
39 | 37 |
40 | 38 |
41 // Useful sub-macros exported by this header file: | 39 // Useful sub-macros exported by this header file: |
42 | 40 |
43 #define VM_SYMBOL_ENUM_NAME(name) name##_enum | 41 #define VM_SYMBOL_ENUM_NAME(name) name##_enum |
457 \ | 455 \ |
458 /* symbol aliases needed by intrinsics */ \ | 456 /* symbol aliases needed by intrinsics */ \ |
459 VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, do_alias) \ | 457 VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, do_alias) \ |
460 \ | 458 \ |
461 /* returned by the C1 compiler in case there's not enough memory to allocate a new symbol*/ \ | 459 /* returned by the C1 compiler in case there's not enough memory to allocate a new symbol*/ \ |
462 template(dummy_symbol_oop, "illegal symbol") \ | 460 template(dummy_symbol, "illegal symbol") \ |
463 \ | 461 \ |
464 /* used by ClassFormatError when class name is not known yet */ \ | 462 /* used by ClassFormatError when class name is not known yet */ \ |
465 template(unknown_class_name, "<Unknown>") \ | 463 template(unknown_class_name, "<Unknown>") \ |
466 \ | 464 \ |
467 /* used to identify class loaders handling parallel class loading */ \ | 465 /* used to identify class loaders handling parallel class loading */ \ |
936 | 934 |
937 | 935 |
938 // Class vmSymbols | 936 // Class vmSymbols |
939 | 937 |
940 class vmSymbols: AllStatic { | 938 class vmSymbols: AllStatic { |
941 friend class vmSymbolHandles; | |
942 friend class vmIntrinsics; | 939 friend class vmIntrinsics; |
943 public: | 940 public: |
944 // enum for figuring positions and size of array holding symbolOops | 941 // enum for figuring positions and size of array holding Symbol*s |
945 enum SID { | 942 enum SID { |
946 NO_SID = 0, | 943 NO_SID = 0, |
947 | 944 |
948 #define VM_SYMBOL_ENUM(name, string) VM_SYMBOL_ENUM_NAME(name), | 945 #define VM_SYMBOL_ENUM(name, string) VM_SYMBOL_ENUM_NAME(name), |
949 VM_SYMBOLS_DO(VM_SYMBOL_ENUM, VM_ALIAS_IGNORE) | 946 VM_SYMBOLS_DO(VM_SYMBOL_ENUM, VM_ALIAS_IGNORE) |
961 log2_SID_LIMIT = 10 // checked by an assert at start-up | 958 log2_SID_LIMIT = 10 // checked by an assert at start-up |
962 }; | 959 }; |
963 | 960 |
964 private: | 961 private: |
965 // The symbol array | 962 // The symbol array |
966 static symbolOop _symbols[]; | 963 static Symbol* _symbols[]; |
967 | 964 |
968 // Field signatures indexed by BasicType. | 965 // Field signatures indexed by BasicType. |
969 static symbolOop _type_signatures[T_VOID+1]; | 966 static Symbol* _type_signatures[T_VOID+1]; |
970 | 967 |
971 public: | 968 public: |
972 // Initialization | 969 // Initialization |
973 static void initialize(TRAPS); | 970 static void initialize(TRAPS); |
974 // Accessing | 971 // Accessing |
975 #define VM_SYMBOL_DECLARE(name, ignore) \ | 972 #define VM_SYMBOL_DECLARE(name, ignore) \ |
976 static symbolOop name() { return _symbols[VM_SYMBOL_ENUM_NAME(name)]; } | 973 static Symbol* name() { \ |
974 return _symbols[VM_SYMBOL_ENUM_NAME(name)]; \ | |
975 } | |
977 VM_SYMBOLS_DO(VM_SYMBOL_DECLARE, VM_SYMBOL_DECLARE) | 976 VM_SYMBOLS_DO(VM_SYMBOL_DECLARE, VM_SYMBOL_DECLARE) |
978 #undef VM_SYMBOL_DECLARE | 977 #undef VM_SYMBOL_DECLARE |
979 | 978 |
980 // GC support | 979 // Sharing support |
981 static void oops_do(OopClosure* f, bool do_all = false); | 980 static void symbols_do(SymbolClosure* f); |
982 | 981 static void serialize(SerializeOopClosure* soc); |
983 static symbolOop type_signature(BasicType t) { | 982 |
983 static Symbol* type_signature(BasicType t) { | |
984 assert((uint)t < T_VOID+1, "range check"); | 984 assert((uint)t < T_VOID+1, "range check"); |
985 assert(_type_signatures[t] != NULL, "domain check"); | 985 assert(_type_signatures[t] != NULL, "domain check"); |
986 return _type_signatures[t]; | 986 return _type_signatures[t]; |
987 } | 987 } |
988 // inverse of type_signature; returns T_OBJECT if s is not recognized | 988 // inverse of type_signature; returns T_OBJECT if s is not recognized |
989 static BasicType signature_type(symbolOop s); | 989 static BasicType signature_type(Symbol* s); |
990 | 990 |
991 static symbolOop symbol_at(SID id) { | 991 static Symbol* symbol_at(SID id) { |
992 assert(id >= FIRST_SID && id < SID_LIMIT, "oob"); | 992 assert(id >= FIRST_SID && id < SID_LIMIT, "oob"); |
993 assert(_symbols[id] != NULL, "init"); | 993 assert(_symbols[id] != NULL, "init"); |
994 return _symbols[id]; | 994 return _symbols[id]; |
995 } | 995 } |
996 | 996 |
997 // Returns symbol's SID if one is assigned, else NO_SID. | 997 // Returns symbol's SID if one is assigned, else NO_SID. |
998 static SID find_sid(symbolOop symbol); | 998 static SID find_sid(Symbol* symbol); |
999 | 999 |
1000 #ifndef PRODUCT | 1000 #ifndef PRODUCT |
1001 // No need for this in the product: | 1001 // No need for this in the product: |
1002 static const char* name_for(SID sid); | 1002 static const char* name_for(SID sid); |
1003 #endif //PRODUCT | 1003 #endif //PRODUCT |
1004 }; | |
1005 | |
1006 | |
1007 // Class vmSymbolHandles | |
1008 | |
1009 class vmSymbolHandles: AllStatic { | |
1010 friend class vmIntrinsics; | |
1011 friend class ciObjectFactory; | |
1012 | |
1013 public: | |
1014 // Accessing | |
1015 #define VM_SYMBOL_HANDLE_DECLARE(name, ignore) \ | |
1016 static symbolHandle name() { return symbol_handle_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); } | |
1017 VM_SYMBOLS_DO(VM_SYMBOL_HANDLE_DECLARE, VM_SYMBOL_HANDLE_DECLARE) | |
1018 #undef VM_SYMBOL_HANDLE_DECLARE | |
1019 | |
1020 static symbolHandle symbol_handle_at(vmSymbols::SID id) { | |
1021 return symbolHandle(&vmSymbols::_symbols[(int)id], false); | |
1022 } | |
1023 | |
1024 static symbolHandle type_signature(BasicType t) { | |
1025 assert(vmSymbols::type_signature(t) != NULL, "domain check"); | |
1026 return symbolHandle(&vmSymbols::_type_signatures[t], false); | |
1027 } | |
1028 // inverse of type_signature; returns T_OBJECT if s is not recognized | |
1029 static BasicType signature_type(symbolHandle s) { | |
1030 return vmSymbols::signature_type(s()); | |
1031 } | |
1032 }; | 1004 }; |
1033 | 1005 |
1034 // VM Intrinsic ID's uniquely identify some very special methods | 1006 // VM Intrinsic ID's uniquely identify some very special methods |
1035 class vmIntrinsics: AllStatic { | 1007 class vmIntrinsics: AllStatic { |
1036 friend class vmSymbols; | 1008 friend class vmSymbols; |