Chromium Code Reviews| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 170 |
| 171 // Initialize frequently used symbols in the vm isolate. | 171 // Initialize frequently used symbols in the vm isolate. |
| 172 static void InitOnce(Isolate* isolate); | 172 static void InitOnce(Isolate* isolate); |
| 173 | 173 |
| 174 // Initialize and setup a symbol table for the isolate. | 174 // Initialize and setup a symbol table for the isolate. |
| 175 static void SetupSymbolTable(Isolate* isolate); | 175 static void SetupSymbolTable(Isolate* isolate); |
| 176 | 176 |
| 177 // Get number of symbols in an isolate's symbol table. | 177 // Get number of symbols in an isolate's symbol table. |
| 178 static intptr_t Size(Isolate* isolate); | 178 static intptr_t Size(Isolate* isolate); |
| 179 | 179 |
| 180 // Helper functions to create a symbol given a string or set of characters. | 180 // Creates a Symbol given a C string that is assumed to contain |
| 181 static RawString* New(const char* str); | 181 // UTF-8 encoded characters and '\0' is considered a termination character. |
| 182 template<typename T> | 182 static RawString* New(const char* cstr); |
| 183 static RawString* New(const T* characters, intptr_t len); | 183 |
| 184 // Creates a new Symbol from an array of UTF-8 encoded characters. | |
|
cshapiro
2012/12/04 00:41:07
This comment needs to be updated.
// Creates a
siva
2012/12/04 00:55:57
This has changed some.
On 2012/12/04 00:41:07, cs
| |
| 185 static RawString* New(const uint8_t* utf8_array, intptr_t len); | |
| 186 | |
| 187 // Creates a new Symbol from an array of UTF-16 encoded characters. | |
| 188 static RawString* New(const uint16_t* utf16_array, intptr_t len); | |
| 189 | |
| 190 // Creates a new Symbol from an array of UTF-32 encoded characters. | |
| 191 static RawString* New(const int32_t* utf32_array, intptr_t len); | |
| 192 | |
| 184 static RawString* New(const String& str); | 193 static RawString* New(const String& str); |
| 185 static RawString* New(const String& str, | 194 static RawString* New(const String& str, |
| 186 intptr_t begin_index, | 195 intptr_t begin_index, |
| 187 intptr_t length); | 196 intptr_t length); |
| 188 | 197 |
| 189 // Returns char* of predefined symbol. | 198 // Returns char* of predefined symbol. |
| 190 static const char* Name(SymbolId symbol); | 199 static const char* Name(SymbolId symbol); |
| 191 | 200 |
| 192 static RawString* FromCharCode(int32_t char_code); | 201 static RawString* FromCharCode(int32_t char_code); |
| 193 | 202 |
| 194 static RawString** PredefinedAddress() { | 203 static RawString** PredefinedAddress() { |
| 195 return reinterpret_cast<RawString**>(&predefined_); | 204 return reinterpret_cast<RawString**>(&predefined_); |
| 196 } | 205 } |
| 197 | 206 |
| 198 private: | 207 private: |
| 199 enum { | 208 enum { |
| 200 kInitialVMIsolateSymtabSize = ((kMaxId + 15) & -16), | 209 kInitialVMIsolateSymtabSize = ((kMaxId + 15) & -16), |
| 201 kInitialSymtabSize = 256 | 210 kInitialSymtabSize = 256 |
| 202 }; | 211 }; |
| 203 | 212 |
| 213 // Helper functions to create a symbol given a string or set of characters. | |
| 214 template<typename T> | |
| 215 static RawString* NewSymbol(const T* characters, intptr_t len); | |
| 216 | |
| 204 // Add the string into the VM isolate symbol table. | 217 // Add the string into the VM isolate symbol table. |
| 205 static void Add(const Array& symbol_table, const String& str); | 218 static void Add(const Array& symbol_table, const String& str); |
| 206 | 219 |
| 207 // Insert symbol into symbol table, growing it if necessary. | 220 // Insert symbol into symbol table, growing it if necessary. |
| 208 static void InsertIntoSymbolTable(const Array& symbol_table, | 221 static void InsertIntoSymbolTable(const Array& symbol_table, |
| 209 const String& symbol, | 222 const String& symbol, |
| 210 intptr_t index); | 223 intptr_t index); |
| 211 | 224 |
| 212 // Grow the symbol table. | 225 // Grow the symbol table. |
| 213 static void GrowSymbolTable(const Array& symbol_table); | 226 static void GrowSymbolTable(const Array& symbol_table); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 237 friend class SnapshotReader; | 250 friend class SnapshotReader; |
| 238 friend class SnapshotWriter; | 251 friend class SnapshotWriter; |
| 239 friend class ApiMessageReader; | 252 friend class ApiMessageReader; |
| 240 | 253 |
| 241 DISALLOW_COPY_AND_ASSIGN(Symbols); | 254 DISALLOW_COPY_AND_ASSIGN(Symbols); |
| 242 }; | 255 }; |
| 243 | 256 |
| 244 } // namespace dart | 257 } // namespace dart |
| 245 | 258 |
| 246 #endif // VM_SYMBOLS_H_ | 259 #endif // VM_SYMBOLS_H_ |
| OLD | NEW |