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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Zone allocated objects cannot be individually deallocated, but have | 91 // Zone allocated objects cannot be individually deallocated, but have |
92 // to rely on the destructor of Zone which is called when the Zone | 92 // to rely on the destructor of Zone which is called when the Zone |
93 // goes out of scope to reclaim memory. | 93 // goes out of scope to reclaim memory. |
94 class ZoneAllocated { | 94 class ZoneAllocated { |
95 public: | 95 public: |
96 ZoneAllocated() { } | 96 ZoneAllocated() { } |
97 | 97 |
98 // Implicitly allocate the object in the current zone. | 98 // Implicitly allocate the object in the current zone. |
99 void* operator new(uword size); | 99 void* operator new(uword size); |
100 | 100 |
101 // DEPRECATED: Use Zone version. | |
102 // Implicitly allocate the object in the current zone given the current | |
103 // isolate. | |
104 void* operator new(uword size, BaseIsolate* isolate); | |
105 | |
106 // Allocate the object in the given zone, which must be the current zone. | 101 // Allocate the object in the given zone, which must be the current zone. |
107 void* operator new(uword size, Zone* zone); | 102 void* operator new(uword size, Zone* zone); |
108 | 103 |
109 // Ideally, the delete operator should be protected instead of | 104 // Ideally, the delete operator should be protected instead of |
110 // public, but unfortunately the compiler sometimes synthesizes | 105 // public, but unfortunately the compiler sometimes synthesizes |
111 // (unused) destructors for classes derived from ZoneObject, which | 106 // (unused) destructors for classes derived from ZoneObject, which |
112 // require the operator to be visible. MSVC requires the delete | 107 // require the operator to be visible. MSVC requires the delete |
113 // operator to be public. | 108 // operator to be public. |
114 | 109 |
115 // Disallow explicit deallocation of nodes. Nodes can only be | 110 // Disallow explicit deallocation of nodes. Nodes can only be |
116 // deallocated by invoking DeleteAll() on the zone they live in. | 111 // deallocated by invoking DeleteAll() on the zone they live in. |
117 void operator delete(void* pointer) { UNREACHABLE(); } | 112 void operator delete(void* pointer) { UNREACHABLE(); } |
118 | 113 |
119 private: | 114 private: |
120 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); | 115 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); |
121 }; | 116 }; |
122 | 117 |
123 } // namespace dart | 118 } // namespace dart |
124 | 119 |
125 #endif // VM_ALLOCATION_H_ | 120 #endif // VM_ALLOCATION_H_ |
OLD | NEW |