OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 812 |
813 friend class ImplementationUtilities; | 813 friend class ImplementationUtilities; |
814 }; | 814 }; |
815 | 815 |
816 | 816 |
817 /** | 817 /** |
818 * A simple Maybe type, representing an object which may or may not have a | 818 * A simple Maybe type, representing an object which may or may not have a |
819 * value. | 819 * value. |
820 */ | 820 */ |
821 template<class T> | 821 template<class T> |
822 struct V8_EXPORT Maybe { | 822 struct Maybe { |
823 Maybe() : has_value(false) {} | 823 Maybe() : has_value(false) {} |
824 explicit Maybe(T t) : has_value(true), value(t) {} | 824 explicit Maybe(T t) : has_value(true), value(t) {} |
825 Maybe(bool has, T t) : has_value(has), value(t) {} | 825 Maybe(bool has, T t) : has_value(has), value(t) {} |
826 | 826 |
827 bool has_value; | 827 bool has_value; |
828 T value; | 828 T value; |
829 }; | 829 }; |
830 | 830 |
831 | 831 |
832 // --- Special objects --- | 832 // --- Special objects --- |
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 V8_INLINE int Length() const; | 2357 V8_INLINE int Length() const; |
2358 V8_INLINE Local<Value> operator[](int i) const; | 2358 V8_INLINE Local<Value> operator[](int i) const; |
2359 V8_INLINE Local<Function> Callee() const; | 2359 V8_INLINE Local<Function> Callee() const; |
2360 V8_INLINE Local<Object> This() const; | 2360 V8_INLINE Local<Object> This() const; |
2361 V8_INLINE Local<Object> Holder() const; | 2361 V8_INLINE Local<Object> Holder() const; |
2362 V8_INLINE bool IsConstructCall() const; | 2362 V8_INLINE bool IsConstructCall() const; |
2363 V8_INLINE Local<Value> Data() const; | 2363 V8_INLINE Local<Value> Data() const; |
2364 V8_INLINE Isolate* GetIsolate() const; | 2364 V8_INLINE Isolate* GetIsolate() const; |
2365 V8_INLINE ReturnValue<T> GetReturnValue() const; | 2365 V8_INLINE ReturnValue<T> GetReturnValue() const; |
2366 // This shouldn't be public, but the arm compiler needs it. | 2366 // This shouldn't be public, but the arm compiler needs it. |
2367 static const int kArgsLength = 7; | 2367 static const int kArgsLength = 6; |
2368 | 2368 |
2369 protected: | 2369 protected: |
2370 friend class internal::FunctionCallbackArguments; | 2370 friend class internal::FunctionCallbackArguments; |
2371 friend class internal::CustomArguments<FunctionCallbackInfo>; | 2371 friend class internal::CustomArguments<FunctionCallbackInfo>; |
2372 static const int kReturnValueIndex = 0; | 2372 static const int kReturnValueIndex = 0; |
2373 static const int kReturnValueDefaultValueIndex = -1; | 2373 static const int kReturnValueDefaultValueIndex = -1; |
2374 static const int kIsolateIndex = -2; | 2374 static const int kIsolateIndex = -2; |
2375 static const int kDataIndex = -3; | 2375 static const int kDataIndex = -3; |
2376 static const int kCalleeIndex = -4; | 2376 static const int kCalleeIndex = -4; |
2377 static const int kHolderIndex = -5; | 2377 static const int kHolderIndex = -5; |
2378 static const int kContextSaveIndex = -6; | |
2379 | 2378 |
2380 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, | 2379 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, |
2381 internal::Object** values, | 2380 internal::Object** values, |
2382 int length, | 2381 int length, |
2383 bool is_construct_call); | 2382 bool is_construct_call); |
2384 internal::Object** implicit_args_; | 2383 internal::Object** implicit_args_; |
2385 internal::Object** values_; | 2384 internal::Object** values_; |
2386 int length_; | 2385 int length_; |
2387 bool is_construct_call_; | 2386 bool is_construct_call_; |
2388 }; | 2387 }; |
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3864 | 3863 |
3865 enum GCCallbackFlags { | 3864 enum GCCallbackFlags { |
3866 kNoGCCallbackFlags = 0, | 3865 kNoGCCallbackFlags = 0, |
3867 kGCCallbackFlagCompacted = 1 << 0, | 3866 kGCCallbackFlagCompacted = 1 << 0, |
3868 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1 | 3867 kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1 |
3869 }; | 3868 }; |
3870 | 3869 |
3871 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); | 3870 typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags); |
3872 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); | 3871 typedef void (*GCEpilogueCallback)(GCType type, GCCallbackFlags flags); |
3873 | 3872 |
| 3873 typedef void (*GCCallback)(); |
| 3874 |
3874 | 3875 |
3875 /** | 3876 /** |
3876 * Collection of V8 heap information. | 3877 * Collection of V8 heap information. |
3877 * | 3878 * |
3878 * Instances of this class can be passed to v8::V8::HeapStatistics to | 3879 * Instances of this class can be passed to v8::V8::HeapStatistics to |
3879 * get heap statistics from V8. | 3880 * get heap statistics from V8. |
3880 */ | 3881 */ |
3881 class V8_EXPORT HeapStatistics { | 3882 class V8_EXPORT HeapStatistics { |
3882 public: | 3883 public: |
3883 HeapStatistics(); | 3884 HeapStatistics(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4047 | 4048 |
4048 /** | 4049 /** |
4049 * Allows the host application to declare implicit references from an object | 4050 * Allows the host application to declare implicit references from an object |
4050 * to another object. If the parent object is alive, the child object is alive | 4051 * to another object. If the parent object is alive, the child object is alive |
4051 * too. After each garbage collection, all implicit references are removed. It | 4052 * too. After each garbage collection, all implicit references are removed. It |
4052 * is intended to be used in the before-garbage-collection callback function. | 4053 * is intended to be used in the before-garbage-collection callback function. |
4053 */ | 4054 */ |
4054 void SetReference(const Persistent<Object>& parent, | 4055 void SetReference(const Persistent<Object>& parent, |
4055 const Persistent<Value>& child); | 4056 const Persistent<Value>& child); |
4056 | 4057 |
4057 typedef void (*GCPrologueCallback)(Isolate* isolate, | |
4058 GCType type, | |
4059 GCCallbackFlags flags); | |
4060 typedef void (*GCEpilogueCallback)(Isolate* isolate, | |
4061 GCType type, | |
4062 GCCallbackFlags flags); | |
4063 | |
4064 /** | |
4065 * Enables the host application to receive a notification before a | |
4066 * garbage collection. Allocations are not allowed in the | |
4067 * callback function, you therefore cannot manipulate objects (set | |
4068 * or delete properties for example) since it is possible such | |
4069 * operations will result in the allocation of objects. It is possible | |
4070 * to specify the GCType filter for your callback. But it is not possible to | |
4071 * register the same callback function two times with different | |
4072 * GCType filters. | |
4073 */ | |
4074 void AddGCPrologueCallback( | |
4075 GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); | |
4076 | |
4077 /** | |
4078 * This function removes callback which was installed by | |
4079 * AddGCPrologueCallback function. | |
4080 */ | |
4081 void RemoveGCPrologueCallback(GCPrologueCallback callback); | |
4082 | |
4083 /** | |
4084 * Enables the host application to receive a notification after a | |
4085 * garbage collection. Allocations are not allowed in the | |
4086 * callback function, you therefore cannot manipulate objects (set | |
4087 * or delete properties for example) since it is possible such | |
4088 * operations will result in the allocation of objects. It is possible | |
4089 * to specify the GCType filter for your callback. But it is not possible to | |
4090 * register the same callback function two times with different | |
4091 * GCType filters. | |
4092 */ | |
4093 void AddGCEpilogueCallback( | |
4094 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); | |
4095 | |
4096 /** | |
4097 * This function removes callback which was installed by | |
4098 * AddGCEpilogueCallback function. | |
4099 */ | |
4100 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | |
4101 | |
4102 private: | 4058 private: |
4103 Isolate(); | 4059 Isolate(); |
4104 Isolate(const Isolate&); | 4060 Isolate(const Isolate&); |
4105 ~Isolate(); | 4061 ~Isolate(); |
4106 Isolate& operator=(const Isolate&); | 4062 Isolate& operator=(const Isolate&); |
4107 void* operator new(size_t size); | 4063 void* operator new(size_t size); |
4108 void operator delete(void*, size_t); | 4064 void operator delete(void*, size_t); |
4109 }; | 4065 }; |
4110 | 4066 |
4111 | 4067 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4449 static void AddGCPrologueCallback( | 4405 static void AddGCPrologueCallback( |
4450 GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); | 4406 GCPrologueCallback callback, GCType gc_type_filter = kGCTypeAll); |
4451 | 4407 |
4452 /** | 4408 /** |
4453 * This function removes callback which was installed by | 4409 * This function removes callback which was installed by |
4454 * AddGCPrologueCallback function. | 4410 * AddGCPrologueCallback function. |
4455 */ | 4411 */ |
4456 static void RemoveGCPrologueCallback(GCPrologueCallback callback); | 4412 static void RemoveGCPrologueCallback(GCPrologueCallback callback); |
4457 | 4413 |
4458 /** | 4414 /** |
| 4415 * The function is deprecated. Please use AddGCPrologueCallback instead. |
| 4416 * Enables the host application to receive a notification before a |
| 4417 * garbage collection. Allocations are not allowed in the |
| 4418 * callback function, you therefore cannot manipulate objects (set |
| 4419 * or delete properties for example) since it is possible such |
| 4420 * operations will result in the allocation of objects. |
| 4421 */ |
| 4422 V8_DEPRECATED(static void SetGlobalGCPrologueCallback(GCCallback)); |
| 4423 |
| 4424 /** |
4459 * Enables the host application to receive a notification after a | 4425 * Enables the host application to receive a notification after a |
4460 * garbage collection. Allocations are not allowed in the | 4426 * garbage collection. Allocations are not allowed in the |
4461 * callback function, you therefore cannot manipulate objects (set | 4427 * callback function, you therefore cannot manipulate objects (set |
4462 * or delete properties for example) since it is possible such | 4428 * or delete properties for example) since it is possible such |
4463 * operations will result in the allocation of objects. It is possible | 4429 * operations will result in the allocation of objects. It is possible |
4464 * to specify the GCType filter for your callback. But it is not possible to | 4430 * to specify the GCType filter for your callback. But it is not possible to |
4465 * register the same callback function two times with different | 4431 * register the same callback function two times with different |
4466 * GCType filters. | 4432 * GCType filters. |
4467 */ | 4433 */ |
4468 static void AddGCEpilogueCallback( | 4434 static void AddGCEpilogueCallback( |
4469 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); | 4435 GCEpilogueCallback callback, GCType gc_type_filter = kGCTypeAll); |
4470 | 4436 |
4471 /** | 4437 /** |
4472 * This function removes callback which was installed by | 4438 * This function removes callback which was installed by |
4473 * AddGCEpilogueCallback function. | 4439 * AddGCEpilogueCallback function. |
4474 */ | 4440 */ |
4475 static void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | 4441 static void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
4476 | 4442 |
4477 /** | 4443 /** |
| 4444 * The function is deprecated. Please use AddGCEpilogueCallback instead. |
| 4445 * Enables the host application to receive a notification after a |
| 4446 * major garbage collection. Allocations are not allowed in the |
| 4447 * callback function, you therefore cannot manipulate objects (set |
| 4448 * or delete properties for example) since it is possible such |
| 4449 * operations will result in the allocation of objects. |
| 4450 */ |
| 4451 V8_DEPRECATED(static void SetGlobalGCEpilogueCallback(GCCallback)); |
| 4452 |
| 4453 /** |
4478 * Enables the host application to provide a mechanism to be notified | 4454 * Enables the host application to provide a mechanism to be notified |
4479 * and perform custom logging when V8 Allocates Executable Memory. | 4455 * and perform custom logging when V8 Allocates Executable Memory. |
4480 */ | 4456 */ |
4481 static void AddMemoryAllocationCallback(MemoryAllocationCallback callback, | 4457 static void AddMemoryAllocationCallback(MemoryAllocationCallback callback, |
4482 ObjectSpace space, | 4458 ObjectSpace space, |
4483 AllocationAction action); | 4459 AllocationAction action); |
4484 | 4460 |
4485 /** | 4461 /** |
4486 * Removes callback that was installed by AddMemoryAllocationCallback. | 4462 * Removes callback that was installed by AddMemoryAllocationCallback. |
4487 */ | 4463 */ |
(...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6455 */ | 6431 */ |
6456 | 6432 |
6457 | 6433 |
6458 } // namespace v8 | 6434 } // namespace v8 |
6459 | 6435 |
6460 | 6436 |
6461 #undef TYPE_CHECK | 6437 #undef TYPE_CHECK |
6462 | 6438 |
6463 | 6439 |
6464 #endif // V8_H_ | 6440 #endif // V8_H_ |
OLD | NEW |