| 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 | 643 |
| 644 | 644 |
| 645 #ifdef DEBUG | 645 #ifdef DEBUG |
| 646 | 646 |
| 647 inline bool Heap::allow_allocation(bool new_state) { | 647 inline bool Heap::allow_allocation(bool new_state) { |
| 648 bool old = allocation_allowed_; | 648 bool old = allocation_allowed_; |
| 649 allocation_allowed_ = new_state; | 649 allocation_allowed_ = new_state; |
| 650 return old; | 650 return old; |
| 651 } | 651 } |
| 652 | 652 |
| 653 inline void Heap::set_allow_allocation(bool allocation_allowed) { |
| 654 allocation_allowed_ = allocation_allowed; |
| 655 } |
| 656 |
| 653 #endif | 657 #endif |
| 654 | 658 |
| 655 | 659 |
| 656 void ExternalStringTable::AddString(String* string) { | 660 void ExternalStringTable::AddString(String* string) { |
| 657 ASSERT(string->IsExternalString()); | 661 ASSERT(string->IsExternalString()); |
| 658 if (heap_->InNewSpace(string)) { | 662 if (heap_->InNewSpace(string)) { |
| 659 new_space_strings_.Add(string); | 663 new_space_strings_.Add(string); |
| 660 } else { | 664 } else { |
| 661 old_space_strings_.Add(string); | 665 old_space_strings_.Add(string); |
| 662 } | 666 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 861 |
| 858 | 862 |
| 859 DisallowAllocationFailure::~DisallowAllocationFailure() { | 863 DisallowAllocationFailure::~DisallowAllocationFailure() { |
| 860 #ifdef DEBUG | 864 #ifdef DEBUG |
| 861 HEAP->disallow_allocation_failure_ = old_state_; | 865 HEAP->disallow_allocation_failure_ = old_state_; |
| 862 #endif | 866 #endif |
| 863 } | 867 } |
| 864 | 868 |
| 865 | 869 |
| 866 #ifdef DEBUG | 870 #ifdef DEBUG |
| 867 AssertNoAllocation::AssertNoAllocation() { | 871 bool EnterAllocationScope(Isolate* isolate, bool allow_allocation) { |
| 868 Isolate* isolate = ISOLATE; | 872 bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
| 869 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | 873 bool last_state = isolate->heap()->IsAllocationAllowed(); |
| 870 if (active_) { | 874 if (active) { |
| 871 old_state_ = isolate->heap()->allow_allocation(false); | 875 isolate->heap()->set_allow_allocation(allow_allocation); |
| 872 } | 876 } |
| 877 return last_state; |
| 873 } | 878 } |
| 874 | 879 |
| 875 | 880 |
| 876 AssertNoAllocation::~AssertNoAllocation() { | 881 void ExitAllocationScope(Isolate* isolate, bool last_state) { |
| 877 if (active_) HEAP->allow_allocation(old_state_); | 882 isolate->heap()->set_allow_allocation(last_state); |
| 878 } | 883 } |
| 879 | 884 |
| 880 | 885 |
| 881 DisableAssertNoAllocation::DisableAssertNoAllocation() { | 886 AssertNoAllocation::AssertNoAllocation() |
| 882 Isolate* isolate = ISOLATE; | 887 : last_state_(EnterAllocationScope(ISOLATE, false)) { |
| 883 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | |
| 884 if (active_) { | |
| 885 old_state_ = isolate->heap()->allow_allocation(true); | |
| 886 } | |
| 887 } | 888 } |
| 888 | 889 |
| 890 AssertNoAllocation::~AssertNoAllocation() { |
| 891 ExitAllocationScope(ISOLATE, last_state_); |
| 892 } |
| 893 |
| 894 DisableAssertNoAllocation::DisableAssertNoAllocation() |
| 895 : last_state_(EnterAllocationScope(ISOLATE, true)) { |
| 896 } |
| 889 | 897 |
| 890 DisableAssertNoAllocation::~DisableAssertNoAllocation() { | 898 DisableAssertNoAllocation::~DisableAssertNoAllocation() { |
| 891 if (active_) HEAP->allow_allocation(old_state_); | 899 ExitAllocationScope(ISOLATE, last_state_); |
| 892 } | 900 } |
| 893 | |
| 894 #else | 901 #else |
| 895 | 902 |
| 896 AssertNoAllocation::AssertNoAllocation() { } | 903 AssertNoAllocation::AssertNoAllocation() { } |
| 897 AssertNoAllocation::~AssertNoAllocation() { } | 904 AssertNoAllocation::~AssertNoAllocation() { } |
| 898 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 905 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
| 899 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 906 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
| 900 | 907 |
| 901 #endif | 908 #endif |
| 902 | 909 |
| 903 | 910 |
| 904 } } // namespace v8::internal | 911 } } // namespace v8::internal |
| 905 | 912 |
| 906 #endif // V8_HEAP_INL_H_ | 913 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |