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

Unified Diff: runtime/vm/freelist.cc

Issue 2083103002: Remove some uses of STL map. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/flow_graph_range_analysis.cc ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/freelist.cc
diff --git a/runtime/vm/freelist.cc b/runtime/vm/freelist.cc
index b8df85169f1d710eda0df3d953442e9bd93c42c6..b90f93fe79613d1003bbf2f5ea82f6f38e788616 100644
--- a/runtime/vm/freelist.cc
+++ b/runtime/vm/freelist.cc
@@ -4,13 +4,12 @@
#include "vm/freelist.h"
-#include <map>
-
#include "vm/bit_set.h"
+#include "vm/hash_map.h"
#include "vm/lockers.h"
#include "vm/object.h"
-#include "vm/raw_object.h"
#include "vm/os_thread.h"
+#include "vm/raw_object.h"
namespace dart {
@@ -286,26 +285,53 @@ void FreeList::PrintSmall() const {
}
+class IntptrPair {
+ public:
+ IntptrPair() : first_(-1), second_(-1) {}
+ IntptrPair(intptr_t first, intptr_t second)
+ : first_(first), second_(second) {}
+
+ intptr_t first() const { return first_; }
+ intptr_t second() const { return second_; }
+ void set_second(intptr_t s) { second_ = s; }
+
+ bool operator==(const IntptrPair& other) {
+ return (first_ == other.first_) && (second_ == other.second_);
+ }
+
+ bool operator!=(const IntptrPair& other) {
+ return (first_ != other.first_) || (second_ != other.second_);
+ }
+
+ private:
+ intptr_t first_;
+ intptr_t second_;
+};
+
+
void FreeList::PrintLarge() const {
int large_sizes = 0;
int large_objects = 0;
intptr_t large_bytes = 0;
- std::map<intptr_t, intptr_t> sorted;
- std::map<intptr_t, intptr_t>::iterator it;
+ MallocDirectChainedHashMap<NumbersKeyValueTrait<IntptrPair> > map;
FreeListElement* node;
for (node = free_lists_[kNumLists]; node != NULL; node = node->next()) {
- it = sorted.find(node->Size());
- if (it != sorted.end()) {
- it->second += 1;
- } else {
+ IntptrPair* pair = map.Lookup(node->Size());
+ if (pair == NULL) {
large_sizes += 1;
- sorted.insert(std::make_pair(node->Size(), 1));
+ map.Insert(IntptrPair(node->Size(), 1));
+ } else {
+ pair->set_second(pair->second() + 1);
}
large_objects += 1;
}
- for (it = sorted.begin(); it != sorted.end(); ++it) {
- intptr_t size = it->first;
- intptr_t list_length = it->second;
+
+ MallocDirectChainedHashMap<NumbersKeyValueTrait<IntptrPair> >::Iterator it =
+ map.GetIterator();
+ IntptrPair* pair;
+ while ((pair = it.Next()) != NULL) {
+ intptr_t size = pair->first();
+ intptr_t list_length = pair->second();
intptr_t list_bytes = list_length * size;
large_bytes += list_bytes;
OS::Print("large %3" Pd " [%8" Pd " bytes] : "
« no previous file with comments | « runtime/vm/flow_graph_range_analysis.cc ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698