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

Side by Side Diff: runtime/vm/verifier.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/thread_test.cc ('k') | no next file » | 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/verifier.h" 5 #include "vm/verifier.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/freelist.h" 10 #include "vm/freelist.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void VerifyWeakPointersVisitor::VisitHandle(uword addr) { 60 void VerifyWeakPointersVisitor::VisitHandle(uword addr) {
61 FinalizablePersistentHandle* handle = 61 FinalizablePersistentHandle* handle =
62 reinterpret_cast<FinalizablePersistentHandle*>(addr); 62 reinterpret_cast<FinalizablePersistentHandle*>(addr);
63 RawObject* raw_obj = handle->raw(); 63 RawObject* raw_obj = handle->raw();
64 visitor_->VisitPointer(&raw_obj); 64 visitor_->VisitPointer(&raw_obj);
65 } 65 }
66 66
67 void VerifyPointersVisitor::VerifyPointers(MarkExpectation mark_expectation) { 67 void VerifyPointersVisitor::VerifyPointers(MarkExpectation mark_expectation) {
68 NoSafepointScope no_safepoint;
69 Thread* thread = Thread::Current(); 68 Thread* thread = Thread::Current();
70 Isolate* isolate = thread->isolate(); 69 Isolate* isolate = thread->isolate();
70 HeapIterationScope iteration(thread);
71 StackZone stack_zone(thread); 71 StackZone stack_zone(thread);
72 ObjectSet* allocated_set = isolate->heap()->CreateAllocatedObjectSet( 72 ObjectSet* allocated_set = isolate->heap()->CreateAllocatedObjectSet(
73 stack_zone.GetZone(), mark_expectation); 73 stack_zone.GetZone(), mark_expectation);
74
74 VerifyPointersVisitor visitor(isolate, allocated_set); 75 VerifyPointersVisitor visitor(isolate, allocated_set);
75 // Visit all strongly reachable objects. 76 // Visit all strongly reachable objects.
76 isolate->IterateObjectPointers(&visitor, StackFrameIterator::kValidateFrames); 77 iteration.IterateObjectPointers(&visitor,
78 StackFrameIterator::kValidateFrames);
77 VerifyWeakPointersVisitor weak_visitor(&visitor); 79 VerifyWeakPointersVisitor weak_visitor(&visitor);
78 // Visit weak handles and prologue weak handles. 80 // Visit weak handles and prologue weak handles.
79 isolate->VisitWeakPersistentHandles(&weak_visitor); 81 isolate->VisitWeakPersistentHandles(&weak_visitor);
80 } 82 }
81 83
82 #if defined(DEBUG) 84 #if defined(DEBUG)
83 VerifyCanonicalVisitor::VerifyCanonicalVisitor(Thread* thread) 85 VerifyCanonicalVisitor::VerifyCanonicalVisitor(Thread* thread)
84 : thread_(thread), instanceHandle_(Instance::Handle(thread->zone())) {} 86 : thread_(thread), instanceHandle_(Instance::Handle(thread->zone())) {}
85 87
86 void VerifyCanonicalVisitor::VisitObject(RawObject* obj) { 88 void VerifyCanonicalVisitor::VisitObject(RawObject* obj) {
87 if (obj->GetClassId() >= kInstanceCid) { 89 if (obj->GetClassId() >= kInstanceCid) {
88 if (obj->IsCanonical()) { 90 if (obj->IsCanonical()) {
89 instanceHandle_ ^= obj; 91 instanceHandle_ ^= obj;
90 const bool is_canonical = instanceHandle_.CheckIsCanonical(thread_); 92 const bool is_canonical = instanceHandle_.CheckIsCanonical(thread_);
91 if (!is_canonical) { 93 if (!is_canonical) {
92 OS::PrintErr("Instance `%s` is not canonical!\n", 94 OS::PrintErr("Instance `%s` is not canonical!\n",
93 instanceHandle_.ToCString()); 95 instanceHandle_.ToCString());
94 } 96 }
95 ASSERT(is_canonical); 97 ASSERT(is_canonical);
96 } 98 }
97 } 99 }
98 } 100 }
99 #endif // defined(DEBUG) 101 #endif // defined(DEBUG)
100 102
101 } // namespace dart 103 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698