[foreign-memaccess+abi] RFR: 8296417: Make memory session a pure lifetime abstraction [v8]
Quan Anh Mai
qamai at openjdk.org
Wed Nov 9 14:52:56 UTC 2022
On Mon, 7 Nov 2022 14:01:29 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Add description
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Update test/micro/org/openjdk/bench/java/lang/foreign/StrLenTest.java
>
> Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
My view is that an `Arena` is the temporal abstraction of memory, as it can create and free memory. On the other hand, a `MemorySession` is merely a view on its owning `Arena`, allowing queries of the arena's status. An implicit session can be understood as a session that has an implicit `Arena`.
While I agree with your definition of an arena from the theoretical point of view, practically, an arena allocator is often used to indicate a more specific kind of allocator and the arena is often used to indicate the underlying segment that gets sliced. For example, protobuf C++ API specifies an Arena as: [1]
> With arena allocation, new objects are allocated out of a large piece of preallocated memory called the arena.
In contrast, in C++ standard, to specify a kind of memory source that "releases the allocated memory only when the resource is destroyed." is called `std::pmr::monotonic_buffer_resource`. [2]
Thanks a lot.
[1]: https://developers.google.com/protocol-buffers/docs/reference/arenas
[2]: https://en.cppreference.com/w/cpp/memory/monotonic_buffer_resource
-------------
PR: https://git.openjdk.org/panama-foreign/pull/750
More information about the panama-dev
mailing list