| OLD | NEW |
| 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 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 Handle<Value> GetScriptId() const; | 2363 Handle<Value> GetScriptId() const; |
| 2364 ScriptOrigin GetScriptOrigin() const; | 2364 ScriptOrigin GetScriptOrigin() const; |
| 2365 V8_INLINE(static Function* Cast(Value* obj)); | 2365 V8_INLINE(static Function* Cast(Value* obj)); |
| 2366 static const int kLineOffsetNotFound; | 2366 static const int kLineOffsetNotFound; |
| 2367 | 2367 |
| 2368 private: | 2368 private: |
| 2369 Function(); | 2369 Function(); |
| 2370 static void CheckCast(Value* obj); | 2370 static void CheckCast(Value* obj); |
| 2371 }; | 2371 }; |
| 2372 | 2372 |
| 2373 /** | |
| 2374 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| | |
| 2375 * populates an instance of this class with a pointer to data and byte length. | |
| 2376 * | |
| 2377 * |ArrayBufferContents| is the owner of its data. When an instance of | |
| 2378 * this class is destructed, the |Data| is freed. | |
| 2379 * | |
| 2380 * This API is experimental and may change significantly. | |
| 2381 */ | |
| 2382 class V8EXPORT ArrayBufferContents { | |
| 2383 public: | |
| 2384 ArrayBufferContents() : data_(NULL), byte_length_(0) {} | |
| 2385 ~ArrayBufferContents(); | |
| 2386 | |
| 2387 void* Data() const { return data_; } | |
| 2388 size_t ByteLength() const { return byte_length_; } | |
| 2389 | |
| 2390 private: | |
| 2391 void* data_; | |
| 2392 size_t byte_length_; | |
| 2393 | |
| 2394 friend class ArrayBuffer; | |
| 2395 }; | |
| 2396 | |
| 2397 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | 2373 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT |
| 2398 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | 2374 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 |
| 2399 #endif | 2375 #endif |
| 2400 | 2376 |
| 2401 /** | 2377 /** |
| 2402 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). | 2378 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). |
| 2403 * This API is experimental and may change significantly. | 2379 * This API is experimental and may change significantly. |
| 2404 */ | 2380 */ |
| 2405 class V8EXPORT ArrayBuffer : public Object { | 2381 class V8EXPORT ArrayBuffer : public Object { |
| 2406 public: | 2382 public: |
| 2407 /** | 2383 /** |
| 2384 * Allocator that V8 uses to allocate |ArrayBuffer|'s memory. |
| 2385 * The allocator is a global V8 setting. It should be set with |
| 2386 * V8::SetArrayBufferAllocator prior to creation of a first ArrayBuffer. |
| 2387 * |
| 2388 * This API is experimental and may change significantly. |
| 2389 */ |
| 2390 class V8EXPORT Allocator { // NOLINT |
| 2391 public: |
| 2392 virtual ~Allocator() {} |
| 2393 |
| 2394 /** |
| 2395 * Allocate |length| bytes. Return NULL if allocation is not successful. |
| 2396 */ |
| 2397 virtual void* Allocate(size_t length) = 0; |
| 2398 /** |
| 2399 * Free the memory pointed to |data|. That memory is guaranteed to be |
| 2400 * previously allocated by |Allocate|. |
| 2401 */ |
| 2402 virtual void Free(void* data) = 0; |
| 2403 }; |
| 2404 |
| 2405 /** |
| 2406 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| |
| 2407 * returns an instance of this class, populated, with a pointer to data |
| 2408 * and byte length. |
| 2409 * |
| 2410 * The Data pointer of ArrayBuffer::Contents is always allocated with |
| 2411 * Allocator::Allocate that is set with V8::SetArrayBufferAllocator. |
| 2412 * |
| 2413 * This API is experimental and may change significantly. |
| 2414 */ |
| 2415 class V8EXPORT Contents { // NOLINT |
| 2416 public: |
| 2417 Contents() : data_(NULL), byte_length_(0) {} |
| 2418 |
| 2419 void* Data() const { return data_; } |
| 2420 size_t ByteLength() const { return byte_length_; } |
| 2421 |
| 2422 private: |
| 2423 void* data_; |
| 2424 size_t byte_length_; |
| 2425 |
| 2426 friend class ArrayBuffer; |
| 2427 }; |
| 2428 |
| 2429 |
| 2430 /** |
| 2408 * Data length in bytes. | 2431 * Data length in bytes. |
| 2409 */ | 2432 */ |
| 2410 size_t ByteLength() const; | 2433 size_t ByteLength() const; |
| 2411 | 2434 |
| 2412 /** | 2435 /** |
| 2413 * Create a new ArrayBuffer. Allocate |byte_length| bytes. | 2436 * Create a new ArrayBuffer. Allocate |byte_length| bytes. |
| 2414 * Allocated memory will be owned by a created ArrayBuffer and | 2437 * Allocated memory will be owned by a created ArrayBuffer and |
| 2415 * will be deallocated when it is garbage-collected, | 2438 * will be deallocated when it is garbage-collected, |
| 2416 * unless the object is externalized. | 2439 * unless the object is externalized. |
| 2417 */ | 2440 */ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2433 | 2456 |
| 2434 /** | 2457 /** |
| 2435 * Neuters this ArrayBuffer and all its views (typed arrays). | 2458 * Neuters this ArrayBuffer and all its views (typed arrays). |
| 2436 * Neutering sets the byte length of the buffer and all typed arrays to zero, | 2459 * Neutering sets the byte length of the buffer and all typed arrays to zero, |
| 2437 * preventing JavaScript from ever accessing underlying backing store. | 2460 * preventing JavaScript from ever accessing underlying backing store. |
| 2438 * ArrayBuffer should have been externalized. | 2461 * ArrayBuffer should have been externalized. |
| 2439 */ | 2462 */ |
| 2440 void Neuter(); | 2463 void Neuter(); |
| 2441 | 2464 |
| 2442 /** | 2465 /** |
| 2443 * Pass the ownership of this ArrayBuffer's backing store to | 2466 * Make this ArrayBuffer external. The pointer to underlying memory block |
| 2444 * a given ArrayBufferContents. | 2467 * and byte length are returned as |Contents| structure. After ArrayBuffer |
| 2468 * had been etxrenalized, it does no longer owns the memory block. The caller |
| 2469 * should take steps to free memory when it is no longer needed. |
| 2470 * |
| 2471 * The memory block is guaranteed to be allocated with |Allocator::Allocate| |
| 2472 * that has been set with V8::SetArrayBufferAllocator. |
| 2445 */ | 2473 */ |
| 2446 void Externalize(ArrayBufferContents* contents); | 2474 Contents Externalize(); |
| 2447 | 2475 |
| 2448 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); | 2476 V8_INLINE(static ArrayBuffer* Cast(Value* obj)); |
| 2449 | 2477 |
| 2450 | |
| 2451 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | 2478 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; |
| 2452 | 2479 |
| 2453 private: | 2480 private: |
| 2454 ArrayBuffer(); | 2481 ArrayBuffer(); |
| 2455 static void CheckCast(Value* obj); | 2482 static void CheckCast(Value* obj); |
| 2456 }; | 2483 }; |
| 2457 | 2484 |
| 2458 | 2485 |
| 2459 /** | 2486 /** |
| 2460 * A base class for an instance of TypedArray series of constructors | 2487 * A base class for an instance of TypedArray series of constructors |
| (...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4186 static void SetFatalErrorHandler(FatalErrorCallback that); | 4213 static void SetFatalErrorHandler(FatalErrorCallback that); |
| 4187 | 4214 |
| 4188 /** | 4215 /** |
| 4189 * Set the callback to invoke to check if code generation from | 4216 * Set the callback to invoke to check if code generation from |
| 4190 * strings should be allowed. | 4217 * strings should be allowed. |
| 4191 */ | 4218 */ |
| 4192 static void SetAllowCodeGenerationFromStringsCallback( | 4219 static void SetAllowCodeGenerationFromStringsCallback( |
| 4193 AllowCodeGenerationFromStringsCallback that); | 4220 AllowCodeGenerationFromStringsCallback that); |
| 4194 | 4221 |
| 4195 /** | 4222 /** |
| 4223 * Set allocator to use for ArrayBuffer memory. |
| 4224 * The allocator should be set only once. The allocator should be set |
| 4225 * before any code tha uses ArrayBuffers is executed. |
| 4226 * This allocator is used in all isolates. |
| 4227 */ |
| 4228 static void SetArrayBufferAllocator(ArrayBuffer::Allocator* allocator); |
| 4229 |
| 4230 /** |
| 4196 * Ignore out-of-memory exceptions. | 4231 * Ignore out-of-memory exceptions. |
| 4197 * | 4232 * |
| 4198 * V8 running out of memory is treated as a fatal error by default. | 4233 * V8 running out of memory is treated as a fatal error by default. |
| 4199 * This means that the fatal error handler is called and that V8 is | 4234 * This means that the fatal error handler is called and that V8 is |
| 4200 * terminated. | 4235 * terminated. |
| 4201 * | 4236 * |
| 4202 * IgnoreOutOfMemoryException can be used to not treat an | 4237 * IgnoreOutOfMemoryException can be used to not treat an |
| 4203 * out-of-memory situation as a fatal error. This way, the contexts | 4238 * out-of-memory situation as a fatal error. This way, the contexts |
| 4204 * that did not cause the out of memory problem might be able to | 4239 * that did not cause the out of memory problem might be able to |
| 4205 * continue execution. | 4240 * continue execution. |
| (...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6327 | 6362 |
| 6328 | 6363 |
| 6329 } // namespace v8 | 6364 } // namespace v8 |
| 6330 | 6365 |
| 6331 | 6366 |
| 6332 #undef V8EXPORT | 6367 #undef V8EXPORT |
| 6333 #undef TYPE_CHECK | 6368 #undef TYPE_CHECK |
| 6334 | 6369 |
| 6335 | 6370 |
| 6336 #endif // V8_H_ | 6371 #endif // V8_H_ |
| OLD | NEW |