Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 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 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 32 | #include "apiutils.h" |
| 33 | |
| 34 | namespace v8 { |
| 35 | namespace internal { |
| 36 | |
| 37 | // ---------------------------------------------------------------------------- |
| 38 | // A Handle provides a reference to an object that survives relocation by |
| 39 | // the garbage collector. |
| 40 | // Handles are only valid within a HandleScope. |
| 41 | // When a handle is created for an object a cell is allocated in the heap. |
| 42 | |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 43 | template<typename T> |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 44 | class Handle { |
| 45 | public: |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 46 | INLINE(explicit Handle(T** location)) { location_ = location; } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 47 | INLINE(explicit Handle(T* obj)); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 48 | INLINE(Handle(T* obj, Isolate* isolate)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 49 | |
| 50 | INLINE(Handle()) : location_(NULL) {} |
| 51 | |
| 52 | // Constructor for handling automatic up casting. |
| 53 | // Ex. Handle<JSFunction> can be passed when Handle<Object> is expected. |
| 54 | template <class S> Handle(Handle<S> handle) { |
| 55 | #ifdef DEBUG |
| 56 | T* a = NULL; |
| 57 | S* b = NULL; |
| 58 | a = b; // Fake assignment to enforce type checks. |
| 59 | USE(a); |
| 60 | #endif |
| 61 | location_ = reinterpret_cast<T**>(handle.location()); |
| 62 | } |
| 63 | |
| 64 | INLINE(T* operator ->() const) { return operator*(); } |
| 65 | |
| 66 | // Check if this handle refers to the exact same object as the other handle. |
| 67 | bool is_identical_to(const Handle<T> other) const { |
| 68 | return operator*() == *other; |
| 69 | } |
| 70 | |
| 71 | // Provides the C++ dereference operator. |
| 72 | INLINE(T* operator*() const); |
| 73 | |
| 74 | // Returns the address to where the raw pointer is stored. |
| 75 | T** location() const { |
| 76 | ASSERT(location_ == NULL || |
| 77 | reinterpret_cast<Address>(*location_) != kZapValue); |
| 78 | return location_; |
| 79 | } |
| 80 | |
| 81 | template <class S> static Handle<T> cast(Handle<S> that) { |
| 82 | T::cast(*that); |
| 83 | return Handle<T>(reinterpret_cast<T**>(that.location())); |
| 84 | } |
| 85 | |
| 86 | static Handle<T> null() { return Handle<T>(); } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 87 | bool is_null() const { return location_ == NULL; } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 88 | |
| 89 | // Closes the given scope, but lets this handle escape. See |
| 90 | // implementation in api.h. |
| 91 | inline Handle<T> EscapeFrom(v8::HandleScope* scope); |
| 92 | |
| 93 | private: |
| 94 | T** location_; |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | // A stack-allocated class that governs a number of local handles. |
| 99 | // After a handle scope has been created, all local handles will be |
| 100 | // allocated within that handle scope until either the handle scope is |
| 101 | // 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 |
| 103 | // place in the new handle scope until it is deleted. After that, |
| 104 | // new handles will again be allocated in the original handle scope. |
| 105 | // |
| 106 | // After the handle scope of a local handle has been deleted the |
| 107 | // garbage collector will no longer track the object stored in the |
| 108 | // handle and may deallocate it. The behavior of accessing a handle |
| 109 | // for which the handle scope has been deleted is undefined. |
| 110 | class HandleScope { |
| 111 | public: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 112 | inline HandleScope(); |
| 113 | explicit inline HandleScope(Isolate* isolate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 114 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 115 | inline ~HandleScope(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 116 | |
| 117 | // Counts the number of allocated handles. |
| 118 | static int NumberOfHandles(); |
| 119 | |
| 120 | // Creates a new handle with the given value. |
| 121 | template <typename T> |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 122 | static inline T** CreateHandle(T* value, Isolate* isolate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 123 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 124 | // Deallocates any extensions used by the current scope. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 125 | static void DeleteExtensions(Isolate* isolate); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 126 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 127 | static Address current_next_address(); |
| 128 | static Address current_limit_address(); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 129 | static Address current_level_address(); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 130 | |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 131 | // Closes the HandleScope (invalidating all handles |
| 132 | // created in the scope of the HandleScope) and returns |
| 133 | // a Handle backed by the parent scope holding the |
| 134 | // value of the argument handle. |
| 135 | template <typename T> |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 136 | Handle<T> CloseAndEscape(Handle<T> handle_value); |
| 137 | |
| 138 | Isolate* isolate() { return isolate_; } |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 139 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 140 | private: |
| 141 | // Prevent heap allocation or illegal handle scopes. |
| 142 | HandleScope(const HandleScope&); |
| 143 | void operator=(const HandleScope&); |
| 144 | void* operator new(size_t size); |
| 145 | void operator delete(void* size_t); |
| 146 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 147 | inline void CloseScope(); |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 148 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 149 | Isolate* isolate_; |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 150 | Object** prev_next_; |
| 151 | Object** prev_limit_; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 152 | |
| 153 | // Extend the handle scope making room for more handles. |
| 154 | static internal::Object** Extend(); |
| 155 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 156 | // Zaps the handles in the half-open interval [start, end). |
| 157 | static void ZapRange(internal::Object** start, internal::Object** end); |
| 158 | |
| 159 | friend class v8::HandleScope; |
| 160 | friend class v8::ImplementationUtilities; |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | // ---------------------------------------------------------------------------- |
| 165 | // Handle operations. |
| 166 | // 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 |
| 168 | // of space or encountering an internal error. |
| 169 | |
| 170 | void NormalizeProperties(Handle<JSObject> object, |
| 171 | PropertyNormalizationMode mode, |
| 172 | int expected_additional_properties); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 173 | Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 174 | void TransformToFastProperties(Handle<JSObject> object, |
| 175 | int unused_property_fields); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 176 | MUST_USE_RESULT Handle<NumberDictionary> NumberDictionarySet( |
| 177 | Handle<NumberDictionary> dictionary, |
| 178 | uint32_t index, |
| 179 | Handle<Object> value, |
| 180 | PropertyDetails details); |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 181 | |
| 182 | // Flattens a string. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 183 | void FlattenString(Handle<String> str); |
| 184 | |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 185 | // Flattens a string and returns the underlying external or sequential |
| 186 | // string. |
| 187 | Handle<String> FlattenGetString(Handle<String> str); |
| 188 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 189 | Handle<Object> SetProperty(Handle<JSReceiver> object, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 190 | Handle<String> key, |
| 191 | Handle<Object> value, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 192 | PropertyAttributes attributes, |
| 193 | StrictModeFlag strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 194 | |
| 195 | Handle<Object> SetProperty(Handle<Object> object, |
| 196 | Handle<Object> key, |
| 197 | Handle<Object> value, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 198 | PropertyAttributes attributes, |
| 199 | StrictModeFlag strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 200 | |
| 201 | Handle<Object> ForceSetProperty(Handle<JSObject> object, |
| 202 | Handle<Object> key, |
| 203 | Handle<Object> value, |
| 204 | PropertyAttributes attributes); |
| 205 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 206 | Handle<Object> SetNormalizedProperty(Handle<JSObject> object, |
| 207 | Handle<String> key, |
| 208 | Handle<Object> value, |
| 209 | PropertyDetails details); |
| 210 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 211 | Handle<Object> ForceDeleteProperty(Handle<JSObject> object, |
| 212 | Handle<Object> key); |
| 213 | |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 214 | Handle<Object> SetLocalPropertyIgnoreAttributes( |
| 215 | Handle<JSObject> object, |
| 216 | Handle<String> key, |
| 217 | Handle<Object> value, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 218 | PropertyAttributes attributes); |
| 219 | |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 220 | // Used to set local properties on the object we totally control |
| 221 | // and which therefore has no accessors and alikes. |
| 222 | void SetLocalPropertyNoThrow(Handle<JSObject> object, |
| 223 | Handle<String> key, |
| 224 | Handle<Object> value, |
| 225 | PropertyAttributes attributes = NONE); |
| 226 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 227 | Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, |
| 228 | Handle<String> key, |
| 229 | Handle<Object> value, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 230 | PropertyAttributes attributes, |
| 231 | StrictModeFlag strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 232 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 233 | MUST_USE_RESULT Handle<Object> SetElement(Handle<JSObject> object, |
| 234 | uint32_t index, |
| 235 | Handle<Object> value, |
| 236 | StrictModeFlag strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 237 | |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 238 | Handle<Object> SetOwnElement(Handle<JSObject> object, |
| 239 | uint32_t index, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 240 | Handle<Object> value, |
| 241 | StrictModeFlag strict_mode); |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 242 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 243 | Handle<Object> GetProperty(Handle<JSReceiver> obj, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 244 | const char* name); |
| 245 | |
| 246 | Handle<Object> GetProperty(Handle<Object> obj, |
| 247 | Handle<Object> key); |
| 248 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 249 | Handle<Object> GetProperty(Handle<JSReceiver> obj, |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 250 | Handle<String> name, |
| 251 | LookupResult* result); |
| 252 | |
| 253 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 254 | Handle<Object> GetElement(Handle<Object> obj, |
| 255 | uint32_t index); |
| 256 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 257 | Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver, |
| 258 | Handle<JSObject> holder, |
| 259 | Handle<String> name, |
| 260 | PropertyAttributes* attributes); |
| 261 | |
| 262 | Handle<Object> GetPrototype(Handle<Object> obj); |
| 263 | |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 264 | Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value); |
| 265 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 266 | // Return the object's hidden properties object. If the object has no hidden |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame^] | 267 | // properties and HiddenPropertiesFlag::ALLOW_CREATION is passed, then a new |
| 268 | // hidden property object will be allocated. Otherwise Heap::undefined_value |
| 269 | // is returned. |
| 270 | Handle<Object> GetHiddenProperties(Handle<JSObject> obj, |
| 271 | JSObject::HiddenPropertiesFlag flag); |
| 272 | |
| 273 | int GetIdentityHash(Handle<JSObject> obj); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 274 | |
| 275 | Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); |
| 276 | Handle<Object> DeleteProperty(Handle<JSObject> obj, Handle<String> prop); |
| 277 | |
| 278 | Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index); |
| 279 | |
| 280 | Handle<JSObject> Copy(Handle<JSObject> obj); |
| 281 | |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 282 | Handle<Object> SetAccessor(Handle<JSObject> obj, Handle<AccessorInfo> info); |
| 283 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 284 | Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray>, |
| 285 | Handle<JSArray> array); |
| 286 | |
| 287 | // Get the JS object corresponding to the given script; create it |
| 288 | // if none exists. |
| 289 | Handle<JSValue> GetScriptWrapper(Handle<Script> script); |
| 290 | |
| 291 | // Script line number computations. |
| 292 | void InitScriptLineEnds(Handle<Script> script); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 293 | // For string calculates an array of line end positions. If the string |
| 294 | // does not end with a new line character, this character may optionally be |
| 295 | // imagined. |
| 296 | Handle<FixedArray> CalculateLineEnds(Handle<String> string, |
| 297 | bool with_imaginary_last_new_line); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 298 | int GetScriptLineNumber(Handle<Script> script, int code_position); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 299 | // The safe version does not make heap allocations but may work much slower. |
| 300 | int GetScriptLineNumberSafe(Handle<Script> script, int code_position); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 301 | |
| 302 | // Computes the enumerable keys from interceptors. Used for debug mirrors and |
| 303 | // by GetKeysInFixedArrayFor below. |
| 304 | v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver, |
| 305 | Handle<JSObject> object); |
| 306 | v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSObject> receiver, |
| 307 | Handle<JSObject> object); |
| 308 | |
| 309 | enum KeyCollectionType { LOCAL_ONLY, INCLUDE_PROTOS }; |
| 310 | |
| 311 | // Computes the enumerable keys for a JSObject. Used for implementing |
| 312 | // "for (n in object) { }". |
| 313 | Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object, |
| 314 | KeyCollectionType type); |
| 315 | Handle<JSArray> GetKeysFor(Handle<JSObject> object); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 316 | Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, |
| 317 | bool cache_result); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 318 | |
| 319 | // Computes the union of keys and return the result. |
| 320 | // Used for implementing "for (n in object) { }" |
| 321 | Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first, |
| 322 | Handle<FixedArray> second); |
| 323 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 324 | Handle<String> SubString(Handle<String> str, |
| 325 | int start, |
| 326 | int end, |
| 327 | PretenureFlag pretenure = NOT_TENURED); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 328 | |
| 329 | |
| 330 | // Sets the expected number of properties for the function's instances. |
| 331 | void SetExpectedNofProperties(Handle<JSFunction> func, int nof); |
| 332 | |
| 333 | // Sets the prototype property for a function instance. |
| 334 | void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value); |
| 335 | |
| 336 | // Sets the expected number of properties based on estimate from compiler. |
| 337 | void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, |
| 338 | int estimate); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 339 | |
| 340 | |
| 341 | Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( |
| 342 | Handle<JSFunction> constructor, |
| 343 | Handle<JSGlobalProxy> global); |
| 344 | |
| 345 | Handle<Object> SetPrototype(Handle<JSFunction> function, |
| 346 | Handle<Object> prototype); |
| 347 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 348 | Handle<Object> PreventExtensions(Handle<JSObject> object); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 349 | |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame^] | 350 | Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, |
| 351 | Handle<JSObject> key, |
| 352 | Handle<Object> value); |
| 353 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 354 | // Does lazy compilation of the given function. Returns true on success and |
| 355 | // false if the compilation resulted in a stack overflow. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 356 | enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; |
| 357 | |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 358 | bool EnsureCompiled(Handle<SharedFunctionInfo> shared, |
| 359 | ClearExceptionFlag flag); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 360 | |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 361 | bool CompileLazyShared(Handle<SharedFunctionInfo> shared, |
| 362 | ClearExceptionFlag flag); |
| 363 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 364 | bool CompileLazy(Handle<JSFunction> function, ClearExceptionFlag flag); |
Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame] | 365 | |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 366 | bool CompileLazyInLoop(Handle<JSFunction> function, ClearExceptionFlag flag); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 367 | |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 368 | bool CompileOptimized(Handle<JSFunction> function, |
| 369 | int osr_ast_id, |
| 370 | ClearExceptionFlag flag); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 371 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 372 | class NoHandleAllocation BASE_EMBEDDED { |
| 373 | public: |
| 374 | #ifndef DEBUG |
| 375 | NoHandleAllocation() {} |
| 376 | ~NoHandleAllocation() {} |
| 377 | #else |
| 378 | inline NoHandleAllocation(); |
| 379 | inline ~NoHandleAllocation(); |
| 380 | private: |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 381 | int level_; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 382 | #endif |
| 383 | }; |
| 384 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 385 | } } // namespace v8::internal |
| 386 | |
| 387 | #endif // V8_HANDLES_H_ |