Commit 8bab33e3 by Nicolas Capens Committed by Nicolas Capens

Remove named anonymous mmap for GL/VK allocations

The use of named anonymous file mappings was only meant for the allocation of executable memory by the Reactor JIT. Bug: b/174801963 Change-Id: Ifae13c7ed5cdbb7d940cea750d3f061d08e9f442 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50889 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent bae138de
...@@ -53,23 +53,6 @@ void *allocateRaw(size_t bytes, size_t alignment) ...@@ -53,23 +53,6 @@ void *allocateRaw(size_t bytes, size_t alignment)
{ {
ASSERT((alignment & (alignment - 1)) == 0); // Power of 2 alignment. ASSERT((alignment & (alignment - 1)) == 0); // Power of 2 alignment.
#if defined(LINUX_ENABLE_NAMED_MMAP)
if(alignment < sizeof(void*))
{
return malloc(bytes);
}
else
{
void *allocation;
int result = posix_memalign(&allocation, alignment, bytes);
if(result != 0)
{
errno = result;
allocation = nullptr;
}
return allocation;
}
#else
unsigned char *block = new unsigned char[bytes + sizeof(Allocation) + alignment]; unsigned char *block = new unsigned char[bytes + sizeof(Allocation) + alignment];
unsigned char *aligned = nullptr; unsigned char *aligned = nullptr;
...@@ -83,7 +66,6 @@ void *allocateRaw(size_t bytes, size_t alignment) ...@@ -83,7 +66,6 @@ void *allocateRaw(size_t bytes, size_t alignment)
} }
return aligned; return aligned;
#endif
} }
} // anonymous namespace } // anonymous namespace
...@@ -119,9 +101,6 @@ void *allocate(size_t bytes, size_t alignment) ...@@ -119,9 +101,6 @@ void *allocate(size_t bytes, size_t alignment)
void deallocate(void *memory) void deallocate(void *memory)
{ {
#if defined(LINUX_ENABLE_NAMED_MMAP)
free(memory);
#else
if(memory) if(memory)
{ {
unsigned char *aligned = (unsigned char*)memory; unsigned char *aligned = (unsigned char*)memory;
...@@ -129,7 +108,6 @@ void deallocate(void *memory) ...@@ -129,7 +108,6 @@ void deallocate(void *memory)
delete[] allocation->block; delete[] allocation->block;
} }
#endif
} }
void clear(uint16_t *memory, uint16_t element, size_t count) void clear(uint16_t *memory, uint16_t element, size_t count)
......
...@@ -54,23 +54,6 @@ void *allocateRaw(size_t bytes, size_t alignment) ...@@ -54,23 +54,6 @@ void *allocateRaw(size_t bytes, size_t alignment)
{ {
ASSERT((alignment & (alignment - 1)) == 0); // Power of 2 alignment. ASSERT((alignment & (alignment - 1)) == 0); // Power of 2 alignment.
#if defined(LINUX_ENABLE_NAMED_MMAP)
if(alignment < sizeof(void *))
{
return malloc(bytes);
}
else
{
void *allocation;
int result = posix_memalign(&allocation, alignment, bytes);
if(result != 0)
{
errno = result;
allocation = nullptr;
}
return allocation;
}
#else
unsigned char *block = (unsigned char *)malloc(bytes + sizeof(Allocation) + alignment); unsigned char *block = (unsigned char *)malloc(bytes + sizeof(Allocation) + alignment);
unsigned char *aligned = nullptr; unsigned char *aligned = nullptr;
...@@ -84,7 +67,6 @@ void *allocateRaw(size_t bytes, size_t alignment) ...@@ -84,7 +67,6 @@ void *allocateRaw(size_t bytes, size_t alignment)
} }
return aligned; return aligned;
#endif
} }
} // anonymous namespace } // anonymous namespace
...@@ -118,9 +100,6 @@ void *allocate(size_t bytes, size_t alignment) ...@@ -118,9 +100,6 @@ void *allocate(size_t bytes, size_t alignment)
void deallocate(void *memory) void deallocate(void *memory)
{ {
#if defined(LINUX_ENABLE_NAMED_MMAP)
free(memory);
#else
if(memory) if(memory)
{ {
unsigned char *aligned = (unsigned char *)memory; unsigned char *aligned = (unsigned char *)memory;
...@@ -128,7 +107,6 @@ void deallocate(void *memory) ...@@ -128,7 +107,6 @@ void deallocate(void *memory)
free(allocation->block); free(allocation->block);
} }
#endif
} }
void clear(uint16_t *memory, uint16_t element, size_t count) void clear(uint16_t *memory, uint16_t element, size_t count)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment