8323159: Consider adding some text re. memory zeroing in Arena::allocate

Reviewed-by: mcimadamore, jvernee
This commit is contained in:
Per Minborg 2024-01-15 16:07:56 +00:00
parent 1f4474f677
commit f5b757ced6
2 changed files with 51 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -219,6 +219,9 @@ public interface Arena extends SegmentAllocator, AutoCloseable {
* Segments allocated with the returned arena can be
* {@linkplain MemorySegment#isAccessibleBy(Thread) accessed} by any thread.
* Calling {@link #close()} on the returned arena will result in an {@link UnsupportedOperationException}.
* <p>
* Memory segments {@linkplain #allocate(long, long) allocated} by the returned arena
* are zero-initialized.
*
* @return a new arena that is managed, automatically, by the garbage collector
*/
@ -231,6 +234,9 @@ public interface Arena extends SegmentAllocator, AutoCloseable {
* {@linkplain MemorySegment#isAccessibleBy(Thread) accessed} by any thread.
* Calling {@link #close()} on the returned arena will result in
* an {@link UnsupportedOperationException}.
* <p>
* Memory segments {@linkplain #allocate(long, long) allocated} by the returned arena
* are zero-initialized.
*/
static Arena global() {
class Holder {
@ -243,6 +249,9 @@ public interface Arena extends SegmentAllocator, AutoCloseable {
* {@return a new confined arena} Segments allocated with the confined arena can be
* {@linkplain MemorySegment#isAccessibleBy(Thread) accessed} by the thread
* that created the arena, the arena's <em>owner thread</em>.
* <p>
* Memory segments {@linkplain #allocate(long, long) allocated} by the returned arena
* are zero-initialized.
*/
static Arena ofConfined() {
return MemorySessionImpl.createConfined(Thread.currentThread()).asArena();
@ -251,6 +260,9 @@ public interface Arena extends SegmentAllocator, AutoCloseable {
/**
* {@return a new shared arena} Segments allocated with the global arena can be
* {@linkplain MemorySegment#isAccessibleBy(Thread) accessed} by any thread.
* <p>
* Memory segments {@linkplain #allocate(long, long) allocated} by the returned arena
* are zero-initialized.
*/
static Arena ofShared() {
return MemorySessionImpl.createShared().asArena();