| 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 as long as the DeferredHandles object is alive. |
| 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 |
| 164 // ---------------------------------------------------------------------------- | 194 // ---------------------------------------------------------------------------- |
| 165 // Handle operations. | 195 // Handle operations. |
| 166 // They might invoke garbage collection. The result is an handle to | 196 // 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 | 197 // an object of expected type, or the handle is an error if running out |
| 168 // of space or encountering an internal error. | 198 // of space or encountering an internal error. |
| 169 | 199 |
| 170 // Flattens a string. | 200 // Flattens a string. |
| 171 void FlattenString(Handle<String> str); | 201 void FlattenString(Handle<String> str); |
| 172 | 202 |
| 173 // Flattens a string and returns the underlying external or sequential | 203 // 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(); | 323 inline NoHandleAllocation(); |
| 294 inline ~NoHandleAllocation(); | 324 inline ~NoHandleAllocation(); |
| 295 private: | 325 private: |
| 296 int level_; | 326 int level_; |
| 297 #endif | 327 #endif |
| 298 }; | 328 }; |
| 299 | 329 |
| 300 } } // namespace v8::internal | 330 } } // namespace v8::internal |
| 301 | 331 |
| 302 #endif // V8_HANDLES_H_ | 332 #endif // V8_HANDLES_H_ |
| OLD | NEW |