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 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 * This is an experimental feature. | 1913 * This is an experimental feature. |
1914 */ | 1914 */ |
1915 bool IsFloat64Array() const; | 1915 bool IsFloat64Array() const; |
1916 | 1916 |
1917 /** | 1917 /** |
1918 * Returns true if this value is a DataView. | 1918 * Returns true if this value is a DataView. |
1919 * This is an experimental feature. | 1919 * This is an experimental feature. |
1920 */ | 1920 */ |
1921 bool IsDataView() const; | 1921 bool IsDataView() const; |
1922 | 1922 |
1923 /** | |
1924 * Returns true if this value is a SharedArrayBuffer. | |
1925 * This is an experimental feature. | |
1926 */ | |
1927 bool IsSharedArrayBuffer() const; | |
1928 | |
1929 | |
1930 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( | 1923 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( |
1931 Local<Context> context) const; | 1924 Local<Context> context) const; |
1932 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( | 1925 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( |
1933 Local<Context> context) const; | 1926 Local<Context> context) const; |
1934 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( | 1927 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( |
1935 Local<Context> context) const; | 1928 Local<Context> context) const; |
1936 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString( | 1929 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString( |
1937 Local<Context> context) const; | 1930 Local<Context> context) const; |
1938 V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( | 1931 V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( |
1939 Local<Context> context) const; | 1932 Local<Context> context) const; |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3344 * Create a new ArrayBuffer over an existing memory block. | 3337 * Create a new ArrayBuffer over an existing memory block. |
3345 * The created array buffer is by default immediately in externalized state. | 3338 * The created array buffer is by default immediately in externalized state. |
3346 * The memory block will not be reclaimed when a created ArrayBuffer | 3339 * The memory block will not be reclaimed when a created ArrayBuffer |
3347 * is garbage-collected. | 3340 * is garbage-collected. |
3348 */ | 3341 */ |
3349 static Local<ArrayBuffer> New( | 3342 static Local<ArrayBuffer> New( |
3350 Isolate* isolate, void* data, size_t byte_length, | 3343 Isolate* isolate, void* data, size_t byte_length, |
3351 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); | 3344 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); |
3352 | 3345 |
3353 /** | 3346 /** |
3354 * Returns true if ArrayBuffer is externalized, that is, does not | 3347 * Returns true if ArrayBuffer is extrenalized, that is, does not |
3355 * own its memory block. | 3348 * own its memory block. |
3356 */ | 3349 */ |
3357 bool IsExternal() const; | 3350 bool IsExternal() const; |
3358 | 3351 |
3359 /** | 3352 /** |
3360 * Returns true if this ArrayBuffer may be neutered. | 3353 * Returns true if this ArrayBuffer may be neutered. |
3361 */ | 3354 */ |
3362 bool IsNeuterable() const; | 3355 bool IsNeuterable() const; |
3363 | 3356 |
3364 /** | 3357 /** |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3629 public: | 3622 public: |
3630 static Local<DataView> New(Handle<ArrayBuffer> array_buffer, | 3623 static Local<DataView> New(Handle<ArrayBuffer> array_buffer, |
3631 size_t byte_offset, size_t length); | 3624 size_t byte_offset, size_t length); |
3632 V8_INLINE static DataView* Cast(Value* obj); | 3625 V8_INLINE static DataView* Cast(Value* obj); |
3633 | 3626 |
3634 private: | 3627 private: |
3635 DataView(); | 3628 DataView(); |
3636 static void CheckCast(Value* obj); | 3629 static void CheckCast(Value* obj); |
3637 }; | 3630 }; |
3638 | 3631 |
3639 | |
3640 /** | |
3641 * An instance of the built-in SharedArrayBuffer constructor. | |
3642 * This API is experimental and may change significantly. | |
3643 */ | |
3644 class V8_EXPORT SharedArrayBuffer : public Object { | |
3645 public: | |
3646 /** | |
3647 * The contents of an |SharedArrayBuffer|. Externalization of | |
3648 * |SharedArrayBuffer| returns an instance of this class, populated, with a | |
3649 * pointer to data and byte length. | |
3650 * | |
3651 * The Data pointer of SharedArrayBuffer::Contents is always allocated with | |
3652 * |ArrayBuffer::Allocator::Allocate| by the allocator specified in | |
3653 * v8::Isolate::CreateParams::array_buffer_allocator. | |
3654 * | |
3655 * This API is experimental and may change significantly. | |
3656 */ | |
3657 class V8_EXPORT Contents { // NOLINT | |
3658 public: | |
3659 Contents() : data_(NULL), byte_length_(0) {} | |
3660 | |
3661 void* Data() const { return data_; } | |
3662 size_t ByteLength() const { return byte_length_; } | |
3663 | |
3664 private: | |
3665 void* data_; | |
3666 size_t byte_length_; | |
3667 | |
3668 friend class SharedArrayBuffer; | |
3669 }; | |
3670 | |
3671 | |
3672 /** | |
3673 * Data length in bytes. | |
3674 */ | |
3675 size_t ByteLength() const; | |
3676 | |
3677 /** | |
3678 * Create a new SharedArrayBuffer. Allocate |byte_length| bytes. | |
3679 * Allocated memory will be owned by a created SharedArrayBuffer and | |
3680 * will be deallocated when it is garbage-collected, | |
3681 * unless the object is externalized. | |
3682 */ | |
3683 static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length); | |
3684 | |
3685 /** | |
3686 * Create a new SharedArrayBuffer over an existing memory block. The created | |
3687 * array buffer is immediately in externalized state unless otherwise | |
3688 * specified. The memory block will not be reclaimed when a created | |
3689 * SharedArrayBuffer is garbage-collected. | |
3690 */ | |
3691 static Local<SharedArrayBuffer> New( | |
3692 Isolate* isolate, void* data, size_t byte_length, | |
3693 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); | |
3694 | |
3695 /** | |
3696 * Returns true if SharedArrayBuffer is externalized, that is, does not | |
3697 * own its memory block. | |
3698 */ | |
3699 bool IsExternal() const; | |
3700 | |
3701 /** | |
3702 * Make this SharedArrayBuffer external. The pointer to underlying memory | |
3703 * block and byte length are returned as |Contents| structure. After | |
3704 * SharedArrayBuffer had been etxrenalized, it does no longer owns the memory | |
3705 * block. The caller should take steps to free memory when it is no longer | |
3706 * needed. | |
3707 * | |
3708 * The memory block is guaranteed to be allocated with |Allocator::Allocate| | |
3709 * by the allocator specified in | |
3710 * v8::Isolate::CreateParams::array_buffer_allocator. | |
3711 * | |
3712 */ | |
3713 Contents Externalize(); | |
3714 | |
3715 /** | |
3716 * Get a pointer to the ArrayBuffer's underlying memory block without | |
3717 * externalizing it. If the ArrayBuffer is not externalized, this pointer | |
3718 * will become invalid as soon as the ArrayBuffer became garbage collected. | |
3719 * | |
3720 * The embedder should make sure to hold a strong reference to the | |
3721 * ArrayBuffer while accessing this pointer. | |
3722 * | |
3723 * The memory block is guaranteed to be allocated with |Allocator::Allocate| | |
3724 * by the allocator specified in | |
3725 * v8::Isolate::CreateParams::array_buffer_allocator. | |
3726 */ | |
3727 Contents GetContents(); | |
3728 | |
3729 V8_INLINE static SharedArrayBuffer* Cast(Value* obj); | |
3730 | |
3731 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | |
3732 | |
3733 private: | |
3734 SharedArrayBuffer(); | |
3735 static void CheckCast(Value* obj); | |
3736 }; | |
3737 | |
3738 | 3632 |
3739 /** | 3633 /** |
3740 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 3634 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
3741 */ | 3635 */ |
3742 class V8_EXPORT Date : public Object { | 3636 class V8_EXPORT Date : public Object { |
3743 public: | 3637 public: |
3744 static V8_DEPRECATE_SOON("Use maybe version.", | 3638 static V8_DEPRECATE_SOON("Use maybe version.", |
3745 Local<Value> New(Isolate* isolate, double time)); | 3639 Local<Value> New(Isolate* isolate, double time)); |
3746 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context, | 3640 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context, |
3747 double time); | 3641 double time); |
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6845 static const int kHeapObjectMapOffset = 0; | 6739 static const int kHeapObjectMapOffset = 0; |
6846 static const int kMapInstanceTypeAndBitFieldOffset = | 6740 static const int kMapInstanceTypeAndBitFieldOffset = |
6847 1 * kApiPointerSize + kApiIntSize; | 6741 1 * kApiPointerSize + kApiIntSize; |
6848 static const int kStringResourceOffset = 3 * kApiPointerSize; | 6742 static const int kStringResourceOffset = 3 * kApiPointerSize; |
6849 | 6743 |
6850 static const int kOddballKindOffset = 3 * kApiPointerSize; | 6744 static const int kOddballKindOffset = 3 * kApiPointerSize; |
6851 static const int kForeignAddressOffset = kApiPointerSize; | 6745 static const int kForeignAddressOffset = kApiPointerSize; |
6852 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 6746 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
6853 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 6747 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
6854 static const int kContextHeaderSize = 2 * kApiPointerSize; | 6748 static const int kContextHeaderSize = 2 * kApiPointerSize; |
6855 static const int kContextEmbedderDataIndex = 79; | 6749 static const int kContextEmbedderDataIndex = 78; |
6856 static const int kFullStringRepresentationMask = 0x07; | 6750 static const int kFullStringRepresentationMask = 0x07; |
6857 static const int kStringEncodingMask = 0x4; | 6751 static const int kStringEncodingMask = 0x4; |
6858 static const int kExternalTwoByteRepresentationTag = 0x02; | 6752 static const int kExternalTwoByteRepresentationTag = 0x02; |
6859 static const int kExternalOneByteRepresentationTag = 0x06; | 6753 static const int kExternalOneByteRepresentationTag = 0x06; |
6860 | 6754 |
6861 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; | 6755 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; |
6862 static const int kAmountOfExternalAllocatedMemoryOffset = | 6756 static const int kAmountOfExternalAllocatedMemoryOffset = |
6863 4 * kApiPointerSize; | 6757 4 * kApiPointerSize; |
6864 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = | 6758 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = |
6865 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; | 6759 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7916 | 7810 |
7917 | 7811 |
7918 DataView* DataView::Cast(v8::Value* value) { | 7812 DataView* DataView::Cast(v8::Value* value) { |
7919 #ifdef V8_ENABLE_CHECKS | 7813 #ifdef V8_ENABLE_CHECKS |
7920 CheckCast(value); | 7814 CheckCast(value); |
7921 #endif | 7815 #endif |
7922 return static_cast<DataView*>(value); | 7816 return static_cast<DataView*>(value); |
7923 } | 7817 } |
7924 | 7818 |
7925 | 7819 |
7926 SharedArrayBuffer* SharedArrayBuffer::Cast(v8::Value* value) { | |
7927 #ifdef V8_ENABLE_CHECKS | |
7928 CheckCast(value); | |
7929 #endif | |
7930 return static_cast<SharedArrayBuffer*>(value); | |
7931 } | |
7932 | |
7933 | |
7934 Function* Function::Cast(v8::Value* value) { | 7820 Function* Function::Cast(v8::Value* value) { |
7935 #ifdef V8_ENABLE_CHECKS | 7821 #ifdef V8_ENABLE_CHECKS |
7936 CheckCast(value); | 7822 CheckCast(value); |
7937 #endif | 7823 #endif |
7938 return static_cast<Function*>(value); | 7824 return static_cast<Function*>(value); |
7939 } | 7825 } |
7940 | 7826 |
7941 | 7827 |
7942 External* External::Cast(v8::Value* value) { | 7828 External* External::Cast(v8::Value* value) { |
7943 #ifdef V8_ENABLE_CHECKS | 7829 #ifdef V8_ENABLE_CHECKS |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8229 */ | 8115 */ |
8230 | 8116 |
8231 | 8117 |
8232 } // namespace v8 | 8118 } // namespace v8 |
8233 | 8119 |
8234 | 8120 |
8235 #undef TYPE_CHECK | 8121 #undef TYPE_CHECK |
8236 | 8122 |
8237 | 8123 |
8238 #endif // V8_H_ | 8124 #endif // V8_H_ |
OLD | NEW |