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

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

Issue 10696029: Implement a 2-pass heap verification algorithm. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/verifier.h ('k') | runtime/vm/visitor.h » ('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/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"
11 #include "vm/heap.h" 11 #include "vm/heap.h"
12 #include "vm/isolate.h" 12 #include "vm/isolate.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_set.h"
14 #include "vm/raw_object.h" 15 #include "vm/raw_object.h"
15 #include "vm/stack_frame.h" 16 #include "vm/stack_frame.h"
16 17
17 namespace dart { 18 namespace dart {
18 19
19 DEFINE_FLAG(bool, verify_on_transition, false, "Verify on dart <==> VM."); 20 DEFINE_FLAG(bool, verify_on_transition, false, "Verify on dart <==> VM.");
20 21
21 22
23 void VerifyObjectVisitor::VisitObject(RawObject* raw_obj) {
24 allocated_set_->Add(raw_obj);
25 raw_obj->Validate(isolate());
26 }
27
28
22 void VerifyPointersVisitor::VisitPointers(RawObject** first, RawObject** last) { 29 void VerifyPointersVisitor::VisitPointers(RawObject** first, RawObject** last) {
23 for (RawObject** current = first; current <= last; current++) { 30 for (RawObject** current = first; current <= last; current++) {
24 RawObject* raw_obj = *current; 31 RawObject* raw_obj = *current;
25 if (raw_obj->IsHeapObject()) { 32 if (raw_obj->IsHeapObject()) {
26 uword obj_addr = RawObject::ToAddr(raw_obj); 33 if (!allocated_set_->Contains(raw_obj)) {
27 if (!Isolate::Current()->heap()->Contains(obj_addr) && 34 uword raw_addr = RawObject::ToAddr(raw_obj);
28 !Dart::vm_isolate()->heap()->Contains(obj_addr)) { 35 FATAL1("Invalid object pointer encountered %#lx\n", raw_addr);
29 FATAL1("Invalid object pointer encountered 0x%lx\n", obj_addr);
30 } 36 }
31 raw_obj->Validate(isolate());
32 } 37 }
33 } 38 }
34 } 39 }
35 40
36 41
37 void VerifyWeakPointersVisitor::VisitHandle(uword addr) { 42 void VerifyWeakPointersVisitor::VisitHandle(uword addr) {
38 FinalizablePersistentHandle* handle = 43 FinalizablePersistentHandle* handle =
39 reinterpret_cast<FinalizablePersistentHandle*>(addr); 44 reinterpret_cast<FinalizablePersistentHandle*>(addr);
40 RawObject* raw_obj = handle->raw(); 45 RawObject* raw_obj = handle->raw();
41 visitor_->VisitPointer(&raw_obj); 46 visitor_->VisitPointer(&raw_obj);
42 } 47 }
43 48
44 49
45 void VerifyPointersVisitor::VerifyPointers() { 50 void VerifyPointersVisitor::VerifyPointers() {
46 NoGCScope no_gc; 51 NoGCScope no_gc;
47 Isolate* isolate = Isolate::Current(); 52 Isolate* isolate = Isolate::Current();
48 VerifyPointersVisitor visitor(isolate); 53 ObjectSet* allocated_set = isolate->heap()->CreateAllocatedObjectSet();
54 VerifyPointersVisitor visitor(isolate, allocated_set);
49 // Visit all strongly reachable objects. 55 // Visit all strongly reachable objects.
50 isolate->VisitObjectPointers(&visitor, 56 isolate->VisitObjectPointers(&visitor,
51 false, // skip prologue weak handles 57 false, // skip prologue weak handles
52 StackFrameIterator::kValidateFrames); 58 StackFrameIterator::kValidateFrames);
53 VerifyWeakPointersVisitor weak_visitor(&visitor); 59 VerifyWeakPointersVisitor weak_visitor(&visitor);
54 // Visit weak handles and prologue weak handles. 60 // Visit weak handles and prologue weak handles.
55 isolate->VisitWeakPersistentHandles(&weak_visitor, 61 isolate->VisitWeakPersistentHandles(&weak_visitor,
56 true); // visit prologue weak handles 62 true); // visit prologue weak handles
63 delete allocated_set;
57 } 64 }
58 65
59 } // namespace dart 66 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/verifier.h ('k') | runtime/vm/visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698