forked from gnustep/libobjc2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This replaces a few home-grown datastructures with third-party ones that get a lot more testing: - The home-grown hopscotch hash table is moved to using robin map. The original was designed to be lock free, but we've been using it behind a lock for ages. - The selector list is now a std::vector. - The types list now use std::forward_list. This also removes a couple of code paths that haven't been used since we started using the new ABI data structures internally and upgrading at load time. The new code tries to differentiate in the static type system between registered and unregistered selectors. The check for whether a selector is registered is fragile and depends on no selector being mapped or allocated in memory below the total number of selectors. This check can now disappear on most code paths. On a single test machine (not guaranteed to be representative) the test suite now completes around 20% faster.
- Loading branch information
1 parent
7c23a07
commit e23882f
Showing
11 changed files
with
836 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#ifdef _WIN32 | ||
#include "safewindows.h" | ||
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP && _WIN32_WINNT >= 0x0A00 | ||
// Prefer the *FromApp versions when we're being built in a Windows Store App context on | ||
// Windows >= 10. *FromApp require the application to be manifested for "codeGeneration". | ||
#define VirtualAlloc VirtualAllocFromApp | ||
#define VirtualProtect VirtualProtectFromApp | ||
#endif // App family partition | ||
|
||
inline void *allocate_pages(size_t size) | ||
{ | ||
return VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); | ||
} | ||
|
||
#else | ||
#include <sys/mman.h> | ||
inline void *allocate_pages(size_t size) | ||
{ | ||
void *ret = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); | ||
return ret == MAP_FAILED ? nullptr : ret; | ||
|
||
} | ||
#endif | ||
|
||
template<typename T> | ||
class PoolAllocate | ||
{ | ||
static constexpr size_t PageSize = 4096; | ||
static constexpr size_t ChunkSize = sizeof(T) * PageSize; | ||
static inline size_t index = PageSize; | ||
static inline T *buffer = nullptr; | ||
public: | ||
static T *allocate() | ||
{ | ||
if (index == PageSize) | ||
{ | ||
index = 0; | ||
buffer = static_cast<T*>(allocate_pages(ChunkSize)); | ||
} | ||
return &buffer[index++]; | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.