| 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/hash_table.h" | 9 #include "vm/hash_table.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // 3. Walk the heap and build a new table from surviving symbols. | 398 // 3. Walk the heap and build a new table from surviving symbols. |
| 399 GrowableArray<String*> symbols; | 399 GrowableArray<String*> symbols; |
| 400 class SymbolCollector : public ObjectVisitor { | 400 class SymbolCollector : public ObjectVisitor { |
| 401 public: | 401 public: |
| 402 SymbolCollector(Thread* thread, | 402 SymbolCollector(Thread* thread, |
| 403 GrowableArray<String*>* symbols) | 403 GrowableArray<String*>* symbols) |
| 404 : symbols_(symbols), | 404 : symbols_(symbols), |
| 405 zone_(thread->zone()) {} | 405 zone_(thread->zone()) {} |
| 406 | 406 |
| 407 void VisitObject(RawObject* obj) { | 407 void VisitObject(RawObject* obj) { |
| 408 if (obj->IsString() && obj->IsCanonical()) { | 408 if (obj->IsCanonical() && obj->IsStringInstance()) { |
| 409 symbols_->Add(&String::ZoneHandle(zone_, String::RawCast(obj))); | 409 symbols_->Add(&String::ZoneHandle(zone_, String::RawCast(obj))); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 private: | 413 private: |
| 414 GrowableArray<String*>* symbols_; | 414 GrowableArray<String*>* symbols_; |
| 415 Zone* zone_; | 415 Zone* zone_; |
| 416 }; | 416 }; |
| 417 | 417 |
| 418 SymbolCollector visitor(Thread::Current(), &symbols); | 418 SymbolCollector visitor(Thread::Current(), &symbols); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 771 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
| 772 ASSERT(IsVMSymbolId(object_id)); | 772 ASSERT(IsVMSymbolId(object_id)); |
| 773 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 773 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 774 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 774 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
| 775 return symbol_handles_[i]->raw(); | 775 return symbol_handles_[i]->raw(); |
| 776 } | 776 } |
| 777 return Object::null(); | 777 return Object::null(); |
| 778 } | 778 } |
| 779 | 779 |
| 780 } // namespace dart | 780 } // namespace dart |
| OLD | NEW |