| 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 #include "vm/symbols.h" | 5 #include "vm/symbols.h" |
| 6 | 6 |
| 7 #include "vm/handles.h" | 7 #include "vm/handles.h" |
| 8 #include "vm/handles_impl.h" | 8 #include "vm/handles_impl.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kNullCharId); | 58 ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kNullCharId); |
| 59 ObjectStore* object_store = isolate->object_store(); | 59 ObjectStore* object_store = isolate->object_store(); |
| 60 Array& symbol_table = Array::Handle(); | 60 Array& symbol_table = Array::Handle(); |
| 61 | 61 |
| 62 | 62 |
| 63 // First set up all the predefined string symbols. | 63 // First set up all the predefined string symbols. |
| 64 for (intptr_t i = 1; i < Symbols::kNullCharId; i++) { | 64 for (intptr_t i = 1; i < Symbols::kNullCharId; i++) { |
| 65 // The symbol_table needs to be reloaded as it might have grown in the | 65 // The symbol_table needs to be reloaded as it might have grown in the |
| 66 // previous iteration. | 66 // previous iteration. |
| 67 symbol_table = object_store->symbol_table(); | 67 symbol_table = object_store->symbol_table(); |
| 68 String* str = String::ReadOnlyHandle(isolate); | 68 String* str = String::ReadOnlyHandle(); |
| 69 *str = OneByteString::New(names[i], Heap::kOld); | 69 *str = OneByteString::New(names[i], Heap::kOld); |
| 70 Add(symbol_table, *str); | 70 Add(symbol_table, *str); |
| 71 symbol_handles_[i] = str; | 71 symbol_handles_[i] = str; |
| 72 } | 72 } |
| 73 Object::RegisterSingletonClassNames(); | 73 Object::RegisterSingletonClassNames(); |
| 74 | 74 |
| 75 // Add Latin1 characters as Symbols, so that Symbols::FromCharCode is fast. | 75 // Add Latin1 characters as Symbols, so that Symbols::FromCharCode is fast. |
| 76 for (intptr_t c = 0; c < kNumberOfOneCharCodeSymbols; c++) { | 76 for (intptr_t c = 0; c < kNumberOfOneCharCodeSymbols; c++) { |
| 77 // The symbol_table needs to be reloaded as it might have grown in the | 77 // The symbol_table needs to be reloaded as it might have grown in the |
| 78 // previous iteration. | 78 // previous iteration. |
| 79 symbol_table = object_store->symbol_table(); | 79 symbol_table = object_store->symbol_table(); |
| 80 intptr_t idx = (kNullCharId + c); | 80 intptr_t idx = (kNullCharId + c); |
| 81 ASSERT(idx < kMaxPredefinedId); | 81 ASSERT(idx < kMaxPredefinedId); |
| 82 ASSERT(Utf::IsLatin1(c)); | 82 ASSERT(Utf::IsLatin1(c)); |
| 83 uint8_t ch = static_cast<uint8_t>(c); | 83 uint8_t ch = static_cast<uint8_t>(c); |
| 84 String* str = String::ReadOnlyHandle(isolate); | 84 String* str = String::ReadOnlyHandle(); |
| 85 *str = OneByteString::New(&ch, 1, Heap::kOld); | 85 *str = OneByteString::New(&ch, 1, Heap::kOld); |
| 86 Add(symbol_table, *str); | 86 Add(symbol_table, *str); |
| 87 predefined_[c] = str->raw(); | 87 predefined_[c] = str->raw(); |
| 88 symbol_handles_[idx] = str; | 88 symbol_handles_[idx] = str; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 void Symbols::SetupSymbolTable(Isolate* isolate) { | 93 void Symbols::SetupSymbolTable(Isolate* isolate) { |
| 94 ASSERT(isolate != NULL); | 94 ASSERT(isolate != NULL); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 447 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
| 448 ASSERT(IsVMSymbolId(object_id)); | 448 ASSERT(IsVMSymbolId(object_id)); |
| 449 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 449 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 450 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 450 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
| 451 return symbol_handles_[i]->raw(); | 451 return symbol_handles_[i]->raw(); |
| 452 } | 452 } |
| 453 return Object::null(); | 453 return Object::null(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 } // namespace dart | 456 } // namespace dart |
| OLD | NEW |