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

Unified Diff: runtime/vm/class_table.cc

Issue 1241863002: VM: Refactor allocation stats code and remove duplicate code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_table.cc
diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc
index 1966b217ebcc47956415dada5beeda4f73203738..c4dbfe8f0f85b5343ea3fecf4011b821f1c91b70 100644
--- a/runtime/vm/class_table.cc
+++ b/runtime/vm/class_table.cc
@@ -422,6 +422,50 @@ void ClassTable::UpdatePromoted() {
}
+ClassHeapStats** ClassTable::TableAddressFor(intptr_t cid) {
+ return (cid < kNumPredefinedCids)
+ ? &predefined_class_heap_stats_table_
+ : &class_heap_stats_table_;
+}
+
+
+intptr_t ClassTable::TableOffsetFor(intptr_t cid) {
+ return (cid < kNumPredefinedCids)
+ ? OFFSET_OF(ClassTable, predefined_class_heap_stats_table_)
+ : OFFSET_OF(ClassTable, class_heap_stats_table_);
+}
+
+
+intptr_t ClassTable::ClassOffsetFor(intptr_t cid) {
+ return cid * sizeof(ClassHeapStats); // NOLINT
+}
+
+
+intptr_t ClassTable::CounterOffsetFor(intptr_t cid, bool is_new_space) {
+ const intptr_t class_offset = ClassOffsetFor(cid);
+ const intptr_t count_field_offset = is_new_space
+ ? ClassHeapStats::allocated_since_gc_new_space_offset()
+ : ClassHeapStats::allocated_since_gc_old_space_offset();
+ return class_offset + count_field_offset;
+}
+
+
+ClassHeapStats** ClassTable::StateAddressFor(intptr_t cid,
+ intptr_t* state_offset) {
+ *state_offset = ClassOffsetFor(cid)+ ClassHeapStats::state_offset();
+ return TableAddressFor(cid);
+}
+
+
+intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) {
+ const uword class_offset = ClassOffsetFor(cid);
+ const uword size_field_offset = is_new_space
+ ? ClassHeapStats::allocated_size_since_gc_new_space_offset()
+ : ClassHeapStats::allocated_size_since_gc_old_space_offset();
+ return class_offset + size_field_offset;
+}
+
+
void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) {
Isolate* isolate = Isolate::Current();
ASSERT(isolate != NULL);
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698