| 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 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3480 * | 3480 * |
| 3481 * Memory allocated through this allocator by V8 is accounted for as external | 3481 * Memory allocated through this allocator by V8 is accounted for as external |
| 3482 * memory by V8. Note that V8 keeps track of the memory for all internalized | 3482 * memory by V8. Note that V8 keeps track of the memory for all internalized |
| 3483 * |ArrayBuffer|s. Responsibility for tracking external memory (using | 3483 * |ArrayBuffer|s. Responsibility for tracking external memory (using |
| 3484 * Isolate::AdjustAmountOfExternalAllocatedMemory) is handed over to the | 3484 * Isolate::AdjustAmountOfExternalAllocatedMemory) is handed over to the |
| 3485 * embedder upon externalization and taken over upon internalization (creating | 3485 * embedder upon externalization and taken over upon internalization (creating |
| 3486 * an internalized buffer from an existing buffer). | 3486 * an internalized buffer from an existing buffer). |
| 3487 * | 3487 * |
| 3488 * Note that it is unsafe to call back into V8 from any of the allocator | 3488 * Note that it is unsafe to call back into V8 from any of the allocator |
| 3489 * functions. | 3489 * functions. |
| 3490 * | |
| 3491 * This API is experimental and may change significantly. | |
| 3492 */ | 3490 */ |
| 3493 class V8_EXPORT Allocator { // NOLINT | 3491 class V8_EXPORT Allocator { // NOLINT |
| 3494 public: | 3492 public: |
| 3495 virtual ~Allocator() {} | 3493 virtual ~Allocator() {} |
| 3496 | 3494 |
| 3497 /** | 3495 /** |
| 3498 * Allocate |length| bytes. Return NULL if allocation is not successful. | 3496 * Allocate |length| bytes. Return NULL if allocation is not successful. |
| 3499 * Memory should be initialized to zeroes. | 3497 * Memory should be initialized to zeroes. |
| 3500 */ | 3498 */ |
| 3501 virtual void* Allocate(size_t length) = 0; | 3499 virtual void* Allocate(size_t length) = 0; |
| 3502 | 3500 |
| 3503 /** | 3501 /** |
| 3504 * Allocate |length| bytes. Return NULL if allocation is not successful. | 3502 * Allocate |length| bytes. Return NULL if allocation is not successful. |
| 3505 * Memory does not have to be initialized. | 3503 * Memory does not have to be initialized. |
| 3506 */ | 3504 */ |
| 3507 virtual void* AllocateUninitialized(size_t length) = 0; | 3505 virtual void* AllocateUninitialized(size_t length) = 0; |
| 3506 |
| 3508 /** | 3507 /** |
| 3509 * Free the memory block of size |length|, pointed to by |data|. | 3508 * Free the memory block of size |length|, pointed to by |data|. |
| 3510 * That memory is guaranteed to be previously allocated by |Allocate|. | 3509 * That memory is guaranteed to be previously allocated by |Allocate|. |
| 3511 */ | 3510 */ |
| 3512 virtual void Free(void* data, size_t length) = 0; | 3511 virtual void Free(void* data, size_t length) = 0; |
| 3512 |
| 3513 /** |
| 3514 * malloc/free based convenience allocator. |
| 3515 * |
| 3516 * Caller takes ownership. |
| 3517 */ |
| 3518 static Allocator* NewDefaultAllocator(); |
| 3513 }; | 3519 }; |
| 3514 | 3520 |
| 3515 /** | 3521 /** |
| 3516 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| | 3522 * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| |
| 3517 * returns an instance of this class, populated, with a pointer to data | 3523 * returns an instance of this class, populated, with a pointer to data |
| 3518 * and byte length. | 3524 * and byte length. |
| 3519 * | 3525 * |
| 3520 * The Data pointer of ArrayBuffer::Contents is always allocated with | 3526 * The Data pointer of ArrayBuffer::Contents is always allocated with |
| 3521 * Allocator::Allocate that is set via Isolate::CreateParams. | 3527 * Allocator::Allocate that is set via Isolate::CreateParams. |
| 3522 * | 3528 * |
| (...skipping 5375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8898 */ | 8904 */ |
| 8899 | 8905 |
| 8900 | 8906 |
| 8901 } // namespace v8 | 8907 } // namespace v8 |
| 8902 | 8908 |
| 8903 | 8909 |
| 8904 #undef TYPE_CHECK | 8910 #undef TYPE_CHECK |
| 8905 | 8911 |
| 8906 | 8912 |
| 8907 #endif // INCLUDE_V8_H_ | 8913 #endif // INCLUDE_V8_H_ |
| OLD | NEW |