Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: runtime/vm/allocation.h

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/platform/globals.h ('k') | runtime/vm/allocation_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 // Forward declarations. 14 // Forward declarations.
15 class Isolate; 15 class Isolate;
16 class Thread; 16 class Thread;
17 17
18 // Stack allocated objects subclass from this base class. Objects of this type 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 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 20 // of this type will not be run unless the stack is unwound through normal
21 // program control flow. 21 // program control flow.
22 class ValueObject { 22 class ValueObject {
23 public: 23 public:
24 ValueObject() { } 24 ValueObject() {}
25 ~ValueObject() { } 25 ~ValueObject() {}
26 26
27 private: 27 private:
28 DISALLOW_ALLOCATION(); 28 DISALLOW_ALLOCATION();
29 DISALLOW_COPY_AND_ASSIGN(ValueObject); 29 DISALLOW_COPY_AND_ASSIGN(ValueObject);
30 }; 30 };
31 31
32 32
33 // Stack resources subclass from this base class. The VM will ensure that the 33 // 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 34 // 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 35 // objects location on the stack. Use stack resource objects if objects
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 DISALLOW_ALLOCATION(); 72 DISALLOW_ALLOCATION();
73 DISALLOW_IMPLICIT_CONSTRUCTORS(AllStatic); 73 DISALLOW_IMPLICIT_CONSTRUCTORS(AllStatic);
74 }; 74 };
75 75
76 76
77 // Zone allocated objects cannot be individually deallocated, but have 77 // Zone allocated objects cannot be individually deallocated, but have
78 // to rely on the destructor of Zone which is called when the Zone 78 // to rely on the destructor of Zone which is called when the Zone
79 // goes out of scope to reclaim memory. 79 // goes out of scope to reclaim memory.
80 class ZoneAllocated { 80 class ZoneAllocated {
81 public: 81 public:
82 ZoneAllocated() { } 82 ZoneAllocated() {}
83 83
84 // Implicitly allocate the object in the current zone. 84 // Implicitly allocate the object in the current zone.
85 void* operator new(uword size); 85 void* operator new(uword size);
86 86
87 // Allocate the object in the given zone, which must be the current zone. 87 // Allocate the object in the given zone, which must be the current zone.
88 void* operator new(uword size, Zone* zone); 88 void* operator new(uword size, Zone* zone);
89 89
90 // Ideally, the delete operator should be protected instead of 90 // Ideally, the delete operator should be protected instead of
91 // public, but unfortunately the compiler sometimes synthesizes 91 // public, but unfortunately the compiler sometimes synthesizes
92 // (unused) destructors for classes derived from ZoneObject, which 92 // (unused) destructors for classes derived from ZoneObject, which
93 // require the operator to be visible. MSVC requires the delete 93 // require the operator to be visible. MSVC requires the delete
94 // operator to be public. 94 // operator to be public.
95 95
96 // Disallow explicit deallocation of nodes. Nodes can only be 96 // Disallow explicit deallocation of nodes. Nodes can only be
97 // deallocated by invoking DeleteAll() on the zone they live in. 97 // deallocated by invoking DeleteAll() on the zone they live in.
98 void operator delete(void* pointer) { UNREACHABLE(); } 98 void operator delete(void* pointer) { UNREACHABLE(); }
99 99
100 private: 100 private:
101 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated); 101 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated);
102 }; 102 };
103 103
104 104
105
106 // Within a NoSafepointScope, the thread must not reach any safepoint. Used 105 // Within a NoSafepointScope, the thread must not reach any safepoint. Used
107 // around code that manipulates raw object pointers directly without handles. 106 // around code that manipulates raw object pointers directly without handles.
108 #if defined(DEBUG) 107 #if defined(DEBUG)
109 class NoSafepointScope : public StackResource { 108 class NoSafepointScope : public StackResource {
110 public: 109 public:
111 NoSafepointScope(); 110 NoSafepointScope();
112 ~NoSafepointScope(); 111 ~NoSafepointScope();
112
113 private: 113 private:
114 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); 114 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope);
115 }; 115 };
116 #else // defined(DEBUG) 116 #else // defined(DEBUG)
117 class NoSafepointScope : public ValueObject { 117 class NoSafepointScope : public ValueObject {
118 public: 118 public:
119 NoSafepointScope() {} 119 NoSafepointScope() {}
120
120 private: 121 private:
121 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope); 122 DISALLOW_COPY_AND_ASSIGN(NoSafepointScope);
122 }; 123 };
123 #endif // defined(DEBUG) 124 #endif // defined(DEBUG)
124 125
125 } // namespace dart 126 } // namespace dart
126 127
127 #endif // RUNTIME_VM_ALLOCATION_H_ 128 #endif // RUNTIME_VM_ALLOCATION_H_
OLDNEW
« no previous file with comments | « runtime/platform/globals.h ('k') | runtime/vm/allocation_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698