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

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

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_ZONE_H_ 5 #ifndef VM_ZONE_H_
6 #define VM_ZONE_H_ 6 #define VM_ZONE_H_
7 7
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/handles.h" 10 #include "vm/handles.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 Segment* large_segments_; 90 Segment* large_segments_;
91 91
92 friend class Zone; 92 friend class Zone;
93 friend class ApiZone; 93 friend class ApiZone;
94 DISALLOW_COPY_AND_ASSIGN(BaseZone); 94 DISALLOW_COPY_AND_ASSIGN(BaseZone);
95 }; 95 };
96 96
97 97
98 class Zone : public StackResource { 98 class Zone : public StackResource {
99 public: 99 public:
100 // Create an empty zone outside an isolate context.
101 explicit Zone();
siva 2012/02/04 01:55:43 If you use ApiZone I guess these changes to Zone a
Søren Gjesse 2012/02/06 16:25:52 See previous comments.
102
100 // Create an empty zone and set is at the current zone for the Isolate. 103 // Create an empty zone and set is at the current zone for the Isolate.
101 explicit Zone(Isolate* isolate); 104 explicit Zone(Isolate* isolate);
102 105
103 // Delete all memory associated with the zone. 106 // Delete all memory associated with the zone.
104 ~Zone(); 107 ~Zone();
105 108
106 // Allocate 'size' bytes of memory in the zone; expands the zone by 109 // Allocate 'size' bytes of memory in the zone; expands the zone by
107 // allocating new segments of memory on demand using 'new'. 110 // allocating new segments of memory on demand using 'new'.
108 uword Allocate(intptr_t size) { return zone_.Allocate(size); } 111 uword Allocate(intptr_t size) { return zone_.Allocate(size); }
109 112
(...skipping 17 matching lines...) Expand all
127 void VisitObjectPointers(ObjectPointerVisitor* visitor); 130 void VisitObjectPointers(ObjectPointerVisitor* visitor);
128 131
129 private: 132 private:
130 BaseZone zone_; 133 BaseZone zone_;
131 134
132 // Structure for managing handles allocation. 135 // Structure for managing handles allocation.
133 VMHandles handles_; 136 VMHandles handles_;
134 137
135 // Used for chaining zones in order to allow unwinding of stacks. 138 // Used for chaining zones in order to allow unwinding of stacks.
136 Zone* previous_; 139 Zone* previous_;
137 DISALLOW_IMPLICIT_CONSTRUCTORS(Zone);
138 }; 140 };
139 141
140 142
141 inline uword BaseZone::Allocate(intptr_t size) { 143 inline uword BaseZone::Allocate(intptr_t size) {
142 ASSERT(size >= 0); 144 ASSERT(size >= 0);
143 145
144 // Round up the requested size to fit the alignment. 146 // Round up the requested size to fit the alignment.
145 size = Utils::RoundUp(size, kAlignment); 147 size = Utils::RoundUp(size, kAlignment);
146 148
147 // Check if the requested size is available without expanding. 149 // Check if the requested size is available without expanding.
148 uword result; 150 uword result;
149 intptr_t free_size = (limit_ - position_); 151 intptr_t free_size = (limit_ - position_);
150 if (free_size >= size) { 152 if (free_size >= size) {
151 result = position_; 153 result = position_;
152 position_ += size; 154 position_ += size;
153 } else { 155 } else {
154 result = AllocateExpand(size); 156 result = AllocateExpand(size);
155 } 157 }
156 158
157 // Check that the result has the proper alignment and return it. 159 // Check that the result has the proper alignment and return it.
158 ASSERT(Utils::IsAligned(result, kAlignment)); 160 ASSERT(Utils::IsAligned(result, kAlignment));
159 return result; 161 return result;
160 } 162 }
161 163
162 } // namespace dart 164 } // namespace dart
163 165
164 #endif // VM_ZONE_H_ 166 #endif // VM_ZONE_H_
OLDNEW
« runtime/vm/snapshot.h ('K') | « runtime/vm/snapshot.cc ('k') | runtime/vm/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698