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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 | 857 |
858 | 858 |
859 DisallowAllocationFailure::~DisallowAllocationFailure() { | 859 DisallowAllocationFailure::~DisallowAllocationFailure() { |
860 #ifdef DEBUG | 860 #ifdef DEBUG |
861 HEAP->disallow_allocation_failure_ = old_state_; | 861 HEAP->disallow_allocation_failure_ = old_state_; |
862 #endif | 862 #endif |
863 } | 863 } |
864 | 864 |
865 | 865 |
866 #ifdef DEBUG | 866 #ifdef DEBUG |
867 AssertNoAllocation::AssertNoAllocation() { | 867 AllocationScopeData EnterAllocationScope(Isolate* isolate, |
868 Isolate* isolate = ISOLATE; | 868 bool allow_allocation) { |
869 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | 869 bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
870 if (active_) { | 870 if (active) { |
871 old_state_ = isolate->heap()->allow_allocation(false); | 871 bool old_state = isolate->heap()->allow_allocation(allow_allocation); |
872 return 0x10 || old_state; | |
Sven Panne
2013/04/30 12:21:30
This is "a bit" obscure. Why don't we simply remem
marja
2013/04/30 13:39:29
|| ? Maybe you meant |? Maybe something else?
marja
2013/04/30 13:42:43
Maybe you meant old_state || 0x10? :)
| |
872 } | 873 } |
874 return 0; | |
873 } | 875 } |
874 | 876 |
875 | 877 |
876 AssertNoAllocation::~AssertNoAllocation() { | 878 void ExitAllocationScope(Isolate* isolate, AllocationScopeData data) { |
877 if (active_) HEAP->allow_allocation(old_state_); | 879 if (data) isolate->heap()->allow_allocation(data); |
Sven Panne
2013/04/30 12:21:30
Passing a uint8_t as a bool looks wrong. Again, a
| |
878 } | 880 } |
879 | 881 |
880 | 882 |
881 DisableAssertNoAllocation::DisableAssertNoAllocation() { | 883 AssertNoAllocation::AssertNoAllocation() |
882 Isolate* isolate = ISOLATE; | 884 : data_(EnterAllocationScope(ISOLATE, false)) { |
883 active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | |
884 if (active_) { | |
885 old_state_ = isolate->heap()->allow_allocation(true); | |
886 } | |
887 } | 885 } |
888 | 886 |
887 AssertNoAllocation::~AssertNoAllocation() { | |
888 ExitAllocationScope(ISOLATE, data_); | |
889 } | |
890 | |
891 DisableAssertNoAllocation::DisableAssertNoAllocation() | |
892 : data_(EnterAllocationScope(ISOLATE, true)) { | |
893 } | |
889 | 894 |
890 DisableAssertNoAllocation::~DisableAssertNoAllocation() { | 895 DisableAssertNoAllocation::~DisableAssertNoAllocation() { |
891 if (active_) HEAP->allow_allocation(old_state_); | 896 ExitAllocationScope(ISOLATE, data_); |
892 } | 897 } |
893 | |
894 #else | 898 #else |
895 | 899 |
896 AssertNoAllocation::AssertNoAllocation() { } | 900 AssertNoAllocation::AssertNoAllocation() { } |
897 AssertNoAllocation::~AssertNoAllocation() { } | 901 AssertNoAllocation::~AssertNoAllocation() { } |
898 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 902 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
899 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 903 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
900 | 904 |
901 #endif | 905 #endif |
902 | 906 |
903 | 907 |
904 } } // namespace v8::internal | 908 } } // namespace v8::internal |
905 | 909 |
906 #endif // V8_HEAP_INL_H_ | 910 #endif // V8_HEAP_INL_H_ |
OLD | NEW |