| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 461 |
| 462 | 462 |
| 463 intptr_t Heap::AdjustAmountOfExternalAllocatedMemory( | 463 intptr_t Heap::AdjustAmountOfExternalAllocatedMemory( |
| 464 intptr_t change_in_bytes) { | 464 intptr_t change_in_bytes) { |
| 465 ASSERT(HasBeenSetUp()); | 465 ASSERT(HasBeenSetUp()); |
| 466 intptr_t amount = amount_of_external_allocated_memory_ + change_in_bytes; | 466 intptr_t amount = amount_of_external_allocated_memory_ + change_in_bytes; |
| 467 if (change_in_bytes >= 0) { | 467 if (change_in_bytes >= 0) { |
| 468 // Avoid overflow. | 468 // Avoid overflow. |
| 469 if (amount > amount_of_external_allocated_memory_) { | 469 if (amount > amount_of_external_allocated_memory_) { |
| 470 amount_of_external_allocated_memory_ = amount; | 470 amount_of_external_allocated_memory_ = amount; |
| 471 } else { |
| 472 // Give up and reset the counters in case of an overflow. |
| 473 amount_of_external_allocated_memory_ = 0; |
| 474 amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
| 471 } | 475 } |
| 472 intptr_t amount_since_last_global_gc = | 476 intptr_t amount_since_last_global_gc = PromotedExternalMemorySize(); |
| 473 amount_of_external_allocated_memory_ - | |
| 474 amount_of_external_allocated_memory_at_last_global_gc_; | |
| 475 if (amount_since_last_global_gc > external_allocation_limit_) { | 477 if (amount_since_last_global_gc > external_allocation_limit_) { |
| 476 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); | 478 CollectAllGarbage(kNoGCFlags, "external memory allocation limit reached"); |
| 477 } | 479 } |
| 478 } else { | 480 } else { |
| 479 // Avoid underflow. | 481 // Avoid underflow. |
| 480 if (amount >= 0) { | 482 if (amount >= 0) { |
| 481 amount_of_external_allocated_memory_ = amount; | 483 amount_of_external_allocated_memory_ = amount; |
| 484 } else { |
| 485 // Give up and reset the counters in case of an overflow. |
| 486 amount_of_external_allocated_memory_ = 0; |
| 487 amount_of_external_allocated_memory_at_last_global_gc_ = 0; |
| 482 } | 488 } |
| 483 } | 489 } |
| 484 ASSERT(amount_of_external_allocated_memory_ >= 0); | 490 ASSERT(amount_of_external_allocated_memory_ >= 0); |
| 485 return amount_of_external_allocated_memory_; | 491 return amount_of_external_allocated_memory_; |
| 486 } | 492 } |
| 487 | 493 |
| 488 | 494 |
| 489 void Heap::SetLastScriptId(Object* last_script_id) { | 495 void Heap::SetLastScriptId(Object* last_script_id) { |
| 490 roots_[kLastScriptIdRootIndex] = last_script_id; | 496 roots_[kLastScriptIdRootIndex] = last_script_id; |
| 491 } | 497 } |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 AssertNoAllocation::~AssertNoAllocation() { } | 812 AssertNoAllocation::~AssertNoAllocation() { } |
| 807 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 813 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
| 808 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 814 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
| 809 | 815 |
| 810 #endif | 816 #endif |
| 811 | 817 |
| 812 | 818 |
| 813 } } // namespace v8::internal | 819 } } // namespace v8::internal |
| 814 | 820 |
| 815 #endif // V8_HEAP_INL_H_ | 821 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |