| 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 HEAP->disallow_allocation_failure_ = old_state_; | 865 HEAP->disallow_allocation_failure_ = old_state_; |
| 866 #endif | 866 #endif |
| 867 } | 867 } |
| 868 | 868 |
| 869 | 869 |
| 870 #ifdef DEBUG | 870 #ifdef DEBUG |
| 871 bool EnterAllocationScope(Isolate* isolate, bool allow_allocation) { | 871 bool EnterAllocationScope(Isolate* isolate, bool allow_allocation) { |
| 872 bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); | 872 bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
| 873 bool last_state = isolate->heap()->IsAllocationAllowed(); | 873 bool last_state = isolate->heap()->IsAllocationAllowed(); |
| 874 if (active) { | 874 if (active) { |
| 875 // TODO(yangguo): Make HandleDereferenceGuard avoid isolate mutation in the |
| 876 // same way if running on the optimizer thread. |
| 875 isolate->heap()->set_allow_allocation(allow_allocation); | 877 isolate->heap()->set_allow_allocation(allow_allocation); |
| 876 } | 878 } |
| 877 return last_state; | 879 return last_state; |
| 878 } | 880 } |
| 879 | 881 |
| 880 | 882 |
| 881 void ExitAllocationScope(Isolate* isolate, bool last_state) { | 883 void ExitAllocationScope(Isolate* isolate, bool last_state) { |
| 882 isolate->heap()->set_allow_allocation(last_state); | 884 bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread(); |
| 885 if (active) { |
| 886 isolate->heap()->set_allow_allocation(last_state); |
| 887 } |
| 883 } | 888 } |
| 884 | 889 |
| 885 | 890 |
| 886 AssertNoAllocation::AssertNoAllocation() | 891 AssertNoAllocation::AssertNoAllocation() |
| 887 : last_state_(EnterAllocationScope(ISOLATE, false)) { | 892 : last_state_(EnterAllocationScope(ISOLATE, false)) { |
| 888 } | 893 } |
| 889 | 894 |
| 890 AssertNoAllocation::~AssertNoAllocation() { | 895 AssertNoAllocation::~AssertNoAllocation() { |
| 891 ExitAllocationScope(ISOLATE, last_state_); | 896 ExitAllocationScope(ISOLATE, last_state_); |
| 892 } | 897 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 904 AssertNoAllocation::~AssertNoAllocation() { } | 909 AssertNoAllocation::~AssertNoAllocation() { } |
| 905 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 910 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
| 906 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 911 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
| 907 | 912 |
| 908 #endif | 913 #endif |
| 909 | 914 |
| 910 | 915 |
| 911 } } // namespace v8::internal | 916 } } // namespace v8::internal |
| 912 | 917 |
| 913 #endif // V8_HEAP_INL_H_ | 918 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |