OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 88 |
89 // Closes the given scope, but lets this handle escape. See | 89 // Closes the given scope, but lets this handle escape. See |
90 // implementation in api.h. | 90 // implementation in api.h. |
91 inline Handle<T> EscapeFrom(v8::HandleScope* scope); | 91 inline Handle<T> EscapeFrom(v8::HandleScope* scope); |
92 | 92 |
93 private: | 93 private: |
94 T** location_; | 94 T** location_; |
95 }; | 95 }; |
96 | 96 |
97 | 97 |
98 class HandleScopeImplementer; | |
99 | |
100 | |
98 // A stack-allocated class that governs a number of local handles. | 101 // A stack-allocated class that governs a number of local handles. |
99 // After a handle scope has been created, all local handles will be | 102 // After a handle scope has been created, all local handles will be |
100 // allocated within that handle scope until either the handle scope is | 103 // allocated within that handle scope until either the handle scope is |
101 // deleted or another handle scope is created. If there is already a | 104 // deleted or another handle scope is created. If there is already a |
102 // handle scope and a new one is created, all allocations will take | 105 // handle scope and a new one is created, all allocations will take |
103 // place in the new handle scope until it is deleted. After that, | 106 // place in the new handle scope until it is deleted. After that, |
104 // new handles will again be allocated in the original handle scope. | 107 // new handles will again be allocated in the original handle scope. |
105 // | 108 // |
106 // After the handle scope of a local handle has been deleted the | 109 // After the handle scope of a local handle has been deleted the |
107 // garbage collector will no longer track the object stored in the | 110 // garbage collector will no longer track the object stored in the |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 Object** prev_next_; | 153 Object** prev_next_; |
151 Object** prev_limit_; | 154 Object** prev_limit_; |
152 | 155 |
153 // Extend the handle scope making room for more handles. | 156 // Extend the handle scope making room for more handles. |
154 static internal::Object** Extend(); | 157 static internal::Object** Extend(); |
155 | 158 |
156 // Zaps the handles in the half-open interval [start, end). | 159 // Zaps the handles in the half-open interval [start, end). |
157 static void ZapRange(internal::Object** start, internal::Object** end); | 160 static void ZapRange(internal::Object** start, internal::Object** end); |
158 | 161 |
159 friend class v8::HandleScope; | 162 friend class v8::HandleScope; |
163 friend class v8::internal::HandleScopeImplementer; | |
160 friend class v8::ImplementationUtilities; | 164 friend class v8::ImplementationUtilities; |
161 }; | 165 }; |
162 | 166 |
163 | 167 |
168 class DeferredHandles; | |
169 | |
170 | |
171 class DeferredHandleScope { | |
172 public: | |
173 explicit DeferredHandleScope(Isolate* isolate); | |
174 // The DeferredHandles object returned stores the Handles created | |
175 // since the creation of this DeferredHandleScope. The Handles are | |
176 // alive till as long as the DeferredHandles object is alive. | |
Erik Corry
2012/06/27 10:28:15
till as long as -> as long as
sanjoy
2012/06/27 11:17:09
Fixed.
| |
177 DeferredHandles* Detach(); | |
178 ~DeferredHandleScope(); | |
179 | |
180 private: | |
181 Object** prev_limit_; | |
182 Object** prev_next_; | |
183 HandleScopeImplementer* impl_; | |
184 | |
185 #ifdef DEBUG | |
186 bool handles_detached_; | |
187 int prev_level_; | |
188 #endif | |
189 | |
190 friend class HandleScopeImplementer; | |
191 }; | |
192 | |
193 | |
194 class CompilationInfo; | |
Erik Corry
2012/06/27 10:28:15
This declaration and the CompilationHandleScope ar
sanjoy
2012/06/27 11:17:09
Moved to compiler.h.
| |
195 | |
196 | |
197 // A wrapper around a CompilationInfo that Detaches the Handles from | |
Erik Corry
2012/06/27 10:28:15
Detaches -> detaches
sanjoy
2012/06/27 11:17:09
Fixed.
| |
198 // the underlying DeferredHandleScope and stores them in info_ on | |
199 // destruction. | |
200 class CompilationHandleScope BASE_EMBEDDED { | |
201 public: | |
202 explicit CompilationHandleScope(CompilationInfo* info); | |
203 ~CompilationHandleScope(); | |
204 | |
205 private: | |
206 DeferredHandleScope deferred_; | |
207 CompilationInfo* info_; | |
208 }; | |
209 | |
210 | |
164 // ---------------------------------------------------------------------------- | 211 // ---------------------------------------------------------------------------- |
165 // Handle operations. | 212 // Handle operations. |
166 // They might invoke garbage collection. The result is an handle to | 213 // They might invoke garbage collection. The result is an handle to |
167 // an object of expected type, or the handle is an error if running out | 214 // an object of expected type, or the handle is an error if running out |
168 // of space or encountering an internal error. | 215 // of space or encountering an internal error. |
169 | 216 |
170 // Flattens a string. | 217 // Flattens a string. |
171 void FlattenString(Handle<String> str); | 218 void FlattenString(Handle<String> str); |
172 | 219 |
173 // Flattens a string and returns the underlying external or sequential | 220 // Flattens a string and returns the underlying external or sequential |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 inline NoHandleAllocation(); | 340 inline NoHandleAllocation(); |
294 inline ~NoHandleAllocation(); | 341 inline ~NoHandleAllocation(); |
295 private: | 342 private: |
296 int level_; | 343 int level_; |
297 #endif | 344 #endif |
298 }; | 345 }; |
299 | 346 |
300 } } // namespace v8::internal | 347 } } // namespace v8::internal |
301 | 348 |
302 #endif // V8_HANDLES_H_ | 349 #endif // V8_HANDLES_H_ |
OLD | NEW |