| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 lo_space_->SizeOfObjects() / KB, | 405 lo_space_->SizeOfObjects() / KB, |
| 406 lo_space_->Available() / KB, | 406 lo_space_->Available() / KB, |
| 407 lo_space_->CommittedMemory() / KB); | 407 lo_space_->CommittedMemory() / KB); |
| 408 PrintPID("All spaces, used: %6" V8_PTR_PREFIX "d KB" | 408 PrintPID("All spaces, used: %6" V8_PTR_PREFIX "d KB" |
| 409 ", available: %6" V8_PTR_PREFIX "d KB" | 409 ", available: %6" V8_PTR_PREFIX "d KB" |
| 410 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 410 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
| 411 this->SizeOfObjects() / KB, | 411 this->SizeOfObjects() / KB, |
| 412 this->Available() / KB, | 412 this->Available() / KB, |
| 413 this->CommittedMemory() / KB); | 413 this->CommittedMemory() / KB); |
| 414 PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n", | 414 PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n", |
| 415 amount_of_external_allocated_memory_ / KB); | 415 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB)); |
| 416 PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_); | 416 PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_); |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 // TODO(1238405): Combine the infrastructure for --heap-stats and | 420 // TODO(1238405): Combine the infrastructure for --heap-stats and |
| 421 // --log-gc to avoid the complicated preprocessor and flag testing. | 421 // --log-gc to avoid the complicated preprocessor and flag testing. |
| 422 void Heap::ReportStatisticsAfterGC() { | 422 void Heap::ReportStatisticsAfterGC() { |
| 423 // Similar to the before GC, we use some complicated logic to ensure that | 423 // Similar to the before GC, we use some complicated logic to ensure that |
| 424 // NewSpace statistics are logged exactly once when --log-gc is turned on. | 424 // NewSpace statistics are logged exactly once when --log-gc is turned on. |
| 425 #if defined(DEBUG) | 425 #if defined(DEBUG) |
| (...skipping 3540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3966 } | 3966 } |
| 3967 | 3967 |
| 3968 | 3968 |
| 3969 MaybeObject* Heap::AllocateSubString(String* buffer, | 3969 MaybeObject* Heap::AllocateSubString(String* buffer, |
| 3970 int start, | 3970 int start, |
| 3971 int end, | 3971 int end, |
| 3972 PretenureFlag pretenure) { | 3972 PretenureFlag pretenure) { |
| 3973 int length = end - start; | 3973 int length = end - start; |
| 3974 if (length <= 0) { | 3974 if (length <= 0) { |
| 3975 return empty_string(); | 3975 return empty_string(); |
| 3976 } else if (length == 1) { | 3976 } |
| 3977 |
| 3978 // Make an attempt to flatten the buffer to reduce access time. |
| 3979 buffer = buffer->TryFlattenGetString(); |
| 3980 |
| 3981 if (length == 1) { |
| 3977 return LookupSingleCharacterStringFromCode(buffer->Get(start)); | 3982 return LookupSingleCharacterStringFromCode(buffer->Get(start)); |
| 3978 } else if (length == 2) { | 3983 } else if (length == 2) { |
| 3979 // Optimization for 2-byte strings often used as keys in a decompression | 3984 // Optimization for 2-byte strings often used as keys in a decompression |
| 3980 // dictionary. Check whether we already have the string in the string | 3985 // dictionary. Check whether we already have the string in the string |
| 3981 // table to prevent creation of many unnecessary strings. | 3986 // table to prevent creation of many unnecessary strings. |
| 3982 uint16_t c1 = buffer->Get(start); | 3987 uint16_t c1 = buffer->Get(start); |
| 3983 uint16_t c2 = buffer->Get(start + 1); | 3988 uint16_t c2 = buffer->Get(start + 1); |
| 3984 return MakeOrFindTwoCharacterString(this, c1, c2); | 3989 return MakeOrFindTwoCharacterString(this, c1, c2); |
| 3985 } | 3990 } |
| 3986 | 3991 |
| 3987 // Make an attempt to flatten the buffer to reduce access time. | |
| 3988 buffer = buffer->TryFlattenGetString(); | |
| 3989 | |
| 3990 if (!FLAG_string_slices || | 3992 if (!FLAG_string_slices || |
| 3991 !buffer->IsFlat() || | 3993 !buffer->IsFlat() || |
| 3992 length < SlicedString::kMinLength || | 3994 length < SlicedString::kMinLength || |
| 3993 pretenure == TENURED) { | 3995 pretenure == TENURED) { |
| 3994 Object* result; | 3996 Object* result; |
| 3995 // WriteToFlat takes care of the case when an indirect string has a | 3997 // WriteToFlat takes care of the case when an indirect string has a |
| 3996 // different encoding from its underlying string. These encodings may | 3998 // different encoding from its underlying string. These encodings may |
| 3997 // differ because of externalization. | 3999 // differ because of externalization. |
| 3998 bool is_one_byte = buffer->IsOneByteRepresentation(); | 4000 bool is_one_byte = buffer->IsOneByteRepresentation(); |
| 3999 { MaybeObject* maybe_result = is_one_byte | 4001 { MaybeObject* maybe_result = is_one_byte |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4979 // Reset the map for the object. | 4981 // Reset the map for the object. |
| 4980 object->set_map(constructor->initial_map()); | 4982 object->set_map(constructor->initial_map()); |
| 4981 | 4983 |
| 4982 // Reinitialize the object from the constructor map. | 4984 // Reinitialize the object from the constructor map. |
| 4983 InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); | 4985 InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); |
| 4984 return object; | 4986 return object; |
| 4985 } | 4987 } |
| 4986 | 4988 |
| 4987 | 4989 |
| 4988 MaybeObject* Heap::AllocateStringFromOneByte(Vector<const uint8_t> string, | 4990 MaybeObject* Heap::AllocateStringFromOneByte(Vector<const uint8_t> string, |
| 4989 PretenureFlag pretenure) { | 4991 PretenureFlag pretenure) { |
| 4990 int length = string.length(); | 4992 int length = string.length(); |
| 4991 if (length == 1) { | 4993 if (length == 1) { |
| 4992 return Heap::LookupSingleCharacterStringFromCode(string[0]); | 4994 return Heap::LookupSingleCharacterStringFromCode(string[0]); |
| 4993 } | 4995 } |
| 4994 Object* result; | 4996 Object* result; |
| 4995 { MaybeObject* maybe_result = | 4997 { MaybeObject* maybe_result = |
| 4996 AllocateRawOneByteString(string.length(), pretenure); | 4998 AllocateRawOneByteString(string.length(), pretenure); |
| 4997 if (!maybe_result->ToObject(&result)) return maybe_result; | 4999 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 4998 } | 5000 } |
| 4999 | 5001 |
| (...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6589 | 6591 |
| 6590 | 6592 |
| 6591 bool Heap::AdvanceSweepers(int step_size) { | 6593 bool Heap::AdvanceSweepers(int step_size) { |
| 6592 ASSERT(isolate()->num_sweeper_threads() == 0); | 6594 ASSERT(isolate()->num_sweeper_threads() == 0); |
| 6593 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); | 6595 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); |
| 6594 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); | 6596 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); |
| 6595 return sweeping_complete; | 6597 return sweeping_complete; |
| 6596 } | 6598 } |
| 6597 | 6599 |
| 6598 | 6600 |
| 6599 intptr_t Heap::PromotedExternalMemorySize() { | 6601 int64_t Heap::PromotedExternalMemorySize() { |
| 6600 if (amount_of_external_allocated_memory_ | 6602 if (amount_of_external_allocated_memory_ |
| 6601 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0; | 6603 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0; |
| 6602 return amount_of_external_allocated_memory_ | 6604 return amount_of_external_allocated_memory_ |
| 6603 - amount_of_external_allocated_memory_at_last_global_gc_; | 6605 - amount_of_external_allocated_memory_at_last_global_gc_; |
| 6604 } | 6606 } |
| 6605 | 6607 |
| 6606 | 6608 |
| 6607 void Heap::EnableInlineAllocation() { | 6609 void Heap::EnableInlineAllocation() { |
| 6608 ASSERT(inline_allocation_disabled_); | 6610 ASSERT(inline_allocation_disabled_); |
| 6609 inline_allocation_disabled_ = false; | 6611 inline_allocation_disabled_ = false; |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7814 old_space_strings_.Trim(); | 7816 old_space_strings_.Trim(); |
| 7815 #ifdef VERIFY_HEAP | 7817 #ifdef VERIFY_HEAP |
| 7816 if (FLAG_verify_heap) { | 7818 if (FLAG_verify_heap) { |
| 7817 Verify(); | 7819 Verify(); |
| 7818 } | 7820 } |
| 7819 #endif | 7821 #endif |
| 7820 } | 7822 } |
| 7821 | 7823 |
| 7822 | 7824 |
| 7823 void ExternalStringTable::TearDown() { | 7825 void ExternalStringTable::TearDown() { |
| 7826 for (int i = 0; i < new_space_strings_.length(); ++i) { |
| 7827 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i])); |
| 7828 } |
| 7824 new_space_strings_.Free(); | 7829 new_space_strings_.Free(); |
| 7830 for (int i = 0; i < old_space_strings_.length(); ++i) { |
| 7831 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i])); |
| 7832 } |
| 7825 old_space_strings_.Free(); | 7833 old_space_strings_.Free(); |
| 7826 } | 7834 } |
| 7827 | 7835 |
| 7828 | 7836 |
| 7829 void Heap::QueueMemoryChunkForFree(MemoryChunk* chunk) { | 7837 void Heap::QueueMemoryChunkForFree(MemoryChunk* chunk) { |
| 7830 chunk->set_next_chunk(chunks_queued_for_free_); | 7838 chunk->set_next_chunk(chunks_queued_for_free_); |
| 7831 chunks_queued_for_free_ = chunk; | 7839 chunks_queued_for_free_ = chunk; |
| 7832 } | 7840 } |
| 7833 | 7841 |
| 7834 | 7842 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7960 static_cast<int>(object_sizes_last_time_[index])); | 7968 static_cast<int>(object_sizes_last_time_[index])); |
| 7961 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7969 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7962 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7970 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7963 | 7971 |
| 7964 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7972 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7965 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7973 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7966 ClearObjectStats(); | 7974 ClearObjectStats(); |
| 7967 } | 7975 } |
| 7968 | 7976 |
| 7969 } } // namespace v8::internal | 7977 } } // namespace v8::internal |
| OLD | NEW |