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

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

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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/parser.cc ('k') | runtime/vm/scanner.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/raw_object.h" 5 #include "vm/raw_object.h"
6 6
7 #include "vm/class_table.h" 7 #include "vm/class_table.h"
8 #include "vm/freelist.h" 8 #include "vm/freelist.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/visitor.h" 11 #include "vm/visitor.h"
12 12
13 13
14 namespace dart { 14 namespace dart {
15 15
16 void RawObject::Validate(Isolate* isolate) const { 16 void RawObject::Validate(Isolate* isolate) const {
17 if (Object::null_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) { 17 if (Object::null_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) {
18 // Validation relies on properly initialized class classes. Skip if the 18 // Validation relies on properly initialized class classes. Skip if the
19 // VM is still being initialized. 19 // VM is still being initialized.
20 return; 20 return;
21 } 21 }
22 // All Smi values are valid. 22 // All Smi values are valid.
23 if (!IsHeapObject()) { 23 if (!IsHeapObject()) {
24 return; 24 return;
25 } 25 }
26 // Validate that the tags_ field is sensible. 26 // Validate that the tags_ field is sensible.
27 uword tags = ptr()->tags_; 27 uword tags = ptr()->tags_;
28 intptr_t reserved = ReservedBits::decode(tags); 28 intptr_t reserved = ReservedBits::decode(tags);
29 if (reserved != 0) { 29 if (reserved != 0) {
30 FATAL1("Invalid tags field encountered %#lx\n", tags); 30 FATAL1("Invalid tags field encountered %#"Px"\n", tags);
31 } 31 }
32 intptr_t class_id = ClassIdTag::decode(tags); 32 intptr_t class_id = ClassIdTag::decode(tags);
33 if (!isolate->class_table()->IsValidIndex(class_id)) { 33 if (!isolate->class_table()->IsValidIndex(class_id)) {
34 FATAL1("Invalid class id encountered %d\n", class_id); 34 FATAL1("Invalid class id encountered %"Pd"\n", class_id);
35 } 35 }
36 intptr_t size = SizeTag::decode(tags); 36 intptr_t size = SizeTag::decode(tags);
37 if (size != 0 && size != SizeFromClass()) { 37 if (size != 0 && size != SizeFromClass()) {
38 FATAL1("Inconsistent class size encountered %d\n", size); 38 FATAL1("Inconsistent class size encountered %"Pd"\n", size);
39 } 39 }
40 } 40 }
41 41
42 42
43 intptr_t RawObject::SizeFromClass() const { 43 intptr_t RawObject::SizeFromClass() const {
44 Isolate* isolate = Isolate::Current(); 44 Isolate* isolate = Isolate::Current();
45 NoHandleScope no_handles(isolate); 45 NoHandleScope no_handles(isolate);
46 46
47 // Only reasonable to be called on heap objects. 47 // Only reasonable to be called on heap objects.
48 ASSERT(IsHeapObject()); 48 ASSERT(IsHeapObject());
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) 281 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS)
282 #undef RAW_VISITPOINTERS 282 #undef RAW_VISITPOINTERS
283 case kFreeListElement: { 283 case kFreeListElement: {
284 ASSERT(FreeBit::decode(ptr()->tags_)); 284 ASSERT(FreeBit::decode(ptr()->tags_));
285 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); 285 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this));
286 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); 286 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
287 size = element->Size(); 287 size = element->Size();
288 break; 288 break;
289 } 289 }
290 default: 290 default:
291 OS::Print("Class Id: %d\n", class_id); 291 OS::Print("Class Id: %"Pd"\n", class_id);
292 UNREACHABLE(); 292 UNREACHABLE();
293 break; 293 break;
294 } 294 }
295 } else { 295 } else {
296 RawClass* raw_class = visitor->isolate()->class_table()->At(class_id); 296 RawClass* raw_class = visitor->isolate()->class_table()->At(class_id);
297 if (Class::IsSignatureClass(raw_class)) { 297 if (Class::IsSignatureClass(raw_class)) {
298 RawClosure* raw_obj = reinterpret_cast<RawClosure*>(this); 298 RawClosure* raw_obj = reinterpret_cast<RawClosure*>(this);
299 size = RawClosure::VisitClosurePointers(raw_obj, visitor); 299 size = RawClosure::VisitClosurePointers(raw_obj, visitor);
300 } else { 300 } else {
301 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this); 301 RawInstance* raw_obj = reinterpret_cast<RawInstance*>(this);
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 978
979 intptr_t RawWeakProperty::VisitWeakPropertyPointers( 979 intptr_t RawWeakProperty::VisitWeakPropertyPointers(
980 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { 980 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) {
981 // Make sure that we got here with the tagged pointer as this. 981 // Make sure that we got here with the tagged pointer as this.
982 ASSERT(raw_obj->IsHeapObject()); 982 ASSERT(raw_obj->IsHeapObject());
983 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 983 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
984 return WeakProperty::InstanceSize(); 984 return WeakProperty::InstanceSize();
985 } 985 }
986 986
987 } // namespace dart 987 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698