| OLD | NEW |
| 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // Memory is exhausted and we will die. | 630 // Memory is exhausted and we will die. |
| 631 V8::FatalProcessOutOfMemory("Committing semi space failed."); | 631 V8::FatalProcessOutOfMemory("Committing semi space failed."); |
| 632 } | 632 } |
| 633 | 633 |
| 634 | 634 |
| 635 void Heap::ClearJSFunctionResultCaches() { | 635 void Heap::ClearJSFunctionResultCaches() { |
| 636 if (isolate_->bootstrapper()->IsActive()) return; | 636 if (isolate_->bootstrapper()->IsActive()) return; |
| 637 | 637 |
| 638 Object* context = global_contexts_list_; | 638 Object* context = global_contexts_list_; |
| 639 while (!context->IsUndefined()) { | 639 while (!context->IsUndefined()) { |
| 640 // Get the caches for this context: | 640 // Get the caches for this context. GC can happen when the context |
| 641 FixedArray* caches = | 641 // is not fully initialized, so the caches can be undefined. |
| 642 Context::cast(context)->jsfunction_result_caches(); | 642 Object* caches_or_undefined = |
| 643 // Clear the caches: | 643 Context::cast(context)->get(Context::JSFUNCTION_RESULT_CACHES_INDEX); |
| 644 int length = caches->length(); | 644 if (!caches_or_undefined->IsUndefined()) { |
| 645 for (int i = 0; i < length; i++) { | 645 FixedArray* caches = FixedArray::cast(caches_or_undefined); |
| 646 JSFunctionResultCache::cast(caches->get(i))->Clear(); | 646 // Clear the caches: |
| 647 int length = caches->length(); |
| 648 for (int i = 0; i < length; i++) { |
| 649 JSFunctionResultCache::cast(caches->get(i))->Clear(); |
| 650 } |
| 647 } | 651 } |
| 648 // Get the next context: | 652 // Get the next context: |
| 649 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 653 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); |
| 650 } | 654 } |
| 651 } | 655 } |
| 652 | 656 |
| 653 | 657 |
| 654 | 658 |
| 655 void Heap::ClearNormalizedMapCaches() { | 659 void Heap::ClearNormalizedMapCaches() { |
| 656 if (isolate_->bootstrapper()->IsActive() && | 660 if (isolate_->bootstrapper()->IsActive() && |
| 657 !incremental_marking()->IsMarking()) { | 661 !incremental_marking()->IsMarking()) { |
| 658 return; | 662 return; |
| 659 } | 663 } |
| 660 | 664 |
| 661 Object* context = global_contexts_list_; | 665 Object* context = global_contexts_list_; |
| 662 while (!context->IsUndefined()) { | 666 while (!context->IsUndefined()) { |
| 663 Context::cast(context)->normalized_map_cache()->Clear(); | 667 // GC can happen when the context is not fully initialized, |
| 668 // so the cache can be undefined. |
| 669 Object* cache = |
| 670 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX); |
| 671 if (!cache->IsUndefined()) { |
| 672 NormalizedMapCache::cast(cache)->Clear(); |
| 673 } |
| 664 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 674 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); |
| 665 } | 675 } |
| 666 } | 676 } |
| 667 | 677 |
| 668 | 678 |
| 669 void Heap::UpdateSurvivalRateTrend(int start_new_space_size) { | 679 void Heap::UpdateSurvivalRateTrend(int start_new_space_size) { |
| 670 double survival_rate = | 680 double survival_rate = |
| 671 (static_cast<double>(young_survivors_after_last_gc_) * 100) / | 681 (static_cast<double>(young_survivors_after_last_gc_) * 100) / |
| 672 start_new_space_size; | 682 start_new_space_size; |
| 673 | 683 |
| (...skipping 5829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6503 isolate_->heap()->store_buffer()->Compact(); | 6513 isolate_->heap()->store_buffer()->Compact(); |
| 6504 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6514 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); |
| 6505 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6515 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { |
| 6506 next = chunk->next_chunk(); | 6516 next = chunk->next_chunk(); |
| 6507 isolate_->memory_allocator()->Free(chunk); | 6517 isolate_->memory_allocator()->Free(chunk); |
| 6508 } | 6518 } |
| 6509 chunks_queued_for_free_ = NULL; | 6519 chunks_queued_for_free_ = NULL; |
| 6510 } | 6520 } |
| 6511 | 6521 |
| 6512 } } // namespace v8::internal | 6522 } } // namespace v8::internal |
| OLD | NEW |