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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // 2. Knock out the symbol table and do a full garbage collection. | 368 // 2. Knock out the symbol table and do a full garbage collection. |
369 isolate->object_store()->set_symbol_table(Object::empty_array()); | 369 isolate->object_store()->set_symbol_table(Object::empty_array()); |
370 isolate->heap()->CollectAllGarbage(); | 370 isolate->heap()->CollectAllGarbage(); |
371 | 371 |
372 // 3. Walk the heap and build a new table from surviving symbols. | 372 // 3. Walk the heap and build a new table from surviving symbols. |
373 GrowableArray<String*> symbols; | 373 GrowableArray<String*> symbols; |
374 class SymbolCollector : public ObjectVisitor { | 374 class SymbolCollector : public ObjectVisitor { |
375 public: | 375 public: |
376 SymbolCollector(Thread* thread, | 376 SymbolCollector(Thread* thread, |
377 GrowableArray<String*>* symbols) | 377 GrowableArray<String*>* symbols) |
378 : ObjectVisitor(thread->isolate()), | 378 : symbols_(symbols), |
379 symbols_(symbols), | |
380 zone_(thread->zone()) {} | 379 zone_(thread->zone()) {} |
381 | 380 |
382 void VisitObject(RawObject* obj) { | 381 void VisitObject(RawObject* obj) { |
383 if (obj->IsString() && obj->IsCanonical()) { | 382 if (obj->IsString() && obj->IsCanonical()) { |
384 symbols_->Add(&String::ZoneHandle(zone_, String::RawCast(obj))); | 383 symbols_->Add(&String::ZoneHandle(zone_, String::RawCast(obj))); |
385 } | 384 } |
386 } | 385 } |
387 | 386 |
388 private: | 387 private: |
389 GrowableArray<String*>* symbols_; | 388 GrowableArray<String*>* symbols_; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 687 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
689 ASSERT(IsVMSymbolId(object_id)); | 688 ASSERT(IsVMSymbolId(object_id)); |
690 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 689 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
691 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 690 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
692 return symbol_handles_[i]->raw(); | 691 return symbol_handles_[i]->raw(); |
693 } | 692 } |
694 return Object::null(); | 693 return Object::null(); |
695 } | 694 } |
696 | 695 |
697 } // namespace dart | 696 } // namespace dart |
OLD | NEW |