Skip to content

Commit

Permalink
Add new benchmarks test (dhrystone) and fix only native target for th…
Browse files Browse the repository at this point in the history
…e test.
  • Loading branch information
yomaytk committed May 30, 2024
1 parent 3418f73 commit dcf963e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bin/elfconv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ main() {

# LLVM bc -> target file
case "$TARGET" in
wasm-browser)
browser)
echo -e "[\033[32mINFO\033[0m] Converting LLVM bitcode to WASM binary (for browser) ..."
cd "${BIN_DIR}" || { echo "cd Failure"; exit 1; }
$WASMCC -c lift.bc -o lift.o && \
$WASMCC -o exe.wasm.html -L"./" -sWASM -sALLOW_MEMORY_GROWTH lift.o -lelfconv
echo -e "[\033[32mINFO\033[0m] Generate WASM binary."
return 0
;;
wasm-host)
wasi)
echo -e "[\033[32mINFO\033[0m] Converting LLVM bitcode to WASM binary (for server) ..."
cd "${BIN_DIR}" || { echo "cd Failure"; exit 1; }
$WASMCC -c lift.bc -o lift.o && \
Expand Down
2 changes: 2 additions & 0 deletions runtime/syscalls/SysTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define AARCH64_SYS_RT_SIGACTION 134
#define AARCH64_SYS_RT_SIGPROCMASK 135
#define AARCH64_SYS_UNAME 160
#define AARCH64_SYS_GETRUSAGE 165
#define AARCH64_SYS_GETPID 172
#define AARCH64_SYS_GETPPID 173
#define AARCH64_SYS_GETTUID 174
Expand All @@ -35,6 +36,7 @@
#define AARCH64_SYS_MUNMAP 215
#define AARCH64_SYS_MMAP 222
#define AARCH64_SYS_MPROTECT 226
#define AARCH64_SYS_WAIT4 260
#define AARCH64_SYS_PRLIMIT64 261
#define AARCH64_SYS_GETRANDOM 278
#define AARCH64_SYS_STATX 291
Expand Down
9 changes: 9 additions & 0 deletions runtime/syscalls/SyscallNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include <signal.h>
#include <stdlib.h>
#include <string>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>
#include <utils/Util.h>
Expand Down Expand Up @@ -228,6 +230,9 @@ void __svc_native_call(void) {
memcpy(_ecv_translate_ptr(state_gpr.x0.qword), &_utsname, sizeof(utsname));
state_gpr.x0.dword = ret;
} break;
case AARCH64_SYS_GETRUSAGE: /* getrusage (int who, struct rusage *ru) */
state_gpr.x0.dword =
getrusage(state_gpr.x0.dword, (struct rusage *) _ecv_translate_ptr(state_gpr.x1.qword));
case AARCH64_SYS_GETPID: /* getpid () */ state_gpr.x0.dword = getpid(); break;
case AARCH64_SYS_GETPPID: /* getppid () */ state_gpr.x0.dword = getppid(); break;
case AARCH64_SYS_GETTUID: /* getuid () */ state_gpr.x0.dword = getuid(); break;
Expand Down Expand Up @@ -275,6 +280,10 @@ void __svc_native_call(void) {
state_gpr.x0.qword = 0;
NOP_SYSCALL(AARCH64_SYS_MPROTECT);
break;
case AARCH64_SYS_WAIT4: /* pid_t wait4 (pid_t pid, int *stat_addr, int options, struct rusage *ru) */
state_gpr.x0.dword =
wait4(state_gpr.x0.dword, (int *) _ecv_translate_ptr(state_gpr.x1.qword),
state_gpr.x2.dword, (struct rusage *) _ecv_translate_ptr(state_gpr.x3.qword));
case AARCH64_SYS_PRLIMIT64: /* prlimit64 (pid_t pid, unsigned int resource, const struct rlimit64 *new_rlim, struct rlimit64 *oldrlim) */
state_gpr.x0.qword = 0;
NOP_SYSCALL(AARCH64_SYS_PRLIMIT64);
Expand Down
16 changes: 7 additions & 9 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ main() {
echo -e "[\033[32mINFO\033[0m] Generate native binary."
return 0
;;
wasm-browser)
browser)
ELFCONV_MACROS="-DELFC_BROWSER_ENV=1"
cd "${BUILD_LIFTER_DIR}" && \
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o Entry.wasm.o -c ${RUNTIME_DIR}/Entry.cpp && \
Expand All @@ -103,21 +103,19 @@ main() {
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o VmIntrinsics.wasm.o -c ${RUNTIME_DIR}/VmIntrinsics.cpp && \
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o Util.wasm.o -c ${UTILS_DIR}/Util.cpp && \
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o elfconv.wasm.o -c ${UTILS_DIR}/elfconv.cpp && \
$WASMCC -c liftO3.ll -o lift.wasm.o
$WASMCC -c lift.ll -o lift.wasm.o
$WASMCC -o exe.wasm.html -sWASM -sALLOW_MEMORY_GROWTH lift.wasm.o Entry.wasm.o Memory.wasm.o Syscall.wasm.o \
VmIntrinsics.wasm.o Util.wasm.o elfconv.wasm.o
echo -e "[\033[32mINFO\033[0m] Generate WASM binary."
# delete obj
cd "${BUILD_LIFTER_DIR}" && rm *.o
return 0
;;
wasm-host)
wasi)
ELFCONV_MACROS="-DELFC_WASI_ENV=1"
if [ -n "$WASISDK" ]; then
WASMCC=$WASISDK_CXX
WASMCCFLAGS=$WASISDKFLAGS
ELFCONV_MACROS="${ELFCONV_MACROS} -fno-exceptions"
fi
WASMCC=$WASISDK_CXX
WASMCCFLAGS=$WASISDKFLAGS
ELFCONV_MACROS="${ELFCONV_MACROS} -fno-exceptions"
cd "${BUILD_LIFTER_DIR}" && \
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o Entry.wasm.o -c ${RUNTIME_DIR}/Entry.cpp && \
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o Memory.wasm.o -c ${RUNTIME_DIR}/Memory.cpp && \
Expand All @@ -126,7 +124,7 @@ main() {
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o Util.wasm.o -c ${UTILS_DIR}/Util.cpp && \
$WASMCC $WASMCCFLAGS $ELFCONV_MACROS $ELFCONV_DEBUG_MACROS -o elfconv.wasm.o -c ${UTILS_DIR}/elfconv.cpp && \
$WASMCC -O3 -c lift.ll -o lift.wasm.o
$WASMCC -O3 $WASISDK_LINKFLAGS -o exe.wasm lift.wasm.o Entry.wasm.o Memory.wasm.o Syscall.wasm.o VmIntrinsics.wasm.o Util.wasm.o elfconv.wasm.o
$WASMCC -O3 $WASISDK_LINKFLAGS -o exe.wasm lift.wasm.o Entry.wasm.o Memory.wasm.o Syscall.wasm.o VmIntrinsics.wasm.o Util.wasm.o elfconv.wasm.o
echo -e "[\033[32mINFO\033[0m] Generate WASM binary."
# delete obj
cd "${BUILD_LIFTER_DIR}" && rm *.o
Expand Down

0 comments on commit dcf963e

Please sign in to comment.