Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: include/v8.h

Issue 1136553006: Implement SharedArrayBuffer (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix dumb typo Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | src/api.h » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
1923 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( 1930 V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(
1924 Local<Context> context) const; 1931 Local<Context> context) const;
1925 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( 1932 V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber(
1926 Local<Context> context) const; 1933 Local<Context> context) const;
1927 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( 1934 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
1928 Local<Context> context) const; 1935 Local<Context> context) const;
1929 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString( 1936 V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
1930 Local<Context> context) const; 1937 Local<Context> context) const;
1931 V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( 1938 V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
1932 Local<Context> context) const; 1939 Local<Context> context) const;
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 * Create a new ArrayBuffer over an existing memory block. 3344 * Create a new ArrayBuffer over an existing memory block.
3338 * The created array buffer is by default immediately in externalized state. 3345 * The created array buffer is by default immediately in externalized state.
3339 * The memory block will not be reclaimed when a created ArrayBuffer 3346 * The memory block will not be reclaimed when a created ArrayBuffer
3340 * is garbage-collected. 3347 * is garbage-collected.
3341 */ 3348 */
3342 static Local<ArrayBuffer> New( 3349 static Local<ArrayBuffer> New(
3343 Isolate* isolate, void* data, size_t byte_length, 3350 Isolate* isolate, void* data, size_t byte_length,
3344 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); 3351 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
3345 3352
3346 /** 3353 /**
3347 * Returns true if ArrayBuffer is extrenalized, that is, does not 3354 * Returns true if ArrayBuffer is externalized, that is, does not
3348 * own its memory block. 3355 * own its memory block.
3349 */ 3356 */
3350 bool IsExternal() const; 3357 bool IsExternal() const;
3351 3358
3352 /** 3359 /**
3353 * Returns true if this ArrayBuffer may be neutered. 3360 * Returns true if this ArrayBuffer may be neutered.
3354 */ 3361 */
3355 bool IsNeuterable() const; 3362 bool IsNeuterable() const;
3356 3363
3357 /** 3364 /**
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 size_t byte_offset, size_t length); 3631 size_t byte_offset, size_t length);
3625 V8_INLINE static DataView* Cast(Value* obj); 3632 V8_INLINE static DataView* Cast(Value* obj);
3626 3633
3627 private: 3634 private:
3628 DataView(); 3635 DataView();
3629 static void CheckCast(Value* obj); 3636 static void CheckCast(Value* obj);
3630 }; 3637 };
3631 3638
3632 3639
3633 /** 3640 /**
3641 * TODO(binji): document
3642 * An instance of the built-in SharedArrayBuffer constructor (ES6 draft
3643 * 15.13.5).
3644 * This API is experimental and may change significantly.
3645 */
3646 class V8_EXPORT SharedArrayBuffer : public Object {
3647 public:
3648 /**
3649 * The contents of an |SharedArrayBuffer|. Externalization of
3650 * |SharedArrayBuffer| returns an instance of this class, populated, with a
3651 * pointer to data and byte length.
3652 *
3653 * The Data pointer of SharedArrayBuffer::Contents is always allocated with
3654 * |ArrayBuffer::Allocator::Allocate| by the allocator specified in
3655 * v8::Isolate::CreateParams::shared_array_buffer_allocator.
3656 *
3657 * This API is experimental and may change significantly.
3658 */
3659 class V8_EXPORT Contents { // NOLINT
3660 public:
3661 Contents() : data_(NULL), byte_length_(0) {}
3662
3663 void* Data() const { return data_; }
3664 size_t ByteLength() const { return byte_length_; }
3665
3666 private:
3667 void* data_;
3668 size_t byte_length_;
3669
3670 friend class SharedArrayBuffer;
3671 };
3672
3673
3674 /**
3675 * Data length in bytes.
3676 */
3677 size_t ByteLength() const;
3678
3679 /**
3680 * Create a new SharedArrayBuffer. Allocate |byte_length| bytes.
3681 * Allocated memory will be owned by a created SharedArrayBuffer and
3682 * will be deallocated when it is garbage-collected,
3683 * unless the object is externalized.
3684 */
3685 static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length);
3686
3687 /**
3688 * Create a new SharedArrayBuffer over an existing memory block. The created
3689 * array buffer is immediately in externalized state unless otherwise
3690 * specified. The memory block will not be reclaimed when a created
3691 * SharedArrayBuffer is garbage-collected.
3692 */
3693 static Local<SharedArrayBuffer> New(
3694 Isolate* isolate, void* data, size_t byte_length,
3695 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
3696
3697 /**
3698 * Returns true if SharedArrayBuffer is externalized, that is, does not
3699 * own its memory block.
3700 */
3701 bool IsExternal() const;
3702
3703 /**
3704 * Make this SharedArrayBuffer external. The pointer to underlying memory
3705 * block and byte length are returned as |Contents| structure. After
3706 * SharedArrayBuffer had been etxrenalized, it does no longer owns the memory
3707 * block. The caller should take steps to free memory when it is no longer
3708 * needed.
3709 *
3710 * The memory block is guaranteed to be allocated with |Allocator::Allocate|
3711 * by the allocator specified in
3712 * v8::Isolate::CreateParams::shared_array_buffer_allocator.
3713 *
3714 */
3715 Contents Externalize();
3716
3717 /**
3718 * Get a pointer to the ArrayBuffer's underlying memory block without
3719 * externalizing it. If the ArrayBuffer is not externalized, this pointer
3720 * will become invalid as soon as the ArrayBuffer became garbage collected.
3721 *
3722 * The embedder should make sure to hold a strong reference to the
3723 * ArrayBuffer while accessing this pointer.
3724 *
3725 * The memory block is guaranteed to be allocated with |Allocator::Allocate|
3726 * by the allocator specified in
3727 * v8::Isolate::CreateParams::shared_array_buffer_allocator.
3728 */
3729 Contents GetContents();
3730
3731 V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
3732
3733 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
3734
3735 private:
3736 SharedArrayBuffer();
3737 static void CheckCast(Value* obj);
3738 };
3739
3740
3741 /**
3634 * An instance of the built-in Date constructor (ECMA-262, 15.9). 3742 * An instance of the built-in Date constructor (ECMA-262, 15.9).
3635 */ 3743 */
3636 class V8_EXPORT Date : public Object { 3744 class V8_EXPORT Date : public Object {
3637 public: 3745 public:
3638 static V8_DEPRECATE_SOON("Use maybe version.", 3746 static V8_DEPRECATE_SOON("Use maybe version.",
3639 Local<Value> New(Isolate* isolate, double time)); 3747 Local<Value> New(Isolate* isolate, double time));
3640 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context, 3748 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
3641 double time); 3749 double time);
3642 3750
3643 /** 3751 /**
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
4999 * Initial configuration parameters for a new Isolate. 5107 * Initial configuration parameters for a new Isolate.
5000 */ 5108 */
5001 struct CreateParams { 5109 struct CreateParams {
5002 CreateParams() 5110 CreateParams()
5003 : entry_hook(NULL), 5111 : entry_hook(NULL),
5004 code_event_handler(NULL), 5112 code_event_handler(NULL),
5005 snapshot_blob(NULL), 5113 snapshot_blob(NULL),
5006 counter_lookup_callback(NULL), 5114 counter_lookup_callback(NULL),
5007 create_histogram_callback(NULL), 5115 create_histogram_callback(NULL),
5008 add_histogram_sample_callback(NULL), 5116 add_histogram_sample_callback(NULL),
5009 array_buffer_allocator(NULL) {} 5117 array_buffer_allocator(NULL),
5118 shared_array_buffer_allocator(NULL) {}
5010 5119
5011 /** 5120 /**
5012 * The optional entry_hook allows the host application to provide the 5121 * The optional entry_hook allows the host application to provide the
5013 * address of a function that's invoked on entry to every V8-generated 5122 * address of a function that's invoked on entry to every V8-generated
5014 * function. Note that entry_hook is invoked at the very start of each 5123 * function. Note that entry_hook is invoked at the very start of each
5015 * generated function. Furthermore, if an entry_hook is given, V8 will 5124 * generated function. Furthermore, if an entry_hook is given, V8 will
5016 * always run without a context snapshot. 5125 * always run without a context snapshot.
5017 */ 5126 */
5018 FunctionEntryHook entry_hook; 5127 FunctionEntryHook entry_hook;
5019 5128
(...skipping 27 matching lines...) Expand all
5047 * function. 5156 * function.
5048 */ 5157 */
5049 CreateHistogramCallback create_histogram_callback; 5158 CreateHistogramCallback create_histogram_callback;
5050 AddHistogramSampleCallback add_histogram_sample_callback; 5159 AddHistogramSampleCallback add_histogram_sample_callback;
5051 5160
5052 /** 5161 /**
5053 * The ArrayBuffer::Allocator to use for allocating and freeing the backing 5162 * The ArrayBuffer::Allocator to use for allocating and freeing the backing
5054 * store of ArrayBuffers. 5163 * store of ArrayBuffers.
5055 */ 5164 */
5056 ArrayBuffer::Allocator* array_buffer_allocator; 5165 ArrayBuffer::Allocator* array_buffer_allocator;
5166
5167 /**
5168 * The ArrayBuffer::Allocator to use for allocating and freeing the backing
5169 * store of SharedArrayBuffers.
5170 */
5171 ArrayBuffer::Allocator* shared_array_buffer_allocator;
jochen (gone - plz use gerrit) 2015/05/22 08:37:47 why do we need a separate allocator?
binji 2015/05/22 09:27:34 We probably don't. Removed.
5057 }; 5172 };
5058 5173
5059 5174
5060 /** 5175 /**
5061 * Stack-allocated class which sets the isolate for all operations 5176 * Stack-allocated class which sets the isolate for all operations
5062 * executed within a local scope. 5177 * executed within a local scope.
5063 */ 5178 */
5064 class V8_EXPORT Scope { 5179 class V8_EXPORT Scope {
5065 public: 5180 public:
5066 explicit Scope(Isolate* isolate) : isolate_(isolate) { 5181 explicit Scope(Isolate* isolate) : isolate_(isolate) {
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
6739 static const int kHeapObjectMapOffset = 0; 6854 static const int kHeapObjectMapOffset = 0;
6740 static const int kMapInstanceTypeAndBitFieldOffset = 6855 static const int kMapInstanceTypeAndBitFieldOffset =
6741 1 * kApiPointerSize + kApiIntSize; 6856 1 * kApiPointerSize + kApiIntSize;
6742 static const int kStringResourceOffset = 3 * kApiPointerSize; 6857 static const int kStringResourceOffset = 3 * kApiPointerSize;
6743 6858
6744 static const int kOddballKindOffset = 3 * kApiPointerSize; 6859 static const int kOddballKindOffset = 3 * kApiPointerSize;
6745 static const int kForeignAddressOffset = kApiPointerSize; 6860 static const int kForeignAddressOffset = kApiPointerSize;
6746 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; 6861 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
6747 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; 6862 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
6748 static const int kContextHeaderSize = 2 * kApiPointerSize; 6863 static const int kContextHeaderSize = 2 * kApiPointerSize;
6749 static const int kContextEmbedderDataIndex = 78; 6864 static const int kContextEmbedderDataIndex = 79;
6750 static const int kFullStringRepresentationMask = 0x07; 6865 static const int kFullStringRepresentationMask = 0x07;
6751 static const int kStringEncodingMask = 0x4; 6866 static const int kStringEncodingMask = 0x4;
6752 static const int kExternalTwoByteRepresentationTag = 0x02; 6867 static const int kExternalTwoByteRepresentationTag = 0x02;
6753 static const int kExternalOneByteRepresentationTag = 0x06; 6868 static const int kExternalOneByteRepresentationTag = 0x06;
6754 6869
6755 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; 6870 static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
6756 static const int kAmountOfExternalAllocatedMemoryOffset = 6871 static const int kAmountOfExternalAllocatedMemoryOffset =
6757 4 * kApiPointerSize; 6872 4 * kApiPointerSize;
6758 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset = 6873 static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset =
6759 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size; 6874 kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size;
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
7810 7925
7811 7926
7812 DataView* DataView::Cast(v8::Value* value) { 7927 DataView* DataView::Cast(v8::Value* value) {
7813 #ifdef V8_ENABLE_CHECKS 7928 #ifdef V8_ENABLE_CHECKS
7814 CheckCast(value); 7929 CheckCast(value);
7815 #endif 7930 #endif
7816 return static_cast<DataView*>(value); 7931 return static_cast<DataView*>(value);
7817 } 7932 }
7818 7933
7819 7934
7935 SharedArrayBuffer* SharedArrayBuffer::Cast(v8::Value* value) {
7936 #ifdef V8_ENABLE_CHECKS
7937 CheckCast(value);
7938 #endif
7939 return static_cast<SharedArrayBuffer*>(value);
7940 }
7941
7942
7820 Function* Function::Cast(v8::Value* value) { 7943 Function* Function::Cast(v8::Value* value) {
7821 #ifdef V8_ENABLE_CHECKS 7944 #ifdef V8_ENABLE_CHECKS
7822 CheckCast(value); 7945 CheckCast(value);
7823 #endif 7946 #endif
7824 return static_cast<Function*>(value); 7947 return static_cast<Function*>(value);
7825 } 7948 }
7826 7949
7827 7950
7828 External* External::Cast(v8::Value* value) { 7951 External* External::Cast(v8::Value* value) {
7829 #ifdef V8_ENABLE_CHECKS 7952 #ifdef V8_ENABLE_CHECKS
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
8115 */ 8238 */
8116 8239
8117 8240
8118 } // namespace v8 8241 } // namespace v8
8119 8242
8120 8243
8121 #undef TYPE_CHECK 8244 #undef TYPE_CHECK
8122 8245
8123 8246
8124 #endif // V8_H_ 8247 #endif // V8_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/api.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698