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

Side by Side Diff: src/global-handles.cc

Issue 3048034: Releasing allocated chunks in Pool's destructor. (Closed)
Patch Set: Created 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 class GlobalHandles::Pool BASE_EMBEDDED { 220 class GlobalHandles::Pool BASE_EMBEDDED {
221 public: 221 public:
222 Pool() { 222 Pool() {
223 current_ = new Chunk(); 223 current_ = new Chunk();
224 current_->previous = NULL; 224 current_->previous = NULL;
225 next_ = current_->nodes; 225 next_ = current_->nodes;
226 limit_ = current_->nodes + kNodesPerChunk; 226 limit_ = current_->nodes + kNodesPerChunk;
227 } 227 }
228 228
229 ~Pool() {
230 if (current_ != NULL) {
231 Release();
232 }
233 }
234
229 Node* Allocate() { 235 Node* Allocate() {
230 if (next_ < limit_) { 236 if (next_ < limit_) {
231 return next_++; 237 return next_++;
232 } 238 }
233 return SlowAllocate(); 239 return SlowAllocate();
234 } 240 }
235 241
236 void Release() { 242 void Release() {
237 Chunk* current = current_; 243 Chunk* current = current_;
238 ASSERT(current != NULL); // At least a single block must by allocated 244 ASSERT(current != NULL); // At least a single block must by allocated
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 517
512 void GlobalHandles::RemoveObjectGroups() { 518 void GlobalHandles::RemoveObjectGroups() {
513 List<ObjectGroup*>* object_groups = ObjectGroups(); 519 List<ObjectGroup*>* object_groups = ObjectGroups();
514 for (int i = 0; i< object_groups->length(); i++) { 520 for (int i = 0; i< object_groups->length(); i++) {
515 delete object_groups->at(i); 521 delete object_groups->at(i);
516 } 522 }
517 object_groups->Clear(); 523 object_groups->Clear();
518 } 524 }
519 525
520 } } // namespace v8::internal 526 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698