OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_ALLOCATION_H_ | 5 #ifndef V8_ALLOCATION_H_ |
6 #define V8_ALLOCATION_H_ | 6 #define V8_ALLOCATION_H_ |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 27 matching lines...) Expand all Loading... |
38 public: | 38 public: |
39 void* operator new(size_t size); | 39 void* operator new(size_t size); |
40 void operator delete(void* p); | 40 void operator delete(void* p); |
41 }; | 41 }; |
42 #define BASE_EMBEDDED : public Embedded | 42 #define BASE_EMBEDDED : public Embedded |
43 #else | 43 #else |
44 #define BASE_EMBEDDED | 44 #define BASE_EMBEDDED |
45 #endif | 45 #endif |
46 | 46 |
47 | 47 |
48 // Superclass for classes only using statics. | 48 // Superclass for classes only using static method functions. |
| 49 // The subclass of AllStatic cannot be instantiated at all. |
49 class AllStatic { | 50 class AllStatic { |
50 #ifdef DEBUG | 51 #ifdef DEBUG |
51 public: | 52 public: |
52 void* operator new(size_t size); | 53 AllStatic() = delete; |
53 void operator delete(void* p); | |
54 #endif | 54 #endif |
55 }; | 55 }; |
56 | 56 |
57 | 57 |
58 template <typename T> | 58 template <typename T> |
59 T* NewArray(size_t size) { | 59 T* NewArray(size_t size) { |
60 T* result = new T[size]; | 60 T* result = new T[size]; |
61 if (result == NULL) FatalProcessOutOfMemory("NewArray"); | 61 if (result == NULL) FatalProcessOutOfMemory("NewArray"); |
62 return result; | 62 return result; |
63 } | 63 } |
(...skipping 21 matching lines...) Expand all Loading... |
85 }; | 85 }; |
86 | 86 |
87 | 87 |
88 void* AlignedAlloc(size_t size, size_t alignment); | 88 void* AlignedAlloc(size_t size, size_t alignment); |
89 void AlignedFree(void *ptr); | 89 void AlignedFree(void *ptr); |
90 | 90 |
91 } // namespace internal | 91 } // namespace internal |
92 } // namespace v8 | 92 } // namespace v8 |
93 | 93 |
94 #endif // V8_ALLOCATION_H_ | 94 #endif // V8_ALLOCATION_H_ |
OLD | NEW |