1
1
/*
2
- * Copyright (c) 2021, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2021, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -54,10 +54,10 @@ public class StrLenTest extends CLayouts {
54
54
Arena arena = Arena .ofConfined ();
55
55
56
56
SegmentAllocator segmentAllocator ;
57
- SegmentAllocator arenaAllocator = new RingAllocator ( arena ) ;
58
- SlicingPool pool = new SlicingPool () ;
57
+ SegmentAllocator arenaAllocator ;
58
+ SlicingPool pool ;
59
59
60
- @ Param ({"5" , "20" , "100" })
60
+ @ Param ({"5" , "20" , "100" , "451" })
61
61
public int size ;
62
62
public String str ;
63
63
@@ -76,6 +76,8 @@ public class StrLenTest extends CLayouts {
76
76
@ Setup
77
77
public void setup () {
78
78
str = makeString (size );
79
+ arenaAllocator = new RingAllocator (arena , size + 1 );
80
+ pool = new SlicingPool (size + 1 );
79
81
segmentAllocator = SegmentAllocator .prefixAllocator (arena .allocate (size + 1 , 1 ));
80
82
}
81
83
@@ -142,6 +144,9 @@ static String makeString(int size) {
142
144
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
143
145
mollit anim id est laborum.
144
146
""" ;
147
+ while (lorem .length () < size ) {
148
+ lorem += lorem ;
149
+ }
145
150
return lorem .substring (0 , size );
146
151
}
147
152
@@ -150,8 +155,8 @@ static class RingAllocator implements SegmentAllocator {
150
155
SegmentAllocator current ;
151
156
long rem ;
152
157
153
- public RingAllocator (Arena session ) {
154
- this .segment = session .allocate (1024 , 1 );
158
+ public RingAllocator (Arena session , int size ) {
159
+ this .segment = session .allocate (size , 1 );
155
160
reset ();
156
161
}
157
162
@@ -173,9 +178,13 @@ void reset() {
173
178
}
174
179
175
180
static class SlicingPool {
176
- final MemorySegment pool = Arena . ofAuto (). allocate ( 1024 ) ;
181
+ final MemorySegment pool ;
177
182
boolean isAcquired = false ;
178
183
184
+ public SlicingPool (int size ) {
185
+ this .pool = Arena .ofAuto ().allocate (size );
186
+ }
187
+
179
188
public Arena acquire () {
180
189
if (isAcquired ) {
181
190
throw new IllegalStateException ("An allocator is already in use" );
0 commit comments