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

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

Issue 2995543004: [vm, gc] Require a safepoint for heap iteration. (Closed)
Patch Set: explicit-thread 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
« no previous file with comments | « runtime/vm/stack_frame_test.cc ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Thread* thread = Thread::Current();
374 HeapIterationScope iteration(thread);
375 SymbolCollector visitor(thread, &symbols);
376 iteration.IterateObjects(&visitor);
377 }
374 378
375 // 3. Build a new table from the surviving symbols. 379 // 3. Build a new table from the surviving symbols.
376 Array& array = Array::Handle( 380 Array& array = Array::Handle(
377 zone, HashTables::New<SymbolTable>(symbols.length() * 4 / 3, Heap::kOld)); 381 zone, HashTables::New<SymbolTable>(symbols.length() * 4 / 3, Heap::kOld));
378 SymbolTable table(zone, array.raw()); 382 SymbolTable table(zone, array.raw());
379 for (intptr_t i = 0; i < symbols.length(); i++) { 383 for (intptr_t i = 0; i < symbols.length(); i++) {
380 String& symbol = *symbols[i]; 384 String& symbol = *symbols[i];
381 ASSERT(symbol.IsString()); 385 ASSERT(symbol.IsString());
382 ASSERT(symbol.IsCanonical()); 386 ASSERT(symbol.IsCanonical());
383 bool present = table.Insert(symbol); 387 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) { 697 RawObject* Symbols::GetPredefinedSymbol(intptr_t object_id) {
694 ASSERT(IsPredefinedSymbolId(object_id)); 698 ASSERT(IsPredefinedSymbolId(object_id));
695 intptr_t i = (object_id - kMaxPredefinedObjectIds); 699 intptr_t i = (object_id - kMaxPredefinedObjectIds);
696 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { 700 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) {
697 return symbol_handles_[i]->raw(); 701 return symbol_handles_[i]->raw();
698 } 702 }
699 return Object::null(); 703 return Object::null();
700 } 704 }
701 705
702 } // namespace dart 706 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/stack_frame_test.cc ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698