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

Side by Side Diff: runtime/vm/class_finalizer.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/benchmark_test.cc ('k') | runtime/vm/class_table.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/hash_table.h" 8 #include "vm/hash_table.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 3636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 obj->SetClassId(new_cid); 3647 obj->SetClassId(new_cid);
3648 } 3648 }
3649 } 3649 }
3650 } 3650 }
3651 3651
3652 private: 3652 private:
3653 intptr_t* old_to_new_cids_; 3653 intptr_t* old_to_new_cids_;
3654 }; 3654 };
3655 3655
3656 void ClassFinalizer::RemapClassIds(intptr_t* old_to_new_cid) { 3656 void ClassFinalizer::RemapClassIds(intptr_t* old_to_new_cid) {
3657 Isolate* I = Thread::Current()->isolate(); 3657 Thread* T = Thread::Current();
3658 Isolate* I = T->isolate();
3658 3659
3659 // Code, ICData, allocation stubs have now-invalid cids. 3660 // Code, ICData, allocation stubs have now-invalid cids.
3660 ClearAllCode(); 3661 ClearAllCode();
3661 3662
3662 { 3663 {
3663 HeapIterationScope his; 3664 HeapIterationScope his(T);
3664 I->set_remapping_cids(true); 3665 I->set_remapping_cids(true);
3665 3666
3666 // Update the class table. Do it before rewriting cids in headers, as the 3667 // Update the class table. Do it before rewriting cids in headers, as the
3667 // heap walkers load an object's size *after* calling the visitor. 3668 // heap walkers load an object's size *after* calling the visitor.
3668 I->class_table()->Remap(old_to_new_cid); 3669 I->class_table()->Remap(old_to_new_cid);
3669 3670
3670 // Rewrite cids in headers and cids in Classes, Fields, Types and 3671 // Rewrite cids in headers and cids in Classes, Fields, Types and
3671 // TypeParameters. 3672 // TypeParameters.
3672 { 3673 {
3673 CidRewriteVisitor visitor(old_to_new_cid); 3674 CidRewriteVisitor visitor(old_to_new_cid);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3713 BoundedType& bounded_type_; 3714 BoundedType& bounded_type_;
3714 }; 3715 };
3715 3716
3716 void ClassFinalizer::RehashTypes() { 3717 void ClassFinalizer::RehashTypes() {
3717 Thread* T = Thread::Current(); 3718 Thread* T = Thread::Current();
3718 Zone* Z = T->zone(); 3719 Zone* Z = T->zone();
3719 Isolate* I = T->isolate(); 3720 Isolate* I = T->isolate();
3720 3721
3721 // Clear all cached hash values. 3722 // Clear all cached hash values.
3722 { 3723 {
3723 HeapIterationScope his; 3724 HeapIterationScope his(T);
3724 ClearTypeHashVisitor visitor(Z); 3725 ClearTypeHashVisitor visitor(Z);
3725 I->heap()->VisitObjects(&visitor); 3726 I->heap()->VisitObjects(&visitor);
3726 } 3727 }
3727 3728
3728 // Rehash the canonical Types table. 3729 // Rehash the canonical Types table.
3729 ObjectStore* object_store = I->object_store(); 3730 ObjectStore* object_store = I->object_store();
3730 GrowableObjectArray& types = 3731 GrowableObjectArray& types =
3731 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); 3732 GrowableObjectArray::Handle(Z, GrowableObjectArray::New());
3732 Array& types_array = Array::Handle(Z); 3733 Array& types_array = Array::Handle(Z);
3733 Type& type = Type::Handle(Z); 3734 Type& type = Type::Handle(Z);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3790 ProgramVisitor::VisitFunctions(&function_visitor); 3791 ProgramVisitor::VisitFunctions(&function_visitor);
3791 3792
3792 class ClearCodeClassVisitor : public ClassVisitor { 3793 class ClearCodeClassVisitor : public ClassVisitor {
3793 void Visit(const Class& cls) { cls.DisableAllocationStub(); } 3794 void Visit(const Class& cls) { cls.DisableAllocationStub(); }
3794 }; 3795 };
3795 ClearCodeClassVisitor class_visitor; 3796 ClearCodeClassVisitor class_visitor;
3796 ProgramVisitor::VisitClasses(&class_visitor); 3797 ProgramVisitor::VisitClasses(&class_visitor);
3797 } 3798 }
3798 3799
3799 } // namespace dart 3800 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | runtime/vm/class_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698