Skip to content

Commit

Permalink
Change USE_MMAP_CODEBLOCK to CLASP_APPLE_SILICON
Browse files Browse the repository at this point in the history
  • Loading branch information
drmeister committed Dec 16, 2024
1 parent f51e3c3 commit 135be55
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion include/clasp/core/configure_clasp.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ THE SOFTWARE.

#if defined(_TARGET_OS_DARWIN) && defined(__aarch64__)
#define CLASP_APPLE_SILICON 1
#define USE_MMAP_CODEBLOCK 1
#endif

// ----------------------------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions include/clasp/llvmo/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ class CodeBlock_O : public core::CxxObject_O {

public:
template <typename Stage> static CodeBlock_sp make(uintptr_t size) {
#ifdef USE_MMAP_CODEBLOCK
CodeBlock_sp codeblock = gctools::GC<CodeBlock_O>::allocate<Stage>(size);
#ifdef CLASP_APPLE_SILICON
CodeBlock_sp codeblock = gctools::GC<CodeBlock_O>::allocate<Stage>(0);
void* mmappedBlock = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_JIT, -1, 0);
if (mmappedBlock == MAP_FAILED || !mmappedBlock) {
printf("%s:%d:%s mmap failed\n", __FILE__, __LINE__, __FUNCTION__);
Expand Down Expand Up @@ -272,21 +272,21 @@ class CodeBlock_O : public core::CxxObject_O {
* Return false if it won't fit and true if it will and then lock in the allocation
*/
void* dataStart() const {
#ifdef USE_MMAP_CODEBLOCK
#ifdef CLASP_APPLE_SILICON
return (void*)this->_mmapBlock;
#else
return (void*)&this->_DataCode[0];
#endif
};
void* dataEnd() const {
#ifdef USE_MMAP_CODEBLOCK
#ifdef CLASP_APPLE_SILICON
return (void*)((uintptr_t)this->_mmapBlock + this->_HeadOffset);
#else
return (void*)&this->_DataCode[this->_HeadOffset];
#endif
};
unsigned char* address(uintptr_t index) const {
#ifdef USE_MMAP_CODEBLOCK
#ifdef CLASP_APPLE_SILICON
return (unsigned char*)((uintptr_t)this->_mmapBlock + index);
#else
return (unsigned char*)&this->_DataCode[index];
Expand All @@ -303,7 +303,7 @@ class CodeBlock_O : public core::CxxObject_O {

CodeBlock_O(uintptr_t totalSize)
: _HeadOffset(0), _TailOffset(totalSize)
#ifdef USE_MMAP_CODEBLOCK
#ifdef CLASP_APPLE_SILICON
,
_mmapBlock(NULL), _mmapSize(totalSize)
#else
Expand Down
4 changes: 4 additions & 0 deletions src/core/lisp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,9 @@ CL_DECLARE();
CL_DOCSTRING(R"dx(exit)dx");
DOCGROUP(clasp);
CL_DEFUN void core__exit(int exitValue) {
#ifdef CLASP_APPLE_SILICON
exit(exitValue);
#else
gctools::global_debuggerOnSIGABRT = false;
if (exitValue != 0) {
if (core::_sym_STARexit_backtraceSTAR->symbolValue().notnilp()) {
Expand All @@ -1418,6 +1421,7 @@ CL_DEFUN void core__exit(int exitValue) {
VirtualMachine& vm = my_thread->_VM;
vm.shutdown();
throw(ExitProgramException(exitValue));
#endif
};

CL_LAMBDA(&optional (exit-value 0));
Expand Down
4 changes: 2 additions & 2 deletions src/gctools/boehmGarbageCollection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ CL_DEFUN core::T_sp core__gc_base(uint64_t addr)


void clasp_gc_registerRoots(void* rootsStart, size_t numberOfRoots) {
#ifdef USE_MMAP_CODEBLOCK
#ifdef CLASP_APPLE_SILICON
//
// This is experimental for Apple Silicon M1 chip
//
Expand All @@ -587,7 +587,7 @@ void clasp_gc_registerRoots(void* rootsStart, size_t numberOfRoots) {
}

void clasp_gc_deregisterRoots(void* rootsStart, size_t numberOfRoots) {
#ifdef USE_MMAP_CODEBLOCK
#ifdef CLASP_APPLE_SILICON
//
// This is experimental for Apple Silicon M1 chip
//
Expand Down

0 comments on commit 135be55

Please sign in to comment.