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/assert.h" | 9 #include "platform/assert.h" |
9 #include "vm/base_isolate.h" | 10 #include "vm/base_isolate.h" |
10 #include "vm/globals.h" | 11 #include "vm/globals.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 // Forward declarations. | 15 // Forward declarations. |
15 class Isolate; | 16 class Isolate; |
16 class Thread; | 17 class Thread; |
17 | 18 |
18 // Stack allocated objects subclass from this base class. Objects of this type | |
19 // cannot be allocated on either the C or object heaps. Destructors for objects | |
20 // of this type will not be run unless the stack is unwound through normal | |
21 // program control flow. | |
22 class ValueObject { | |
23 public: | |
24 ValueObject() {} | |
25 ~ValueObject() {} | |
26 | |
27 private: | |
28 DISALLOW_ALLOCATION(); | |
29 DISALLOW_COPY_AND_ASSIGN(ValueObject); | |
30 }; | |
31 | |
32 | |
33 // Stack resources subclass from this base class. The VM will ensure that the | 19 // Stack resources subclass from this base class. The VM will ensure that the |
34 // destructors of these objects are called before the stack is unwound past the | 20 // destructors of these objects are called before the stack is unwound past the |
35 // objects location on the stack. Use stack resource objects if objects | 21 // objects location on the stack. Use stack resource objects if objects |
36 // need to be destroyed even in the case of exceptions when a Longjump is done | 22 // need to be destroyed even in the case of exceptions when a Longjump is done |
37 // to a stack frame above the frame where these objects were allocated. | 23 // to a stack frame above the frame where these objects were allocated. |
38 class StackResource { | 24 class StackResource { |
39 public: | 25 public: |
40 explicit StackResource(Thread* thread) : thread_(NULL), previous_(NULL) { | 26 explicit StackResource(Thread* thread) : thread_(NULL), previous_(NULL) { |
41 Init(thread); | 27 Init(thread); |
42 } | 28 } |
(...skipping 15 matching lines...) Expand all Loading... |
58 void Init(Thread* thread); | 44 void Init(Thread* thread); |
59 | 45 |
60 Thread* thread_; | 46 Thread* thread_; |
61 StackResource* previous_; | 47 StackResource* previous_; |
62 | 48 |
63 DISALLOW_ALLOCATION(); | 49 DISALLOW_ALLOCATION(); |
64 DISALLOW_IMPLICIT_CONSTRUCTORS(StackResource); | 50 DISALLOW_IMPLICIT_CONSTRUCTORS(StackResource); |
65 }; | 51 }; |
66 | 52 |
67 | 53 |
68 // Static allocated classes only contain static members and can never | |
69 // be instantiated in the heap or on the stack. | |
70 class AllStatic { | |
71 private: | |
72 DISALLOW_ALLOCATION(); | |
73 DISALLOW_IMPLICIT_CONSTRUCTORS(AllStatic); | |
74 }; | |
75 | |
76 | |
77 // Zone allocated objects cannot be individually deallocated, but have | 54 // Zone allocated objects cannot be individually deallocated, but have |
78 // to rely on the destructor of Zone which is called when the Zone | 55 // to rely on the destructor of Zone which is called when the Zone |
79 // goes out of scope to reclaim memory. | 56 // goes out of scope to reclaim memory. |
80 class ZoneAllocated { | 57 class ZoneAllocated { |
81 public: | 58 public: |
82 ZoneAllocated() {} | 59 ZoneAllocated() {} |
83 | 60 |
84 // Implicitly allocate the object in the current zone. | 61 // Implicitly allocate the object in the current zone. |
85 void* operator new(uword size); | 62 void* operator new(uword size); |
86 | 63 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 NoSafepointScope() {} | 96 NoSafepointScope() {} |
120 | 97 |
121 private: | 98 private: |
122 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); | 99 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); |
123 }; | 100 }; |
124 #endif // defined(DEBUG) | 101 #endif // defined(DEBUG) |
125 | 102 |
126 } // namespace dart | 103 } // namespace dart |
127 | 104 |
128 #endif // RUNTIME_VM_ALLOCATION_H_ | 105 #endif // RUNTIME_VM_ALLOCATION_H_ |
OLD | NEW |