| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. | 
 | 2 | // Redistribution and use in source and binary forms, with or without | 
 | 3 | // modification, are permitted provided that the following conditions are | 
 | 4 | // met: | 
 | 5 | // | 
 | 6 | //     * Redistributions of source code must retain the above copyright | 
 | 7 | //       notice, this list of conditions and the following disclaimer. | 
 | 8 | //     * Redistributions in binary form must reproduce the above | 
 | 9 | //       copyright notice, this list of conditions and the following | 
 | 10 | //       disclaimer in the documentation and/or other materials provided | 
 | 11 | //       with the distribution. | 
 | 12 | //     * Neither the name of Google Inc. nor the names of its | 
 | 13 | //       contributors may be used to endorse or promote products derived | 
 | 14 | //       from this software without specific prior written permission. | 
 | 15 | // | 
 | 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
 | 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
 | 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 
 | 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
 | 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 
 | 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
 | 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
 | 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
 | 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
 | 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
 | 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
 | 27 |  | 
 | 28 | #ifndef V8_HANDLES_H_ | 
 | 29 | #define V8_HANDLES_H_ | 
 | 30 |  | 
 | 31 | #include "apiutils.h" | 
 | 32 |  | 
 | 33 | namespace v8 { | 
 | 34 | namespace internal { | 
 | 35 |  | 
 | 36 | // ---------------------------------------------------------------------------- | 
 | 37 | // A Handle provides a reference to an object that survives relocation by | 
 | 38 | // the garbage collector. | 
 | 39 | // Handles are only valid within a HandleScope. | 
 | 40 | // When a handle is created for an object a cell is allocated in the heap. | 
 | 41 |  | 
 | 42 | template<class T> | 
 | 43 | class Handle { | 
 | 44 |  public: | 
| Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 45 |   INLINE(explicit Handle(T** location)) { location_ = location; } | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 46 |   INLINE(explicit Handle(T* obj)); | 
 | 47 |  | 
 | 48 |   INLINE(Handle()) : location_(NULL) {} | 
 | 49 |  | 
 | 50 |   // Constructor for handling automatic up casting. | 
 | 51 |   // Ex. Handle<JSFunction> can be passed when Handle<Object> is expected. | 
 | 52 |   template <class S> Handle(Handle<S> handle) { | 
 | 53 | #ifdef DEBUG | 
 | 54 |     T* a = NULL; | 
 | 55 |     S* b = NULL; | 
 | 56 |     a = b;  // Fake assignment to enforce type checks. | 
 | 57 |     USE(a); | 
 | 58 | #endif | 
 | 59 |     location_ = reinterpret_cast<T**>(handle.location()); | 
 | 60 |   } | 
 | 61 |  | 
 | 62 |   INLINE(T* operator ->() const) { return operator*(); } | 
 | 63 |  | 
 | 64 |   // Check if this handle refers to the exact same object as the other handle. | 
 | 65 |   bool is_identical_to(const Handle<T> other) const { | 
 | 66 |     return operator*() == *other; | 
 | 67 |   } | 
 | 68 |  | 
 | 69 |   // Provides the C++ dereference operator. | 
 | 70 |   INLINE(T* operator*() const); | 
 | 71 |  | 
 | 72 |   // Returns the address to where the raw pointer is stored. | 
 | 73 |   T** location() const { | 
 | 74 |     ASSERT(location_ == NULL || | 
 | 75 |            reinterpret_cast<Address>(*location_) != kZapValue); | 
 | 76 |     return location_; | 
 | 77 |   } | 
 | 78 |  | 
 | 79 |   template <class S> static Handle<T> cast(Handle<S> that) { | 
 | 80 |     T::cast(*that); | 
 | 81 |     return Handle<T>(reinterpret_cast<T**>(that.location())); | 
 | 82 |   } | 
 | 83 |  | 
 | 84 |   static Handle<T> null() { return Handle<T>(); } | 
 | 85 |   bool is_null() { return location_ == NULL; } | 
 | 86 |  | 
 | 87 |   // Closes the given scope, but lets this handle escape. See | 
 | 88 |   // implementation in api.h. | 
 | 89 |   inline Handle<T> EscapeFrom(v8::HandleScope* scope); | 
 | 90 |  | 
 | 91 |  private: | 
 | 92 |   T** location_; | 
 | 93 | }; | 
 | 94 |  | 
 | 95 |  | 
 | 96 | // A stack-allocated class that governs a number of local handles. | 
 | 97 | // After a handle scope has been created, all local handles will be | 
 | 98 | // allocated within that handle scope until either the handle scope is | 
 | 99 | // deleted or another handle scope is created.  If there is already a | 
 | 100 | // handle scope and a new one is created, all allocations will take | 
 | 101 | // place in the new handle scope until it is deleted.  After that, | 
 | 102 | // new handles will again be allocated in the original handle scope. | 
 | 103 | // | 
 | 104 | // After the handle scope of a local handle has been deleted the | 
 | 105 | // garbage collector will no longer track the object stored in the | 
 | 106 | // handle and may deallocate it.  The behavior of accessing a handle | 
 | 107 | // for which the handle scope has been deleted is undefined. | 
 | 108 | class HandleScope { | 
 | 109 |  public: | 
| John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 110 |   HandleScope() : prev_next_(current_.next), prev_limit_(current_.limit) { | 
 | 111 |     current_.level++; | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 112 |   } | 
 | 113 |  | 
 | 114 |   ~HandleScope() { | 
| John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 115 |     current_.next = prev_next_; | 
 | 116 |     current_.level--; | 
 | 117 |     if (current_.limit != prev_limit_) { | 
 | 118 |       current_.limit = prev_limit_; | 
 | 119 |       DeleteExtensions(); | 
 | 120 |     } | 
 | 121 | #ifdef DEBUG | 
 | 122 |     ZapRange(prev_next_, prev_limit_); | 
 | 123 | #endif | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 124 |   } | 
 | 125 |  | 
 | 126 |   // Counts the number of allocated handles. | 
 | 127 |   static int NumberOfHandles(); | 
 | 128 |  | 
 | 129 |   // Creates a new handle with the given value. | 
 | 130 |   template <typename T> | 
 | 131 |   static inline T** CreateHandle(T* value) { | 
 | 132 |     internal::Object** cur = current_.next; | 
 | 133 |     if (cur == current_.limit) cur = Extend(); | 
 | 134 |     // Update the current next field, set the value in the created | 
 | 135 |     // handle, and return the result. | 
 | 136 |     ASSERT(cur < current_.limit); | 
 | 137 |     current_.next = cur + 1; | 
 | 138 |  | 
 | 139 |     T** result = reinterpret_cast<T**>(cur); | 
 | 140 |     *result = value; | 
 | 141 |     return result; | 
 | 142 |   } | 
 | 143 |  | 
| Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 144 |   // Deallocates any extensions used by the current scope. | 
 | 145 |   static void DeleteExtensions(); | 
 | 146 |  | 
| Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 147 |   static Address current_next_address(); | 
 | 148 |   static Address current_limit_address(); | 
| John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 149 |   static Address current_level_address(); | 
| Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 150 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 151 |  private: | 
 | 152 |   // Prevent heap allocation or illegal handle scopes. | 
 | 153 |   HandleScope(const HandleScope&); | 
 | 154 |   void operator=(const HandleScope&); | 
 | 155 |   void* operator new(size_t size); | 
 | 156 |   void operator delete(void* size_t); | 
 | 157 |  | 
 | 158 |   static v8::ImplementationUtilities::HandleScopeData current_; | 
| John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 159 |   Object** const prev_next_; | 
 | 160 |   Object** const prev_limit_; | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 161 |  | 
 | 162 |   // Extend the handle scope making room for more handles. | 
 | 163 |   static internal::Object** Extend(); | 
 | 164 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 165 |   // Zaps the handles in the half-open interval [start, end). | 
 | 166 |   static void ZapRange(internal::Object** start, internal::Object** end); | 
 | 167 |  | 
 | 168 |   friend class v8::HandleScope; | 
 | 169 |   friend class v8::ImplementationUtilities; | 
 | 170 | }; | 
 | 171 |  | 
 | 172 |  | 
 | 173 | // ---------------------------------------------------------------------------- | 
 | 174 | // Handle operations. | 
 | 175 | // They might invoke garbage collection. The result is an handle to | 
 | 176 | // an object of expected type, or the handle is an error if running out | 
 | 177 | // of space or encountering an internal error. | 
 | 178 |  | 
 | 179 | void NormalizeProperties(Handle<JSObject> object, | 
 | 180 |                          PropertyNormalizationMode mode, | 
 | 181 |                          int expected_additional_properties); | 
 | 182 | void NormalizeElements(Handle<JSObject> object); | 
 | 183 | void TransformToFastProperties(Handle<JSObject> object, | 
 | 184 |                                int unused_property_fields); | 
| John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 185 | void NumberDictionarySet(Handle<NumberDictionary> dictionary, | 
 | 186 |                          uint32_t index, | 
 | 187 |                          Handle<Object> value, | 
 | 188 |                          PropertyDetails details); | 
| Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 189 |  | 
 | 190 | // Flattens a string. | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 191 | void FlattenString(Handle<String> str); | 
 | 192 |  | 
| Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 193 | // Flattens a string and returns the underlying external or sequential | 
 | 194 | // string. | 
 | 195 | Handle<String> FlattenGetString(Handle<String> str); | 
 | 196 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | Handle<Object> SetProperty(Handle<JSObject> object, | 
 | 198 |                            Handle<String> key, | 
 | 199 |                            Handle<Object> value, | 
 | 200 |                            PropertyAttributes attributes); | 
 | 201 |  | 
 | 202 | Handle<Object> SetProperty(Handle<Object> object, | 
 | 203 |                            Handle<Object> key, | 
 | 204 |                            Handle<Object> value, | 
 | 205 |                            PropertyAttributes attributes); | 
 | 206 |  | 
 | 207 | Handle<Object> ForceSetProperty(Handle<JSObject> object, | 
 | 208 |                                 Handle<Object> key, | 
 | 209 |                                 Handle<Object> value, | 
 | 210 |                                 PropertyAttributes attributes); | 
 | 211 |  | 
| Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 212 | Handle<Object> SetNormalizedProperty(Handle<JSObject> object, | 
 | 213 |                                      Handle<String> key, | 
 | 214 |                                      Handle<Object> value, | 
 | 215 |                                      PropertyDetails details); | 
 | 216 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 217 | Handle<Object> ForceDeleteProperty(Handle<JSObject> object, | 
 | 218 |                                    Handle<Object> key); | 
 | 219 |  | 
 | 220 | Handle<Object> IgnoreAttributesAndSetLocalProperty(Handle<JSObject> object, | 
 | 221 |                                                    Handle<String> key, | 
 | 222 |                                                    Handle<Object> value, | 
 | 223 |     PropertyAttributes attributes); | 
 | 224 |  | 
 | 225 | Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, | 
 | 226 |                                           Handle<String> key, | 
 | 227 |                                           Handle<Object> value, | 
 | 228 |                                           PropertyAttributes attributes); | 
 | 229 |  | 
 | 230 | Handle<Object> SetElement(Handle<JSObject> object, | 
 | 231 |                           uint32_t index, | 
 | 232 |                           Handle<Object> value); | 
 | 233 |  | 
 | 234 | Handle<Object> GetProperty(Handle<JSObject> obj, | 
 | 235 |                            const char* name); | 
 | 236 |  | 
 | 237 | Handle<Object> GetProperty(Handle<Object> obj, | 
 | 238 |                            Handle<Object> key); | 
 | 239 |  | 
| Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 240 | Handle<Object> GetElement(Handle<Object> obj, | 
 | 241 |                           uint32_t index); | 
 | 242 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 243 | Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver, | 
 | 244 |                                           Handle<JSObject> holder, | 
 | 245 |                                           Handle<String> name, | 
 | 246 |                                           PropertyAttributes* attributes); | 
 | 247 |  | 
 | 248 | Handle<Object> GetPrototype(Handle<Object> obj); | 
 | 249 |  | 
| Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 250 | Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value); | 
 | 251 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 252 | // Return the object's hidden properties object. If the object has no hidden | 
 | 253 | // properties and create_if_needed is true, then a new hidden property object | 
 | 254 | // will be allocated. Otherwise the Heap::undefined_value is returned. | 
 | 255 | Handle<Object> GetHiddenProperties(Handle<JSObject> obj, bool create_if_needed); | 
 | 256 |  | 
 | 257 | Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); | 
 | 258 | Handle<Object> DeleteProperty(Handle<JSObject> obj, Handle<String> prop); | 
 | 259 |  | 
 | 260 | Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index); | 
 | 261 |  | 
 | 262 | Handle<JSObject> Copy(Handle<JSObject> obj); | 
 | 263 |  | 
| Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 264 | Handle<Object> SetAccessor(Handle<JSObject> obj, Handle<AccessorInfo> info); | 
 | 265 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 266 | Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray>, | 
 | 267 |                                       Handle<JSArray> array); | 
 | 268 |  | 
 | 269 | // Get the JS object corresponding to the given script; create it | 
 | 270 | // if none exists. | 
 | 271 | Handle<JSValue> GetScriptWrapper(Handle<Script> script); | 
 | 272 |  | 
 | 273 | // Script line number computations. | 
 | 274 | void InitScriptLineEnds(Handle<Script> script); | 
| Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 275 | // For string calculates an array of line end positions. If the string | 
 | 276 | // does not end with a new line character, this character may optionally be | 
 | 277 | // imagined. | 
 | 278 | Handle<FixedArray> CalculateLineEnds(Handle<String> string, | 
 | 279 |                                      bool with_imaginary_last_new_line); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 280 | int GetScriptLineNumber(Handle<Script> script, int code_position); | 
| Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 281 | // The safe version does not make heap allocations but may work much slower. | 
 | 282 | int GetScriptLineNumberSafe(Handle<Script> script, int code_position); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 283 |  | 
 | 284 | // Computes the enumerable keys from interceptors. Used for debug mirrors and | 
 | 285 | // by GetKeysInFixedArrayFor below. | 
 | 286 | v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, | 
 | 287 |                                                  Handle<JSObject> object); | 
 | 288 | v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSObject> receiver, | 
 | 289 |                                                    Handle<JSObject> object); | 
 | 290 |  | 
 | 291 | enum KeyCollectionType { LOCAL_ONLY, INCLUDE_PROTOS }; | 
 | 292 |  | 
 | 293 | // Computes the enumerable keys for a JSObject. Used for implementing | 
 | 294 | // "for (n in object) { }". | 
 | 295 | Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object, | 
 | 296 |                                           KeyCollectionType type); | 
 | 297 | Handle<JSArray> GetKeysFor(Handle<JSObject> object); | 
| Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 298 | Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, | 
 | 299 |                                        bool cache_result); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 300 |  | 
 | 301 | // Computes the union of keys and return the result. | 
 | 302 | // Used for implementing "for (n in object) { }" | 
 | 303 | Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first, | 
 | 304 |                                Handle<FixedArray> second); | 
 | 305 |  | 
| Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 306 | Handle<String> SubString(Handle<String> str, | 
 | 307 |                          int start, | 
 | 308 |                          int end, | 
 | 309 |                          PretenureFlag pretenure = NOT_TENURED); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 310 |  | 
 | 311 |  | 
 | 312 | // Sets the expected number of properties for the function's instances. | 
 | 313 | void SetExpectedNofProperties(Handle<JSFunction> func, int nof); | 
 | 314 |  | 
 | 315 | // Sets the prototype property for a function instance. | 
 | 316 | void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value); | 
 | 317 |  | 
 | 318 | // Sets the expected number of properties based on estimate from compiler. | 
 | 319 | void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, | 
 | 320 |                                           int estimate); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 321 |  | 
 | 322 |  | 
 | 323 | Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( | 
 | 324 |     Handle<JSFunction> constructor, | 
 | 325 |     Handle<JSGlobalProxy> global); | 
 | 326 |  | 
 | 327 | Handle<Object> SetPrototype(Handle<JSFunction> function, | 
 | 328 |                             Handle<Object> prototype); | 
 | 329 |  | 
 | 330 |  | 
| Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 331 | // Does lazy compilation of the given function. Returns true on success and | 
 | 332 | // false if the compilation resulted in a stack overflow. | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 333 | enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; | 
 | 334 |  | 
| Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 335 | bool EnsureCompiled(Handle<SharedFunctionInfo> shared, | 
 | 336 |                     ClearExceptionFlag flag); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 337 |  | 
| Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 338 | bool CompileLazyShared(Handle<SharedFunctionInfo> shared, | 
 | 339 |                        ClearExceptionFlag flag); | 
 | 340 |  | 
| Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 341 | bool CompileLazy(Handle<JSFunction> function, ClearExceptionFlag flag); | 
| Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 342 |  | 
| Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 343 | bool CompileLazyInLoop(Handle<JSFunction> function, ClearExceptionFlag flag); | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 344 |  | 
| Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 345 | bool CompileOptimized(Handle<JSFunction> function, int osr_ast_id); | 
 | 346 |  | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 347 | class NoHandleAllocation BASE_EMBEDDED { | 
 | 348 |  public: | 
 | 349 | #ifndef DEBUG | 
 | 350 |   NoHandleAllocation() {} | 
 | 351 |   ~NoHandleAllocation() {} | 
 | 352 | #else | 
 | 353 |   inline NoHandleAllocation(); | 
 | 354 |   inline ~NoHandleAllocation(); | 
 | 355 |  private: | 
| John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 356 |   int level_; | 
| Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 357 | #endif | 
 | 358 | }; | 
 | 359 |  | 
 | 360 |  | 
 | 361 | // ---------------------------------------------------------------------------- | 
 | 362 |  | 
 | 363 |  | 
 | 364 | // Stack allocated wrapper call for optimizing adding multiple | 
 | 365 | // properties to an object. | 
 | 366 | class OptimizedObjectForAddingMultipleProperties BASE_EMBEDDED { | 
 | 367 |  public: | 
 | 368 |   OptimizedObjectForAddingMultipleProperties(Handle<JSObject> object, | 
 | 369 |                                              int expected_property_count, | 
 | 370 |                                              bool condition = true); | 
 | 371 |   ~OptimizedObjectForAddingMultipleProperties(); | 
 | 372 |  private: | 
 | 373 |   bool has_been_transformed_;  // Tells whether the object has been transformed. | 
 | 374 |   int unused_property_fields_;  // Captures the unused number of field. | 
 | 375 |   Handle<JSObject> object_;    // The object being optimized. | 
 | 376 | }; | 
 | 377 |  | 
 | 378 |  | 
 | 379 | } }  // namespace v8::internal | 
 | 380 |  | 
 | 381 | #endif  // V8_HANDLES_H_ |