| 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 553 |
| 554 bool Heap::CollectGarbage(AllocationSpace space, | 554 bool Heap::CollectGarbage(AllocationSpace space, |
| 555 const char* gc_reason, | 555 const char* gc_reason, |
| 556 const v8::GCCallbackFlags callbackFlags) { | 556 const v8::GCCallbackFlags callbackFlags) { |
| 557 const char* collector_reason = NULL; | 557 const char* collector_reason = NULL; |
| 558 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); | 558 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); |
| 559 return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); | 559 return CollectGarbage(collector, gc_reason, collector_reason, callbackFlags); |
| 560 } | 560 } |
| 561 | 561 |
| 562 | 562 |
| 563 MaybeObject* Heap::PrepareForCompare(String* str) { | |
| 564 // Always flatten small strings and force flattening of long strings | |
| 565 // after we have accumulated a certain amount we failed to flatten. | |
| 566 static const int kMaxAlwaysFlattenLength = 32; | |
| 567 static const int kFlattenLongThreshold = 16*KB; | |
| 568 | |
| 569 const int length = str->length(); | |
| 570 MaybeObject* obj = str->TryFlatten(); | |
| 571 if (length <= kMaxAlwaysFlattenLength || | |
| 572 unflattened_strings_length_ >= kFlattenLongThreshold) { | |
| 573 return obj; | |
| 574 } | |
| 575 if (obj->IsFailure()) { | |
| 576 unflattened_strings_length_ += length; | |
| 577 } | |
| 578 return str; | |
| 579 } | |
| 580 | |
| 581 | |
| 582 int64_t Heap::AdjustAmountOfExternalAllocatedMemory( | 563 int64_t Heap::AdjustAmountOfExternalAllocatedMemory( |
| 583 int64_t change_in_bytes) { | 564 int64_t change_in_bytes) { |
| 584 ASSERT(HasBeenSetUp()); | 565 ASSERT(HasBeenSetUp()); |
| 585 int64_t amount = amount_of_external_allocated_memory_ + change_in_bytes; | 566 int64_t amount = amount_of_external_allocated_memory_ + change_in_bytes; |
| 586 if (change_in_bytes > 0) { | 567 if (change_in_bytes > 0) { |
| 587 // Avoid overflow. | 568 // Avoid overflow. |
| 588 if (amount > amount_of_external_allocated_memory_) { | 569 if (amount > amount_of_external_allocated_memory_) { |
| 589 amount_of_external_allocated_memory_ = amount; | 570 amount_of_external_allocated_memory_ = amount; |
| 590 } else { | 571 } else { |
| 591 // Give up and reset the counters in case of an overflow. | 572 // Give up and reset the counters in case of an overflow. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 798 |
| 818 | 799 |
| 819 double GCTracer::SizeOfHeapObjects() { | 800 double GCTracer::SizeOfHeapObjects() { |
| 820 return (static_cast<double>(heap_->SizeOfObjects())) / MB; | 801 return (static_cast<double>(heap_->SizeOfObjects())) / MB; |
| 821 } | 802 } |
| 822 | 803 |
| 823 | 804 |
| 824 } } // namespace v8::internal | 805 } } // namespace v8::internal |
| 825 | 806 |
| 826 #endif // V8_HEAP_INL_H_ | 807 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |