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

Side by Side Diff: src/heap-inl.h

Issue 9323007: Tweak compaction candidate selection to avoid keeping page with low occupancy around. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months 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 | « src/heap.cc ('k') | src/log.cc » ('j') | src/mark-compact.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 ASSERT(HEAP->InFromSpace(*p)); 431 ASSERT(HEAP->InFromSpace(*p));
432 *p = dest; 432 *p = dest;
433 return; 433 return;
434 } 434 }
435 435
436 // Call the slow part of scavenge object. 436 // Call the slow part of scavenge object.
437 return ScavengeObjectSlow(p, object); 437 return ScavengeObjectSlow(p, object);
438 } 438 }
439 439
440 440
441 bool Heap::CollectGarbage(AllocationSpace space) { 441 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) {
442 return CollectGarbage(space, SelectGarbageCollector(space)); 442 const char* collector_reason = NULL;
443 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason);
444 return CollectGarbage(space, collector, gc_reason, collector_reason);
443 } 445 }
444 446
445 447
446 MaybeObject* Heap::PrepareForCompare(String* str) { 448 MaybeObject* Heap::PrepareForCompare(String* str) {
447 // Always flatten small strings and force flattening of long strings 449 // Always flatten small strings and force flattening of long strings
448 // after we have accumulated a certain amount we failed to flatten. 450 // after we have accumulated a certain amount we failed to flatten.
449 static const int kMaxAlwaysFlattenLength = 32; 451 static const int kMaxAlwaysFlattenLength = 32;
450 static const int kFlattenLongThreshold = 16*KB; 452 static const int kFlattenLongThreshold = 16*KB;
451 453
452 const int length = str->length(); 454 const int length = str->length();
(...skipping 14 matching lines...) Expand all
467 int amount = amount_of_external_allocated_memory_ + change_in_bytes; 469 int amount = amount_of_external_allocated_memory_ + change_in_bytes;
468 if (change_in_bytes >= 0) { 470 if (change_in_bytes >= 0) {
469 // Avoid overflow. 471 // Avoid overflow.
470 if (amount > amount_of_external_allocated_memory_) { 472 if (amount > amount_of_external_allocated_memory_) {
471 amount_of_external_allocated_memory_ = amount; 473 amount_of_external_allocated_memory_ = amount;
472 } 474 }
473 int amount_since_last_global_gc = 475 int amount_since_last_global_gc =
474 amount_of_external_allocated_memory_ - 476 amount_of_external_allocated_memory_ -
475 amount_of_external_allocated_memory_at_last_global_gc_; 477 amount_of_external_allocated_memory_at_last_global_gc_;
476 if (amount_since_last_global_gc > external_allocation_limit_) { 478 if (amount_since_last_global_gc > external_allocation_limit_) {
477 CollectAllGarbage(kNoGCFlags); 479 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached");
478 } 480 }
479 } else { 481 } else {
480 // Avoid underflow. 482 // Avoid underflow.
481 if (amount >= 0) { 483 if (amount >= 0) {
482 amount_of_external_allocated_memory_ = amount; 484 amount_of_external_allocated_memory_ = amount;
483 } 485 }
484 } 486 }
485 ASSERT(amount_of_external_allocated_memory_ >= 0); 487 ASSERT(amount_of_external_allocated_memory_ >= 0);
486 return amount_of_external_allocated_memory_; 488 return amount_of_external_allocated_memory_;
487 } 489 }
(...skipping 28 matching lines...) Expand all
516 do { \ 518 do { \
517 GC_GREEDY_CHECK(); \ 519 GC_GREEDY_CHECK(); \
518 MaybeObject* __maybe_object__ = FUNCTION_CALL; \ 520 MaybeObject* __maybe_object__ = FUNCTION_CALL; \
519 Object* __object__ = NULL; \ 521 Object* __object__ = NULL; \
520 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ 522 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \
521 if (__maybe_object__->IsOutOfMemory()) { \ 523 if (__maybe_object__->IsOutOfMemory()) { \
522 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\ 524 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\
523 } \ 525 } \
524 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ 526 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \
525 ISOLATE->heap()->CollectGarbage(Failure::cast(__maybe_object__)-> \ 527 ISOLATE->heap()->CollectGarbage(Failure::cast(__maybe_object__)-> \
526 allocation_space()); \ 528 allocation_space(), \
529 "allocation failure"); \
527 __maybe_object__ = FUNCTION_CALL; \ 530 __maybe_object__ = FUNCTION_CALL; \
528 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ 531 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \
529 if (__maybe_object__->IsOutOfMemory()) { \ 532 if (__maybe_object__->IsOutOfMemory()) { \
530 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\ 533 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\
531 } \ 534 } \
532 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ 535 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \
533 ISOLATE->counters()->gc_last_resort_from_handles()->Increment(); \ 536 ISOLATE->counters()->gc_last_resort_from_handles()->Increment(); \
534 ISOLATE->heap()->CollectAllAvailableGarbage(); \ 537 ISOLATE->heap()->CollectAllAvailableGarbage("last resort gc"); \
535 { \ 538 { \
536 AlwaysAllocateScope __scope__; \ 539 AlwaysAllocateScope __scope__; \
537 __maybe_object__ = FUNCTION_CALL; \ 540 __maybe_object__ = FUNCTION_CALL; \
538 } \ 541 } \
539 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ 542 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \
540 if (__maybe_object__->IsOutOfMemory() || \ 543 if (__maybe_object__->IsOutOfMemory() || \
541 __maybe_object__->IsRetryAfterGC()) { \ 544 __maybe_object__->IsRetryAfterGC()) { \
542 /* TODO(1181417): Fix this. */ \ 545 /* TODO(1181417): Fix this. */ \
543 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_2", true);\ 546 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_2", true);\
544 } \ 547 } \
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 AssertNoAllocation::~AssertNoAllocation() { } 787 AssertNoAllocation::~AssertNoAllocation() { }
785 DisableAssertNoAllocation::DisableAssertNoAllocation() { } 788 DisableAssertNoAllocation::DisableAssertNoAllocation() { }
786 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } 789 DisableAssertNoAllocation::~DisableAssertNoAllocation() { }
787 790
788 #endif 791 #endif
789 792
790 793
791 } } // namespace v8::internal 794 } } // namespace v8::internal
792 795
793 #endif // V8_HEAP_INL_H_ 796 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/log.cc » ('j') | src/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698