| 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/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 void VerifyWeakPointersVisitor::VisitHandle(uword addr) { | 62 void VerifyWeakPointersVisitor::VisitHandle(uword addr) { |
| 63 FinalizablePersistentHandle* handle = | 63 FinalizablePersistentHandle* handle = |
| 64 reinterpret_cast<FinalizablePersistentHandle*>(addr); | 64 reinterpret_cast<FinalizablePersistentHandle*>(addr); |
| 65 RawObject* raw_obj = handle->raw(); | 65 RawObject* raw_obj = handle->raw(); |
| 66 visitor_->VisitPointer(&raw_obj); | 66 visitor_->VisitPointer(&raw_obj); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 void VerifyPointersVisitor::VerifyPointers(MarkExpectation mark_expectation) { | 70 void VerifyPointersVisitor::VerifyPointers(MarkExpectation mark_expectation) { |
| 71 NoSafepointScope no_safepoint; | 71 NoSafepointScope no_safepoint; |
| 72 Isolate* isolate = Isolate::Current(); | 72 Thread* thread = Thread::Current(); |
| 73 Isolate* isolate = thread->isolate(); |
| 74 StackZone stack_zone(thread); |
| 73 ObjectSet* allocated_set = | 75 ObjectSet* allocated_set = |
| 74 isolate->heap()->CreateAllocatedObjectSet(mark_expectation); | 76 isolate->heap()->CreateAllocatedObjectSet(stack_zone.GetZone(), |
| 77 mark_expectation); |
| 75 VerifyPointersVisitor visitor(isolate, allocated_set); | 78 VerifyPointersVisitor visitor(isolate, allocated_set); |
| 76 // Visit all strongly reachable objects. | 79 // Visit all strongly reachable objects. |
| 77 isolate->IterateObjectPointers(&visitor, | 80 isolate->IterateObjectPointers(&visitor, |
| 78 StackFrameIterator::kValidateFrames); | 81 StackFrameIterator::kValidateFrames); |
| 79 VerifyWeakPointersVisitor weak_visitor(&visitor); | 82 VerifyWeakPointersVisitor weak_visitor(&visitor); |
| 80 // Visit weak handles and prologue weak handles. | 83 // Visit weak handles and prologue weak handles. |
| 81 isolate->VisitWeakPersistentHandles(&weak_visitor); | 84 isolate->VisitWeakPersistentHandles(&weak_visitor); |
| 82 delete allocated_set; | |
| 83 } | 85 } |
| 84 | 86 |
| 85 | 87 |
| 86 #if defined(DEBUG) | 88 #if defined(DEBUG) |
| 87 VerifyCanonicalVisitor::VerifyCanonicalVisitor(Thread* thread) | 89 VerifyCanonicalVisitor::VerifyCanonicalVisitor(Thread* thread) |
| 88 : thread_(thread), | 90 : thread_(thread), |
| 89 instanceHandle_(Instance::Handle(thread->zone())) { | 91 instanceHandle_(Instance::Handle(thread->zone())) { |
| 90 } | 92 } |
| 91 | 93 |
| 92 | 94 |
| 93 void VerifyCanonicalVisitor::VisitObject(RawObject* obj) { | 95 void VerifyCanonicalVisitor::VisitObject(RawObject* obj) { |
| 94 if (obj->GetClassId() >= kInstanceCid) { | 96 if (obj->GetClassId() >= kInstanceCid) { |
| 95 if (obj->IsCanonical()) { | 97 if (obj->IsCanonical()) { |
| 96 instanceHandle_ ^= obj; | 98 instanceHandle_ ^= obj; |
| 97 ASSERT(instanceHandle_.CheckIsCanonical(thread_)); | 99 ASSERT(instanceHandle_.CheckIsCanonical(thread_)); |
| 98 } | 100 } |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 #endif // defined(DEBUG) | 103 #endif // defined(DEBUG) |
| 102 | 104 |
| 103 } // namespace dart | 105 } // namespace dart |
| OLD | NEW |