| 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/class_table.h" | 5 #include "vm/class_table.h" |
| 6 | 6 |
| 7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 #if defined(DEBUG) | 207 #if defined(DEBUG) |
| 208 void ClassTable::Unregister(intptr_t index) { | 208 void ClassTable::Unregister(intptr_t index) { |
| 209 table_[index] = 0; | 209 table_[index] = 0; |
| 210 } | 210 } |
| 211 #endif | 211 #endif |
| 212 | 212 |
| 213 | 213 |
| 214 #if defined(DART_PRECOMPILER) |
| 215 void ClassTable::Remap(intptr_t* old_to_new_cid) { |
| 216 intptr_t num_cids = NumCids(); |
| 217 RawClass** cls_by_old_cid = new RawClass*[num_cids]; |
| 218 for (intptr_t i = 0; i < num_cids; i++) { |
| 219 cls_by_old_cid[i] = table_[i]; |
| 220 } |
| 221 for (intptr_t i = 0; i < num_cids; i++) { |
| 222 table_[old_to_new_cid[i]] = cls_by_old_cid[i]; |
| 223 } |
| 224 delete[] cls_by_old_cid; |
| 225 } |
| 226 #endif |
| 227 |
| 228 |
| 214 void ClassTable::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 229 void ClassTable::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 215 ASSERT(visitor != NULL); | 230 ASSERT(visitor != NULL); |
| 216 visitor->VisitPointers(reinterpret_cast<RawObject**>(&table_[0]), top_); | 231 visitor->VisitPointers(reinterpret_cast<RawObject**>(&table_[0]), top_); |
| 217 } | 232 } |
| 218 | 233 |
| 219 | 234 |
| 220 void ClassTable::Validate() { | 235 void ClassTable::Validate() { |
| 221 Class& cls = Class::Handle(); | 236 Class& cls = Class::Handle(); |
| 222 for (intptr_t i = kNumPredefinedCids; i < top_; i++) { | 237 for (intptr_t cid = kNumPredefinedCids; cid < top_; cid++) { |
| 223 // Some of the class table entries maybe NULL as we create some | 238 // Some of the class table entries maybe NULL as we create some |
| 224 // top level classes but do not add them to the list of anonymous | 239 // top level classes but do not add them to the list of anonymous |
| 225 // classes in a library if there are no top level fields or functions. | 240 // classes in a library if there are no top level fields or functions. |
| 226 // Since there are no references to these top level classes they are | 241 // Since there are no references to these top level classes they are |
| 227 // not written into a full snapshot and will not be recreated when | 242 // not written into a full snapshot and will not be recreated when |
| 228 // we read back the full snapshot. These class slots end up with NULL | 243 // we read back the full snapshot. These class slots end up with NULL |
| 229 // entries. | 244 // entries. |
| 230 if (HasValidClassAt(i)) { | 245 if (HasValidClassAt(cid)) { |
| 231 cls = At(i); | 246 cls = At(cid); |
| 232 ASSERT(cls.IsClass()); | 247 ASSERT(cls.IsClass()); |
| 248 ASSERT(cls.id() == cid); |
| 233 } | 249 } |
| 234 } | 250 } |
| 235 } | 251 } |
| 236 | 252 |
| 237 | 253 |
| 238 void ClassTable::Print() { | 254 void ClassTable::Print() { |
| 239 Class& cls = Class::Handle(); | 255 Class& cls = Class::Handle(); |
| 240 String& name = String::Handle(); | 256 String& name = String::Handle(); |
| 241 | 257 |
| 242 for (intptr_t i = 1; i < top_; i++) { | 258 for (intptr_t i = 1; i < top_; i++) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 596 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { |
| 581 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 597 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
| 582 ASSERT(stats != NULL); | 598 ASSERT(stats != NULL); |
| 583 ASSERT(size >= 0); | 599 ASSERT(size >= 0); |
| 584 stats->post_gc.AddNew(size); | 600 stats->post_gc.AddNew(size); |
| 585 } | 601 } |
| 586 #endif // !PRODUCT | 602 #endif // !PRODUCT |
| 587 | 603 |
| 588 | 604 |
| 589 } // namespace dart | 605 } // namespace dart |
| OLD | NEW |