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. |
|
cshapiro
2012/12/04 01:00:46
Same TODO here as well?
siva
2012/12/04 02:36:16
Done.
| |
| 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. | |
| 185 static RawString* NewFromUTF8(const uint8_t* utf8_array, intptr_t len); | |
|
cshapiro
2012/12/04 01:00:46
Maybe s/NewFromUTF8/FromUTF8/
?
siva
2012/12/04 02:36:16
Renamed this to FromUTF8 and all the subsequent
on
| |
| 186 | |
| 187 // Creates a new Symbol from an array of Latin-1 encoded characters. | |
| 188 static RawString* New(const uint8_t* latin1_array, intptr_t len); | |
| 189 | |
| 190 // Creates a new Symbol from an array of UTF-16 encoded characters. | |
| 191 static RawString* New(const uint16_t* utf16_array, intptr_t len); | |
| 192 | |
| 193 // Creates a new Symbol from an array of UTF-32 encoded characters. | |
| 194 static RawString* New(const int32_t* utf32_array, intptr_t len); | |
| 195 | |
| 184 static RawString* New(const String& str); | 196 static RawString* New(const String& str); |
| 185 static RawString* New(const String& str, | 197 static RawString* New(const String& str, |
| 186 intptr_t begin_index, | 198 intptr_t begin_index, |
| 187 intptr_t length); | 199 intptr_t length); |
| 188 | 200 |
| 189 // Returns char* of predefined symbol. | 201 // Returns char* of predefined symbol. |
| 190 static const char* Name(SymbolId symbol); | 202 static const char* Name(SymbolId symbol); |
| 191 | 203 |
| 192 static RawString* FromCharCode(int32_t char_code); | 204 static RawString* FromCharCode(int32_t char_code); |
| 193 | 205 |
| 194 static RawString** PredefinedAddress() { | 206 static RawString** PredefinedAddress() { |
| 195 return reinterpret_cast<RawString**>(&predefined_); | 207 return reinterpret_cast<RawString**>(&predefined_); |
| 196 } | 208 } |
| 197 | 209 |
| 198 private: | 210 private: |
| 199 enum { | 211 enum { |
| 200 kInitialVMIsolateSymtabSize = ((kMaxId + 15) & -16), | 212 kInitialVMIsolateSymtabSize = ((kMaxId + 15) & -16), |
| 201 kInitialSymtabSize = 256 | 213 kInitialSymtabSize = 256 |
| 202 }; | 214 }; |
| 203 | 215 |
| 216 // Helper functions to create a symbol given a string or set of characters. | |
| 217 template<typename T> | |
| 218 static RawString* NewSymbol(const T* characters, intptr_t len); | |
| 219 | |
| 204 // Add the string into the VM isolate symbol table. | 220 // Add the string into the VM isolate symbol table. |
| 205 static void Add(const Array& symbol_table, const String& str); | 221 static void Add(const Array& symbol_table, const String& str); |
| 206 | 222 |
| 207 // Insert symbol into symbol table, growing it if necessary. | 223 // Insert symbol into symbol table, growing it if necessary. |
| 208 static void InsertIntoSymbolTable(const Array& symbol_table, | 224 static void InsertIntoSymbolTable(const Array& symbol_table, |
| 209 const String& symbol, | 225 const String& symbol, |
| 210 intptr_t index); | 226 intptr_t index); |
| 211 | 227 |
| 212 // Grow the symbol table. | 228 // Grow the symbol table. |
| 213 static void GrowSymbolTable(const Array& symbol_table); | 229 static void GrowSymbolTable(const Array& symbol_table); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 237 friend class SnapshotReader; | 253 friend class SnapshotReader; |
| 238 friend class SnapshotWriter; | 254 friend class SnapshotWriter; |
| 239 friend class ApiMessageReader; | 255 friend class ApiMessageReader; |
| 240 | 256 |
| 241 DISALLOW_COPY_AND_ASSIGN(Symbols); | 257 DISALLOW_COPY_AND_ASSIGN(Symbols); |
| 242 }; | 258 }; |
| 243 | 259 |
| 244 } // namespace dart | 260 } // namespace dart |
| 245 | 261 |
| 246 #endif // VM_SYMBOLS_H_ | 262 #endif // VM_SYMBOLS_H_ |
| OLD | NEW |