OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_ALLOCATION_H_ | 5 #ifndef VM_ALLOCATION_H_ |
6 #define VM_ALLOCATION_H_ | 6 #define VM_ALLOCATION_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/base_isolate.h" | 9 #include "vm/base_isolate.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 DISALLOW_IMPLICIT_CONSTRUCTORS(AllStatic); | 82 DISALLOW_IMPLICIT_CONSTRUCTORS(AllStatic); |
83 }; | 83 }; |
84 | 84 |
85 | 85 |
86 // Zone allocated objects cannot be individually deallocated, but have | 86 // Zone allocated objects cannot be individually deallocated, but have |
87 // to rely on the destructor of Zone which is called when the Zone | 87 // to rely on the destructor of Zone which is called when the Zone |
88 // goes out of scope to reclaim memory. | 88 // goes out of scope to reclaim memory. |
89 class ZoneAllocated { | 89 class ZoneAllocated { |
90 public: | 90 public: |
91 ZoneAllocated() { } | 91 ZoneAllocated() { } |
92 // It would be ideal if the destructor method could be made private, | |
93 // but the g++ compiler complains when this is subclassed. | |
94 virtual ~ZoneAllocated(); | |
95 | 92 |
96 // Implicitly allocate the object in the current zone. | 93 // Implicitly allocate the object in the current zone. |
97 void* operator new(uword size); | 94 void* operator new(uword size); |
98 | 95 |
99 // Implicitly allocate the object in the current zone given the current | 96 // Implicitly allocate the object in the current zone given the current |
100 // isolate. | 97 // isolate. |
101 void* operator new(uword size, BaseIsolate* isolate); | 98 void* operator new(uword size, BaseIsolate* isolate); |
102 | 99 |
103 // Ideally, the delete operator should be protected instead of | 100 // Ideally, the delete operator should be protected instead of |
104 // public, but unfortunately the compiler sometimes synthesizes | 101 // public, but unfortunately the compiler sometimes synthesizes |
105 // (unused) destructors for classes derived from ZoneObject, which | 102 // (unused) destructors for classes derived from ZoneObject, which |
106 // require the operator to be visible. MSVC requires the delete | 103 // require the operator to be visible. MSVC requires the delete |
107 // operator to be public. | 104 // operator to be public. |
108 | 105 |
109 // Disallow explicit deallocation of nodes. Nodes can only be | 106 // Disallow explicit deallocation of nodes. Nodes can only be |
110 // deallocated by invoking DeleteAll() on the zone they live in. | 107 // deallocated by invoking DeleteAll() on the zone they live in. |
111 void operator delete(void* pointer) { UNREACHABLE(); } | 108 void operator delete(void* pointer) { UNREACHABLE(); } |
112 | 109 |
113 private: | 110 private: |
114 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); | 111 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); |
115 }; | 112 }; |
116 | 113 |
117 } // namespace dart | 114 } // namespace dart |
118 | 115 |
119 #endif // VM_ALLOCATION_H_ | 116 #endif // VM_ALLOCATION_H_ |
OLD | NEW |