Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/vmSymbols.hpp @ 2181:d25d4ca69222
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Wed, 16 Feb 2011 13:47:20 +0100 |
parents | 89bf01e6b049 3582bf76420e |
children | 0cd39a385a72 |
comparison
equal
deleted
inserted
replaced
2108:50b45e2d9725 | 2181:d25d4ca69222 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
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 |
109 template(sun_misc_Signal, "sun/misc/Signal") \ | 107 template(sun_misc_Signal, "sun/misc/Signal") \ |
110 template(java_lang_AssertionStatusDirectives, "java/lang/AssertionStatusDirectives") \ | 108 template(java_lang_AssertionStatusDirectives, "java/lang/AssertionStatusDirectives") \ |
111 template(sun_jkernel_DownloadManager, "sun/jkernel/DownloadManager") \ | 109 template(sun_jkernel_DownloadManager, "sun/jkernel/DownloadManager") \ |
112 template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ | 110 template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ |
113 template(setBootClassLoaderHook_name, "setBootClassLoaderHook") \ | 111 template(setBootClassLoaderHook_name, "setBootClassLoaderHook") \ |
112 template(sun_misc_PostVMInitHook, "sun/misc/PostVMInitHook") \ | |
114 \ | 113 \ |
115 /* class file format tags */ \ | 114 /* class file format tags */ \ |
116 template(tag_source_file, "SourceFile") \ | 115 template(tag_source_file, "SourceFile") \ |
117 template(tag_inner_classes, "InnerClasses") \ | 116 template(tag_inner_classes, "InnerClasses") \ |
118 template(tag_constant_value, "ConstantValue") \ | 117 template(tag_constant_value, "ConstantValue") \ |
525 \ | 524 \ |
526 /* symbol aliases needed by intrinsics */ \ | 525 /* symbol aliases needed by intrinsics */ \ |
527 VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, do_alias) \ | 526 VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, do_alias) \ |
528 \ | 527 \ |
529 /* returned by the C1 compiler in case there's not enough memory to allocate a new symbol*/ \ | 528 /* returned by the C1 compiler in case there's not enough memory to allocate a new symbol*/ \ |
530 template(dummy_symbol_oop, "illegal symbol") \ | 529 template(dummy_symbol, "illegal symbol") \ |
531 \ | 530 \ |
532 /* used by ClassFormatError when class name is not known yet */ \ | 531 /* used by ClassFormatError when class name is not known yet */ \ |
533 template(unknown_class_name, "<Unknown>") \ | 532 template(unknown_class_name, "<Unknown>") \ |
534 \ | 533 \ |
535 /* used to identify class loaders handling parallel class loading */ \ | 534 /* used to identify class loaders handling parallel class loading */ \ |
1004 | 1003 |
1005 | 1004 |
1006 // Class vmSymbols | 1005 // Class vmSymbols |
1007 | 1006 |
1008 class vmSymbols: AllStatic { | 1007 class vmSymbols: AllStatic { |
1009 friend class vmSymbolHandles; | |
1010 friend class vmIntrinsics; | 1008 friend class vmIntrinsics; |
1011 public: | 1009 public: |
1012 // enum for figuring positions and size of array holding symbolOops | 1010 // enum for figuring positions and size of array holding Symbol*s |
1013 enum SID { | 1011 enum SID { |
1014 NO_SID = 0, | 1012 NO_SID = 0, |
1015 | 1013 |
1016 #define VM_SYMBOL_ENUM(name, string) VM_SYMBOL_ENUM_NAME(name), | 1014 #define VM_SYMBOL_ENUM(name, string) VM_SYMBOL_ENUM_NAME(name), |
1017 VM_SYMBOLS_DO(VM_SYMBOL_ENUM, VM_ALIAS_IGNORE) | 1015 VM_SYMBOLS_DO(VM_SYMBOL_ENUM, VM_ALIAS_IGNORE) |
1029 log2_SID_LIMIT = 10 // checked by an assert at start-up | 1027 log2_SID_LIMIT = 10 // checked by an assert at start-up |
1030 }; | 1028 }; |
1031 | 1029 |
1032 private: | 1030 private: |
1033 // The symbol array | 1031 // The symbol array |
1034 static symbolOop _symbols[]; | 1032 static Symbol* _symbols[]; |
1035 | 1033 |
1036 // Field signatures indexed by BasicType. | 1034 // Field signatures indexed by BasicType. |
1037 static symbolOop _type_signatures[T_VOID+1]; | 1035 static Symbol* _type_signatures[T_VOID+1]; |
1038 | 1036 |
1039 public: | 1037 public: |
1040 // Initialization | 1038 // Initialization |
1041 static void initialize(TRAPS); | 1039 static void initialize(TRAPS); |
1042 // Accessing | 1040 // Accessing |
1043 #define VM_SYMBOL_DECLARE(name, ignore) \ | 1041 #define VM_SYMBOL_DECLARE(name, ignore) \ |
1044 static symbolOop name() { return _symbols[VM_SYMBOL_ENUM_NAME(name)]; } | 1042 static Symbol* name() { \ |
1043 return _symbols[VM_SYMBOL_ENUM_NAME(name)]; \ | |
1044 } | |
1045 VM_SYMBOLS_DO(VM_SYMBOL_DECLARE, VM_SYMBOL_DECLARE) | 1045 VM_SYMBOLS_DO(VM_SYMBOL_DECLARE, VM_SYMBOL_DECLARE) |
1046 #undef VM_SYMBOL_DECLARE | 1046 #undef VM_SYMBOL_DECLARE |
1047 | 1047 |
1048 // GC support | 1048 // Sharing support |
1049 static void oops_do(OopClosure* f, bool do_all = false); | 1049 static void symbols_do(SymbolClosure* f); |
1050 | 1050 static void serialize(SerializeOopClosure* soc); |
1051 static symbolOop type_signature(BasicType t) { | 1051 |
1052 static Symbol* type_signature(BasicType t) { | |
1052 assert((uint)t < T_VOID+1, "range check"); | 1053 assert((uint)t < T_VOID+1, "range check"); |
1053 assert(_type_signatures[t] != NULL, "domain check"); | 1054 assert(_type_signatures[t] != NULL, "domain check"); |
1054 return _type_signatures[t]; | 1055 return _type_signatures[t]; |
1055 } | 1056 } |
1056 // inverse of type_signature; returns T_OBJECT if s is not recognized | 1057 // inverse of type_signature; returns T_OBJECT if s is not recognized |
1057 static BasicType signature_type(symbolOop s); | 1058 static BasicType signature_type(Symbol* s); |
1058 | 1059 |
1059 static symbolOop symbol_at(SID id) { | 1060 static Symbol* symbol_at(SID id) { |
1060 assert(id >= FIRST_SID && id < SID_LIMIT, "oob"); | 1061 assert(id >= FIRST_SID && id < SID_LIMIT, "oob"); |
1061 assert(_symbols[id] != NULL, "init"); | 1062 assert(_symbols[id] != NULL, "init"); |
1062 return _symbols[id]; | 1063 return _symbols[id]; |
1063 } | 1064 } |
1064 | 1065 |
1065 // Returns symbol's SID if one is assigned, else NO_SID. | 1066 // Returns symbol's SID if one is assigned, else NO_SID. |
1066 static SID find_sid(symbolOop symbol); | 1067 static SID find_sid(Symbol* symbol); |
1067 | 1068 |
1068 #ifndef PRODUCT | 1069 #ifndef PRODUCT |
1069 // No need for this in the product: | 1070 // No need for this in the product: |
1070 static const char* name_for(SID sid); | 1071 static const char* name_for(SID sid); |
1071 #endif //PRODUCT | 1072 #endif //PRODUCT |
1072 }; | |
1073 | |
1074 | |
1075 // Class vmSymbolHandles | |
1076 | |
1077 class vmSymbolHandles: AllStatic { | |
1078 friend class vmIntrinsics; | |
1079 friend class ciObjectFactory; | |
1080 | |
1081 public: | |
1082 // Accessing | |
1083 #define VM_SYMBOL_HANDLE_DECLARE(name, ignore) \ | |
1084 static symbolHandle name() { return symbol_handle_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); } | |
1085 VM_SYMBOLS_DO(VM_SYMBOL_HANDLE_DECLARE, VM_SYMBOL_HANDLE_DECLARE) | |
1086 #undef VM_SYMBOL_HANDLE_DECLARE | |
1087 | |
1088 static symbolHandle symbol_handle_at(vmSymbols::SID id) { | |
1089 return symbolHandle(&vmSymbols::_symbols[(int)id], false); | |
1090 } | |
1091 | |
1092 static symbolHandle type_signature(BasicType t) { | |
1093 assert(vmSymbols::type_signature(t) != NULL, "domain check"); | |
1094 return symbolHandle(&vmSymbols::_type_signatures[t], false); | |
1095 } | |
1096 // inverse of type_signature; returns T_OBJECT if s is not recognized | |
1097 static BasicType signature_type(symbolHandle s) { | |
1098 return vmSymbols::signature_type(s()); | |
1099 } | |
1100 }; | 1073 }; |
1101 | 1074 |
1102 // VM Intrinsic ID's uniquely identify some very special methods | 1075 // VM Intrinsic ID's uniquely identify some very special methods |
1103 class vmIntrinsics: AllStatic { | 1076 class vmIntrinsics: AllStatic { |
1104 friend class vmSymbols; | 1077 friend class vmSymbols; |