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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ | 63 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ |
64 k##symbol, | 64 k##symbol, |
65 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) | 65 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) |
66 #undef DEFINE_SYMBOL_INDEX | 66 #undef DEFINE_SYMBOL_INDEX |
67 | 67 |
68 kMaxPredefined, | 68 kMaxPredefined, |
69 }; | 69 }; |
70 | 70 |
71 // Access methods for symbols stored in the vm isolate. | 71 // Access methods for symbols stored in the vm isolate. |
72 #define DEFINE_SYMBOL_ACCESSOR(symbol, literal) \ | 72 #define DEFINE_SYMBOL_ACCESSOR(symbol, literal) \ |
73 static RawString* symbol() { return Symbols::New(literal); } | 73 static RawString* symbol() { return predefined_[k##symbol]; } |
74 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_ACCESSOR) | 74 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_ACCESSOR) |
75 #undef DEFINE_SYMBOL_ACCESSOR | 75 #undef DEFINE_SYMBOL_ACCESSOR |
76 | 76 |
77 // Initialize frequently used symbols in the vm isolate. | 77 // Initialize frequently used symbols in the vm isolate. |
78 static void InitOnce(Isolate* isolate); | 78 static void InitOnce(Isolate* isolate); |
79 | 79 |
80 // Initialize and setup a symbol table for the isolate. | 80 // Initialize and setup a symbol table for the isolate. |
81 static void SetupSymbolTable(Isolate* isolate); | 81 static void SetupSymbolTable(Isolate* isolate); |
82 | 82 |
83 // Get number of symbols in an isolate's symbol table. | 83 // Get number of symbols in an isolate's symbol table. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 template<typename T> | 115 template<typename T> |
116 static intptr_t FindIndex(const Array& symbol_table, | 116 static intptr_t FindIndex(const Array& symbol_table, |
117 const T* characters, | 117 const T* characters, |
118 intptr_t len, | 118 intptr_t len, |
119 intptr_t hash); | 119 intptr_t hash); |
120 static intptr_t FindIndex(const Array& symbol_table, | 120 static intptr_t FindIndex(const Array& symbol_table, |
121 const String& str, | 121 const String& str, |
122 intptr_t begin_index, | 122 intptr_t begin_index, |
123 intptr_t len, | 123 intptr_t len, |
124 intptr_t hash); | 124 intptr_t hash); |
| 125 static intptr_t LookupVMSymbol(RawObject* obj); |
| 126 static RawObject* GetVMSymbol(intptr_t index); |
125 | 127 |
126 // List of symbols that are stored in the vm isolate for easy access. | 128 // List of symbols that are stored in the vm isolate for easy access. |
127 static RawString* predefined_[kMaxPredefined]; | 129 static RawString* predefined_[kMaxPredefined]; |
128 | 130 |
129 friend class SnapshotReader; | 131 friend class SnapshotReader; |
| 132 friend class SnapshotWriter; |
| 133 friend class ApiMessageReader; |
130 | 134 |
131 DISALLOW_COPY_AND_ASSIGN(Symbols); | 135 DISALLOW_COPY_AND_ASSIGN(Symbols); |
132 }; | 136 }; |
133 | 137 |
134 } // namespace dart | 138 } // namespace dart |
135 | 139 |
136 #endif // VM_SYMBOLS_H_ | 140 #endif // VM_SYMBOLS_H_ |
OLD | NEW |