| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // Called when allocation routines fail to allocate. | 34 // Called when allocation routines fail to allocate. |
| 35 // This function should not return, but should terminate the current | 35 // This function should not return, but should terminate the current |
| 36 // processing. | 36 // processing. |
| 37 void FatalProcessOutOfMemory(const char* message); | 37 void FatalProcessOutOfMemory(const char* message); |
| 38 | 38 |
| 39 // A class that controls whether allocation is allowed. This is for | 39 // A class that controls whether allocation is allowed. This is for |
| 40 // the C++ heap only! | 40 // the C++ heap only! |
| 41 class NativeAllocationChecker { | 41 class NativeAllocationChecker { |
| 42 public: | 42 public: |
| 43 typedef enum { ALLOW, DISALLOW } NativeAllocationAllowed; | 43 enum NativeAllocationAllowed { ALLOW, DISALLOW }; |
| 44 explicit inline NativeAllocationChecker(NativeAllocationAllowed allowed); | 44 #ifdef DEBUG |
| 45 inline ~NativeAllocationChecker(); | 45 explicit NativeAllocationChecker(NativeAllocationAllowed allowed); |
| 46 static inline bool allocation_allowed(); | 46 ~NativeAllocationChecker(); |
| 47 static bool allocation_allowed(); |
| 47 private: | 48 private: |
| 48 // This flag applies to this particular instance. | 49 // This flag applies to this particular instance. |
| 49 NativeAllocationAllowed allowed_; | 50 NativeAllocationAllowed allowed_; |
| 51 #else |
| 52 explicit inline NativeAllocationChecker(NativeAllocationAllowed allowed) {} |
| 53 static inline bool allocation_allowed() { return true; } |
| 54 #endif |
| 50 }; | 55 }; |
| 51 | 56 |
| 52 | 57 |
| 53 // Superclass for classes managed with new & delete. | 58 // Superclass for classes managed with new & delete. |
| 54 class Malloced { | 59 class Malloced { |
| 55 public: | 60 public: |
| 56 void* operator new(size_t size) { return New(size); } | 61 void* operator new(size_t size) { return New(size); } |
| 57 void operator delete(void* p) { Delete(p); } | 62 void operator delete(void* p) { Delete(p); } |
| 58 | 63 |
| 59 static void FatalProcessOutOfMemory(); | 64 static void FatalProcessOutOfMemory(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 151 |
| 147 friend class Isolate; | 152 friend class Isolate; |
| 148 | 153 |
| 149 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); | 154 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); |
| 150 }; | 155 }; |
| 151 | 156 |
| 152 | 157 |
| 153 } } // namespace v8::internal | 158 } } // namespace v8::internal |
| 154 | 159 |
| 155 #endif // V8_ALLOCATION_H_ | 160 #endif // V8_ALLOCATION_H_ |
| OLD | NEW |