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

Side by Side Diff: src/small-pointer-list.h

Issue 7655017: Improve memory usage of receiver type feedback. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ReceiverTypeList -> SmallMapList Created 9 years, 4 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 37
38 // SmallPointerList is a list optimized for storing no or just a 38 // SmallPointerList is a list optimized for storing no or just a
39 // single value. When more values are given it falls back to ZoneList. 39 // single value. When more values are given it falls back to ZoneList.
40 // 40 //
41 // The interface tries to be as close to List from list.h as possible. 41 // The interface tries to be as close to List from list.h as possible.
42 template <typename T> 42 template <typename T>
43 class SmallPointerList { 43 class SmallPointerList {
44 public: 44 public:
45 SmallPointerList() : data_(kEmptyTag) {} 45 SmallPointerList() : data_(kEmptyTag) {}
46 46
47 explicit SmallPointerList(int capacity) : data_(kEmptyTag) {
48 Reserve(capacity);
49 }
50
51 void Reserve(int capacity) {
52 if (capacity < 2) return;
53 if ((data_ & kTagMask) == kListTag) {
54 if (list()->capacity() >= capacity) return;
55 int old_length = list()->length();
56 list()->AddBlock(NULL, capacity - list()->capacity());
57 list()->Rewind(old_length);
58 return;
59 }
60 PointerList* list = new PointerList(capacity);
61 if ((data_ & kTagMask) == kSingletonTag) {
62 list->Add(single_value());
63 }
64 ASSERT(IsAligned(reinterpret_cast<intptr_t>(list), kPointerAlignment));
65 data_ = reinterpret_cast<intptr_t>(list) | kListTag;
66 }
67
68 void Clear() {
69 data_ = kEmptyTag;
70 }
71
47 bool is_empty() const { return length() == 0; } 72 bool is_empty() const { return length() == 0; }
48 73
49 int length() const { 74 int length() const {
50 if ((data_ & kTagMask) == kEmptyTag) return 0; 75 if ((data_ & kTagMask) == kEmptyTag) return 0;
51 if ((data_ & kTagMask) == kSingletonTag) return 1; 76 if ((data_ & kTagMask) == kSingletonTag) return 1;
52 return list()->length(); 77 return list()->length();
53 } 78 }
54 79
55 void Add(T* pointer) { 80 void Add(T* pointer) {
56 ASSERT(IsAligned(reinterpret_cast<intptr_t>(pointer), kPointerAlignment)); 81 ASSERT(IsAligned(reinterpret_cast<intptr_t>(pointer), kPointerAlignment));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 179 }
155 180
156 intptr_t data_; 181 intptr_t data_;
157 182
158 DISALLOW_COPY_AND_ASSIGN(SmallPointerList); 183 DISALLOW_COPY_AND_ASSIGN(SmallPointerList);
159 }; 184 };
160 185
161 } } // namespace v8::internal 186 } } // namespace v8::internal
162 187
163 #endif // V8_SMALL_POINTER_LIST_H_ 188 #endif // V8_SMALL_POINTER_LIST_H_
OLDNEW
« src/ast.h ('K') | « src/hydrogen-instructions.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698