| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 * | 152 * |
| 153 * There are two types of handles: local and persistent handles. | 153 * There are two types of handles: local and persistent handles. |
| 154 * Local handles are light-weight and transient and typically used in | 154 * Local handles are light-weight and transient and typically used in |
| 155 * local operations. They are managed by HandleScopes. Persistent | 155 * local operations. They are managed by HandleScopes. Persistent |
| 156 * handles can be used when storing objects across several independent | 156 * handles can be used when storing objects across several independent |
| 157 * operations and have to be explicitly deallocated when they're no | 157 * operations and have to be explicitly deallocated when they're no |
| 158 * longer used. | 158 * longer used. |
| 159 * | 159 * |
| 160 * It is safe to extract the object stored in the handle by | 160 * It is safe to extract the object stored in the handle by |
| 161 * dereferencing the handle (for instance, to extract the Object* from | 161 * dereferencing the handle (for instance, to extract the Object* from |
| 162 * an Handle<Object>); the value will still be governed by a handle | 162 * a Handle<Object>); the value will still be governed by a handle |
| 163 * behind the scenes and the same rules apply to these values as to | 163 * behind the scenes and the same rules apply to these values as to |
| 164 * their handles. | 164 * their handles. |
| 165 */ | 165 */ |
| 166 template <class T> class Handle { | 166 template <class T> class Handle { |
| 167 public: | 167 public: |
| 168 | 168 |
| 169 /** | 169 /** |
| 170 * Creates an empty handle. | 170 * Creates an empty handle. |
| 171 */ | 171 */ |
| 172 inline Handle(); | 172 inline Handle(); |
| 173 | 173 |
| 174 /** | 174 /** |
| 175 * Creates a new handle for the specified value. | 175 * Creates a new handle for the specified value. |
| 176 */ | 176 */ |
| 177 inline explicit Handle(T* val) : val_(val) { } | 177 inline explicit Handle(T* val) : val_(val) { } |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * Creates a handle for the contents of the specified handle. This | 180 * Creates a handle for the contents of the specified handle. This |
| 181 * constructor allows you to pass handles as arguments by value and | 181 * constructor allows you to pass handles as arguments by value and |
| 182 * to assign between handles. However, if you try to assign between | 182 * to assign between handles. However, if you try to assign between |
| 183 * incompatible handles, for instance from a Handle<String> to a | 183 * incompatible handles, for instance from a Handle<String> to a |
| 184 * Handle<Number> it will cause a compiletime error. Assigning | 184 * Handle<Number> it will cause a compile-time error. Assigning |
| 185 * between compatible handles, for instance assigning a | 185 * between compatible handles, for instance assigning a |
| 186 * Handle<String> to a variable declared as Handle<Value>, is legal | 186 * Handle<String> to a variable declared as Handle<Value>, is legal |
| 187 * because String is a subclass of Value. | 187 * because String is a subclass of Value. |
| 188 */ | 188 */ |
| 189 template <class S> inline Handle(Handle<S> that) | 189 template <class S> inline Handle(Handle<S> that) |
| 190 : val_(reinterpret_cast<T*>(*that)) { | 190 : val_(reinterpret_cast<T*>(*that)) { |
| 191 /** | 191 /** |
| 192 * This check fails when trying to convert between incompatible | 192 * This check fails when trying to convert between incompatible |
| 193 * handles. For example, converting from a Handle<String> to a | 193 * handles. For example, converting from a Handle<String> to a |
| 194 * Handle<Number>. | 194 * Handle<Number>. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 * storage cell. | 318 * storage cell. |
| 319 */ | 319 */ |
| 320 inline Persistent(); | 320 inline Persistent(); |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * Creates a persistent handle for the same storage cell as the | 323 * Creates a persistent handle for the same storage cell as the |
| 324 * specified handle. This constructor allows you to pass persistent | 324 * specified handle. This constructor allows you to pass persistent |
| 325 * handles as arguments by value and to assign between persistent | 325 * handles as arguments by value and to assign between persistent |
| 326 * handles. However, attempting to assign between incompatible | 326 * handles. However, attempting to assign between incompatible |
| 327 * persistent handles, for instance from a Persistent<String> to a | 327 * persistent handles, for instance from a Persistent<String> to a |
| 328 * Persistent<Number> will cause a compiletime error. Assigning | 328 * Persistent<Number> will cause a compile-time error. Assigning |
| 329 * between compatible persistent handles, for instance assigning a | 329 * between compatible persistent handles, for instance assigning a |
| 330 * Persistent<String> to a variable declared as Persistent<Value>, | 330 * Persistent<String> to a variable declared as Persistent<Value>, |
| 331 * is allowed as String is a subclass of Value. | 331 * is allowed as String is a subclass of Value. |
| 332 */ | 332 */ |
| 333 template <class S> inline Persistent(Persistent<S> that) | 333 template <class S> inline Persistent(Persistent<S> that) |
| 334 : Handle<T>(reinterpret_cast<T*>(*that)) { | 334 : Handle<T>(reinterpret_cast<T*>(*that)) { |
| 335 /** | 335 /** |
| 336 * This check fails when trying to convert between incompatible | 336 * This check fails when trying to convert between incompatible |
| 337 * handles. For example, converting from a Handle<String> to a | 337 * handles. For example, converting from a Handle<String> to a |
| 338 * Handle<Number>. | 338 * Handle<Number>. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 364 | 364 |
| 365 /** | 365 /** |
| 366 * Creates a new persistent handle for an existing local or | 366 * Creates a new persistent handle for an existing local or |
| 367 * persistent handle. | 367 * persistent handle. |
| 368 */ | 368 */ |
| 369 inline static Persistent<T> New(Handle<T> that); | 369 inline static Persistent<T> New(Handle<T> that); |
| 370 | 370 |
| 371 /** | 371 /** |
| 372 * Releases the storage cell referenced by this persistent handle. | 372 * Releases the storage cell referenced by this persistent handle. |
| 373 * Does not remove the reference to the cell from any handles. | 373 * Does not remove the reference to the cell from any handles. |
| 374 * This handle's reference, and any any other references to the storage | 374 * This handle's reference, and any other references to the storage |
| 375 * cell remain and IsEmpty will still return false. | 375 * cell remain and IsEmpty will still return false. |
| 376 */ | 376 */ |
| 377 inline void Dispose(); | 377 inline void Dispose(); |
| 378 | 378 |
| 379 /** | 379 /** |
| 380 * Make the reference to this object weak. When only weak handles | 380 * Make the reference to this object weak. When only weak handles |
| 381 * refer to the object, the garbage collector will perform a | 381 * refer to the object, the garbage collector will perform a |
| 382 * callback to the given V8::WeakReferenceCallback function, passing | 382 * callback to the given V8::WeakReferenceCallback function, passing |
| 383 * it the object reference and the given parameters. | 383 * it the object reference and the given parameters. |
| 384 */ | 384 */ |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 * Returns the number of StackFrames. | 768 * Returns the number of StackFrames. |
| 769 */ | 769 */ |
| 770 int GetFrameCount() const; | 770 int GetFrameCount() const; |
| 771 | 771 |
| 772 /** | 772 /** |
| 773 * Returns StackTrace as a v8::Array that contains StackFrame objects. | 773 * Returns StackTrace as a v8::Array that contains StackFrame objects. |
| 774 */ | 774 */ |
| 775 Local<Array> AsArray(); | 775 Local<Array> AsArray(); |
| 776 | 776 |
| 777 /** | 777 /** |
| 778 * Grab a snapshot of the the current JavaScript execution stack. | 778 * Grab a snapshot of the current JavaScript execution stack. |
| 779 * | 779 * |
| 780 * \param frame_limit The maximum number of stack frames we want to capture. | 780 * \param frame_limit The maximum number of stack frames we want to capture. |
| 781 * \param options Enumerates the set of things we will capture for each | 781 * \param options Enumerates the set of things we will capture for each |
| 782 * StackFrame. | 782 * StackFrame. |
| 783 */ | 783 */ |
| 784 static Local<StackTrace> CurrentStackTrace( | 784 static Local<StackTrace> CurrentStackTrace( |
| 785 int frame_limit, | 785 int frame_limit, |
| 786 StackTraceOptions options = kOverview); | 786 StackTraceOptions options = kOverview); |
| 787 }; | 787 }; |
| 788 | 788 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 */ | 827 */ |
| 828 Local<String> GetFunctionName() const; | 828 Local<String> GetFunctionName() const; |
| 829 | 829 |
| 830 /** | 830 /** |
| 831 * Returns whether or not the associated function is compiled via a call to | 831 * Returns whether or not the associated function is compiled via a call to |
| 832 * eval(). | 832 * eval(). |
| 833 */ | 833 */ |
| 834 bool IsEval() const; | 834 bool IsEval() const; |
| 835 | 835 |
| 836 /** | 836 /** |
| 837 * Returns whther or not the associated function is called as a | 837 * Returns whether or not the associated function is called as a |
| 838 * constructor via "new". | 838 * constructor via "new". |
| 839 */ | 839 */ |
| 840 bool IsConstructor() const; | 840 bool IsConstructor() const; |
| 841 }; | 841 }; |
| 842 | 842 |
| 843 | 843 |
| 844 // --- Value --- | 844 // --- Value --- |
| 845 | 845 |
| 846 | 846 |
| 847 /** | 847 /** |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 * this function should not otherwise delete or modify the resource. Neither | 1175 * this function should not otherwise delete or modify the resource. Neither |
| 1176 * should the underlying buffer be deallocated or modified except through the | 1176 * should the underlying buffer be deallocated or modified except through the |
| 1177 * destructor of the external string resource. | 1177 * destructor of the external string resource. |
| 1178 */ | 1178 */ |
| 1179 V8EXPORT static Local<String> NewExternal(ExternalStringResource* resource); | 1179 V8EXPORT static Local<String> NewExternal(ExternalStringResource* resource); |
| 1180 | 1180 |
| 1181 /** | 1181 /** |
| 1182 * Associate an external string resource with this string by transforming it | 1182 * Associate an external string resource with this string by transforming it |
| 1183 * in place so that existing references to this string in the JavaScript heap | 1183 * in place so that existing references to this string in the JavaScript heap |
| 1184 * will use the external string resource. The external string resource's | 1184 * will use the external string resource. The external string resource's |
| 1185 * character contents needs to be equivalent to this string. | 1185 * character contents need to be equivalent to this string. |
| 1186 * Returns true if the string has been changed to be an external string. | 1186 * Returns true if the string has been changed to be an external string. |
| 1187 * The string is not modified if the operation fails. See NewExternal for | 1187 * The string is not modified if the operation fails. See NewExternal for |
| 1188 * information on the lifetime of the resource. | 1188 * information on the lifetime of the resource. |
| 1189 */ | 1189 */ |
| 1190 V8EXPORT bool MakeExternal(ExternalStringResource* resource); | 1190 V8EXPORT bool MakeExternal(ExternalStringResource* resource); |
| 1191 | 1191 |
| 1192 /** | 1192 /** |
| 1193 * Creates a new external string using the ascii data defined in the given | 1193 * Creates a new external string using the ascii data defined in the given |
| 1194 * resource. When the external string is no longer live on V8's heap the | 1194 * resource. When the external string is no longer live on V8's heap the |
| 1195 * resource will be disposed by calling its Dispose method. The caller of | 1195 * resource will be disposed by calling its Dispose method. The caller of |
| 1196 * this function should not otherwise delete or modify the resource. Neither | 1196 * this function should not otherwise delete or modify the resource. Neither |
| 1197 * should the underlying buffer be deallocated or modified except through the | 1197 * should the underlying buffer be deallocated or modified except through the |
| 1198 * destructor of the external string resource. | 1198 * destructor of the external string resource. |
| 1199 */ | 1199 */ |
| 1200 V8EXPORT static Local<String> NewExternal( | 1200 V8EXPORT static Local<String> NewExternal( |
| 1201 ExternalAsciiStringResource* resource); | 1201 ExternalAsciiStringResource* resource); |
| 1202 | 1202 |
| 1203 /** | 1203 /** |
| 1204 * Associate an external string resource with this string by transforming it | 1204 * Associate an external string resource with this string by transforming it |
| 1205 * in place so that existing references to this string in the JavaScript heap | 1205 * in place so that existing references to this string in the JavaScript heap |
| 1206 * will use the external string resource. The external string resource's | 1206 * will use the external string resource. The external string resource's |
| 1207 * character contents needs to be equivalent to this string. | 1207 * character contents need to be equivalent to this string. |
| 1208 * Returns true if the string has been changed to be an external string. | 1208 * Returns true if the string has been changed to be an external string. |
| 1209 * The string is not modified if the operation fails. See NewExternal for | 1209 * The string is not modified if the operation fails. See NewExternal for |
| 1210 * information on the lifetime of the resource. | 1210 * information on the lifetime of the resource. |
| 1211 */ | 1211 */ |
| 1212 V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource); | 1212 V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource); |
| 1213 | 1213 |
| 1214 /** | 1214 /** |
| 1215 * Returns true if this string can be made external. | 1215 * Returns true if this string can be made external. |
| 1216 */ | 1216 */ |
| 1217 V8EXPORT bool CanMakeExternal(); | 1217 V8EXPORT bool CanMakeExternal(); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 V8EXPORT bool HasIndexedLookupInterceptor(); | 1533 V8EXPORT bool HasIndexedLookupInterceptor(); |
| 1534 | 1534 |
| 1535 /** | 1535 /** |
| 1536 * Turns on access check on the object if the object is an instance of | 1536 * Turns on access check on the object if the object is an instance of |
| 1537 * a template that has access check callbacks. If an object has no | 1537 * a template that has access check callbacks. If an object has no |
| 1538 * access check info, the object cannot be accessed by anyone. | 1538 * access check info, the object cannot be accessed by anyone. |
| 1539 */ | 1539 */ |
| 1540 V8EXPORT void TurnOnAccessCheck(); | 1540 V8EXPORT void TurnOnAccessCheck(); |
| 1541 | 1541 |
| 1542 /** | 1542 /** |
| 1543 * Returns the identity hash for this object. The current implemenation uses | 1543 * Returns the identity hash for this object. The current implementation |
| 1544 * a hidden property on the object to store the identity hash. | 1544 * uses a hidden property on the object to store the identity hash. |
| 1545 * | 1545 * |
| 1546 * The return value will never be 0. Also, it is not guaranteed to be | 1546 * The return value will never be 0. Also, it is not guaranteed to be |
| 1547 * unique. | 1547 * unique. |
| 1548 */ | 1548 */ |
| 1549 V8EXPORT int GetIdentityHash(); | 1549 V8EXPORT int GetIdentityHash(); |
| 1550 | 1550 |
| 1551 /** | 1551 /** |
| 1552 * Access hidden properties on JavaScript objects. These properties are | 1552 * Access hidden properties on JavaScript objects. These properties are |
| 1553 * hidden from the executing JavaScript and only accessible through the V8 | 1553 * hidden from the executing JavaScript and only accessible through the V8 |
| 1554 * C++ API. Hidden properties introduced by V8 internally (for example the | 1554 * C++ API. Hidden properties introduced by V8 internally (for example the |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 | 1615 |
| 1616 /** | 1616 /** |
| 1617 * Call an Object as a function if a callback is set by the | 1617 * Call an Object as a function if a callback is set by the |
| 1618 * ObjectTemplate::SetCallAsFunctionHandler method. | 1618 * ObjectTemplate::SetCallAsFunctionHandler method. |
| 1619 */ | 1619 */ |
| 1620 V8EXPORT Local<Value> CallAsFunction(Handle<Object> recv, | 1620 V8EXPORT Local<Value> CallAsFunction(Handle<Object> recv, |
| 1621 int argc, | 1621 int argc, |
| 1622 Handle<Value> argv[]); | 1622 Handle<Value> argv[]); |
| 1623 | 1623 |
| 1624 /** | 1624 /** |
| 1625 * Call an Object as a consturctor if a callback is set by the | 1625 * Call an Object as a constructor if a callback is set by the |
| 1626 * ObjectTemplate::SetCallAsFunctionHandler method. | 1626 * ObjectTemplate::SetCallAsFunctionHandler method. |
| 1627 * Note: This method behaves like the Function::NewInstance method. | 1627 * Note: This method behaves like the Function::NewInstance method. |
| 1628 */ | 1628 */ |
| 1629 V8EXPORT Local<Value> CallAsConstructor(int argc, | 1629 V8EXPORT Local<Value> CallAsConstructor(int argc, |
| 1630 Handle<Value> argv[]); | 1630 Handle<Value> argv[]); |
| 1631 | 1631 |
| 1632 V8EXPORT static Local<Object> New(); | 1632 V8EXPORT static Local<Object> New(); |
| 1633 static inline Object* Cast(Value* obj); | 1633 static inline Object* Cast(Value* obj); |
| 1634 private: | 1634 private: |
| 1635 V8EXPORT Object(); | 1635 V8EXPORT Object(); |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2236 | 2236 |
| 2237 /** | 2237 /** |
| 2238 * Sets an indexed property handler on the object template. | 2238 * Sets an indexed property handler on the object template. |
| 2239 * | 2239 * |
| 2240 * Whenever an indexed property is accessed on objects created from | 2240 * Whenever an indexed property is accessed on objects created from |
| 2241 * this object template, the provided callback is invoked instead of | 2241 * this object template, the provided callback is invoked instead of |
| 2242 * accessing the property directly on the JavaScript object. | 2242 * accessing the property directly on the JavaScript object. |
| 2243 * | 2243 * |
| 2244 * \param getter The callback to invoke when getting a property. | 2244 * \param getter The callback to invoke when getting a property. |
| 2245 * \param setter The callback to invoke when setting a property. | 2245 * \param setter The callback to invoke when setting a property. |
| 2246 * \param query The callback to invoke to check is an object has a property. | 2246 * \param query The callback to invoke to check if an object has a property. |
| 2247 * \param deleter The callback to invoke when deleting a property. | 2247 * \param deleter The callback to invoke when deleting a property. |
| 2248 * \param enumerator The callback to invoke to enumerate all the indexed | 2248 * \param enumerator The callback to invoke to enumerate all the indexed |
| 2249 * properties of an object. | 2249 * properties of an object. |
| 2250 * \param data A piece of data that will be passed to the callbacks | 2250 * \param data A piece of data that will be passed to the callbacks |
| 2251 * whenever they are invoked. | 2251 * whenever they are invoked. |
| 2252 */ | 2252 */ |
| 2253 void SetIndexedPropertyHandler(IndexedPropertyGetter getter, | 2253 void SetIndexedPropertyHandler(IndexedPropertyGetter getter, |
| 2254 IndexedPropertySetter setter = 0, | 2254 IndexedPropertySetter setter = 0, |
| 2255 IndexedPropertyQuery query = 0, | 2255 IndexedPropertyQuery query = 0, |
| 2256 IndexedPropertyDeleter deleter = 0, | 2256 IndexedPropertyDeleter deleter = 0, |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2699 static void SetAllowCodeGenerationFromStringsCallback( | 2699 static void SetAllowCodeGenerationFromStringsCallback( |
| 2700 AllowCodeGenerationFromStringsCallback that); | 2700 AllowCodeGenerationFromStringsCallback that); |
| 2701 | 2701 |
| 2702 /** | 2702 /** |
| 2703 * Ignore out-of-memory exceptions. | 2703 * Ignore out-of-memory exceptions. |
| 2704 * | 2704 * |
| 2705 * V8 running out of memory is treated as a fatal error by default. | 2705 * V8 running out of memory is treated as a fatal error by default. |
| 2706 * This means that the fatal error handler is called and that V8 is | 2706 * This means that the fatal error handler is called and that V8 is |
| 2707 * terminated. | 2707 * terminated. |
| 2708 * | 2708 * |
| 2709 * IgnoreOutOfMemoryException can be used to not treat a | 2709 * IgnoreOutOfMemoryException can be used to not treat an |
| 2710 * out-of-memory situation as a fatal error. This way, the contexts | 2710 * out-of-memory situation as a fatal error. This way, the contexts |
| 2711 * that did not cause the out of memory problem might be able to | 2711 * that did not cause the out of memory problem might be able to |
| 2712 * continue execution. | 2712 * continue execution. |
| 2713 */ | 2713 */ |
| 2714 static void IgnoreOutOfMemoryException(); | 2714 static void IgnoreOutOfMemoryException(); |
| 2715 | 2715 |
| 2716 /** | 2716 /** |
| 2717 * Check if V8 is dead and therefore unusable. This is the case after | 2717 * Check if V8 is dead and therefore unusable. This is the case after |
| 2718 * fatal errors such as out-of-memory situations. | 2718 * fatal errors such as out-of-memory situations. |
| 2719 */ | 2719 */ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2735 * ... make sure the decompressed data stays valid until V8 shutdown | 2735 * ... make sure the decompressed data stays valid until V8 shutdown |
| 2736 */ | 2736 */ |
| 2737 static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm(); | 2737 static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm(); |
| 2738 static int GetCompressedStartupDataCount(); | 2738 static int GetCompressedStartupDataCount(); |
| 2739 static void GetCompressedStartupData(StartupData* compressed_data); | 2739 static void GetCompressedStartupData(StartupData* compressed_data); |
| 2740 static void SetDecompressedStartupData(StartupData* decompressed_data); | 2740 static void SetDecompressedStartupData(StartupData* decompressed_data); |
| 2741 | 2741 |
| 2742 /** | 2742 /** |
| 2743 * Adds a message listener. | 2743 * Adds a message listener. |
| 2744 * | 2744 * |
| 2745 * The same message listener can be added more than once and it that | 2745 * The same message listener can be added more than once and in that |
| 2746 * case it will be called more than once for each message. | 2746 * case it will be called more than once for each message. |
| 2747 */ | 2747 */ |
| 2748 static bool AddMessageListener(MessageCallback that, | 2748 static bool AddMessageListener(MessageCallback that, |
| 2749 Handle<Value> data = Handle<Value>()); | 2749 Handle<Value> data = Handle<Value>()); |
| 2750 | 2750 |
| 2751 /** | 2751 /** |
| 2752 * Remove all message listeners from the specified callback function. | 2752 * Remove all message listeners from the specified callback function. |
| 2753 */ | 2753 */ |
| 2754 static void RemoveMessageListeners(MessageCallback that); | 2754 static void RemoveMessageListeners(MessageCallback that); |
| 2755 | 2755 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3015 * | 3015 * |
| 3016 * TerminateExecution should only be called when then V8 lock has | 3016 * TerminateExecution should only be called when then V8 lock has |
| 3017 * been acquired with a Locker object. Therefore, in order to be | 3017 * been acquired with a Locker object. Therefore, in order to be |
| 3018 * able to terminate long-running threads, preemption must be | 3018 * able to terminate long-running threads, preemption must be |
| 3019 * enabled to allow the user of TerminateExecution to acquire the | 3019 * enabled to allow the user of TerminateExecution to acquire the |
| 3020 * lock. | 3020 * lock. |
| 3021 * | 3021 * |
| 3022 * The termination is achieved by throwing an exception that is | 3022 * The termination is achieved by throwing an exception that is |
| 3023 * uncatchable by JavaScript exception handlers. Termination | 3023 * uncatchable by JavaScript exception handlers. Termination |
| 3024 * exceptions act as if they were caught by a C++ TryCatch exception | 3024 * exceptions act as if they were caught by a C++ TryCatch exception |
| 3025 * handlers. If forceful termination is used, any C++ TryCatch | 3025 * handler. If forceful termination is used, any C++ TryCatch |
| 3026 * exception handler that catches an exception should check if that | 3026 * exception handler that catches an exception should check if that |
| 3027 * exception is a termination exception and immediately return if | 3027 * exception is a termination exception and immediately return if |
| 3028 * that is the case. Returning immediately in that case will | 3028 * that is the case. Returning immediately in that case will |
| 3029 * continue the propagation of the termination exception if needed. | 3029 * continue the propagation of the termination exception if needed. |
| 3030 * | 3030 * |
| 3031 * The thread id passed to TerminateExecution must have been | 3031 * The thread id passed to TerminateExecution must have been |
| 3032 * obtained by calling GetCurrentThreadId on the thread in question. | 3032 * obtained by calling GetCurrentThreadId on the thread in question. |
| 3033 * | 3033 * |
| 3034 * \param thread_id The thread id of the thread to terminate. | 3034 * \param thread_id The thread id of the thread to terminate. |
| 3035 */ | 3035 */ |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3419 * ... | 3419 * ... |
| 3420 * { | 3420 * { |
| 3421 * v8::Locker locker(isolate); | 3421 * v8::Locker locker(isolate); |
| 3422 * v8::Isolate::Scope isolate_scope(isolate); | 3422 * v8::Isolate::Scope isolate_scope(isolate); |
| 3423 * ... | 3423 * ... |
| 3424 * // Code using V8 and isolate goes here. | 3424 * // Code using V8 and isolate goes here. |
| 3425 * ... | 3425 * ... |
| 3426 * } // Destructor called here | 3426 * } // Destructor called here |
| 3427 * \endcode | 3427 * \endcode |
| 3428 * | 3428 * |
| 3429 * If you wish to stop using V8 in a thread A you can do this by either | 3429 * If you wish to stop using V8 in a thread A you can do this either |
| 3430 * by destroying the v8::Locker object as above or by constructing a | 3430 * by destroying the v8::Locker object as above or by constructing a |
| 3431 * v8::Unlocker object: | 3431 * v8::Unlocker object: |
| 3432 * | 3432 * |
| 3433 * \code | 3433 * \code |
| 3434 * { | 3434 * { |
| 3435 * isolate->Exit(); | 3435 * isolate->Exit(); |
| 3436 * v8::Unlocker unlocker(isolate); | 3436 * v8::Unlocker unlocker(isolate); |
| 3437 * ... | 3437 * ... |
| 3438 * // Code not using V8 goes here while V8 can run in another thread. | 3438 * // Code not using V8 goes here while V8 can run in another thread. |
| 3439 * ... | 3439 * ... |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3495 public: | 3495 public: |
| 3496 /** | 3496 /** |
| 3497 * Initialize Locker for a given Isolate. NULL means default isolate. | 3497 * Initialize Locker for a given Isolate. NULL means default isolate. |
| 3498 */ | 3498 */ |
| 3499 explicit Locker(Isolate* isolate = NULL); | 3499 explicit Locker(Isolate* isolate = NULL); |
| 3500 ~Locker(); | 3500 ~Locker(); |
| 3501 | 3501 |
| 3502 /** | 3502 /** |
| 3503 * Start preemption. | 3503 * Start preemption. |
| 3504 * | 3504 * |
| 3505 * When preemption is started, a timer is fired every n milli seconds | 3505 * When preemption is started, a timer is fired every n milliseconds |
| 3506 * that will switch between multiple threads that are in contention | 3506 * that will switch between multiple threads that are in contention |
| 3507 * for the V8 lock. | 3507 * for the V8 lock. |
| 3508 */ | 3508 */ |
| 3509 static void StartPreemption(int every_n_ms); | 3509 static void StartPreemption(int every_n_ms); |
| 3510 | 3510 |
| 3511 /** | 3511 /** |
| 3512 * Stop preemption. | 3512 * Stop preemption. |
| 3513 */ | 3513 */ |
| 3514 static void StopPreemption(); | 3514 static void StopPreemption(); |
| 3515 | 3515 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4089 | 4089 |
| 4090 | 4090 |
| 4091 } // namespace v8 | 4091 } // namespace v8 |
| 4092 | 4092 |
| 4093 | 4093 |
| 4094 #undef V8EXPORT | 4094 #undef V8EXPORT |
| 4095 #undef TYPE_CHECK | 4095 #undef TYPE_CHECK |
| 4096 | 4096 |
| 4097 | 4097 |
| 4098 #endif // V8_H_ | 4098 #endif // V8_H_ |
| OLD | NEW |