| 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 RUNTIME_VM_ALLOCATION_H_ | 5 #ifndef RUNTIME_VM_ALLOCATION_H_ |
| 6 #define RUNTIME_VM_ALLOCATION_H_ | 6 #define RUNTIME_VM_ALLOCATION_H_ |
| 7 | 7 |
| 8 #include "platform/allocation.h" | 8 #include "platform/allocation.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/base_isolate.h" | 10 #include "vm/base_isolate.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 private: | 43 private: |
| 44 void Init(Thread* thread); | 44 void Init(Thread* thread); |
| 45 | 45 |
| 46 Thread* thread_; | 46 Thread* thread_; |
| 47 StackResource* previous_; | 47 StackResource* previous_; |
| 48 | 48 |
| 49 DISALLOW_ALLOCATION(); | 49 DISALLOW_ALLOCATION(); |
| 50 DISALLOW_IMPLICIT_CONSTRUCTORS(StackResource); | 50 DISALLOW_IMPLICIT_CONSTRUCTORS(StackResource); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 | |
| 54 // Zone allocated objects cannot be individually deallocated, but have | 53 // Zone allocated objects cannot be individually deallocated, but have |
| 55 // to rely on the destructor of Zone which is called when the Zone | 54 // to rely on the destructor of Zone which is called when the Zone |
| 56 // goes out of scope to reclaim memory. | 55 // goes out of scope to reclaim memory. |
| 57 class ZoneAllocated { | 56 class ZoneAllocated { |
| 58 public: | 57 public: |
| 59 ZoneAllocated() {} | 58 ZoneAllocated() {} |
| 60 | 59 |
| 61 // Implicitly allocate the object in the current zone. | 60 // Implicitly allocate the object in the current zone. |
| 62 void* operator new(uword size); | 61 void* operator new(uword size); |
| 63 | 62 |
| 64 // Allocate the object in the given zone, which must be the current zone. | 63 // Allocate the object in the given zone, which must be the current zone. |
| 65 void* operator new(uword size, Zone* zone); | 64 void* operator new(uword size, Zone* zone); |
| 66 | 65 |
| 67 // Ideally, the delete operator should be protected instead of | 66 // Ideally, the delete operator should be protected instead of |
| 68 // public, but unfortunately the compiler sometimes synthesizes | 67 // public, but unfortunately the compiler sometimes synthesizes |
| 69 // (unused) destructors for classes derived from ZoneObject, which | 68 // (unused) destructors for classes derived from ZoneObject, which |
| 70 // require the operator to be visible. MSVC requires the delete | 69 // require the operator to be visible. MSVC requires the delete |
| 71 // operator to be public. | 70 // operator to be public. |
| 72 | 71 |
| 73 // Disallow explicit deallocation of nodes. Nodes can only be | 72 // Disallow explicit deallocation of nodes. Nodes can only be |
| 74 // deallocated by invoking DeleteAll() on the zone they live in. | 73 // deallocated by invoking DeleteAll() on the zone they live in. |
| 75 void operator delete(void* pointer) { UNREACHABLE(); } | 74 void operator delete(void* pointer) { UNREACHABLE(); } |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); | 77 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 | |
| 82 // Within a NoSafepointScope, the thread must not reach any safepoint. Used | 80 // Within a NoSafepointScope, the thread must not reach any safepoint. Used |
| 83 // around code that manipulates raw object pointers directly without handles. | 81 // around code that manipulates raw object pointers directly without handles. |
| 84 #if defined(DEBUG) | 82 #if defined(DEBUG) |
| 85 class NoSafepointScope : public StackResource { | 83 class NoSafepointScope : public StackResource { |
| 86 public: | 84 public: |
| 87 NoSafepointScope(); | 85 NoSafepointScope(); |
| 88 ~NoSafepointScope(); | 86 ~NoSafepointScope(); |
| 89 | 87 |
| 90 private: | 88 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); | 89 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
| 92 }; | 90 }; |
| 93 #else // defined(DEBUG) | 91 #else // defined(DEBUG) |
| 94 class NoSafepointScope : public ValueObject { | 92 class NoSafepointScope : public ValueObject { |
| 95 public: | 93 public: |
| 96 NoSafepointScope() {} | 94 NoSafepointScope() {} |
| 97 | 95 |
| 98 private: | 96 private: |
| 99 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); | 97 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
| 100 }; | 98 }; |
| 101 #endif // defined(DEBUG) | 99 #endif // defined(DEBUG) |
| 102 | 100 |
| 103 } // namespace dart | 101 } // namespace dart |
| 104 | 102 |
| 105 #endif // RUNTIME_VM_ALLOCATION_H_ | 103 #endif // RUNTIME_VM_ALLOCATION_H_ |
| OLD | NEW |