Skip to content

Commit

Permalink
Merge InterpreterProxy implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus authored Feb 9, 2024
2 parents 0049d8f + 692a26c commit 7b87b46
Show file tree
Hide file tree
Showing 21 changed files with 2,122 additions and 26 deletions.
6 changes: 5 additions & 1 deletion mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@

import mx
import mx_gate
import mx_unittest

import mx_sdk
import mx_sdk_vm
import mx_sdk_vm_impl
import mx_truffle
import mx_unittest

# re-export custom mx project classes so they can be used from suite.py
from mx_cmake import CMakeNinjaProject #pylint: disable=unused-import

_SUITE = mx.suite('trufflesqueak')
_COMPILER = mx.suite('compiler', fatalIfMissing=False)
Expand Down
56 changes: 40 additions & 16 deletions mx.trufflesqueak/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@
"sha1": "acd1c78c07e894647e8dcbd72c4fa9a136e20d6d",
"licence": "LGPLv21",
},
"OSVM_PLUGINS": {
"baseurl": "https://github.com/hpi-swa/trufflesqueak/releases/download/23.1.0/osvm-plugins-202312181441",
"os_arch": {
"linux": {
"amd64": {
"urls": ["{baseurl}-linux-amd64.zip"],
"digest": "sha512:5e94f289e5e1c71772b3033fda31e637cdcbea17321f2a4448a6755dff6db2db210086cffc993320249bcb6a1df395c17a2a06aedc9636159623336ca92e8008",
},
"aarch64": {
"urls" : ["{baseurl}-linux-aarch64.zip"],
"digest" : "sha512:b4801b2a442ca383c6d5718c5a085b1446e66010e73587f166ff2726d393ecc47d7a195bba9d586e7f6c40d587e9a89c874a39adb3f65e9633a12703b40268e9",
},
},
"windows": {
"amd64": {
"urls": ["{baseurl}-windows-amd64.zip"],
"digest": "sha512:10ec2b4b783bb83a814866ea237a424138802a99ee63b3cfbe2d2b2c6607e94ea000922f58f8a159108f66c0509764bc48b62885337d2a198534337eb2ed6f8e",
},
},
"<others>": {
"<others>": {"optional": True}
},
},
},
"TRUFFLE-ENTERPRISE": {
"digest": "sha512:b883d3ead84778617f9b09edaa43634183f07cdc6ae0666cb2f4edabc52fca913138c4a7a8f9ada1adbd4a9bbe7d16fb4a1b3ceac13446f4e0c47f3d1a20469f",
"maven": {
Expand Down Expand Up @@ -167,24 +191,17 @@
},
"de.hpi.swa.trufflesqueak.ffi.native": {
"subDir": "src",
"native": "shared_lib",
"deliverable": "SqueakFFIPrims",
"class": "CMakeNinjaProject",
"vpath": True,
"ninja_targets": ["all"],
"os_arch": {
"windows": {
"<others>": {
"cflags": []
}
},
"linux": {
"<others>": {
"cflags": ["-g", "-Wall", "-Werror", "-D_GNU_SOURCE"],
"ldlibs": ["-ldl"],
},
},
"<others>": {
"<others>": {
"cflags": ["-g", "-Wall", "-Werror"],
"ldlibs": ["-ldl"],
"cmakeConfig": {},
"results": [
"<lib:SqueakFFIPrims>",
"<lib:InterpreterProxy>",
],
},
},
},
Expand Down Expand Up @@ -308,7 +325,14 @@
"layout": {
"LICENSE_TRUFFLESQUEAK.txt": "file:LICENSE",
"README_TRUFFLESQUEAK.md": "file:README.md",
"lib/": "dependency:de.hpi.swa.trufflesqueak.ffi.native",
"lib/": [
"dependency:de.hpi.swa.trufflesqueak.ffi.native/*",
{
"source_type": "extracted-dependency",
"dependency": "OSVM_PLUGINS",
"path": "*",
},
],
},
"maven": False,
},
Expand Down
29 changes: 29 additions & 0 deletions src/de.hpi.swa.trufflesqueak.ffi.native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright (c) 2023-2024 Software Architecture Group, Hasso Plattner Institute
# Copyright (c) 2023-2024 Oracle and/or its affiliates
#
# Licensed under the MIT License.
#

cmake_minimum_required(VERSION 3.22)
project(de.hpi.swa.trufflesqueak.ffi.native)

if(NOT DEFINED SRC_DIR)
set(SRC_DIR "${CMAKE_SOURCE_DIR}")
endif()

set(CMAKE_C_STANDARD 11)

# don't install into the system but into the MX project's output dir
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})

set(CAPI_SRC "${SRC_DIR}/src")

function(build_library LIB_NAME SOURCE_FILE)
add_library(${LIB_NAME} SHARED ${SOURCE_FILE})
target_include_directories(${LIB_NAME} PUBLIC include)
endfunction()


build_library(InterpreterProxy "${CAPI_SRC}/InterpreterProxy.c")
build_library(SqueakFFIPrims "${CAPI_SRC}/SqueakFFIPrims.c")
114 changes: 114 additions & 0 deletions src/de.hpi.swa.trufflesqueak.ffi.native/include/sqMemoryAccess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright (c) 2023-2024 Software Architecture Group, Hasso Plattner Institute
* Copyright (c) 2023-2024 Oracle and/or its affiliates
*
* Licensed under the MIT License.
*/
#define SIZEOF_VOID_P 8

//////////// from here on: copied from
//////////// https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/ec421b99cf41fc5f2f5fb734b536d6233cdde809/platforms/Cross/vm/sqMemoryAccess.h

#ifndef SIZEOF_LONG
# if LLP64
# define SIZEOF_LONG 4
# else
# define SIZEOF_LONG SIZEOF_VOID_P /* default is sizeof(long)==sizeof(void *) */
# endif
#endif

#if (SQ_VI_BYTES_PER_WORD == 4)
# define SQ_IMAGE32 1
# define SQ_IMAGE64 0
#else
# define SQ_IMAGE64 1
# define SQ_IMAGE32 0
#endif

#if (SQ_IMAGE64 || SPURVM)
# define OBJECTS_64BIT_ALIGNED 1
# define OBJECTS_32BIT_ALIGNED 0
#else
# define OBJECTS_32BIT_ALIGNED 1
# define OBJECTS_64BIT_ALIGNED 0
#endif

#if (SIZEOF_VOID_P == 4)
# define SQ_HOST32 1
#elif (SIZEOF_VOID_P == 8)
# define SQ_HOST64 1
#else
# error host is neither 32- nor 64-bit?
#endif

/* sqInt is a signed integer with size adequate for holding an Object Oriented Pointer (or immediate value)
- that is 32bits long on a 32bits image or 64bits long on a 64bits image
we could use C99 int32_t and int64_t once retiring legacy compiler support this time has not yet come
usqInt is the unsigned flavour
SQABS is a macro for taking absolute value of an sqInt */
#if SQ_IMAGE32
typedef int sqInt;
typedef unsigned int usqInt;
#define PRIdSQINT "d"
#define PRIuSQINT "u"
#define PRIxSQINT "x"
#define PRIXSQINT "X"
# define SQABS abs
#elif SQ_HOST64 && (SIZEOF_LONG == 8)
typedef long sqInt;
typedef unsigned long usqInt;
#define PRIdSQINT "ld"
#define PRIuSQINT "lu"
#define PRIxSQINT "lx"
#define PRIXSQINT "lX"
# define SQABS labs
#elif (SIZEOF_LONG_LONG != 8)
# error long long integers are not 64-bits wide?
#else
typedef long long sqInt;
typedef unsigned long long usqInt;
#define PRIdSQINT "lld"
#define PRIuSQINT "llu"
#define PRIxSQINT "llx"
#define PRIXSQINT "llX"
# define SQABS llabs
#endif

/* sqLong is a signed integer with at least 64bits on both 32 and 64 bits images
usqLong is the unsigned flavour
SQLABS is a macro for taking absolute value of a sqLong */
#if !defined(sqLong)
# if SIZEOF_LONG == 8
# define sqLong long
# define usqLong unsigned long
# define SQLABS labs
# elif _MSC_VER
# define sqLong __int64
# define usqLong unsigned __int64
# define SQLABS llabs
# else
# define sqLong long long
# define usqLong unsigned long long
# define SQLABS llabs
# endif
#endif /* !defined(sqLong) */

/* sqIntptr_t is a signed integer with enough bits to hold a pointer
usqIntptr_t is the unsigned flavour
this is essentially C99 intptr_t and uintptr_t but we support legacy compilers
the C99 printf formats macros are also defined with SQ prefix */
#if SIZEOF_LONG == SIZEOF_VOID_P
typedef long sqIntptr_t;
typedef unsigned long usqIntptr_t;
#define PRIdSQPTR "ld"
#define PRIuSQPTR "lu"
#define PRIxSQPTR "lx"
#define PRIXSQPTR "lX"
#else
typedef long long sqIntptr_t;
typedef unsigned long long usqIntptr_t;
#define PRIdSQPTR "lld"
#define PRIuSQPTR "llu"
#define PRIxSQPTR "llx"
#define PRIXSQPTR "llX"
#endif
Loading

0 comments on commit 7b87b46

Please sign in to comment.