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 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 * This is an experimental feature. | 1911 * This is an experimental feature. |
1912 */ | 1912 */ |
1913 bool IsFloat64Array() const; | 1913 bool IsFloat64Array() const; |
1914 | 1914 |
1915 /** | 1915 /** |
1916 * Returns true if this value is a DataView. | 1916 * Returns true if this value is a DataView. |
1917 * This is an experimental feature. | 1917 * This is an experimental feature. |
1918 */ | 1918 */ |
1919 bool IsDataView() const; | 1919 bool IsDataView() const; |
1920 | 1920 |
| 1921 /** |
| 1922 * Returns true if this value is a SharedArrayBuffer. |
| 1923 * This is an experimental feature. |
| 1924 */ |
| 1925 bool IsSharedArrayBuffer() const; |
| 1926 |
| 1927 |
1921 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( | 1928 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( |
1922 Local<Context> context) const; | 1929 Local<Context> context) const; |
1923 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( | 1930 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( |
1924 Local<Context> context) const; | 1931 Local<Context> context) const; |
1925 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( | 1932 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( |
1926 Local<Context> context) const; | 1933 Local<Context> context) const; |
1927 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString( | 1934 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString( |
1928 Local<Context> context) const; | 1935 Local<Context> context) const; |
1929 V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( | 1936 V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( |
1930 Local<Context> context) const; | 1937 Local<Context> context) const; |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3295 * Create a new ArrayBuffer over an existing memory block. | 3302 * Create a new ArrayBuffer over an existing memory block. |
3296 * The created array buffer is by default immediately in externalized state. | 3303 * The created array buffer is by default immediately in externalized state. |
3297 * The memory block will not be reclaimed when a created ArrayBuffer | 3304 * The memory block will not be reclaimed when a created ArrayBuffer |
3298 * is garbage-collected. | 3305 * is garbage-collected. |
3299 */ | 3306 */ |
3300 static Local<ArrayBuffer> New( | 3307 static Local<ArrayBuffer> New( |
3301 Isolate* isolate, void* data, size_t byte_length, | 3308 Isolate* isolate, void* data, size_t byte_length, |
3302 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); | 3309 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); |
3303 | 3310 |
3304 /** | 3311 /** |
3305 * Returns true if ArrayBuffer is extrenalized, that is, does not | 3312 * Returns true if ArrayBuffer is externalized, that is, does not |
3306 * own its memory block. | 3313 * own its memory block. |
3307 */ | 3314 */ |
3308 bool IsExternal() const; | 3315 bool IsExternal() const; |
3309 | 3316 |
3310 /** | 3317 /** |
3311 * Returns true if this ArrayBuffer may be neutered. | 3318 * Returns true if this ArrayBuffer may be neutered. |
3312 */ | 3319 */ |
3313 bool IsNeuterable() const; | 3320 bool IsNeuterable() const; |
3314 | 3321 |
3315 /** | 3322 /** |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 size_t byte_offset, size_t length); | 3589 size_t byte_offset, size_t length); |
3583 V8_INLINE static DataView* Cast(Value* obj); | 3590 V8_INLINE static DataView* Cast(Value* obj); |
3584 | 3591 |
3585 private: | 3592 private: |
3586 DataView(); | 3593 DataView(); |
3587 static void CheckCast(Value* obj); | 3594 static void CheckCast(Value* obj); |
3588 }; | 3595 }; |
3589 | 3596 |
3590 | 3597 |
3591 /** | 3598 /** |
| 3599 * An instance of the built-in SharedArrayBuffer constructor. |
| 3600 * This API is experimental and may change significantly. |
| 3601 */ |
| 3602 class V8_EXPORT SharedArrayBuffer : public Object { |
| 3603 public: |
| 3604 /** |
| 3605 * The contents of an |SharedArrayBuffer|. Externalization of |
| 3606 * |SharedArrayBuffer| returns an instance of this class, populated, with a |
| 3607 * pointer to data and byte length. |
| 3608 * |
| 3609 * The Data pointer of SharedArrayBuffer::Contents is always allocated with |
| 3610 * |ArrayBuffer::Allocator::Allocate| by the allocator specified in |
| 3611 * v8::Isolate::CreateParams::array_buffer_allocator. |
| 3612 * |
| 3613 * This API is experimental and may change significantly. |
| 3614 */ |
| 3615 class V8_EXPORT Contents { // NOLINT |
| 3616 public: |
| 3617 Contents() : data_(NULL), byte_length_(0) {} |
| 3618 |
| 3619 void* Data() const { return data_; } |
| 3620 size_t ByteLength() const { return byte_length_; } |
| 3621 |
| 3622 private: |
| 3623 void* data_; |
| 3624 size_t byte_length_; |
| 3625 |
| 3626 friend class SharedArrayBuffer; |
| 3627 }; |
| 3628 |
| 3629 |
| 3630 /** |
| 3631 * Data length in bytes. |
| 3632 */ |
| 3633 size_t ByteLength() const; |
| 3634 |
| 3635 /** |
| 3636 * Create a new SharedArrayBuffer. Allocate |byte_length| bytes. |
| 3637 * Allocated memory will be owned by a created SharedArrayBuffer and |
| 3638 * will be deallocated when it is garbage-collected, |
| 3639 * unless the object is externalized. |
| 3640 */ |
| 3641 static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length); |
| 3642 |
| 3643 /** |
| 3644 * Create a new SharedArrayBuffer over an existing memory block. The created |
| 3645 * array buffer is immediately in externalized state unless otherwise |
| 3646 * specified. The memory block will not be reclaimed when a created |
| 3647 * SharedArrayBuffer is garbage-collected. |
| 3648 */ |
| 3649 static Local<SharedArrayBuffer> New( |
| 3650 Isolate* isolate, void* data, size_t byte_length, |
| 3651 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); |
| 3652 |
| 3653 /** |
| 3654 * Returns true if SharedArrayBuffer is externalized, that is, does not |
| 3655 * own its memory block. |
| 3656 */ |
| 3657 bool IsExternal() const; |
| 3658 |
| 3659 /** |
| 3660 * Make this SharedArrayBuffer external. The pointer to underlying memory |
| 3661 * block and byte length are returned as |Contents| structure. After |
| 3662 * SharedArrayBuffer had been etxrenalized, it does no longer owns the memory |
| 3663 * block. The caller should take steps to free memory when it is no longer |
| 3664 * needed. |
| 3665 * |
| 3666 * The memory block is guaranteed to be allocated with |Allocator::Allocate| |
| 3667 * by the allocator specified in |
| 3668 * v8::Isolate::CreateParams::array_buffer_allocator. |
| 3669 * |
| 3670 */ |
| 3671 Contents Externalize(); |
| 3672 |
| 3673 /** |
| 3674 * Get a pointer to the ArrayBuffer's underlying memory block without |
| 3675 * externalizing it. If the ArrayBuffer is not externalized, this pointer |
| 3676 * will become invalid as soon as the ArrayBuffer became garbage collected. |
| 3677 * |
| 3678 * The embedder should make sure to hold a strong reference to the |
| 3679 * ArrayBuffer while accessing this pointer. |
| 3680 * |
| 3681 * The memory block is guaranteed to be allocated with |Allocator::Allocate| |
| 3682 * by the allocator specified in |
| 3683 * v8::Isolate::CreateParams::array_buffer_allocator. |
| 3684 */ |
| 3685 Contents GetContents(); |
| 3686 |
| 3687 V8_INLINE static SharedArrayBuffer* Cast(Value* obj); |
| 3688 |
| 3689 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; |
| 3690 |
| 3691 private: |
| 3692 SharedArrayBuffer(); |
| 3693 static void CheckCast(Value* obj); |
| 3694 }; |
| 3695 |
| 3696 |
| 3697 /** |
3592 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 3698 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
3593 */ | 3699 */ |
3594 class V8_EXPORT Date : public Object { | 3700 class V8_EXPORT Date : public Object { |
3595 public: | 3701 public: |
3596 static V8_DEPRECATE_SOON("Use maybe version.", | 3702 static V8_DEPRECATE_SOON("Use maybe version.", |
3597 Local<Value> New(Isolate* isolate, double time)); | 3703 Local<Value> New(Isolate* isolate, double time)); |
3598 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context, | 3704 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context, |
3599 double time); | 3705 double time); |
3600 | 3706 |
3601 /** | 3707 /** |
(...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6697 static const int kHeapObjectMapOffset = 0; | 6803 static const int kHeapObjectMapOffset = 0; |
6698 static const int kMapInstanceTypeAndBitFieldOffset = | 6804 static const int kMapInstanceTypeAndBitFieldOffset = |
6699 1 * kApiPointerSize + kApiIntSize; | 6805 1 * kApiPointerSize + kApiIntSize; |
6700 static const int kStringResourceOffset = 3 * kApiPointerSize; | 6806 static const int kStringResourceOffset = 3 * kApiPointerSize; |
6701 | 6807 |
6702 static const int kOddballKindOffset = 3 * kApiPointerSize; | 6808 static const int kOddballKindOffset = 3 * kApiPointerSize; |
6703 static const int kForeignAddressOffset = kApiPointerSize; | 6809 static const int kForeignAddressOffset = kApiPointerSize; |
6704 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 6810 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
6705 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 6811 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
6706 static const int kContextHeaderSize = 2 * kApiPointerSize; | 6812 static const int kContextHeaderSize = 2 * kApiPointerSize; |
6707 static const int kContextEmbedderDataIndex = 79; | 6813 static const int kContextEmbedderDataIndex = 80; |
6708 static const int kFullStringRepresentationMask = 0x07; | 6814 static const int kFullStringRepresentationMask = 0x07; |
6709 static const int kStringEncodingMask = 0x4; | 6815 static const int kStringEncodingMask = 0x4; |
6710 static const int kExternalTwoByteRepresentationTag = 0x02; | 6816 static const int kExternalTwoByteRepresentationTag = 0x02; |
6711 static const int kExternalOneByteRepresentationTag = 0x06; | 6817 static const int kExternalOneByteRepresentationTag = 0x06; |
6712 | 6818 |
6713 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; | 6819 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; |
6714 static const int kAmountOfExternalAllocatedMemoryOffset = | 6820 static const int kAmountOfExternalAllocatedMemoryOffset = |
6715 4 * kApiPointerSize; | 6821 4 * kApiPointerSize; |
6716 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = | 6822 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = |
6717 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; | 6823 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7768 | 7874 |
7769 | 7875 |
7770 DataView* DataView::Cast(v8::Value* value) { | 7876 DataView* DataView::Cast(v8::Value* value) { |
7771 #ifdef V8_ENABLE_CHECKS | 7877 #ifdef V8_ENABLE_CHECKS |
7772 CheckCast(value); | 7878 CheckCast(value); |
7773 #endif | 7879 #endif |
7774 return static_cast<DataView*>(value); | 7880 return static_cast<DataView*>(value); |
7775 } | 7881 } |
7776 | 7882 |
7777 | 7883 |
| 7884 SharedArrayBuffer* SharedArrayBuffer::Cast(v8::Value* value) { |
| 7885 #ifdef V8_ENABLE_CHECKS |
| 7886 CheckCast(value); |
| 7887 #endif |
| 7888 return static_cast<SharedArrayBuffer*>(value); |
| 7889 } |
| 7890 |
| 7891 |
7778 Function* Function::Cast(v8::Value* value) { | 7892 Function* Function::Cast(v8::Value* value) { |
7779 #ifdef V8_ENABLE_CHECKS | 7893 #ifdef V8_ENABLE_CHECKS |
7780 CheckCast(value); | 7894 CheckCast(value); |
7781 #endif | 7895 #endif |
7782 return static_cast<Function*>(value); | 7896 return static_cast<Function*>(value); |
7783 } | 7897 } |
7784 | 7898 |
7785 | 7899 |
7786 External* External::Cast(v8::Value* value) { | 7900 External* External::Cast(v8::Value* value) { |
7787 #ifdef V8_ENABLE_CHECKS | 7901 #ifdef V8_ENABLE_CHECKS |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8073 */ | 8187 */ |
8074 | 8188 |
8075 | 8189 |
8076 } // namespace v8 | 8190 } // namespace v8 |
8077 | 8191 |
8078 | 8192 |
8079 #undef TYPE_CHECK | 8193 #undef TYPE_CHECK |
8080 | 8194 |
8081 | 8195 |
8082 #endif // V8_H_ | 8196 #endif // V8_H_ |
OLD | NEW |