| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ~HandleScope() { | 114 ~HandleScope() { |
| 115 Leave(&previous_); | 115 Leave(&previous_); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Counts the number of allocated handles. | 118 // Counts the number of allocated handles. |
| 119 static int NumberOfHandles(); | 119 static int NumberOfHandles(); |
| 120 | 120 |
| 121 // Creates a new handle with the given value. | 121 // Creates a new handle with the given value. |
| 122 template <typename T> | 122 template <typename T> |
| 123 static inline T** CreateHandle(T* value) { | 123 static inline T** CreateHandle(T* value) { |
| 124 void** cur = current_.next; | 124 internal::Object** cur = current_.next; |
| 125 if (cur == current_.limit) cur = Extend(); | 125 if (cur == current_.limit) cur = Extend(); |
| 126 // Update the current next field, set the value in the created | 126 // Update the current next field, set the value in the created |
| 127 // handle, and return the result. | 127 // handle, and return the result. |
| 128 ASSERT(cur < current_.limit); | 128 ASSERT(cur < current_.limit); |
| 129 current_.next = cur + 1; | 129 current_.next = cur + 1; |
| 130 | 130 |
| 131 T** result = reinterpret_cast<T**>(cur); | 131 T** result = reinterpret_cast<T**>(cur); |
| 132 *result = value; | 132 *result = value; |
| 133 return result; | 133 return result; |
| 134 } | 134 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 157 if (current_.extensions > 0) { | 157 if (current_.extensions > 0) { |
| 158 DeleteExtensions(); | 158 DeleteExtensions(); |
| 159 } | 159 } |
| 160 current_ = *previous; | 160 current_ = *previous; |
| 161 #ifdef DEBUG | 161 #ifdef DEBUG |
| 162 ZapRange(current_.next, current_.limit); | 162 ZapRange(current_.next, current_.limit); |
| 163 #endif | 163 #endif |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Extend the handle scope making room for more handles. | 166 // Extend the handle scope making room for more handles. |
| 167 static void** Extend(); | 167 static internal::Object** Extend(); |
| 168 | 168 |
| 169 // Deallocates any extensions used by the current scope. | 169 // Deallocates any extensions used by the current scope. |
| 170 static void DeleteExtensions(); | 170 static void DeleteExtensions(); |
| 171 | 171 |
| 172 // Zaps the handles in the half-open interval [start, end). | 172 // Zaps the handles in the half-open interval [start, end). |
| 173 static void ZapRange(void** start, void** end); | 173 static void ZapRange(internal::Object** start, internal::Object** end); |
| 174 | 174 |
| 175 friend class v8::HandleScope; | 175 friend class v8::HandleScope; |
| 176 friend class v8::ImplementationUtilities; | 176 friend class v8::ImplementationUtilities; |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 | 179 |
| 180 // ---------------------------------------------------------------------------- | 180 // ---------------------------------------------------------------------------- |
| 181 // Handle operations. | 181 // Handle operations. |
| 182 // They might invoke garbage collection. The result is an handle to | 182 // They might invoke garbage collection. The result is an handle to |
| 183 // an object of expected type, or the handle is an error if running out | 183 // an object of expected type, or the handle is an error if running out |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 private: | 346 private: |
| 347 bool has_been_transformed_; // Tells whether the object has been transformed. | 347 bool has_been_transformed_; // Tells whether the object has been transformed. |
| 348 int unused_property_fields_; // Captures the unused number of field. | 348 int unused_property_fields_; // Captures the unused number of field. |
| 349 Handle<JSObject> object_; // The object being optimized. | 349 Handle<JSObject> object_; // The object being optimized. |
| 350 }; | 350 }; |
| 351 | 351 |
| 352 | 352 |
| 353 } } // namespace v8::internal | 353 } } // namespace v8::internal |
| 354 | 354 |
| 355 #endif // V8_HANDLES_H_ | 355 #endif // V8_HANDLES_H_ |
| OLD | NEW |