Merge pull request #142 from devnexen/arm_aal_proposal
AAL, basic arm implementation proposal.
This commit is contained in:
@@ -94,7 +94,15 @@ if (WIN32)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(snmalloc_lib INTERFACE -mcx16)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
target_compile_options(snmalloc_lib INTERFACE -mcx16)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
|
||||
target_compile_options(snmalloc_lib INTERFACE -mcx16)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
|
||||
target_compile_options(snmalloc_lib INTERFACE -mcx16)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
||||
target_compile_options(snmalloc_lib INTERFACE -mcx16)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
# Have to set this globally, as can't be set on an interface target.
|
||||
@@ -136,7 +144,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()
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "../ds/defines.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
|
||||
@@ -9,6 +10,10 @@
|
||||
# define PLATFORM_IS_X86
|
||||
#endif
|
||||
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
# define PLATFORM_IS_ARM
|
||||
#endif
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
/**
|
||||
@@ -22,6 +27,10 @@ namespace snmalloc
|
||||
* and so may use bit operations on pointer values.
|
||||
*/
|
||||
IntegerPointers = (1 << 0),
|
||||
/**
|
||||
* This architecture cannot access cpu cycles counters.
|
||||
*/
|
||||
NoCpuCycleCounters = (1 << 1),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -59,6 +68,15 @@ namespace snmalloc
|
||||
*/
|
||||
static inline uint64_t tick()
|
||||
{
|
||||
if constexpr (
|
||||
(Arch::aal_features & NoCpuCycleCounters) == NoCpuCycleCounters)
|
||||
{
|
||||
auto tick = std::chrono::high_resolution_clock::now();
|
||||
return static_cast<uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
tick.time_since_epoch())
|
||||
.count());
|
||||
}
|
||||
#if __has_builtin(__builtin_readcyclecounter) && \
|
||||
!defined(SNMALLOC_NO_AAL_BUILTINS)
|
||||
return __builtin_readcyclecounter();
|
||||
@@ -70,8 +88,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
|
||||
|
||||
34
src/aal/aal_arm.h
Normal file
34
src/aal/aal_arm.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#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 | NoCpuCycleCounters;
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
};
|
||||
|
||||
using AAL_Arch = AAL_arm;
|
||||
} // namespace snmalloc
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
|
||||
// #define USE_LZCNT
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../ds/address.h"
|
||||
#include "../mem/allocconfig.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user