Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
Expand Down Expand Up @@ -38,22 +38,6 @@ public SlicingAllocator(MemorySegment segment) {
this.segment = segment;
}

public long currentOffset() {
return sp;
}

public void resetTo(long offset) {
if (offset < 0 || offset > sp)
throw new IllegalArgumentException(String.format("offset %d should be in [0, %d] ", offset, sp));
this.sp = offset;
}

public boolean canAllocate(long byteSize, long byteAlignment) {
long min = segment.address();
long start = Utils.alignUp(min + sp, byteAlignment) - min;
return start + byteSize <= segment.byteSize();
}

MemorySegment trySlice(long byteSize, long byteAlignment) {
long min = segment.address();
long start = Utils.alignUp(min + sp, byteAlignment) - min;
Expand Down
122 changes: 0 additions & 122 deletions src/java.base/share/classes/jdk/internal/foreign/abi/BufferStack.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,26 @@ static long pickChunkOffset(long chunkOffset, long byteWidth, int chunkWidth) {
: chunkOffset;
}

private static final int LINKER_STACK_SIZE = Integer.getInteger("jdk.internal.foreign.LINKER_STACK_SIZE", 256);
private static final BufferStack LINKER_STACK = new BufferStack(LINKER_STACK_SIZE);

@ForceInline
public static Arena newBoundedArena(long size) {
return LINKER_STACK.pushFrame(size, 8);
return new Arena() {
final Arena arena = Arena.ofConfined();
final SegmentAllocator slicingAllocator = SegmentAllocator.slicingAllocator(arena.allocate(size));

@Override
public Scope scope() {
return arena.scope();
}

@Override
public void close() {
arena.close();
}

@Override
public MemorySegment allocate(long byteSize, long byteAlignment) {
return slicingAllocator.allocate(byteSize, byteAlignment);
}
};
}

public static Arena newEmptyArena() {
Expand Down
157 changes: 0 additions & 157 deletions test/jdk/java/foreign/TestBufferStack.java

This file was deleted.

39 changes: 0 additions & 39 deletions test/jdk/java/foreign/libTestBufferStack.c

This file was deleted.

Loading