OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_SYMBOLS_H_ | 5 #ifndef VM_SYMBOLS_H_ |
6 #define VM_SYMBOLS_H_ | 6 #define VM_SYMBOLS_H_ |
7 | 7 |
8 #include "vm/object.h" | 8 #include "vm/object.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ | 64 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ |
65 k##symbol, | 65 k##symbol, |
66 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) | 66 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) |
67 #undef DEFINE_SYMBOL_INDEX | 67 #undef DEFINE_SYMBOL_INDEX |
68 | 68 |
69 kMaxPredefined, | 69 kMaxPredefined, |
70 }; | 70 }; |
71 | 71 |
72 // Access methods for symbols stored in the vm isolate. | 72 // Access methods for symbols stored in the vm isolate. |
73 #define DEFINE_SYMBOL_ACCESSOR(symbol, literal) \ | 73 #define DEFINE_SYMBOL_ACCESSOR(symbol, literal) \ |
74 static RawString* symbol() { return Symbols::New(literal); } | 74 static RawString* symbol() { return predefined_[k##symbol]; } |
75 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_ACCESSOR) | 75 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_ACCESSOR) |
76 #undef DEFINE_SYMBOL_ACCESSOR | 76 #undef DEFINE_SYMBOL_ACCESSOR |
77 | 77 |
78 // Initialize frequently used symbols in the vm isolate. | 78 // Initialize frequently used symbols in the vm isolate. |
79 static void InitOnce(Isolate* isolate); | 79 static void InitOnce(Isolate* isolate); |
80 | 80 |
81 // Initialize and setup a symbol table for the isolate. | 81 // Initialize and setup a symbol table for the isolate. |
82 static void SetupSymbolTable(Isolate* isolate); | 82 static void SetupSymbolTable(Isolate* isolate); |
83 | 83 |
84 // Get number of symbols in an isolate's symbol table. | 84 // Get number of symbols in an isolate's symbol table. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 template<typename T> | 116 template<typename T> |
117 static intptr_t FindIndex(const Array& symbol_table, | 117 static intptr_t FindIndex(const Array& symbol_table, |
118 const T* characters, | 118 const T* characters, |
119 intptr_t len, | 119 intptr_t len, |
120 intptr_t hash); | 120 intptr_t hash); |
121 static intptr_t FindIndex(const Array& symbol_table, | 121 static intptr_t FindIndex(const Array& symbol_table, |
122 const String& str, | 122 const String& str, |
123 intptr_t begin_index, | 123 intptr_t begin_index, |
124 intptr_t len, | 124 intptr_t len, |
125 intptr_t hash); | 125 intptr_t hash); |
| 126 static intptr_t LookupVMSymbol(RawObject* obj); |
| 127 static RawObject* GetVMSymbol(intptr_t object_id); |
| 128 static bool IsVMSymbolId(intptr_t object_id) { |
| 129 return (object_id >= Object::kMaxId && |
| 130 object_id < (Object::kMaxId + kMaxPredefined)); |
| 131 } |
126 | 132 |
127 // List of symbols that are stored in the vm isolate for easy access. | 133 // List of symbols that are stored in the vm isolate for easy access. |
128 static RawString* predefined_[kMaxPredefined]; | 134 static RawString* predefined_[kMaxPredefined]; |
129 | 135 |
130 friend class SnapshotReader; | 136 friend class SnapshotReader; |
| 137 friend class SnapshotWriter; |
| 138 friend class ApiMessageReader; |
131 | 139 |
132 DISALLOW_COPY_AND_ASSIGN(Symbols); | 140 DISALLOW_COPY_AND_ASSIGN(Symbols); |
133 }; | 141 }; |
134 | 142 |
135 } // namespace dart | 143 } // namespace dart |
136 | 144 |
137 #endif // VM_SYMBOLS_H_ | 145 #endif // VM_SYMBOLS_H_ |
OLD | NEW |