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

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

Issue 14179015: - Remove heap tracing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/assembler_ia32.cc ('k') | runtime/vm/code_generator.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/class_table.h" 5 #include "vm/class_table.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/heap_trace.h"
9 #include "vm/object.h" 8 #include "vm/object.h"
10 #include "vm/raw_object.h" 9 #include "vm/raw_object.h"
11 #include "vm/visitor.h" 10 #include "vm/visitor.h"
12 11
13 namespace dart { 12 namespace dart {
14 13
15 DEFINE_FLAG(bool, print_class_table, false, "Print initial class table."); 14 DEFINE_FLAG(bool, print_class_table, false, "Print initial class table.");
16 15
17 ClassTable::ClassTable() 16 ClassTable::ClassTable()
18 : top_(kNumPredefinedCids), capacity_(0), table_(NULL) { 17 : top_(kNumPredefinedCids), capacity_(0), table_(NULL) {
(...skipping 24 matching lines...) Expand all
43 42
44 43
45 void ClassTable::Register(const Class& cls) { 44 void ClassTable::Register(const Class& cls) {
46 intptr_t index = cls.id(); 45 intptr_t index = cls.id();
47 if (index != kIllegalCid) { 46 if (index != kIllegalCid) {
48 ASSERT(index > 0); 47 ASSERT(index > 0);
49 ASSERT(index < kNumPredefinedCids); 48 ASSERT(index < kNumPredefinedCids);
50 ASSERT(table_[index] == 0); 49 ASSERT(table_[index] == 0);
51 ASSERT(index < capacity_); 50 ASSERT(index < capacity_);
52 table_[index] = cls.raw(); 51 table_[index] = cls.raw();
53 if (HeapTrace::is_enabled()) {
54 Isolate::Current()->heap()->trace()->TraceRegisterClass(cls);
55 }
56 // Add the vtable for this predefined class into the static vtable registry 52 // Add the vtable for this predefined class into the static vtable registry
57 // if it has not been setup yet. 53 // if it has not been setup yet.
58 cpp_vtable cls_vtable = cls.handle_vtable(); 54 cpp_vtable cls_vtable = cls.handle_vtable();
59 cpp_vtable table_entry = Object::builtin_vtables_[index]; 55 cpp_vtable table_entry = Object::builtin_vtables_[index];
60 ASSERT((table_entry == 0) || (table_entry == cls_vtable)); 56 ASSERT((table_entry == 0) || (table_entry == cls_vtable));
61 if (table_entry == 0) { 57 if (table_entry == 0) {
62 Object::builtin_vtables_[index] = cls_vtable; 58 Object::builtin_vtables_[index] = cls_vtable;
63 } 59 }
64 } else { 60 } else {
65 if (top_ == capacity_) { 61 if (top_ == capacity_) {
66 // Grow the capacity of the class table. 62 // Grow the capacity of the class table.
67 intptr_t new_capacity = capacity_ + capacity_increment_; 63 intptr_t new_capacity = capacity_ + capacity_increment_;
68 RawClass** new_table = reinterpret_cast<RawClass**>( 64 RawClass** new_table = reinterpret_cast<RawClass**>(
69 realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT 65 realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT
70 for (intptr_t i = capacity_; i < new_capacity; i++) { 66 for (intptr_t i = capacity_; i < new_capacity; i++) {
71 new_table[i] = NULL; 67 new_table[i] = NULL;
72 } 68 }
73 capacity_ = new_capacity; 69 capacity_ = new_capacity;
74 table_ = new_table; 70 table_ = new_table;
75 } 71 }
76 ASSERT(top_ < capacity_); 72 ASSERT(top_ < capacity_);
77 cls.set_id(top_); 73 cls.set_id(top_);
78 table_[top_] = cls.raw(); 74 table_[top_] = cls.raw();
79 if (HeapTrace::is_enabled()) {
80 Isolate::Current()->heap()->trace()->TraceRegisterClass(cls);
81 }
82 top_++; // Increment next index. 75 top_++; // Increment next index.
83 } 76 }
84 } 77 }
85 78
86 79
87 void ClassTable::VisitObjectPointers(ObjectPointerVisitor* visitor) { 80 void ClassTable::VisitObjectPointers(ObjectPointerVisitor* visitor) {
88 ASSERT(visitor != NULL); 81 ASSERT(visitor != NULL);
89 visitor->VisitPointers(reinterpret_cast<RawObject**>(&table_[0]), top_); 82 visitor->VisitPointers(reinterpret_cast<RawObject**>(&table_[0]), top_);
90 } 83 }
91 84
92 85
93 void ClassTable::Print() { 86 void ClassTable::Print() {
94 Class& cls = Class::Handle(); 87 Class& cls = Class::Handle();
95 String& name = String::Handle(); 88 String& name = String::Handle();
96 89
97 for (intptr_t i = 1; i < top_; i++) { 90 for (intptr_t i = 1; i < top_; i++) {
98 cls = At(i); 91 cls = At(i);
99 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { 92 if (cls.raw() != reinterpret_cast<RawClass*>(0)) {
100 name = cls.Name(); 93 name = cls.Name();
101 OS::Print("%"Pd": %s\n", i, name.ToCString()); 94 OS::Print("%"Pd": %s\n", i, name.ToCString());
102 } 95 }
103 } 96 }
104 } 97 }
105 98
106 } // namespace dart 99 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/code_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698