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

Side by Side Diff: include/v8.h

Issue 15001041: Externalization API for ArrayBuffer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/api.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 // 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 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 Handle<Value> GetScriptId() const; 2318 Handle<Value> GetScriptId() const;
2319 ScriptOrigin GetScriptOrigin() const; 2319 ScriptOrigin GetScriptOrigin() const;
2320 V8_INLINE(static Function* Cast(Value* obj)); 2320 V8_INLINE(static Function* Cast(Value* obj));
2321 static const int kLineOffsetNotFound; 2321 static const int kLineOffsetNotFound;
2322 2322
2323 private: 2323 private:
2324 Function(); 2324 Function();
2325 static void CheckCast(Value* obj); 2325 static void CheckCast(Value* obj);
2326 }; 2326 };
2327 2327
2328 /**
2329 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer|
2330 * populates an instance of this class with a pointer to data and byte length.
2331 *
2332 * |ArrayBufferContents| is the owner of its data. When an instance of
2333 * this class is destructed, the |Data| is freed.
2334 *
2335 * This API is experimental and may change significantly.
2336 */
2337 class V8EXPORT ArrayBufferContents {
2338 public:
2339 ArrayBufferContents() : data_(NULL), byte_length_(0) {}
2340 ~ArrayBufferContents();
2341
2342 void* Data() const { return data_; }
2343 size_t ByteLength() const { return byte_length_; }
2344
2345 private:
2346 ArrayBufferContents(void* data, size_t byte_length)
Sven Panne 2013/05/23 09:08:41 No callers, remove it.
2347 : data_(data), byte_length_(byte_length) { }
2348
2349 void* data_;
2350 size_t byte_length_;
2351
2352 friend class ArrayBuffer;
2353 };
2354
2355 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
2356 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
2357 #endif
2328 2358
2329 /** 2359 /**
2330 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). 2360 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
2331 * This API is experimental and may change significantly. 2361 * This API is experimental and may change significantly.
2332 */ 2362 */
2333 class V8EXPORT ArrayBuffer : public Object { 2363 class V8EXPORT ArrayBuffer : public Object {
2334 public: 2364 public:
2335 /** 2365 /**
2336 * Data length in bytes. 2366 * Data length in bytes.
2337 */ 2367 */
2338 size_t ByteLength() const; 2368 size_t ByteLength() const;
2339 /**
2340 * Raw pointer to the array buffer data
2341 */
2342 void* Data() const;
2343 2369
2344 /** 2370 /**
2345 * Create a new ArrayBuffer. Allocate |byte_length| bytes. 2371 * Create a new ArrayBuffer. Allocate |byte_length| bytes.
2346 * Allocated memory will be owned by a created ArrayBuffer and 2372 * Allocated memory will be owned by a created ArrayBuffer and
2347 * will be deallocated when it is garbage-collected. 2373 * will be deallocated when it is garbage-collected,
2374 * unless the object is externalized.
2348 */ 2375 */
2349 static Local<ArrayBuffer> New(size_t byte_length); 2376 static Local<ArrayBuffer> New(size_t byte_length);
2350 2377
2351 /** 2378 /**
2352 * Create a new ArrayBuffer over an existing memory block. 2379 * Create a new ArrayBuffer over an existing memory block.
2380 * The created array buffer is immediately in externalized state.
2353 * The memory block will not be reclaimed when a created ArrayBuffer 2381 * The memory block will not be reclaimed when a created ArrayBuffer
2354 * is garbage-collected. 2382 * is garbage-collected.
2355 */ 2383 */
2356 static Local<ArrayBuffer> New(void* data, size_t byte_length); 2384 static Local<ArrayBuffer> New(void* data, size_t byte_length);
2357 2385
2386 /**
2387 * Returns true if ArrayBuffer is extrenalized, that is, does not
2388 * own its memory block.
2389 */
2390 bool IsExternal() const;
2391
2392 /**
2393 * Pass the ownership of this ArrayBuffer's backing store to
2394 * a given ArrayBufferContents.
2395 */
2396 void Externalize(ArrayBufferContents* contents);
2397
2358 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); 2398 V8_INLINE(static ArrayBuffer* Cast(Value* obj));
2359 2399
2400
2401 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
2402
2360 private: 2403 private:
2361 ArrayBuffer(); 2404 ArrayBuffer();
2362 static void CheckCast(Value* obj); 2405 static void CheckCast(Value* obj);
2363 }; 2406 };
2364 2407
2365 2408
2366 /** 2409 /**
2367 * A base class for an instance of TypedArray series of constructors 2410 * A base class for an instance of TypedArray series of constructors
2368 * (ES6 draft 15.13.6). 2411 * (ES6 draft 15.13.6).
2369 * This API is experimental and may change significantly. 2412 * This API is experimental and may change significantly.
(...skipping 3916 matching lines...) Expand 10 before | Expand all | Expand 10 after
6286 6329
6287 6330
6288 } // namespace v8 6331 } // namespace v8
6289 6332
6290 6333
6291 #undef V8EXPORT 6334 #undef V8EXPORT
6292 #undef TYPE_CHECK 6335 #undef TYPE_CHECK
6293 6336
6294 6337
6295 #endif // V8_H_ 6338 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698