| 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 ASSERT(HEAP->InFromSpace(*p)); | 426 ASSERT(HEAP->InFromSpace(*p)); |
| 427 *p = dest; | 427 *p = dest; |
| 428 return; | 428 return; |
| 429 } | 429 } |
| 430 | 430 |
| 431 // Call the slow part of scavenge object. | 431 // Call the slow part of scavenge object. |
| 432 return ScavengeObjectSlow(p, object); | 432 return ScavengeObjectSlow(p, object); |
| 433 } | 433 } |
| 434 | 434 |
| 435 | 435 |
| 436 bool Heap::CollectGarbage(AllocationSpace space) { | 436 bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) { |
| 437 return CollectGarbage(space, SelectGarbageCollector(space)); | 437 const char* collector_reason = NULL; |
| 438 GarbageCollector collector = SelectGarbageCollector(space, &collector_reason); |
| 439 return CollectGarbage(space, collector, gc_reason, collector_reason); |
| 438 } | 440 } |
| 439 | 441 |
| 440 | 442 |
| 441 MaybeObject* Heap::PrepareForCompare(String* str) { | 443 MaybeObject* Heap::PrepareForCompare(String* str) { |
| 442 // Always flatten small strings and force flattening of long strings | 444 // Always flatten small strings and force flattening of long strings |
| 443 // after we have accumulated a certain amount we failed to flatten. | 445 // after we have accumulated a certain amount we failed to flatten. |
| 444 static const int kMaxAlwaysFlattenLength = 32; | 446 static const int kMaxAlwaysFlattenLength = 32; |
| 445 static const int kFlattenLongThreshold = 16*KB; | 447 static const int kFlattenLongThreshold = 16*KB; |
| 446 | 448 |
| 447 const int length = str->length(); | 449 const int length = str->length(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 462 int amount = amount_of_external_allocated_memory_ + change_in_bytes; | 464 int amount = amount_of_external_allocated_memory_ + change_in_bytes; |
| 463 if (change_in_bytes >= 0) { | 465 if (change_in_bytes >= 0) { |
| 464 // Avoid overflow. | 466 // Avoid overflow. |
| 465 if (amount > amount_of_external_allocated_memory_) { | 467 if (amount > amount_of_external_allocated_memory_) { |
| 466 amount_of_external_allocated_memory_ = amount; | 468 amount_of_external_allocated_memory_ = amount; |
| 467 } | 469 } |
| 468 int amount_since_last_global_gc = | 470 int amount_since_last_global_gc = |
| 469 amount_of_external_allocated_memory_ - | 471 amount_of_external_allocated_memory_ - |
| 470 amount_of_external_allocated_memory_at_last_global_gc_; | 472 amount_of_external_allocated_memory_at_last_global_gc_; |
| 471 if (amount_since_last_global_gc > external_allocation_limit_) { | 473 if (amount_since_last_global_gc > external_allocation_limit_) { |
| 472 CollectAllGarbage(kNoGCFlags); | 474 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); |
| 473 } | 475 } |
| 474 } else { | 476 } else { |
| 475 // Avoid underflow. | 477 // Avoid underflow. |
| 476 if (amount >= 0) { | 478 if (amount >= 0) { |
| 477 amount_of_external_allocated_memory_ = amount; | 479 amount_of_external_allocated_memory_ = amount; |
| 478 } | 480 } |
| 479 } | 481 } |
| 480 ASSERT(amount_of_external_allocated_memory_ >= 0); | 482 ASSERT(amount_of_external_allocated_memory_ >= 0); |
| 481 return amount_of_external_allocated_memory_; | 483 return amount_of_external_allocated_memory_; |
| 482 } | 484 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 511 do { \ | 513 do { \ |
| 512 GC_GREEDY_CHECK(); \ | 514 GC_GREEDY_CHECK(); \ |
| 513 MaybeObject* __maybe_object__ = FUNCTION_CALL; \ | 515 MaybeObject* __maybe_object__ = FUNCTION_CALL; \ |
| 514 Object* __object__ = NULL; \ | 516 Object* __object__ = NULL; \ |
| 515 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ | 517 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ |
| 516 if (__maybe_object__->IsOutOfMemory()) { \ | 518 if (__maybe_object__->IsOutOfMemory()) { \ |
| 517 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\ | 519 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\ |
| 518 } \ | 520 } \ |
| 519 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ | 521 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ |
| 520 ISOLATE->heap()->CollectGarbage(Failure::cast(__maybe_object__)-> \ | 522 ISOLATE->heap()->CollectGarbage(Failure::cast(__maybe_object__)-> \ |
| 521 allocation_space()); \ | 523 allocation_space(), \ |
| 524 "allocation failure"); \ |
| 522 __maybe_object__ = FUNCTION_CALL; \ | 525 __maybe_object__ = FUNCTION_CALL; \ |
| 523 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ | 526 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ |
| 524 if (__maybe_object__->IsOutOfMemory()) { \ | 527 if (__maybe_object__->IsOutOfMemory()) { \ |
| 525 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\ | 528 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\ |
| 526 } \ | 529 } \ |
| 527 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ | 530 if (!__maybe_object__->IsRetryAfterGC()) RETURN_EMPTY; \ |
| 528 ISOLATE->counters()->gc_last_resort_from_handles()->Increment(); \ | 531 ISOLATE->counters()->gc_last_resort_from_handles()->Increment(); \ |
| 529 ISOLATE->heap()->CollectAllAvailableGarbage(); \ | 532 ISOLATE->heap()->CollectAllAvailableGarbage("last resort gc"); \ |
| 530 { \ | 533 { \ |
| 531 AlwaysAllocateScope __scope__; \ | 534 AlwaysAllocateScope __scope__; \ |
| 532 __maybe_object__ = FUNCTION_CALL; \ | 535 __maybe_object__ = FUNCTION_CALL; \ |
| 533 } \ | 536 } \ |
| 534 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ | 537 if (__maybe_object__->ToObject(&__object__)) RETURN_VALUE; \ |
| 535 if (__maybe_object__->IsOutOfMemory() || \ | 538 if (__maybe_object__->IsOutOfMemory() || \ |
| 536 __maybe_object__->IsRetryAfterGC()) { \ | 539 __maybe_object__->IsRetryAfterGC()) { \ |
| 537 /* TODO(1181417): Fix this. */ \ | 540 /* TODO(1181417): Fix this. */ \ |
| 538 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_2", true);\ | 541 v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_2", true);\ |
| 539 } \ | 542 } \ |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 | 699 |
| 697 | 700 |
| 698 Heap* _inline_get_heap_() { | 701 Heap* _inline_get_heap_() { |
| 699 return HEAP; | 702 return HEAP; |
| 700 } | 703 } |
| 701 | 704 |
| 702 | 705 |
| 703 } } // namespace v8::internal | 706 } } // namespace v8::internal |
| 704 | 707 |
| 705 #endif // V8_HEAP_INL_H_ | 708 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |