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

Side by Side Diff: include/v8.h

Issue 1116633002: Pass ArrayBuffer::Allocator via Isolate::CreateParams (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | samples/process.cc » ('j') | no next file with comments »
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 3218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 3229
3230 3230
3231 /** 3231 /**
3232 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). 3232 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
3233 * This API is experimental and may change significantly. 3233 * This API is experimental and may change significantly.
3234 */ 3234 */
3235 class V8_EXPORT ArrayBuffer : public Object { 3235 class V8_EXPORT ArrayBuffer : public Object {
3236 public: 3236 public:
3237 /** 3237 /**
3238 * Allocator that V8 uses to allocate |ArrayBuffer|'s memory. 3238 * Allocator that V8 uses to allocate |ArrayBuffer|'s memory.
3239 * The allocator is a global V8 setting. It should be set with 3239 * The allocator is a global V8 setting. It has to be set via
3240 * V8::SetArrayBufferAllocator prior to creation of a first ArrayBuffer. 3240 * Isolate::CreateParams.
3241 * 3241 *
3242 * This API is experimental and may change significantly. 3242 * This API is experimental and may change significantly.
3243 */ 3243 */
3244 class V8_EXPORT Allocator { // NOLINT 3244 class V8_EXPORT Allocator { // NOLINT
3245 public: 3245 public:
3246 virtual ~Allocator() {} 3246 virtual ~Allocator() {}
3247 3247
3248 /** 3248 /**
3249 * Allocate |length| bytes. Return NULL if allocation is not successful. 3249 * Allocate |length| bytes. Return NULL if allocation is not successful.
3250 * Memory should be initialized to zeroes. 3250 * Memory should be initialized to zeroes.
(...skipping 11 matching lines...) Expand all
3262 */ 3262 */
3263 virtual void Free(void* data, size_t length) = 0; 3263 virtual void Free(void* data, size_t length) = 0;
3264 }; 3264 };
3265 3265
3266 /** 3266 /**
3267 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| 3267 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer|
3268 * returns an instance of this class, populated, with a pointer to data 3268 * returns an instance of this class, populated, with a pointer to data
3269 * and byte length. 3269 * and byte length.
3270 * 3270 *
3271 * The Data pointer of ArrayBuffer::Contents is always allocated with 3271 * The Data pointer of ArrayBuffer::Contents is always allocated with
3272 * Allocator::Allocate that is set with V8::SetArrayBufferAllocator. 3272 * Allocator::Allocate that is set via Isolate::CreateParams.
3273 * 3273 *
3274 * This API is experimental and may change significantly. 3274 * This API is experimental and may change significantly.
3275 */ 3275 */
3276 class V8_EXPORT Contents { // NOLINT 3276 class V8_EXPORT Contents { // NOLINT
3277 public: 3277 public:
3278 Contents() : data_(NULL), byte_length_(0) {} 3278 Contents() : data_(NULL), byte_length_(0) {}
3279 3279
3280 void* Data() const { return data_; } 3280 void* Data() const { return data_; }
3281 size_t ByteLength() const { return byte_length_; } 3281 size_t ByteLength() const { return byte_length_; }
3282 3282
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3330 */ 3330 */
3331 void Neuter(); 3331 void Neuter();
3332 3332
3333 /** 3333 /**
3334 * Make this ArrayBuffer external. The pointer to underlying memory block 3334 * Make this ArrayBuffer external. The pointer to underlying memory block
3335 * and byte length are returned as |Contents| structure. After ArrayBuffer 3335 * and byte length are returned as |Contents| structure. After ArrayBuffer
3336 * had been etxrenalized, it does no longer owns the memory block. The caller 3336 * had been etxrenalized, it does no longer owns the memory block. The caller
3337 * should take steps to free memory when it is no longer needed. 3337 * should take steps to free memory when it is no longer needed.
3338 * 3338 *
3339 * The memory block is guaranteed to be allocated with |Allocator::Allocate| 3339 * The memory block is guaranteed to be allocated with |Allocator::Allocate|
3340 * that has been set with V8::SetArrayBufferAllocator. 3340 * that has been set via Isolate::CreateParams.
3341 */ 3341 */
3342 Contents Externalize(); 3342 Contents Externalize();
3343 3343
3344 /** 3344 /**
3345 * Get a pointer to the ArrayBuffer's underlying memory block without 3345 * Get a pointer to the ArrayBuffer's underlying memory block without
3346 * externalizing it. If the ArrayBuffer is not externalized, this pointer 3346 * externalizing it. If the ArrayBuffer is not externalized, this pointer
3347 * will become invalid as soon as the ArrayBuffer became garbage collected. 3347 * will become invalid as soon as the ArrayBuffer became garbage collected.
3348 * 3348 *
3349 * The embedder should make sure to hold a strong reference to the 3349 * The embedder should make sure to hold a strong reference to the
3350 * ArrayBuffer while accessing this pointer. 3350 * ArrayBuffer while accessing this pointer.
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after
4946 /** 4946 /**
4947 * Initial configuration parameters for a new Isolate. 4947 * Initial configuration parameters for a new Isolate.
4948 */ 4948 */
4949 struct CreateParams { 4949 struct CreateParams {
4950 CreateParams() 4950 CreateParams()
4951 : entry_hook(NULL), 4951 : entry_hook(NULL),
4952 code_event_handler(NULL), 4952 code_event_handler(NULL),
4953 snapshot_blob(NULL), 4953 snapshot_blob(NULL),
4954 counter_lookup_callback(NULL), 4954 counter_lookup_callback(NULL),
4955 create_histogram_callback(NULL), 4955 create_histogram_callback(NULL),
4956 add_histogram_sample_callback(NULL) {} 4956 add_histogram_sample_callback(NULL),
4957 array_buffer_allocator(NULL) {}
4957 4958
4958 /** 4959 /**
4959 * The optional entry_hook allows the host application to provide the 4960 * The optional entry_hook allows the host application to provide the
4960 * address of a function that's invoked on entry to every V8-generated 4961 * address of a function that's invoked on entry to every V8-generated
4961 * function. Note that entry_hook is invoked at the very start of each 4962 * function. Note that entry_hook is invoked at the very start of each
4962 * generated function. Furthermore, if an entry_hook is given, V8 will 4963 * generated function. Furthermore, if an entry_hook is given, V8 will
4963 * always run without a context snapshot. 4964 * always run without a context snapshot.
4964 */ 4965 */
4965 FunctionEntryHook entry_hook; 4966 FunctionEntryHook entry_hook;
4966 4967
(...skipping 21 matching lines...) Expand all
4988 CounterLookupCallback counter_lookup_callback; 4989 CounterLookupCallback counter_lookup_callback;
4989 4990
4990 /** 4991 /**
4991 * Enables the host application to provide a mechanism for recording 4992 * Enables the host application to provide a mechanism for recording
4992 * histograms. The CreateHistogram function returns a 4993 * histograms. The CreateHistogram function returns a
4993 * histogram which will later be passed to the AddHistogramSample 4994 * histogram which will later be passed to the AddHistogramSample
4994 * function. 4995 * function.
4995 */ 4996 */
4996 CreateHistogramCallback create_histogram_callback; 4997 CreateHistogramCallback create_histogram_callback;
4997 AddHistogramSampleCallback add_histogram_sample_callback; 4998 AddHistogramSampleCallback add_histogram_sample_callback;
4999
5000 /**
5001 * The ArrayBuffer::Allocator to use for allocating and freeing the backing
5002 * store of ArrayBuffers.
5003 */
5004 ArrayBuffer::Allocator* array_buffer_allocator;
4998 }; 5005 };
4999 5006
5000 5007
5001 /** 5008 /**
5002 * Stack-allocated class which sets the isolate for all operations 5009 * Stack-allocated class which sets the isolate for all operations
5003 * executed within a local scope. 5010 * executed within a local scope.
5004 */ 5011 */
5005 class V8_EXPORT Scope { 5012 class V8_EXPORT Scope {
5006 public: 5013 public:
5007 explicit Scope(Isolate* isolate) : isolate_(isolate) { 5014 explicit Scope(Isolate* isolate) : isolate_(isolate) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
5107 5114
5108 /** 5115 /**
5109 * Creates a new isolate. Does not change the currently entered 5116 * Creates a new isolate. Does not change the currently entered
5110 * isolate. 5117 * isolate.
5111 * 5118 *
5112 * When an isolate is no longer used its resources should be freed 5119 * When an isolate is no longer used its resources should be freed
5113 * by calling Dispose(). Using the delete operator is not allowed. 5120 * by calling Dispose(). Using the delete operator is not allowed.
5114 * 5121 *
5115 * V8::Initialize() must have run prior to this. 5122 * V8::Initialize() must have run prior to this.
5116 */ 5123 */
5117 static Isolate* New(const CreateParams& params = CreateParams()); 5124 static Isolate* New(const CreateParams& params);
5125
5126 static V8_DEPRECATED("Always pass CreateParams", Isolate* New());
5118 5127
5119 /** 5128 /**
5120 * Returns the entered isolate for the current thread or NULL in 5129 * Returns the entered isolate for the current thread or NULL in
5121 * case there is no current isolate. 5130 * case there is no current isolate.
5122 * 5131 *
5123 * This method must not be invoked before V8::Initialize() was invoked. 5132 * This method must not be invoked before V8::Initialize() was invoked.
5124 */ 5133 */
5125 static Isolate* GetCurrent(); 5134 static Isolate* GetCurrent();
5126 5135
5127 /** 5136 /**
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
5697 V8_INLINE static V8_DEPRECATE_SOON( 5706 V8_INLINE static V8_DEPRECATE_SOON(
5698 "Use isolate version", void SetAllowCodeGenerationFromStringsCallback( 5707 "Use isolate version", void SetAllowCodeGenerationFromStringsCallback(
5699 AllowCodeGenerationFromStringsCallback that)); 5708 AllowCodeGenerationFromStringsCallback that));
5700 5709
5701 /** 5710 /**
5702 * Set allocator to use for ArrayBuffer memory. 5711 * Set allocator to use for ArrayBuffer memory.
5703 * The allocator should be set only once. The allocator should be set 5712 * The allocator should be set only once. The allocator should be set
5704 * before any code tha uses ArrayBuffers is executed. 5713 * before any code tha uses ArrayBuffers is executed.
5705 * This allocator is used in all isolates. 5714 * This allocator is used in all isolates.
5706 */ 5715 */
5707 static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator); 5716 static V8_DEPRECATE_SOON(
5717 "Use isolate version",
5718 void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator));
5708 5719
5709 /** 5720 /**
5710 * Check if V8 is dead and therefore unusable. This is the case after 5721 * Check if V8 is dead and therefore unusable. This is the case after
5711 * fatal errors such as out-of-memory situations. 5722 * fatal errors such as out-of-memory situations.
5712 */ 5723 */
5713 V8_INLINE static V8_DEPRECATE_SOON("no alternative", bool IsDead()); 5724 V8_INLINE static V8_DEPRECATE_SOON("no alternative", bool IsDead());
5714 5725
5715 /** 5726 /**
5716 * Hand startup data to V8, in case the embedder has chosen to build 5727 * Hand startup data to V8, in case the embedder has chosen to build
5717 * V8 with external startup data. 5728 * V8 with external startup data.
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after
8008 */ 8019 */
8009 8020
8010 8021
8011 } // namespace v8 8022 } // namespace v8
8012 8023
8013 8024
8014 #undef TYPE_CHECK 8025 #undef TYPE_CHECK
8015 8026
8016 8027
8017 #endif // V8_H_ 8028 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | samples/process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698