Skip to content

Commit b97adc8

Browse files
committed
[libc++] Refactor some code in monotonic_buffer_resource
1. remove unused __default_buffer_alignment 2. two __try_allocate_from_chunk are same, put it together This patch refactor some code in monotonic_buffer_resource.
1 parent e70f9e2 commit b97adc8

12 files changed

+28
-41
lines changed

libcxx/include/__memory_resource/monotonic_buffer_resource.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace pmr {
2727
// [mem.res.monotonic.buffer]
2828

2929
class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resource : public memory_resource {
30-
static const size_t __default_buffer_capacity = 1024;
31-
static const size_t __default_buffer_alignment = 16;
30+
static constexpr size_t __default_buffer_capacity = 1024;
31+
static constexpr size_t __default_growth_factor = 2;
3232

3333
struct __chunk_footer {
3434
__chunk_footer* __next_;
@@ -38,7 +38,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour
3838
_LIBCPP_HIDE_FROM_ABI size_t __allocation_size() {
3939
return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this);
4040
}
41-
void* __try_allocate_from_chunk(size_t, size_t);
4241
};
4342

4443
struct __initial_descriptor {
@@ -48,7 +47,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour
4847
char* __end_;
4948
size_t __size_;
5049
};
51-
void* __try_allocate_from_chunk(size_t, size_t);
5250
};
5351

5452
public:

libcxx/lib/abi/CHANGELOG.TXT

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ Version 20.0
6060
Symbol added: __ZTSNSt3__120__codecvt_utf8_utf16IDsEE
6161
Symbol added: __ZTSNSt3__120__codecvt_utf8_utf16IwEE
6262

63+
* [libc++][PMR] Remove duplicate implementation of __try_allocate_from_chunk
64+
65+
This patch removes member function __try_allocate_from_chunk from __chunk_footer and __initial_descriptor.
66+
The two implementation are almost same and can be easily moved to `memory_resource.cpp` inner implementation.
67+
They are defined and only used in `memory_resource.cpp`, No necessary export to dylib
68+
69+
All platforms
70+
-------------
71+
Symbol removed: _ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm
72+
Symbol removed: _ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm
73+
74+
6375
------------
6476
Version 19.0
6577
------------

libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,6 @@
15981598
{'is_defined': True, 'name': '__ZNSt3__13pmr20null_memory_resourceEv', 'type': 'FUNC'}
15991599
{'is_defined': True, 'name': '__ZNSt3__13pmr20set_default_resourceEPNS0_15memory_resourceE', 'type': 'FUNC'}
16001600
{'is_defined': True, 'name': '__ZNSt3__13pmr25monotonic_buffer_resource11do_allocateEmm', 'type': 'FUNC'}
1601-
{'is_defined': True, 'name': '__ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
1602-
{'is_defined': True, 'name': '__ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
16031601
{'is_defined': True, 'name': '__ZNSt3__13pmr28unsynchronized_pool_resource11do_allocateEmm', 'type': 'FUNC'}
16041602
{'is_defined': True, 'name': '__ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'type': 'FUNC'}
16051603
{'is_defined': True, 'name': '__ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'type': 'FUNC'}

libcxx/lib/abi/i686-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,8 +1234,6 @@
12341234
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr20null_memory_resourceEv', 'type': 'FUNC'}
12351235
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr20set_default_resourceEPNS0_15memory_resourceE', 'type': 'FUNC'}
12361236
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr25monotonic_buffer_resource11do_allocateEjj', 'type': 'FUNC'}
1237-
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEjj', 'type': 'FUNC'}
1238-
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEjj', 'type': 'FUNC'}
12391237
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr28unsynchronized_pool_resource11do_allocateEjj', 'type': 'FUNC'}
12401238
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEjj', 'type': 'FUNC'}
12411239
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'type': 'FUNC'}

libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@
584584
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr20null_memory_resourceEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
585585
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr20set_default_resourceEPNS0_15memory_resourceE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
586586
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource11do_allocateEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
587-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
588-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
589587
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource11do_allocateEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
590588
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
591589
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@
584584
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr20null_memory_resourceEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
585585
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr20set_default_resourceEPNS0_15memory_resourceE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
586586
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource11do_allocateEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
587-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
588-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
589587
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource11do_allocateEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
590588
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
591589
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,6 @@
15981598
{'is_defined': True, 'name': '__ZNSt3__13pmr20null_memory_resourceEv', 'type': 'FUNC'}
15991599
{'is_defined': True, 'name': '__ZNSt3__13pmr20set_default_resourceEPNS0_15memory_resourceE', 'type': 'FUNC'}
16001600
{'is_defined': True, 'name': '__ZNSt3__13pmr25monotonic_buffer_resource11do_allocateEmm', 'type': 'FUNC'}
1601-
{'is_defined': True, 'name': '__ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
1602-
{'is_defined': True, 'name': '__ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
16031601
{'is_defined': True, 'name': '__ZNSt3__13pmr28unsynchronized_pool_resource11do_allocateEmm', 'type': 'FUNC'}
16041602
{'is_defined': True, 'name': '__ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'type': 'FUNC'}
16051603
{'is_defined': True, 'name': '__ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,8 +1234,6 @@
12341234
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr20null_memory_resourceEv', 'type': 'FUNC'}
12351235
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr20set_default_resourceEPNS0_15memory_resourceE', 'type': 'FUNC'}
12361236
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr25monotonic_buffer_resource11do_allocateEmm', 'type': 'FUNC'}
1237-
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
1238-
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
12391237
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr28unsynchronized_pool_resource11do_allocateEmm', 'type': 'FUNC'}
12401238
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'type': 'FUNC'}
12411239
{'is_defined': True, 'name': '_ZNSt6__ndk13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,6 @@
12491249
{'is_defined': True, 'name': '_ZNSt3__13pmr20null_memory_resourceEv', 'type': 'FUNC'}
12501250
{'is_defined': True, 'name': '_ZNSt3__13pmr20set_default_resourceEPNS0_15memory_resourceE', 'type': 'FUNC'}
12511251
{'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource11do_allocateEmm', 'type': 'FUNC'}
1252-
{'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
1253-
{'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
12541252
{'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource11do_allocateEmm', 'type': 'FUNC'}
12551253
{'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'type': 'FUNC'}
12561254
{'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,6 @@
12471247
{'is_defined': True, 'name': '_ZNSt3__13pmr20null_memory_resourceEv', 'type': 'FUNC'}
12481248
{'is_defined': True, 'name': '_ZNSt3__13pmr20set_default_resourceEPNS0_15memory_resourceE', 'type': 'FUNC'}
12491249
{'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource11do_allocateEmm', 'type': 'FUNC'}
1250-
{'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource14__chunk_footer25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
1251-
{'is_defined': True, 'name': '_ZNSt3__13pmr25monotonic_buffer_resource20__initial_descriptor25__try_allocate_from_chunkEmm', 'type': 'FUNC'}
12521250
{'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource11do_allocateEmm', 'type': 'FUNC'}
12531251
{'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__do_allocateEPNS0_15memory_resourceEmm', 'type': 'FUNC'}
12541252
{'is_defined': True, 'name': '_ZNSt3__13pmr28unsynchronized_pool_resource12__adhoc_pool13__release_ptrEPNS0_15memory_resourceE', 'type': 'FUNC'}

0 commit comments

Comments
 (0)