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

Unified Diff: runtime/vm/class_table.cc

Issue 187133004: When reading a full snapshot use the class id from the snapshot instead of generating a new one. Th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_table.cc
===================================================================
--- runtime/vm/class_table.cc (revision 33311)
+++ runtime/vm/class_table.cc (working copy)
@@ -96,12 +96,63 @@
}
+void ClassTable::RegisterAt(intptr_t index, const Class& cls) {
+ ASSERT(index != kIllegalCid);
+ ASSERT(index >= kNumPredefinedCids);
+ if (index >= capacity_) {
+ // Grow the capacity of the class table.
+ intptr_t new_capacity = index + capacity_increment_;
+ if (new_capacity < capacity_) {
+ FATAL1("Fatal error in ClassTable::Register: invalid index %" Pd "\n",
+ index);
+ }
+ RawClass** new_table = reinterpret_cast<RawClass**>(
+ realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT
+ ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>(
+ realloc(class_heap_stats_table_,
+ new_capacity * sizeof(ClassHeapStats))); // NOLINT
+ for (intptr_t i = capacity_; i < new_capacity; i++) {
+ new_table[i] = NULL;
+ new_stats_table[i].Initialize();
+ }
+ capacity_ = new_capacity;
+ table_ = new_table;
+ class_heap_stats_table_ = new_stats_table;
+ ASSERT(capacity_increment_ >= 1);
+ }
+ ASSERT(table_[index] == 0);
+ cls.set_id(index);
+ table_[index] = cls.raw();
+ if (index >= top_) {
+ top_ = index + 1;
+ }
+}
+
+
void ClassTable::VisitObjectPointers(ObjectPointerVisitor* visitor) {
ASSERT(visitor != NULL);
visitor->VisitPointers(reinterpret_cast<RawObject**>(&table_[0]), top_);
}
+void ClassTable::Validate() {
+ Class& cls = Class::Handle();
+ for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
+ // Some of the class table entries maybe NULL as we create some
regis 2014/03/05 00:21:32 maybe -> may be
+ // top level classes but do not add them to the list of anonymous
+ // classes in a library if there are no top level fields or functions.
+ // Since there are no references to these top level classes they are
+ // not written into a full snapshot and will not be recreated when
+ // we read back the full snapshot. These class slots end up with NULL
+ // entries.
+ if (HasValidClassAt(i)) {
+ cls = At(i);
+ ASSERT(cls.IsClass());
+ }
+ }
+}
+
+
void ClassTable::Print() {
Class& cls = Class::Handle();
String& name = String::Handle();
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698