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

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

Issue 395024: Restore invariant (next of first deallocated must point to the head) before c... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 | « no previous file | test/cctest/test-api.cc » ('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 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // behavior. 158 // behavior.
159 WeakReferenceCallback func = callback(); 159 WeakReferenceCallback func = callback();
160 if (func == NULL) return false; 160 if (func == NULL) return false;
161 161
162 v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle()); 162 v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle());
163 { 163 {
164 // Forbid reuse of destroyed nodes as they might be already deallocated. 164 // Forbid reuse of destroyed nodes as they might be already deallocated.
165 // It's fine though to reuse nodes that were destroyed in weak callback 165 // It's fine though to reuse nodes that were destroyed in weak callback
166 // as those cannot be deallocated until we are back from the callback. 166 // as those cannot be deallocated until we are back from the callback.
167 set_first_free(NULL); 167 set_first_free(NULL);
168 if (first_deallocated()) {
169 first_deallocated()->set_next(head());
170 }
168 // Leaving V8. 171 // Leaving V8.
169 VMState state(EXTERNAL); 172 VMState state(EXTERNAL);
170 func(object, par); 173 func(object, par);
171 } 174 }
172 return true; 175 return true;
173 } 176 }
174 177
175 // Place the handle address first to avoid offset computation. 178 // Place the handle address first to avoid offset computation.
176 Object* object_; // Storage for object pointer. 179 Object* object_; // Storage for object pointer.
177 180
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 Counters::global_handles.Increment(); 266 Counters::global_handles.Increment();
264 Node* result; 267 Node* result;
265 if (first_free()) { 268 if (first_free()) {
266 // Take the first node in the free list. 269 // Take the first node in the free list.
267 result = first_free(); 270 result = first_free();
268 set_first_free(result->next_free()); 271 set_first_free(result->next_free());
269 } else if (first_deallocated()) { 272 } else if (first_deallocated()) {
270 // Next try deallocated list 273 // Next try deallocated list
271 result = first_deallocated(); 274 result = first_deallocated();
272 set_first_deallocated(result->next_free()); 275 set_first_deallocated(result->next_free());
276 ASSERT(result->next() == head());
273 set_head(result); 277 set_head(result);
274 } else { 278 } else {
275 // Allocate a new node. 279 // Allocate a new node.
276 result = pool_.Allocate(); 280 result = pool_.Allocate();
277 result->set_next(head()); 281 result->set_next(head());
278 set_head(result); 282 set_head(result);
279 } 283 }
280 result->Initialize(value); 284 result->Initialize(value);
281 return result->handle(); 285 return result->handle();
282 } 286 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 void GlobalHandles::RemoveObjectGroups() { 482 void GlobalHandles::RemoveObjectGroups() {
479 List<ObjectGroup*>* object_groups = ObjectGroups(); 483 List<ObjectGroup*>* object_groups = ObjectGroups();
480 for (int i = 0; i< object_groups->length(); i++) { 484 for (int i = 0; i< object_groups->length(); i++) {
481 delete object_groups->at(i); 485 delete object_groups->at(i);
482 } 486 }
483 object_groups->Clear(); 487 object_groups->Clear();
484 } 488 }
485 489
486 490
487 } } // namespace v8::internal 491 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698