Chromium Code Reviews| Index: runtime/vm/symbols.cc |
| =================================================================== |
| --- runtime/vm/symbols.cc (revision 14902) |
| +++ runtime/vm/symbols.cc (working copy) |
| @@ -28,8 +28,8 @@ |
| }; |
| -const char* Symbols::Name(intptr_t symbol) { |
| - ASSERT((symbol > kIllegal) && (symbol < kMaxId)); |
| +const char* Symbols::Name(SymbolId symbol) { |
|
Ivan Posva
2012/11/15 09:07:10
I find it unfortunate that we cannot access the na
Florian Schneider
2012/11/15 21:54:42
Yes, but not sure if the names are actually needed
|
| + ASSERT((symbol > kIllegal) && (symbol < kMaxPredefinedId)); |
|
Ivan Posva
2012/11/15 09:07:10
I find it unfortunate that we cannot access the na
|
| return names[symbol]; |
| } |
| @@ -44,17 +44,22 @@ |
| // Turn off population of symbols in the VM symbol table, so that we |
| // don't find these symbols while doing a Symbols::New(...). |
| // Create all predefined symbols. |
| - ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kMaxId); |
| + ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kMaxPredefinedId); |
| const Array& symbol_table = |
| Array::Handle(isolate->object_store()->symbol_table()); |
| dart::String& str = String::Handle(); |
| - for (intptr_t i = 1; i < Symbols::kMaxId; i++) { |
| + for (intptr_t i = 1; i < Symbols::kMaxPredefinedId; i++) { |
|
Ivan Posva
2012/11/15 09:07:10
if the single char strings would be part of the na
|
| str = OneByteString::New(names[i], Heap::kOld); |
| Add(symbol_table, str); |
|
Ivan Posva
2012/11/15 09:07:10
The naked Add into the symbol table seems rather s
|
| predefined_[i] = str.raw(); |
| } |
| Object::RegisterSingletonClassNames(); |
| + |
| + for (uint32_t c = 0; c <= kMaxOneByteCharCode; c++) { |
| + ASSERT(kMaxPredefinedId + c < kMaxId); |
| + predefined_[kMaxPredefinedId + c] = New(&c, 1); |
| + } |
| } |
| @@ -118,7 +123,6 @@ |
| template<typename T> |
| RawString* Symbols::New(const T* characters, intptr_t len) { |
| Isolate* isolate = Isolate::Current(); |
| - ASSERT(isolate != Dart::vm_isolate()); |
|
Ivan Posva
2012/11/15 09:07:10
If single char was handled in names, you would not
Florian Schneider
2012/11/15 21:54:42
It is a bit unfortunate, but I also want to avoid
|
| String& symbol = String::Handle(isolate, String::null()); |
| Array& symbol_table = Array::Handle(isolate, Array::null()); |
| @@ -201,6 +205,14 @@ |
| } |
| +RawString* Symbols::FromCharCode(uint32_t char_code) { |
| + if (char_code > kMaxOneByteCharCode) { |
| + return New(&char_code, 1); |
| + } |
| + return predefined_[kMaxPredefinedId + char_code]; |
| +} |
| + |
| + |
| void Symbols::GrowSymbolTable(const Array& symbol_table) { |
| // TODO(iposva): Avoid exponential growth. |
| intptr_t table_size = symbol_table.Length() - 1; |