@@ -131,6 +131,23 @@ static void* GenericMapAligned(void* hint,
131131 return reinterpret_cast <void *>(address);
132132 }
133133#endif
134+
135+ #if (defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_ANDROID)) && \
136+ defined (ARCH_IS_64_BIT )
137+ // Usually. Might be larger on some arm64 configurations.
138+ constexpr intptr_t kSuperPageSize = 2 * MB ;
139+ if (alignment == kSuperPageSize ) {
140+ void * address = Map (nullptr , size, prot, map_flags, -1 , 0 );
141+ if (address != MAP_FAILED ) {
142+ if (Utils::IsAligned (address, alignment)) [[likely]] {
143+ madvise (address, size, MADV_HUGEPAGE );
144+ return address;
145+ }
146+ munmap (address, size);
147+ }
148+ }
149+ #endif
150+
134151 void * address = Map (hint, allocated_size, prot, map_flags, -1 , 0 );
135152 if (address == MAP_FAILED ) {
136153 return nullptr ;
@@ -573,25 +590,6 @@ void VirtualMemory::Init() {
573590 }
574591#endif
575592#endif
576-
577- #if defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_ANDROID)
578- FILE * fp = fopen (" /proc/sys/vm/max_map_count" , " r" );
579- if (fp != nullptr ) {
580- size_t max_map_count = 0 ;
581- int count = fscanf (fp, " %zu" , &max_map_count);
582- fclose (fp);
583- if (count == 1 ) {
584- size_t max_heap_pages = FLAG_old_gen_heap_size * MB / Page::kPageSize ;
585- if (max_map_count < max_heap_pages) {
586- OS::PrintErr (
587- " warning: vm.max_map_count (%zu) is not large enough to support "
588- " --old_gen_heap_size=%d. Consider increasing it with `sysctl -w "
589- " vm.max_map_count=%zu`\n " ,
590- max_map_count, FLAG_old_gen_heap_size, max_heap_pages);
591- }
592- }
593- }
594- #endif
595593}
596594
597595void VirtualMemory::Cleanup () {
0 commit comments