Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: runtime/vm/symbols.cc

Issue 2995543004: [vm, gc] Require a safepoint for heap iteration. (Closed)
Patch Set: . Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/hash_table.h" 8 #include "vm/hash_table.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (obj->IsCanonical() && obj->IsStringInstance()) { 362 if (obj->IsCanonical() && obj->IsStringInstance()) {
363 symbols_->Add(&String::ZoneHandle(zone_, String::RawCast(obj))); 363 symbols_->Add(&String::ZoneHandle(zone_, String::RawCast(obj)));
364 } 364 }
365 } 365 }
366 366
367 private: 367 private:
368 GrowableArray<String*>* symbols_; 368 GrowableArray<String*>* symbols_;
369 Zone* zone_; 369 Zone* zone_;
370 }; 370 };
371 371
372 SymbolCollector visitor(Thread::Current(), &symbols); 372 {
373 isolate->heap()->IterateObjects(&visitor); 373 HeapIterationScope iteration;
374 SymbolCollector visitor(Thread::Current(), &symbols);
375 iteration.IterateObjects(&visitor);
376 }
374 377
375 // 3. Build a new table from the surviving symbols. 378 // 3. Build a new table from the surviving symbols.
376 Array& array = Array::Handle( 379 Array& array = Array::Handle(
377 zone, HashTables::New<SymbolTable>(symbols.length() * 4 / 3, Heap::kOld)); 380 zone, HashTables::New<SymbolTable>(symbols.length() * 4 / 3, Heap::kOld));
378 SymbolTable table(zone, array.raw()); 381 SymbolTable table(zone, array.raw());
379 for (intptr_t i = 0; i < symbols.length(); i++) { 382 for (intptr_t i = 0; i < symbols.length(); i++) {
380 String& symbol = *symbols[i]; 383 String& symbol = *symbols[i];
381 ASSERT(symbol.IsString()); 384 ASSERT(symbol.IsString());
382 ASSERT(symbol.IsCanonical()); 385 ASSERT(symbol.IsCanonical());
383 bool present = table.Insert(symbol); 386 bool present = table.Insert(symbol);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 RawObject* Symbols::GetPredefinedSymbol(intptr_t object_id) { 696 RawObject* Symbols::GetPredefinedSymbol(intptr_t object_id) {
694 ASSERT(IsPredefinedSymbolId(object_id)); 697 ASSERT(IsPredefinedSymbolId(object_id));
695 intptr_t i = (object_id - kMaxPredefinedObjectIds); 698 intptr_t i = (object_id - kMaxPredefinedObjectIds);
696 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { 699 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) {
697 return symbol_handles_[i]->raw(); 700 return symbol_handles_[i]->raw();
698 } 701 }
699 return Object::null(); 702 return Object::null();
700 } 703 }
701 704
702 } // namespace dart 705 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698