| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 for (intptr_t i = 1; i < Symbols::kMaxPredefinedId; i++) { | 69 for (intptr_t i = 1; i < Symbols::kMaxPredefinedId; i++) { |
| 70 // The symbol_table needs to be reloaded as it might have grown in the | 70 // The symbol_table needs to be reloaded as it might have grown in the |
| 71 // previous iteration. | 71 // previous iteration. |
| 72 symbol_table = object_store->symbol_table(); | 72 symbol_table = object_store->symbol_table(); |
| 73 str = OneByteString::New(names[i], Heap::kOld); | 73 str = OneByteString::New(names[i], Heap::kOld); |
| 74 Add(symbol_table, str); | 74 Add(symbol_table, str); |
| 75 predefined_[i] = str.raw(); | 75 predefined_[i] = str.raw(); |
| 76 } | 76 } |
| 77 Object::RegisterSingletonClassNames(); | 77 Object::RegisterSingletonClassNames(); |
| 78 | 78 |
| 79 for (int32_t c = 0; c <= kMaxOneCharCodeSymbol; c++) { | 79 // Add Latin1 characters as Symbols, so that Symbols::FromCharCode is fast. |
| 80 for (intptr_t c = 0; c < kMaxOneCharCodeSymbol; c++) { |
| 81 // The symbol_table needs to be reloaded as it might have grown in the |
| 82 // previous iteration. |
| 83 symbol_table = object_store->symbol_table(); |
| 80 ASSERT(kMaxPredefinedId + c < kMaxId); | 84 ASSERT(kMaxPredefinedId + c < kMaxId); |
| 81 predefined_[kMaxPredefinedId + c] = FromUTF32(&c, 1); | 85 ASSERT(Utf::IsLatin1(c)); |
| 86 uint8_t ch = static_cast<uint8_t>(c); |
| 87 str = OneByteString::New(&ch, 1, Heap::kOld); |
| 88 Add(symbol_table, str); |
| 89 predefined_[kMaxPredefinedId + c] = str.raw(); |
| 82 } | 90 } |
| 83 | 91 |
| 84 predefined_handles_ = new ReadOnlyHandles(); | 92 predefined_handles_ = new ReadOnlyHandles(); |
| 85 #define INITIALIZE_SYMBOL_HANDLE(symbol) \ | 93 #define INITIALIZE_SYMBOL_HANDLE(symbol) \ |
| 86 symbol##_handle_ = reinterpret_cast<String*>( \ | 94 symbol##_handle_ = reinterpret_cast<String*>( \ |
| 87 predefined_handles_->AllocateHandle()); \ | 95 predefined_handles_->AllocateHandle()); \ |
| 88 *symbol##_handle_ = symbol(); | 96 *symbol##_handle_ = symbol(); |
| 89 PREDEFINED_SYMBOL_HANDLES_LIST(INITIALIZE_SYMBOL_HANDLE) | 97 PREDEFINED_SYMBOL_HANDLES_LIST(INITIALIZE_SYMBOL_HANDLE) |
| 90 #undef INITIALIZE_SYMBOL_HANDLE | 98 #undef INITIALIZE_SYMBOL_HANDLE |
| 91 } | 99 } |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 458 } |
| 451 | 459 |
| 452 | 460 |
| 453 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 461 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
| 454 ASSERT(IsVMSymbolId(object_id)); | 462 ASSERT(IsVMSymbolId(object_id)); |
| 455 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 463 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 456 return (i > 0 && i < Symbols::kMaxId) ? predefined_[i] : Object::null(); | 464 return (i > 0 && i < Symbols::kMaxId) ? predefined_[i] : Object::null(); |
| 457 } | 465 } |
| 458 | 466 |
| 459 } // namespace dart | 467 } // namespace dart |
| OLD | NEW |