AAL, basic arm implementation proposal.

This commit is contained in:
David Carlier
2020-03-13 00:04:56 +00:00
parent 8e3efcb1dc
commit 2d4f2c3867
5 changed files with 64 additions and 2 deletions

View File

@@ -136,7 +136,8 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
add_compile_options(-march=native)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
add_compile_options(-march=native)
# XXX elseif ARM?
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
add_compile_options(-march=native)
endif()
endif()

View File

@@ -9,6 +9,10 @@
# define PLATFORM_IS_X86
#endif
#if defined(__arm__) || defined(__aarch64__)
# define PLATFORM_IS_ARM
#endif
namespace snmalloc
{
/**
@@ -70,8 +74,10 @@ namespace snmalloc
} // namespace snmalloc
#ifdef PLATFORM_IS_X86
#if defined(PLATFORM_IS_X86)
# include "aal_x86.h"
#elif defined(PLATFORM_IS_ARM)
# include "aal_arm.h"
#endif
namespace snmalloc

53
src/aal/aal_arm.h Normal file
View File

@@ -0,0 +1,53 @@
#pragma once
#if defined(__arch64__)
# define SNMALLOC_VA_BITS_64
#else
# define SNMALLOC_VA_BITS_32
#endif
#include <iostream>
namespace snmalloc
{
/**
* ARM-specific architecture abstraction layer.
*/
class AAL_arm
{
public:
/**
* Bitmap of AalFeature flags
*/
static constexpr uint64_t aal_features = IntegerPointers;
/**
* On pipelined processors, notify the core that we are in a spin loop and
* that speculative execution past this point may not be a performance gain.
*/
static inline void pause()
{
__asm__ volatile("yield");
}
/**
* Issue a prefetch hint at the specified address.
*/
static inline void prefetch(void* ptr)
{
__builtin_prefetch(ptr, 0, 1);
}
/**
* Return a cycle counter value.
* on ARM cpu counters are accessible only in privileged mode
*/
static inline uint64_t tick()
{
struct timespec n = {0, 0ul};
clock_gettime(CLOCK_MONOTONIC, &n);
return static_cast<uint64_t>((n.tv_sec) * (1000000000ul * n.tv_nsec));
}
};
using AAL_Arch = AAL_arm;
} // namespace snmalloc

View File

@@ -1,6 +1,7 @@
#pragma once
#include <limits>
#include <cstddef>
// #define USE_LZCNT

View File

@@ -4,6 +4,7 @@
#include "../mem/allocconfig.h"
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
extern "C" int puts(const char* str);