| 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 #include "vm/snapshot_ids.h" | 9 #include "vm/snapshot_ids.h" |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 V(_ExternalInt32Array, "_ExternalInt32Array") \ | 137 V(_ExternalInt32Array, "_ExternalInt32Array") \ |
| 138 V(_ExternalUint32Array, "_ExternalUint32Array") \ | 138 V(_ExternalUint32Array, "_ExternalUint32Array") \ |
| 139 V(_ExternalInt64Array, "_ExternalInt64Array") \ | 139 V(_ExternalInt64Array, "_ExternalInt64Array") \ |
| 140 V(_ExternalUint64Array, "_ExternalUint64Array") \ | 140 V(_ExternalUint64Array, "_ExternalUint64Array") \ |
| 141 V(_ExternalFloat32Array, "_ExternalFloat32Array") \ | 141 V(_ExternalFloat32Array, "_ExternalFloat32Array") \ |
| 142 V(_ExternalFloat64Array, "_ExternalFloat64Array") \ | 142 V(_ExternalFloat64Array, "_ExternalFloat64Array") \ |
| 143 V(_WeakProperty, "_WeakProperty") \ | 143 V(_WeakProperty, "_WeakProperty") \ |
| 144 V(InvocationMirror, "_InvocationMirror") \ | 144 V(InvocationMirror, "_InvocationMirror") \ |
| 145 V(AllocateInvocationMirror, "_allocateInvocationMirror") \ | 145 V(AllocateInvocationMirror, "_allocateInvocationMirror") \ |
| 146 | 146 |
| 147 #define PREDEFINED_SYMBOL_HANDLES_LIST(V) \ |
| 148 V(Dot) \ |
| 149 |
| 147 // Contains a list of frequently used strings in a canonicalized form. This | 150 // Contains a list of frequently used strings in a canonicalized form. This |
| 148 // list is kept in the vm_isolate in order to share the copy across isolates | 151 // list is kept in the vm_isolate in order to share the copy across isolates |
| 149 // without having to maintain copies in each isolate. | 152 // without having to maintain copies in each isolate. |
| 150 class Symbols : public AllStatic { | 153 class Symbols : public AllStatic { |
| 151 public: | 154 public: |
| 152 enum { kMaxOneCharCodeSymbol = 0xFF }; | 155 enum { kMaxOneCharCodeSymbol = 0xFF }; |
| 153 | 156 |
| 154 // List of strings that are pre created in the vm isolate. | 157 // List of strings that are pre created in the vm isolate. |
| 155 enum SymbolId { | 158 enum SymbolId { |
| 156 kIllegal = 0, | 159 kIllegal = 0, |
| 157 | 160 |
| 158 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ | 161 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ |
| 159 k##symbol, | 162 k##symbol, |
| 160 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) | 163 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) |
| 161 #undef DEFINE_SYMBOL_INDEX | 164 #undef DEFINE_SYMBOL_INDEX |
| 162 kMaxPredefinedId, | 165 kMaxPredefinedId, |
| 163 kNullCharId = kMaxPredefinedId, | 166 kNullCharId = kMaxPredefinedId, |
| 164 kMaxId = kNullCharId + kMaxOneCharCodeSymbol + 1, | 167 kMaxId = kNullCharId + kMaxOneCharCodeSymbol + 1, |
| 165 }; | 168 }; |
| 166 | 169 |
| 167 // Access methods for symbols stored in the vm isolate. | 170 // Access methods for symbols stored in the vm isolate. |
| 168 #define DEFINE_SYMBOL_ACCESSOR(symbol, literal) \ | 171 #define DEFINE_SYMBOL_ACCESSOR(symbol, literal) \ |
| 169 static RawString* symbol() { return predefined_[k##symbol]; } | 172 static RawString* symbol() { return predefined_[k##symbol]; } |
| 170 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_ACCESSOR) | 173 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_ACCESSOR) |
| 171 #undef DEFINE_SYMBOL_ACCESSOR | 174 #undef DEFINE_SYMBOL_ACCESSOR |
| 172 | 175 |
| 176 // Access methods for symbol handles stored in the vm isolate. |
| 177 #define DEFINE_SYMBOL_HANDLE_ACCESSOR(symbol) \ |
| 178 static const String& symbol##Handle() { return *symbol##_handle_; } |
| 179 PREDEFINED_SYMBOL_HANDLES_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) |
| 180 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR |
| 181 |
| 173 // Initialize frequently used symbols in the vm isolate. | 182 // Initialize frequently used symbols in the vm isolate. |
| 174 static void InitOnce(Isolate* isolate); | 183 static void InitOnce(Isolate* isolate); |
| 175 | 184 |
| 176 // Initialize and setup a symbol table for the isolate. | 185 // Initialize and setup a symbol table for the isolate. |
| 177 static void SetupSymbolTable(Isolate* isolate); | 186 static void SetupSymbolTable(Isolate* isolate); |
| 178 | 187 |
| 179 // Get number of symbols in an isolate's symbol table. | 188 // Get number of symbols in an isolate's symbol table. |
| 180 static intptr_t Size(Isolate* isolate); | 189 static intptr_t Size(Isolate* isolate); |
| 181 | 190 |
| 182 // Creates a Symbol given a C string that is assumed to contain | 191 // Creates a Symbol given a C string that is assumed to contain |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 static intptr_t LookupVMSymbol(RawObject* obj); | 257 static intptr_t LookupVMSymbol(RawObject* obj); |
| 249 static RawObject* GetVMSymbol(intptr_t object_id); | 258 static RawObject* GetVMSymbol(intptr_t object_id); |
| 250 static bool IsVMSymbolId(intptr_t object_id) { | 259 static bool IsVMSymbolId(intptr_t object_id) { |
| 251 return (object_id >= kMaxPredefinedObjectIds && | 260 return (object_id >= kMaxPredefinedObjectIds && |
| 252 object_id < (kMaxPredefinedObjectIds + kMaxId)); | 261 object_id < (kMaxPredefinedObjectIds + kMaxId)); |
| 253 } | 262 } |
| 254 | 263 |
| 255 // List of symbols that are stored in the vm isolate for easy access. | 264 // List of symbols that are stored in the vm isolate for easy access. |
| 256 static RawString* predefined_[kMaxId]; | 265 static RawString* predefined_[kMaxId]; |
| 257 | 266 |
| 267 // Structure for managing handles allocation for symbols that are |
| 268 // stored in the vm isolate. |
| 269 static VMHandles predefined_handles_; |
| 270 |
| 271 #define DECLARE_SYMBOL_HANDLE(symbol) \ |
| 272 static String* symbol##_handle_; |
| 273 PREDEFINED_SYMBOL_HANDLES_LIST(DECLARE_SYMBOL_HANDLE) |
| 274 #undef DECLARE_SYMBOL_HANDLE |
| 275 |
| 258 friend class String; | 276 friend class String; |
| 259 friend class SnapshotReader; | 277 friend class SnapshotReader; |
| 260 friend class SnapshotWriter; | 278 friend class SnapshotWriter; |
| 261 friend class ApiMessageReader; | 279 friend class ApiMessageReader; |
| 262 | 280 |
| 263 DISALLOW_COPY_AND_ASSIGN(Symbols); | 281 DISALLOW_COPY_AND_ASSIGN(Symbols); |
| 264 }; | 282 }; |
| 265 | 283 |
| 266 } // namespace dart | 284 } // namespace dart |
| 267 | 285 |
| 268 #endif // VM_SYMBOLS_H_ | 286 #endif // VM_SYMBOLS_H_ |
| OLD | NEW |