Mercurial > hg > graal-jvmci-8
comparison src/share/vm/ci/ciSymbol.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 | f95d63e2154a |
children | d25d4ca69222 1d1603768966 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
26 #define SHARE_VM_CI_CISYMBOL_HPP | 26 #define SHARE_VM_CI_CISYMBOL_HPP |
27 | 27 |
28 #include "ci/ciObject.hpp" | 28 #include "ci/ciObject.hpp" |
29 #include "ci/ciObjectFactory.hpp" | 29 #include "ci/ciObjectFactory.hpp" |
30 #include "classfile/vmSymbols.hpp" | 30 #include "classfile/vmSymbols.hpp" |
31 #include "oops/symbolOop.hpp" | 31 #include "oops/symbol.hpp" |
32 | 32 |
33 // ciSymbol | 33 // ciSymbol |
34 // | 34 // |
35 // This class represents a symbolOop in the HotSpot virtual | 35 // This class represents a Symbol* in the HotSpot virtual |
36 // machine. | 36 // machine. |
37 class ciSymbol : public ciObject { | 37 class ciSymbol : public ResourceObj { |
38 Symbol* _symbol; | |
39 uint _ident; | |
40 | |
38 CI_PACKAGE_ACCESS | 41 CI_PACKAGE_ACCESS |
39 // These friends all make direct use of get_symbolOop: | 42 // These friends all make direct use of get_symbol: |
40 friend class ciEnv; | 43 friend class ciEnv; |
41 friend class ciInstanceKlass; | 44 friend class ciInstanceKlass; |
42 friend class ciSignature; | 45 friend class ciSignature; |
43 friend class ciMethod; | 46 friend class ciMethod; |
44 friend class ciObjArrayKlass; | 47 friend class ciObjArrayKlass; |
45 | 48 |
46 private: | 49 private: |
47 const vmSymbols::SID _sid; | 50 const vmSymbols::SID _sid; |
48 DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbolOop()) == _sid; } ) | 51 DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbol()) == _sid; } ) |
49 | 52 |
50 ciSymbol(symbolOop s); // normal case, for symbols not mentioned in vmSymbols | 53 ciSymbol(Symbol* s); // normal case, for symbols not mentioned in vmSymbols |
51 ciSymbol(symbolHandle s, vmSymbols::SID sid); // for use with vmSymbolHandles | 54 ciSymbol(Symbol* s, vmSymbols::SID sid); // for use with vmSymbols |
52 | 55 |
53 symbolOop get_symbolOop() const { return (symbolOop)get_oop(); } | 56 Symbol* get_symbol() const { return _symbol; } |
54 | 57 |
55 const char* type_string() { return "ciSymbol"; } | 58 const char* type_string() { return "ciSymbol"; } |
56 | 59 |
57 void print_impl(outputStream* st); | 60 void print_impl(outputStream* st); |
58 | 61 |
59 // This is public in symbolOop but private here, because the base can move: | 62 // This is public in Symbol* but private here, because the base can move: |
60 jbyte* base(); | 63 const jbyte* base(); |
61 | 64 |
62 // Make a ciSymbol from a C string (implementation). | 65 // Make a ciSymbol from a C string (implementation). |
63 static ciSymbol* make_impl(const char* s); | 66 static ciSymbol* make_impl(const char* s); |
64 | 67 |
68 void set_ident(uint id) { _ident = id; } | |
65 public: | 69 public: |
70 // A number unique to this object. | |
71 uint ident() { return _ident; } | |
72 | |
66 // The enumeration ID from vmSymbols, or vmSymbols::NO_SID if none. | 73 // The enumeration ID from vmSymbols, or vmSymbols::NO_SID if none. |
67 vmSymbols::SID sid() const { return _sid; } | 74 vmSymbols::SID sid() const { return _sid; } |
68 | 75 |
69 // The text of the symbol as a null-terminated utf8 string. | 76 // The text of the symbol as a null-terminated utf8 string. |
70 const char* as_utf8(); | 77 const char* as_utf8(); |
77 bool starts_with(const char* prefix, int len) const; | 84 bool starts_with(const char* prefix, int len) const; |
78 | 85 |
79 // Determines where the symbol contains the given substring. | 86 // Determines where the symbol contains the given substring. |
80 int index_of_at(int i, const char* str, int len) const; | 87 int index_of_at(int i, const char* str, int len) const; |
81 | 88 |
82 // What kind of ciObject is this? | |
83 bool is_symbol() { return true; } | |
84 | |
85 void print_symbol_on(outputStream* st); | 89 void print_symbol_on(outputStream* st); |
86 void print_symbol() { | 90 void print_symbol() { |
87 print_symbol_on(tty); | 91 print_symbol_on(tty); |
88 } | 92 } |
89 | 93 |
94 | 98 |
95 #define CI_SYMBOL_DECLARE(name, ignore_def) \ | 99 #define CI_SYMBOL_DECLARE(name, ignore_def) \ |
96 static ciSymbol* name() { return ciObjectFactory::vm_symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); } | 100 static ciSymbol* name() { return ciObjectFactory::vm_symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); } |
97 VM_SYMBOLS_DO(CI_SYMBOL_DECLARE, CI_SYMBOL_DECLARE) | 101 VM_SYMBOLS_DO(CI_SYMBOL_DECLARE, CI_SYMBOL_DECLARE) |
98 #undef CI_SYMBOL_DECLARE | 102 #undef CI_SYMBOL_DECLARE |
103 | |
104 void print() { | |
105 _symbol->print(); | |
106 } | |
107 | |
108 // Are two ciSymbols equal? | |
109 bool equals(ciSymbol* obj) { return this->_symbol == obj->get_symbol(); } | |
99 }; | 110 }; |
100 | 111 |
101 #endif // SHARE_VM_CI_CISYMBOL_HPP | 112 #endif // SHARE_VM_CI_CISYMBOL_HPP |