OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 4383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4394 | 4394 |
4395 /** | 4395 /** |
4396 * Callback function passed to SetJitCodeEventHandler. | 4396 * Callback function passed to SetJitCodeEventHandler. |
4397 * | 4397 * |
4398 * \param event code add, move or removal event. | 4398 * \param event code add, move or removal event. |
4399 */ | 4399 */ |
4400 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); | 4400 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); |
4401 | 4401 |
4402 | 4402 |
4403 /** | 4403 /** |
| 4404 * Interface for iterating through all external resources in the heap. |
| 4405 */ |
| 4406 class V8_EXPORT ExternalResourceVisitor { // NOLINT |
| 4407 public: |
| 4408 virtual ~ExternalResourceVisitor() {} |
| 4409 virtual void VisitExternalString(Handle<String> string) {} |
| 4410 }; |
| 4411 |
| 4412 |
| 4413 /** |
| 4414 * Interface for iterating through all the persistent handles in the heap. |
| 4415 */ |
| 4416 class V8_EXPORT PersistentHandleVisitor { // NOLINT |
| 4417 public: |
| 4418 virtual ~PersistentHandleVisitor() {} |
| 4419 virtual void VisitPersistentHandle(Persistent<Value>* value, |
| 4420 uint16_t class_id) {} |
| 4421 }; |
| 4422 |
| 4423 |
| 4424 /** |
4404 * Isolate represents an isolated instance of the V8 engine. V8 isolates have | 4425 * Isolate represents an isolated instance of the V8 engine. V8 isolates have |
4405 * completely separate states. Objects from one isolate must not be used in | 4426 * completely separate states. Objects from one isolate must not be used in |
4406 * other isolates. The embedder can create multiple isolates and use them in | 4427 * other isolates. The embedder can create multiple isolates and use them in |
4407 * parallel in multiple threads. An isolate can be entered by at most one | 4428 * parallel in multiple threads. An isolate can be entered by at most one |
4408 * thread at any given time. The Locker/Unlocker API must be used to | 4429 * thread at any given time. The Locker/Unlocker API must be used to |
4409 * synchronize. | 4430 * synchronize. |
4410 */ | 4431 */ |
4411 class V8_EXPORT Isolate { | 4432 class V8_EXPORT Isolate { |
4412 public: | 4433 public: |
4413 /** | 4434 /** |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4752 */ | 4773 */ |
4753 void AddGCEpilogueCallback( | 4774 void AddGCEpilogueCallback( |
4754 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); | 4775 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); |
4755 | 4776 |
4756 /** | 4777 /** |
4757 * This function removes callback which was installed by | 4778 * This function removes callback which was installed by |
4758 * AddGCEpilogueCallback function. | 4779 * AddGCEpilogueCallback function. |
4759 */ | 4780 */ |
4760 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | 4781 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
4761 | 4782 |
| 4783 |
| 4784 /** |
| 4785 * Forcefully terminate the current thread of JavaScript execution |
| 4786 * in the given isolate. |
| 4787 * |
| 4788 * This method can be used by any thread even if that thread has not |
| 4789 * acquired the V8 lock with a Locker object. |
| 4790 */ |
| 4791 void TerminateExecution(); |
| 4792 |
| 4793 /** |
| 4794 * Is V8 terminating JavaScript execution. |
| 4795 * |
| 4796 * Returns true if JavaScript execution is currently terminating |
| 4797 * because of a call to TerminateExecution. In that case there are |
| 4798 * still JavaScript frames on the stack and the termination |
| 4799 * exception is still active. |
| 4800 */ |
| 4801 bool IsExecutionTerminating(); |
| 4802 |
| 4803 /** |
| 4804 * Resume execution capability in the given isolate, whose execution |
| 4805 * was previously forcefully terminated using TerminateExecution(). |
| 4806 * |
| 4807 * When execution is forcefully terminated using TerminateExecution(), |
| 4808 * the isolate can not resume execution until all JavaScript frames |
| 4809 * have propagated the uncatchable exception which is generated. This |
| 4810 * method allows the program embedding the engine to handle the |
| 4811 * termination event and resume execution capability, even if |
| 4812 * JavaScript frames remain on the stack. |
| 4813 * |
| 4814 * This method can be used by any thread even if that thread has not |
| 4815 * acquired the V8 lock with a Locker object. |
| 4816 */ |
| 4817 void CancelTerminateExecution(); |
| 4818 |
4762 /** | 4819 /** |
4763 * Request V8 to interrupt long running JavaScript code and invoke | 4820 * Request V8 to interrupt long running JavaScript code and invoke |
4764 * the given |callback| passing the given |data| to it. After |callback| | 4821 * the given |callback| passing the given |data| to it. After |callback| |
4765 * returns control will be returned to the JavaScript code. | 4822 * returns control will be returned to the JavaScript code. |
4766 * At any given moment V8 can remember only a single callback for the very | 4823 * At any given moment V8 can remember only a single callback for the very |
4767 * last interrupt request. | 4824 * last interrupt request. |
4768 * Can be called from another thread without acquiring a |Locker|. | 4825 * Can be called from another thread without acquiring a |Locker|. |
4769 * Registered |callback| must not reenter interrupted Isolate. | 4826 * Registered |callback| must not reenter interrupted Isolate. |
4770 */ | 4827 */ |
4771 void RequestInterrupt(InterruptCallback callback, void* data); | 4828 void RequestInterrupt(InterruptCallback callback, void* data); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4933 * | 4990 * |
4934 * The first page of the code range is reserved for the embedder and is | 4991 * The first page of the code range is reserved for the embedder and is |
4935 * committed, writable, and executable. | 4992 * committed, writable, and executable. |
4936 * | 4993 * |
4937 * Might be empty on other platforms. | 4994 * Might be empty on other platforms. |
4938 * | 4995 * |
4939 * https://code.google.com/p/v8/issues/detail?id=3598 | 4996 * https://code.google.com/p/v8/issues/detail?id=3598 |
4940 */ | 4997 */ |
4941 void GetCodeRange(void** start, size_t* length_in_bytes); | 4998 void GetCodeRange(void** start, size_t* length_in_bytes); |
4942 | 4999 |
| 5000 /** Set the callback to invoke in case of fatal errors. */ |
| 5001 void SetFatalErrorHandler(FatalErrorCallback that); |
| 5002 |
| 5003 /** |
| 5004 * Set the callback to invoke to check if code generation from |
| 5005 * strings should be allowed. |
| 5006 */ |
| 5007 void SetAllowCodeGenerationFromStringsCallback( |
| 5008 AllowCodeGenerationFromStringsCallback callback); |
| 5009 |
| 5010 /** |
| 5011 * Check if V8 is dead and therefore unusable. This is the case after |
| 5012 * fatal errors such as out-of-memory situations. |
| 5013 */ |
| 5014 bool IsDead(); |
| 5015 |
| 5016 /** |
| 5017 * Adds a message listener. |
| 5018 * |
| 5019 * The same message listener can be added more than once and in that |
| 5020 * case it will be called more than once for each message. |
| 5021 * |
| 5022 * If data is specified, it will be passed to the callback when it is called. |
| 5023 * Otherwise, the exception object will be passed to the callback instead. |
| 5024 */ |
| 5025 bool AddMessageListener(MessageCallback that, |
| 5026 Handle<Value> data = Handle<Value>()); |
| 5027 |
| 5028 /** |
| 5029 * Remove all message listeners from the specified callback function. |
| 5030 */ |
| 5031 void RemoveMessageListeners(MessageCallback that); |
| 5032 |
| 5033 /** Callback function for reporting failed access checks.*/ |
| 5034 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback); |
| 5035 |
| 5036 /** |
| 5037 * Tells V8 to capture current stack trace when uncaught exception occurs |
| 5038 * and report it to the message listeners. The option is off by default. |
| 5039 */ |
| 5040 void SetCaptureStackTraceForUncaughtExceptions( |
| 5041 bool capture, int frame_limit = 10, |
| 5042 StackTrace::StackTraceOptions options = StackTrace::kOverview); |
| 5043 |
| 5044 /** |
| 5045 * Enables the host application to provide a mechanism to be notified |
| 5046 * and perform custom logging when V8 Allocates Executable Memory. |
| 5047 */ |
| 5048 void AddMemoryAllocationCallback(MemoryAllocationCallback callback, |
| 5049 ObjectSpace space, AllocationAction action); |
| 5050 |
| 5051 /** |
| 5052 * Removes callback that was installed by AddMemoryAllocationCallback. |
| 5053 */ |
| 5054 void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback); |
| 5055 |
| 5056 /** |
| 5057 * Iterates through all external resources referenced from current isolate |
| 5058 * heap. GC is not invoked prior to iterating, therefore there is no |
| 5059 * guarantee that visited objects are still alive. |
| 5060 */ |
| 5061 void VisitExternalResources(ExternalResourceVisitor* visitor); |
| 5062 |
| 5063 /** |
| 5064 * Iterates through all the persistent handles in the current isolate's heap |
| 5065 * that have class_ids. |
| 5066 */ |
| 5067 void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); |
| 5068 |
| 5069 /** |
| 5070 * Iterates through all the persistent handles in the current isolate's heap |
| 5071 * that have class_ids and are candidates to be marked as partially dependent |
| 5072 * handles. This will visit handles to young objects created since the last |
| 5073 * garbage collection but is free to visit an arbitrary superset of these |
| 5074 * objects. |
| 5075 */ |
| 5076 void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor); |
| 5077 |
4943 private: | 5078 private: |
4944 template<class K, class V, class Traits> friend class PersistentValueMap; | 5079 template<class K, class V, class Traits> friend class PersistentValueMap; |
4945 | 5080 |
4946 Isolate(); | 5081 Isolate(); |
4947 Isolate(const Isolate&); | 5082 Isolate(const Isolate&); |
4948 ~Isolate(); | 5083 ~Isolate(); |
4949 Isolate& operator=(const Isolate&); | 5084 Isolate& operator=(const Isolate&); |
4950 void* operator new(size_t size); | 5085 void* operator new(size_t size); |
4951 void operator delete(void*, size_t); | 5086 void operator delete(void*, size_t); |
4952 | 5087 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5012 * \returns either return_addr_location, or else a pointer to the profiler's | 5147 * \returns either return_addr_location, or else a pointer to the profiler's |
5013 * copy of the original return address. | 5148 * copy of the original return address. |
5014 * | 5149 * |
5015 * \note the resolver function must not cause garbage collection. | 5150 * \note the resolver function must not cause garbage collection. |
5016 */ | 5151 */ |
5017 typedef uintptr_t (*ReturnAddressLocationResolver)( | 5152 typedef uintptr_t (*ReturnAddressLocationResolver)( |
5018 uintptr_t return_addr_location); | 5153 uintptr_t return_addr_location); |
5019 | 5154 |
5020 | 5155 |
5021 /** | 5156 /** |
5022 * Interface for iterating through all external resources in the heap. | |
5023 */ | |
5024 class V8_EXPORT ExternalResourceVisitor { // NOLINT | |
5025 public: | |
5026 virtual ~ExternalResourceVisitor() {} | |
5027 virtual void VisitExternalString(Handle<String> string) {} | |
5028 }; | |
5029 | |
5030 | |
5031 /** | |
5032 * Interface for iterating through all the persistent handles in the heap. | |
5033 */ | |
5034 class V8_EXPORT PersistentHandleVisitor { // NOLINT | |
5035 public: | |
5036 virtual ~PersistentHandleVisitor() {} | |
5037 virtual void VisitPersistentHandle(Persistent<Value>* value, | |
5038 uint16_t class_id) {} | |
5039 }; | |
5040 | |
5041 | |
5042 /** | |
5043 * Container class for static utility functions. | 5157 * Container class for static utility functions. |
5044 */ | 5158 */ |
5045 class V8_EXPORT V8 { | 5159 class V8_EXPORT V8 { |
5046 public: | 5160 public: |
5047 /** Set the callback to invoke in case of fatal errors. */ | 5161 /** Set the callback to invoke in case of fatal errors. */ |
5048 static void SetFatalErrorHandler(FatalErrorCallback that); | 5162 // TODO(dcarney): deprecate this. |
| 5163 V8_INLINE static void SetFatalErrorHandler(FatalErrorCallback that); |
5049 | 5164 |
5050 /** | 5165 /** |
5051 * Set the callback to invoke to check if code generation from | 5166 * Set the callback to invoke to check if code generation from |
5052 * strings should be allowed. | 5167 * strings should be allowed. |
5053 */ | 5168 */ |
5054 static void SetAllowCodeGenerationFromStringsCallback( | 5169 // TODO(dcarney): deprecate this. |
| 5170 V8_INLINE static void SetAllowCodeGenerationFromStringsCallback( |
5055 AllowCodeGenerationFromStringsCallback that); | 5171 AllowCodeGenerationFromStringsCallback that); |
5056 | 5172 |
5057 /** | 5173 /** |
5058 * Set allocator to use for ArrayBuffer memory. | 5174 * Set allocator to use for ArrayBuffer memory. |
5059 * The allocator should be set only once. The allocator should be set | 5175 * The allocator should be set only once. The allocator should be set |
5060 * before any code tha uses ArrayBuffers is executed. | 5176 * before any code tha uses ArrayBuffers is executed. |
5061 * This allocator is used in all isolates. | 5177 * This allocator is used in all isolates. |
5062 */ | 5178 */ |
5063 static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator); | 5179 static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator); |
5064 | 5180 |
5065 /** | 5181 /** |
5066 * Check if V8 is dead and therefore unusable. This is the case after | 5182 * Check if V8 is dead and therefore unusable. This is the case after |
5067 * fatal errors such as out-of-memory situations. | 5183 * fatal errors such as out-of-memory situations. |
5068 */ | 5184 */ |
5069 static bool IsDead(); | 5185 // TODO(dcarney): deprecate this. |
| 5186 V8_INLINE static bool IsDead(); |
5070 | 5187 |
5071 /** | 5188 /** |
5072 * The following 4 functions are to be used when V8 is built with | 5189 * The following 4 functions are to be used when V8 is built with |
5073 * the 'compress_startup_data' flag enabled. In this case, the | 5190 * the 'compress_startup_data' flag enabled. In this case, the |
5074 * embedder must decompress startup data prior to initializing V8. | 5191 * embedder must decompress startup data prior to initializing V8. |
5075 * | 5192 * |
5076 * This is how interaction with V8 should look like: | 5193 * This is how interaction with V8 should look like: |
5077 * int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); | 5194 * int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); |
5078 * v8::StartupData* compressed_data = | 5195 * v8::StartupData* compressed_data = |
5079 * new v8::StartupData[compressed_data_count]; | 5196 * new v8::StartupData[compressed_data_count]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5112 | 5229 |
5113 /** | 5230 /** |
5114 * Adds a message listener. | 5231 * Adds a message listener. |
5115 * | 5232 * |
5116 * The same message listener can be added more than once and in that | 5233 * The same message listener can be added more than once and in that |
5117 * case it will be called more than once for each message. | 5234 * case it will be called more than once for each message. |
5118 * | 5235 * |
5119 * If data is specified, it will be passed to the callback when it is called. | 5236 * If data is specified, it will be passed to the callback when it is called. |
5120 * Otherwise, the exception object will be passed to the callback instead. | 5237 * Otherwise, the exception object will be passed to the callback instead. |
5121 */ | 5238 */ |
5122 static bool AddMessageListener(MessageCallback that, | 5239 // TODO(dcarney): deprecate this. |
5123 Handle<Value> data = Handle<Value>()); | 5240 V8_INLINE static bool AddMessageListener( |
| 5241 MessageCallback that, Handle<Value> data = Handle<Value>()); |
5124 | 5242 |
5125 /** | 5243 /** |
5126 * Remove all message listeners from the specified callback function. | 5244 * Remove all message listeners from the specified callback function. |
5127 */ | 5245 */ |
5128 static void RemoveMessageListeners(MessageCallback that); | 5246 // TODO(dcarney): deprecate this. |
| 5247 V8_INLINE static void RemoveMessageListeners(MessageCallback that); |
5129 | 5248 |
5130 /** | 5249 /** |
5131 * Tells V8 to capture current stack trace when uncaught exception occurs | 5250 * Tells V8 to capture current stack trace when uncaught exception occurs |
5132 * and report it to the message listeners. The option is off by default. | 5251 * and report it to the message listeners. The option is off by default. |
5133 */ | 5252 */ |
5134 static void SetCaptureStackTraceForUncaughtExceptions( | 5253 // TODO(dcarney): deprecate this. |
5135 bool capture, | 5254 V8_INLINE static void SetCaptureStackTraceForUncaughtExceptions( |
5136 int frame_limit = 10, | 5255 bool capture, int frame_limit = 10, |
5137 StackTrace::StackTraceOptions options = StackTrace::kOverview); | 5256 StackTrace::StackTraceOptions options = StackTrace::kOverview); |
5138 | 5257 |
5139 /** | 5258 /** |
5140 * Sets V8 flags from a string. | 5259 * Sets V8 flags from a string. |
5141 */ | 5260 */ |
5142 static void SetFlagsFromString(const char* str, int length); | 5261 static void SetFlagsFromString(const char* str, int length); |
5143 | 5262 |
5144 /** | 5263 /** |
5145 * Sets V8 flags from the command line. | 5264 * Sets V8 flags from the command line. |
5146 */ | 5265 */ |
5147 static void SetFlagsFromCommandLine(int* argc, | 5266 static void SetFlagsFromCommandLine(int* argc, |
5148 char** argv, | 5267 char** argv, |
5149 bool remove_flags); | 5268 bool remove_flags); |
5150 | 5269 |
5151 /** Get the version string. */ | 5270 /** Get the version string. */ |
5152 static const char* GetVersion(); | 5271 static const char* GetVersion(); |
5153 | 5272 |
5154 /** Callback function for reporting failed access checks.*/ | 5273 /** Callback function for reporting failed access checks.*/ |
5155 static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback); | 5274 // TODO(dcarney): deprecate this. |
| 5275 V8_INLINE static void SetFailedAccessCheckCallbackFunction( |
| 5276 FailedAccessCheckCallback); |
5156 | 5277 |
5157 /** | 5278 /** |
5158 * Enables the host application to receive a notification before a | 5279 * Enables the host application to receive a notification before a |
5159 * garbage collection. Allocations are not allowed in the | 5280 * garbage collection. Allocations are not allowed in the |
5160 * callback function, you therefore cannot manipulate objects (set | 5281 * callback function, you therefore cannot manipulate objects (set |
5161 * or delete properties for example) since it is possible such | 5282 * or delete properties for example) since it is possible such |
5162 * operations will result in the allocation of objects. It is possible | 5283 * operations will result in the allocation of objects. It is possible |
5163 * to specify the GCType filter for your callback. But it is not possible to | 5284 * to specify the GCType filter for your callback. But it is not possible to |
5164 * register the same callback function two times with different | 5285 * register the same callback function two times with different |
5165 * GCType filters. | 5286 * GCType filters. |
5166 */ | 5287 */ |
| 5288 // TODO(dcarney): deprecate this. |
5167 static void AddGCPrologueCallback( | 5289 static void AddGCPrologueCallback( |
5168 GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); | 5290 GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); |
5169 | 5291 |
5170 /** | 5292 /** |
5171 * This function removes callback which was installed by | 5293 * This function removes callback which was installed by |
5172 * AddGCPrologueCallback function. | 5294 * AddGCPrologueCallback function. |
5173 */ | 5295 */ |
5174 static void RemoveGCPrologueCallback(GCPrologueCallback callback); | 5296 // TODO(dcarney): deprecate this. |
| 5297 V8_INLINE static void RemoveGCPrologueCallback(GCPrologueCallback callback); |
5175 | 5298 |
5176 /** | 5299 /** |
5177 * Enables the host application to receive a notification after a | 5300 * Enables the host application to receive a notification after a |
5178 * garbage collection. Allocations are not allowed in the | 5301 * garbage collection. Allocations are not allowed in the |
5179 * callback function, you therefore cannot manipulate objects (set | 5302 * callback function, you therefore cannot manipulate objects (set |
5180 * or delete properties for example) since it is possible such | 5303 * or delete properties for example) since it is possible such |
5181 * operations will result in the allocation of objects. It is possible | 5304 * operations will result in the allocation of objects. It is possible |
5182 * to specify the GCType filter for your callback. But it is not possible to | 5305 * to specify the GCType filter for your callback. But it is not possible to |
5183 * register the same callback function two times with different | 5306 * register the same callback function two times with different |
5184 * GCType filters. | 5307 * GCType filters. |
5185 */ | 5308 */ |
| 5309 // TODO(dcarney): deprecate this. |
5186 static void AddGCEpilogueCallback( | 5310 static void AddGCEpilogueCallback( |
5187 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); | 5311 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); |
5188 | 5312 |
5189 /** | 5313 /** |
5190 * This function removes callback which was installed by | 5314 * This function removes callback which was installed by |
5191 * AddGCEpilogueCallback function. | 5315 * AddGCEpilogueCallback function. |
5192 */ | 5316 */ |
5193 static void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | 5317 // TODO(dcarney): deprecate this. |
| 5318 V8_INLINE static void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
5194 | 5319 |
5195 /** | 5320 /** |
5196 * Enables the host application to provide a mechanism to be notified | 5321 * Enables the host application to provide a mechanism to be notified |
5197 * and perform custom logging when V8 Allocates Executable Memory. | 5322 * and perform custom logging when V8 Allocates Executable Memory. |
5198 */ | 5323 */ |
5199 static void AddMemoryAllocationCallback(MemoryAllocationCallback callback, | 5324 // TODO(dcarney): deprecate this. |
5200 ObjectSpace space, | 5325 V8_INLINE static void AddMemoryAllocationCallback( |
5201 AllocationAction action); | 5326 MemoryAllocationCallback callback, ObjectSpace space, |
| 5327 AllocationAction action); |
5202 | 5328 |
5203 /** | 5329 /** |
5204 * Removes callback that was installed by AddMemoryAllocationCallback. | 5330 * Removes callback that was installed by AddMemoryAllocationCallback. |
5205 */ | 5331 */ |
5206 static void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback); | 5332 // TODO(dcarney): deprecate this. |
| 5333 V8_INLINE static void RemoveMemoryAllocationCallback( |
| 5334 MemoryAllocationCallback callback); |
5207 | 5335 |
5208 /** | 5336 /** |
5209 * Initializes V8. This function needs to be called before the first Isolate | 5337 * Initializes V8. This function needs to be called before the first Isolate |
5210 * is created. It always returns true. | 5338 * is created. It always returns true. |
5211 */ | 5339 */ |
5212 static bool Initialize(); | 5340 static bool Initialize(); |
5213 | 5341 |
5214 /** | 5342 /** |
5215 * Allows the host application to provide a callback which can be used | 5343 * Allows the host application to provide a callback which can be used |
5216 * as a source of entropy for random number generators. | 5344 * as a source of entropy for random number generators. |
5217 */ | 5345 */ |
5218 static void SetEntropySource(EntropySource source); | 5346 static void SetEntropySource(EntropySource source); |
5219 | 5347 |
5220 /** | 5348 /** |
5221 * Allows the host application to provide a callback that allows v8 to | 5349 * Allows the host application to provide a callback that allows v8 to |
5222 * cooperate with a profiler that rewrites return addresses on stack. | 5350 * cooperate with a profiler that rewrites return addresses on stack. |
5223 */ | 5351 */ |
5224 static void SetReturnAddressLocationResolver( | 5352 static void SetReturnAddressLocationResolver( |
5225 ReturnAddressLocationResolver return_address_resolver); | 5353 ReturnAddressLocationResolver return_address_resolver); |
5226 | 5354 |
5227 /** | 5355 /** |
5228 * Forcefully terminate the current thread of JavaScript execution | 5356 * Forcefully terminate the current thread of JavaScript execution |
5229 * in the given isolate. | 5357 * in the given isolate. |
5230 * | 5358 * |
5231 * This method can be used by any thread even if that thread has not | 5359 * This method can be used by any thread even if that thread has not |
5232 * acquired the V8 lock with a Locker object. | 5360 * acquired the V8 lock with a Locker object. |
5233 * | 5361 * |
5234 * \param isolate The isolate in which to terminate the current JS execution. | 5362 * \param isolate The isolate in which to terminate the current JS execution. |
5235 */ | 5363 */ |
5236 static void TerminateExecution(Isolate* isolate); | 5364 // TODO(dcarney): deprecate this. |
| 5365 V8_INLINE static void TerminateExecution(Isolate* isolate); |
5237 | 5366 |
5238 /** | 5367 /** |
5239 * Is V8 terminating JavaScript execution. | 5368 * Is V8 terminating JavaScript execution. |
5240 * | 5369 * |
5241 * Returns true if JavaScript execution is currently terminating | 5370 * Returns true if JavaScript execution is currently terminating |
5242 * because of a call to TerminateExecution. In that case there are | 5371 * because of a call to TerminateExecution. In that case there are |
5243 * still JavaScript frames on the stack and the termination | 5372 * still JavaScript frames on the stack and the termination |
5244 * exception is still active. | 5373 * exception is still active. |
5245 * | 5374 * |
5246 * \param isolate The isolate in which to check. | 5375 * \param isolate The isolate in which to check. |
5247 */ | 5376 */ |
5248 static bool IsExecutionTerminating(Isolate* isolate = NULL); | 5377 // TODO(dcarney): deprecate this. |
| 5378 V8_INLINE static bool IsExecutionTerminating(Isolate* isolate = NULL); |
5249 | 5379 |
5250 /** | 5380 /** |
5251 * Resume execution capability in the given isolate, whose execution | 5381 * Resume execution capability in the given isolate, whose execution |
5252 * was previously forcefully terminated using TerminateExecution(). | 5382 * was previously forcefully terminated using TerminateExecution(). |
5253 * | 5383 * |
5254 * When execution is forcefully terminated using TerminateExecution(), | 5384 * When execution is forcefully terminated using TerminateExecution(), |
5255 * the isolate can not resume execution until all JavaScript frames | 5385 * the isolate can not resume execution until all JavaScript frames |
5256 * have propagated the uncatchable exception which is generated. This | 5386 * have propagated the uncatchable exception which is generated. This |
5257 * method allows the program embedding the engine to handle the | 5387 * method allows the program embedding the engine to handle the |
5258 * termination event and resume execution capability, even if | 5388 * termination event and resume execution capability, even if |
5259 * JavaScript frames remain on the stack. | 5389 * JavaScript frames remain on the stack. |
5260 * | 5390 * |
5261 * This method can be used by any thread even if that thread has not | 5391 * This method can be used by any thread even if that thread has not |
5262 * acquired the V8 lock with a Locker object. | 5392 * acquired the V8 lock with a Locker object. |
5263 * | 5393 * |
5264 * \param isolate The isolate in which to resume execution capability. | 5394 * \param isolate The isolate in which to resume execution capability. |
5265 */ | 5395 */ |
5266 static void CancelTerminateExecution(Isolate* isolate); | 5396 // TODO(dcarney): deprecate this. |
| 5397 V8_INLINE static void CancelTerminateExecution(Isolate* isolate); |
5267 | 5398 |
5268 /** | 5399 /** |
5269 * Releases any resources used by v8 and stops any utility threads | 5400 * Releases any resources used by v8 and stops any utility threads |
5270 * that may be running. Note that disposing v8 is permanent, it | 5401 * that may be running. Note that disposing v8 is permanent, it |
5271 * cannot be reinitialized. | 5402 * cannot be reinitialized. |
5272 * | 5403 * |
5273 * It should generally not be necessary to dispose v8 before exiting | 5404 * It should generally not be necessary to dispose v8 before exiting |
5274 * a process, this should happen automatically. It is only necessary | 5405 * a process, this should happen automatically. It is only necessary |
5275 * to use if the process needs the resources taken up by v8. | 5406 * to use if the process needs the resources taken up by v8. |
5276 */ | 5407 */ |
5277 static bool Dispose(); | 5408 static bool Dispose(); |
5278 | 5409 |
5279 /** | 5410 /** |
5280 * Iterates through all external resources referenced from current isolate | 5411 * Iterates through all external resources referenced from current isolate |
5281 * heap. GC is not invoked prior to iterating, therefore there is no | 5412 * heap. GC is not invoked prior to iterating, therefore there is no |
5282 * guarantee that visited objects are still alive. | 5413 * guarantee that visited objects are still alive. |
5283 */ | 5414 */ |
5284 static void VisitExternalResources(ExternalResourceVisitor* visitor); | 5415 // TODO(dcarney): deprecate this. |
| 5416 V8_INLINE static void VisitExternalResources( |
| 5417 ExternalResourceVisitor* visitor); |
5285 | 5418 |
5286 /** | 5419 /** |
5287 * Iterates through all the persistent handles in the current isolate's heap | 5420 * Iterates through all the persistent handles in the current isolate's heap |
5288 * that have class_ids. | 5421 * that have class_ids. |
5289 */ | 5422 */ |
5290 static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); | 5423 // TODO(dcarney): deprecate this. |
| 5424 V8_INLINE static void VisitHandlesWithClassIds( |
| 5425 PersistentHandleVisitor* visitor); |
5291 | 5426 |
5292 /** | 5427 /** |
5293 * Iterates through all the persistent handles in isolate's heap that have | 5428 * Iterates through all the persistent handles in isolate's heap that have |
5294 * class_ids. | 5429 * class_ids. |
5295 */ | 5430 */ |
5296 static void VisitHandlesWithClassIds( | 5431 // TODO(dcarney): deprecate this. |
| 5432 V8_INLINE static void VisitHandlesWithClassIds( |
5297 Isolate* isolate, PersistentHandleVisitor* visitor); | 5433 Isolate* isolate, PersistentHandleVisitor* visitor); |
5298 | 5434 |
5299 /** | 5435 /** |
5300 * Iterates through all the persistent handles in the current isolate's heap | 5436 * Iterates through all the persistent handles in the current isolate's heap |
5301 * that have class_ids and are candidates to be marked as partially dependent | 5437 * that have class_ids and are candidates to be marked as partially dependent |
5302 * handles. This will visit handles to young objects created since the last | 5438 * handles. This will visit handles to young objects created since the last |
5303 * garbage collection but is free to visit an arbitrary superset of these | 5439 * garbage collection but is free to visit an arbitrary superset of these |
5304 * objects. | 5440 * objects. |
5305 */ | 5441 */ |
5306 static void VisitHandlesForPartialDependence( | 5442 // TODO(dcarney): deprecate this. |
| 5443 V8_INLINE static void VisitHandlesForPartialDependence( |
5307 Isolate* isolate, PersistentHandleVisitor* visitor); | 5444 Isolate* isolate, PersistentHandleVisitor* visitor); |
5308 | 5445 |
5309 /** | 5446 /** |
5310 * Initialize the ICU library bundled with V8. The embedder should only | 5447 * Initialize the ICU library bundled with V8. The embedder should only |
5311 * invoke this method when using the bundled ICU. Returns true on success. | 5448 * invoke this method when using the bundled ICU. Returns true on success. |
5312 * | 5449 * |
5313 * If V8 was compiled with the ICU data in an external file, the location | 5450 * If V8 was compiled with the ICU data in an external file, the location |
5314 * of the data file has to be provided. | 5451 * of the data file has to be provided. |
5315 */ | 5452 */ |
5316 static bool InitializeICU(const char* icu_data_file = NULL); | 5453 static bool InitializeICU(const char* icu_data_file = NULL); |
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7069 void* Context::GetAlignedPointerFromEmbedderData(int index) { | 7206 void* Context::GetAlignedPointerFromEmbedderData(int index) { |
7070 #ifndef V8_ENABLE_CHECKS | 7207 #ifndef V8_ENABLE_CHECKS |
7071 typedef internal::Internals I; | 7208 typedef internal::Internals I; |
7072 return I::ReadEmbedderData<void*>(this, index); | 7209 return I::ReadEmbedderData<void*>(this, index); |
7073 #else | 7210 #else |
7074 return SlowGetAlignedPointerFromEmbedderData(index); | 7211 return SlowGetAlignedPointerFromEmbedderData(index); |
7075 #endif | 7212 #endif |
7076 } | 7213 } |
7077 | 7214 |
7078 | 7215 |
| 7216 void V8::SetAllowCodeGenerationFromStringsCallback( |
| 7217 AllowCodeGenerationFromStringsCallback callback) { |
| 7218 Isolate* isolate = Isolate::GetCurrent(); |
| 7219 isolate->SetAllowCodeGenerationFromStringsCallback(callback); |
| 7220 } |
| 7221 |
| 7222 |
| 7223 bool V8::IsDead() { |
| 7224 Isolate* isolate = Isolate::GetCurrent(); |
| 7225 return isolate->IsDead(); |
| 7226 } |
| 7227 |
| 7228 |
| 7229 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
| 7230 Isolate* isolate = Isolate::GetCurrent(); |
| 7231 return isolate->AddMessageListener(that, data); |
| 7232 } |
| 7233 |
| 7234 |
| 7235 void V8::RemoveMessageListeners(MessageCallback that) { |
| 7236 Isolate* isolate = Isolate::GetCurrent(); |
| 7237 isolate->RemoveMessageListeners(that); |
| 7238 } |
| 7239 |
| 7240 |
| 7241 void V8::SetFailedAccessCheckCallbackFunction( |
| 7242 FailedAccessCheckCallback callback) { |
| 7243 Isolate* isolate = Isolate::GetCurrent(); |
| 7244 isolate->SetFailedAccessCheckCallbackFunction(callback); |
| 7245 } |
| 7246 |
| 7247 |
| 7248 void V8::SetCaptureStackTraceForUncaughtExceptions( |
| 7249 bool capture, int frame_limit, StackTrace::StackTraceOptions options) { |
| 7250 Isolate* isolate = Isolate::GetCurrent(); |
| 7251 isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit, |
| 7252 options); |
| 7253 } |
| 7254 |
| 7255 |
| 7256 void V8::SetFatalErrorHandler(FatalErrorCallback callback) { |
| 7257 Isolate* isolate = Isolate::GetCurrent(); |
| 7258 isolate->SetFatalErrorHandler(callback); |
| 7259 } |
| 7260 |
| 7261 |
| 7262 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) { |
| 7263 Isolate* isolate = Isolate::GetCurrent(); |
| 7264 isolate->RemoveGCPrologueCallback( |
| 7265 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback)); |
| 7266 } |
| 7267 |
| 7268 |
| 7269 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { |
| 7270 Isolate* isolate = Isolate::GetCurrent(); |
| 7271 isolate->RemoveGCEpilogueCallback( |
| 7272 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback)); |
| 7273 } |
| 7274 |
| 7275 |
| 7276 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback, |
| 7277 ObjectSpace space, |
| 7278 AllocationAction action) { |
| 7279 Isolate* isolate = Isolate::GetCurrent(); |
| 7280 isolate->AddMemoryAllocationCallback(callback, space, action); |
| 7281 } |
| 7282 |
| 7283 |
| 7284 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { |
| 7285 Isolate* isolate = Isolate::GetCurrent(); |
| 7286 isolate->RemoveMemoryAllocationCallback(callback); |
| 7287 } |
| 7288 |
| 7289 |
| 7290 void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); } |
| 7291 |
| 7292 |
| 7293 bool V8::IsExecutionTerminating(Isolate* isolate) { |
| 7294 if (isolate == NULL) { |
| 7295 isolate = Isolate::GetCurrent(); |
| 7296 } |
| 7297 return isolate->IsExecutionTerminating(); |
| 7298 } |
| 7299 |
| 7300 |
| 7301 void V8::CancelTerminateExecution(Isolate* isolate) { |
| 7302 isolate->CancelTerminateExecution(); |
| 7303 } |
| 7304 |
| 7305 |
| 7306 void V8::VisitExternalResources(ExternalResourceVisitor* visitor) { |
| 7307 Isolate* isolate = Isolate::GetCurrent(); |
| 7308 isolate->VisitExternalResources(visitor); |
| 7309 } |
| 7310 |
| 7311 |
| 7312 void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { |
| 7313 Isolate* isolate = Isolate::GetCurrent(); |
| 7314 isolate->VisitHandlesWithClassIds(visitor); |
| 7315 } |
| 7316 |
| 7317 |
| 7318 void V8::VisitHandlesWithClassIds(Isolate* isolate, |
| 7319 PersistentHandleVisitor* visitor) { |
| 7320 isolate->VisitHandlesWithClassIds(visitor); |
| 7321 } |
| 7322 |
| 7323 |
| 7324 void V8::VisitHandlesForPartialDependence(Isolate* isolate, |
| 7325 PersistentHandleVisitor* visitor) { |
| 7326 isolate->VisitHandlesForPartialDependence(visitor); |
| 7327 } |
| 7328 |
7079 /** | 7329 /** |
7080 * \example shell.cc | 7330 * \example shell.cc |
7081 * A simple shell that takes a list of expressions on the | 7331 * A simple shell that takes a list of expressions on the |
7082 * command-line and executes them. | 7332 * command-line and executes them. |
7083 */ | 7333 */ |
7084 | 7334 |
7085 | 7335 |
7086 /** | 7336 /** |
7087 * \example process.cc | 7337 * \example process.cc |
7088 */ | 7338 */ |
7089 | 7339 |
7090 | 7340 |
7091 } // namespace v8 | 7341 } // namespace v8 |
7092 | 7342 |
7093 | 7343 |
7094 #undef TYPE_CHECK | 7344 #undef TYPE_CHECK |
7095 | 7345 |
7096 | 7346 |
7097 #endif // V8_H_ | 7347 #endif // V8_H_ |
OLD | NEW |