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

Side by Side Diff: src/zone.h

Issue 7066004: Inline more zone stuff. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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
« no previous file with comments | « src/runtime.cc ('k') | src/zone-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 Segment* segment_head_; 127 Segment* segment_head_;
128 Isolate* isolate_; 128 Isolate* isolate_;
129 }; 129 };
130 130
131 131
132 // ZoneObject is an abstraction that helps define classes of objects 132 // ZoneObject is an abstraction that helps define classes of objects
133 // allocated in the Zone. Use it as a base class; see ast.h. 133 // allocated in the Zone. Use it as a base class; see ast.h.
134 class ZoneObject { 134 class ZoneObject {
135 public: 135 public:
136 // Allocate a new ZoneObject of 'size' bytes in the Zone. 136 // Allocate a new ZoneObject of 'size' bytes in the Zone.
137 inline void* operator new(size_t size); 137 INLINE(void* operator new(size_t size));
138 inline void* operator new(size_t size, Zone* zone); 138 INLINE(void* operator new(size_t size, Zone* zone));
139 139
140 // Ideally, the delete operator should be private instead of 140 // Ideally, the delete operator should be private instead of
141 // public, but unfortunately the compiler sometimes synthesizes 141 // public, but unfortunately the compiler sometimes synthesizes
142 // (unused) destructors for classes derived from ZoneObject, which 142 // (unused) destructors for classes derived from ZoneObject, which
143 // require the operator to be visible. MSVC requires the delete 143 // require the operator to be visible. MSVC requires the delete
144 // operator to be public. 144 // operator to be public.
145 145
146 // ZoneObjects should never be deleted individually; use 146 // ZoneObjects should never be deleted individually; use
147 // Zone::DeleteAll() to delete all zone objects in one go. 147 // Zone::DeleteAll() to delete all zone objects in one go.
148 void operator delete(void*, size_t) { UNREACHABLE(); } 148 void operator delete(void*, size_t) { UNREACHABLE(); }
149 }; 149 };
150 150
151 151
152 class AssertNoZoneAllocation { 152 class AssertNoZoneAllocation {
153 public: 153 public:
154 inline AssertNoZoneAllocation(); 154 inline AssertNoZoneAllocation();
155 inline ~AssertNoZoneAllocation(); 155 inline ~AssertNoZoneAllocation();
156 private: 156 private:
157 bool prev_; 157 bool prev_;
158 }; 158 };
159 159
160 160
161 // The ZoneListAllocationPolicy is used to specialize the GenericList 161 // The ZoneListAllocationPolicy is used to specialize the GenericList
162 // implementation to allocate ZoneLists and their elements in the 162 // implementation to allocate ZoneLists and their elements in the
163 // Zone. 163 // Zone.
164 class ZoneListAllocationPolicy { 164 class ZoneListAllocationPolicy {
165 public: 165 public:
166 // Allocate 'size' bytes of memory in the zone. 166 // Allocate 'size' bytes of memory in the zone.
167 static inline void* New(int size); 167 INLINE(static void* New(int size));
168 168
169 // De-allocation attempts are silently ignored. 169 // De-allocation attempts are silently ignored.
170 static void Delete(void* p) { } 170 static void Delete(void* p) { }
171 }; 171 };
172 172
173 173
174 // ZoneLists are growable lists with constant-time access to the 174 // ZoneLists are growable lists with constant-time access to the
175 // elements. The list itself and all its elements are allocated in the 175 // elements. The list itself and all its elements are allocated in the
176 // Zone. ZoneLists cannot be deleted individually; you can delete all 176 // Zone. ZoneLists cannot be deleted individually; you can delete all
177 // objects in the Zone by calling Zone::DeleteAll(). 177 // objects in the Zone by calling Zone::DeleteAll().
178 template<typename T> 178 template<typename T>
179 class ZoneList: public List<T, ZoneListAllocationPolicy> { 179 class ZoneList: public List<T, ZoneListAllocationPolicy> {
180 public: 180 public:
181 inline void* operator new(size_t size); 181 INLINE(void* operator new(size_t size));
182 inline void* operator new(size_t size, Zone* zone); 182 INLINE(void* operator new(size_t size, Zone* zone));
183 183
184 // Construct a new ZoneList with the given capacity; the length is 184 // Construct a new ZoneList with the given capacity; the length is
185 // always zero. The capacity must be non-negative. 185 // always zero. The capacity must be non-negative.
186 explicit ZoneList(int capacity) 186 explicit ZoneList(int capacity)
187 : List<T, ZoneListAllocationPolicy>(capacity) { } 187 : List<T, ZoneListAllocationPolicy>(capacity) { }
188 188
189 // Construct a new ZoneList by copying the elements of the given ZoneList. 189 // Construct a new ZoneList by copying the elements of the given ZoneList.
190 explicit ZoneList(const ZoneList<T>& other) 190 explicit ZoneList(const ZoneList<T>& other)
191 : List<T, ZoneListAllocationPolicy>(other.length()) { 191 : List<T, ZoneListAllocationPolicy>(other.length()) {
192 AddAll(other); 192 AddAll(other);
193 } 193 }
194 }; 194 };
195 195
196 196
197 // Introduce a convenience type for zone lists of map handles. 197 // Introduce a convenience type for zone lists of map handles.
198 typedef ZoneList<Handle<Map> > ZoneMapList; 198 typedef ZoneList<Handle<Map> > ZoneMapList;
199 199
200 200
201 // ZoneScopes keep track of the current parsing and compilation 201 // ZoneScopes keep track of the current parsing and compilation
202 // nesting and cleans up generated ASTs in the Zone when exiting the 202 // nesting and cleans up generated ASTs in the Zone when exiting the
203 // outer-most scope. 203 // outer-most scope.
204 class ZoneScope BASE_EMBEDDED { 204 class ZoneScope BASE_EMBEDDED {
205 public: 205 public:
206 // TODO(isolates): pass isolate pointer here. 206 INLINE(ZoneScope(Isolate* isolate, ZoneScopeMode mode));
207 inline explicit ZoneScope(ZoneScopeMode mode);
208 207
209 virtual ~ZoneScope(); 208 virtual ~ZoneScope();
210 209
211 inline bool ShouldDeleteOnExit(); 210 inline bool ShouldDeleteOnExit();
212 211
213 // For ZoneScopes that do not delete on exit by default, call this 212 // For ZoneScopes that do not delete on exit by default, call this
214 // method to request deletion on exit. 213 // method to request deletion on exit.
215 void DeleteOnExit() { 214 void DeleteOnExit() {
216 mode_ = DELETE_ON_EXIT; 215 mode_ = DELETE_ON_EXIT;
217 } 216 }
(...skipping 14 matching lines...) Expand all
232 public: 231 public:
233 ZoneSplayTree() 232 ZoneSplayTree()
234 : SplayTree<Config, ZoneListAllocationPolicy>() {} 233 : SplayTree<Config, ZoneListAllocationPolicy>() {}
235 ~ZoneSplayTree(); 234 ~ZoneSplayTree();
236 }; 235 };
237 236
238 237
239 } } // namespace v8::internal 238 } } // namespace v8::internal
240 239
241 #endif // V8_ZONE_H_ 240 #endif // V8_ZONE_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/zone-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698