Chromium Code Reviews

Side by Side Diff: src/handles.h

Issue 10640012: Add a second kind of HandleScope that ties the lifetime of Handles created in its scope to the life… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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...)
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...)
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 CompilationInfo;
169
170 // Like a regular stack-allocated HandleScope, but does not delete the
171 // handles allocated in its scope on destruction. Instead, it ties
172 // the Handles created in its scope with the CompilatationInfo passed
173 // to its constructor. The Handles are reclaimed when the
174 // CompilationInfo destructs.
175 class GatheringHandleScope {
danno 2012/06/24 11:07:03 Why not just call this CompilationHandleScope?
danno 2012/06/24 11:07:03 This guy should be responsible for creating the "P
176 public:
177 explicit GatheringHandleScope(CompilationInfo* info);
178 ~GatheringHandleScope();
179
180 private:
181 CompilationInfo* info_;
182 Object** prev_next_;
183 Object** prev_limit_;
184 };
185
186
164 // ---------------------------------------------------------------------------- 187 // ----------------------------------------------------------------------------
165 // Handle operations. 188 // Handle operations.
166 // They might invoke garbage collection. The result is an handle to 189 // 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 190 // an object of expected type, or the handle is an error if running out
168 // of space or encountering an internal error. 191 // of space or encountering an internal error.
169 192
170 // Flattens a string. 193 // Flattens a string.
171 void FlattenString(Handle<String> str); 194 void FlattenString(Handle<String> str);
172 195
173 // Flattens a string and returns the underlying external or sequential 196 // Flattens a string and returns the underlying external or sequential
(...skipping 119 matching lines...)
293 inline NoHandleAllocation(); 316 inline NoHandleAllocation();
294 inline ~NoHandleAllocation(); 317 inline ~NoHandleAllocation();
295 private: 318 private:
296 int level_; 319 int level_;
297 #endif 320 #endif
298 }; 321 };
299 322
300 } } // namespace v8::internal 323 } } // namespace v8::internal
301 324
302 #endif // V8_HANDLES_H_ 325 #endif // V8_HANDLES_H_
OLDNEW

Powered by Google App Engine