Code cleanup: Remove references to IRNodes from SkSLPool.
There is no longer anything IRNode-centric about SkSLPool; it is not
optimized around specific allocation sizes, and could be used to
allocate anything that is associated with a Program. Update comments and
function names to reflect this.
Change-Id: Ica1a78f7415edb25b93a93d00fe54557883c5eed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334676
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLPool.h b/src/sksl/SkSLPool.h
index bc6017f..1666051 100644
--- a/src/sksl/SkSLPool.h
+++ b/src/sksl/SkSLPool.h
@@ -15,37 +15,37 @@
namespace SkSL {
/**
- * Efficiently allocates memory for IRNodes in an SkSL program. Optimized for allocate/release
- * performance over memory efficiency.
+ * Efficiently allocates memory in an SkSL program. Optimized for allocate/release performance over
+ * memory efficiency.
*
- * All allocated IRNodes must be released back to the pool before it can be destroyed or recycled.
+ * All allocated memory must be released back to the pool before it can be destroyed or recycled.
*/
class Pool {
public:
~Pool();
- // Creates a pool to store IRNodes during program creation. Call attachToThread() to start using
- // the pool for IRNode allocations. When your program is complete, call pool->detachFromThread()
- // to take ownership of the pool and its nodes. Before destroying any of the program's nodes,
- // make sure to reattach the pool by calling pool->attachToThread() again.
+ // Creates a pool to store objects during program creation. Call attachToThread() to start using
+ // the pool for its allocations. When your program is complete, call pool->detachFromThread() to
+ // take ownership of the pool and its allocations. Before freeing any of the program's
+ // allocations, make sure to reattach the pool by calling pool->attachToThread() again.
static std::unique_ptr<Pool> Create();
// Attaches a pool to the current thread.
// It is an error to call this while a pool is already attached.
void attachToThread();
- // Once you are done creating or destroying IRNodes in the pool, detach it from the thread.
+ // Once you are done creating or destroying objects in the pool, detach it from the thread.
// It is an error to call this while no pool is attached.
void detachFromThread();
- // Retrieves a node from the thread pool. If the pool is exhausted, or if the requested size
- // exceeds the size that we can deliver from a pool, this will just allocate memory.
- static void* AllocIRNode(size_t size);
+ // Allocates memory from the thread pool. If the pool is exhausted, an additional block of pool
+ // storage will be created to hold the data.
+ static void* AllocMemory(size_t size);
- // Releases a node that was created by AllocIRNode. This will return it to the pool, or free it,
- // as appropriate. Make sure to free all nodes, since some of them may be real allocations.
- static void FreeIRNode(void* node_v);
+ // Releases memory that was created by AllocMemory. All objects in the pool must be freed before
+ // the pool can be destroyed.
+ static void FreeMemory(void* ptr);
private:
void checkForLeaks();