OLD | NEW |
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 int index_; | 377 int index_; |
378 | 378 |
379 DISALLOW_COPY_AND_ASSIGN(NodeIterator); | 379 DISALLOW_COPY_AND_ASSIGN(NodeIterator); |
380 }; | 380 }; |
381 | 381 |
382 | 382 |
383 GlobalHandles::GlobalHandles(Isolate* isolate) | 383 GlobalHandles::GlobalHandles(Isolate* isolate) |
384 : isolate_(isolate), | 384 : isolate_(isolate), |
385 number_of_weak_handles_(0), | 385 number_of_weak_handles_(0), |
386 number_of_global_object_weak_handles_(0), | 386 number_of_global_object_weak_handles_(0), |
| 387 number_of_global_handles_(0), |
387 first_block_(NULL), | 388 first_block_(NULL), |
388 first_used_block_(NULL), | 389 first_used_block_(NULL), |
389 first_free_(NULL), | 390 first_free_(NULL), |
390 post_gc_processing_count_(0) {} | 391 post_gc_processing_count_(0) {} |
391 | 392 |
392 | 393 |
393 GlobalHandles::~GlobalHandles() { | 394 GlobalHandles::~GlobalHandles() { |
394 NodeBlock* block = first_block_; | 395 NodeBlock* block = first_block_; |
395 while (block != NULL) { | 396 while (block != NULL) { |
396 NodeBlock* tmp = block->next(); | 397 NodeBlock* tmp = block->next(); |
397 delete block; | 398 delete block; |
398 block = tmp; | 399 block = tmp; |
399 } | 400 } |
400 first_block_ = NULL; | 401 first_block_ = NULL; |
401 } | 402 } |
402 | 403 |
403 | 404 |
404 Handle<Object> GlobalHandles::Create(Object* value) { | 405 Handle<Object> GlobalHandles::Create(Object* value) { |
405 isolate_->counters()->global_handles()->Increment(); | 406 isolate_->counters()->global_handles()->Increment(); |
| 407 number_of_global_handles_++; |
406 if (first_free_ == NULL) { | 408 if (first_free_ == NULL) { |
407 first_block_ = new NodeBlock(first_block_); | 409 first_block_ = new NodeBlock(first_block_); |
408 first_block_->PutNodesOnFreeList(&first_free_); | 410 first_block_->PutNodesOnFreeList(&first_free_); |
409 } | 411 } |
410 ASSERT(first_free_ != NULL); | 412 ASSERT(first_free_ != NULL); |
411 // Take the first node in the free list. | 413 // Take the first node in the free list. |
412 Node* result = first_free_; | 414 Node* result = first_free_; |
413 first_free_ = result->next_free(); | 415 first_free_ = result->next_free(); |
414 result->Acquire(value, this); | 416 result->Acquire(value, this); |
415 if (isolate_->heap()->InNewSpace(value) && | 417 if (isolate_->heap()->InNewSpace(value) && |
416 !result->is_in_new_space_list()) { | 418 !result->is_in_new_space_list()) { |
417 new_space_nodes_.Add(result); | 419 new_space_nodes_.Add(result); |
418 result->set_in_new_space_list(true); | 420 result->set_in_new_space_list(true); |
419 } | 421 } |
420 return result->handle(); | 422 return result->handle(); |
421 } | 423 } |
422 | 424 |
423 | 425 |
424 void GlobalHandles::Destroy(Object** location) { | 426 void GlobalHandles::Destroy(Object** location) { |
425 isolate_->counters()->global_handles()->Decrement(); | 427 isolate_->counters()->global_handles()->Decrement(); |
| 428 number_of_global_handles_--; |
426 if (location == NULL) return; | 429 if (location == NULL) return; |
427 Node::FromLocation(location)->Release(this); | 430 Node::FromLocation(location)->Release(this); |
428 } | 431 } |
429 | 432 |
430 | 433 |
431 void GlobalHandles::MakeWeak(Object** location, void* parameter, | 434 void GlobalHandles::MakeWeak(Object** location, void* parameter, |
432 WeakReferenceCallback callback) { | 435 WeakReferenceCallback callback) { |
433 ASSERT(callback != NULL); | 436 ASSERT(callback != NULL); |
434 Node::FromLocation(location)->MakeWeak(this, parameter, callback); | 437 Node::FromLocation(location)->MakeWeak(this, parameter, callback); |
435 } | 438 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 implicit_ref_groups_.Clear(); | 715 implicit_ref_groups_.Clear(); |
713 } | 716 } |
714 | 717 |
715 | 718 |
716 void GlobalHandles::TearDown() { | 719 void GlobalHandles::TearDown() { |
717 // TODO(1428): invoke weak callbacks. | 720 // TODO(1428): invoke weak callbacks. |
718 } | 721 } |
719 | 722 |
720 | 723 |
721 } } // namespace v8::internal | 724 } } // namespace v8::internal |
OLD | NEW |