mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 02:54:54 +03:00
1f886f94bd
Port of OpenJDK 17.0.2, zero VM only. More work needed to get the full hotspot VM up and running :^) Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
269 lines
10 KiB
Diff
269 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Timur Sultanov <sultanovts@yandex.ru>
|
|
Date: Sun, 12 Jun 2022 13:55:07 -0600
|
|
Subject: [PATCH] hotspot: Update non-BSD native modules for Serenity
|
|
|
|
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
|
|
---
|
|
src/hotspot/os/posix/os_posix.cpp | 23 ++++++++++++++++++-
|
|
src/hotspot/os/posix/signals_posix.cpp | 12 ++++++++++
|
|
src/hotspot/share/runtime/os.cpp | 6 ++++-
|
|
src/hotspot/share/runtime/os.hpp | 2 +-
|
|
src/hotspot/share/runtime/semaphore.hpp | 2 +-
|
|
.../share/utilities/globalDefinitions.hpp | 4 ++++
|
|
.../share/utilities/globalDefinitions_gcc.hpp | 6 ++---
|
|
src/hotspot/share/utilities/ostream.cpp | 2 +-
|
|
8 files changed, 49 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp
|
|
index 9eb1fcbcc..0676cb83d 100644
|
|
--- a/src/hotspot/os/posix/os_posix.cpp
|
|
+++ b/src/hotspot/os/posix/os_posix.cpp
|
|
@@ -65,7 +65,9 @@
|
|
#include <sys/wait.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
+#ifndef SERENITY
|
|
#include <utmpx.h>
|
|
+#endif
|
|
|
|
#ifdef __APPLE__
|
|
#include <crt_externs.h>
|
|
@@ -272,7 +274,12 @@ static int util_posix_fallocate(int fd, off_t offset, off_t len) {
|
|
}
|
|
return -1;
|
|
#else
|
|
+#ifndef SERENITY
|
|
return posix_fallocate(fd, offset, len);
|
|
+#else
|
|
+ // YOLO
|
|
+ return 0;
|
|
+#endif
|
|
#endif
|
|
}
|
|
|
|
@@ -418,6 +425,7 @@ void os::Posix::print_load_average(outputStream* st) {
|
|
// unfortunately it does not work on macOS and Linux because the utx chain has no entry
|
|
// for reboot at least on my test machines
|
|
void os::Posix::print_uptime_info(outputStream* st) {
|
|
+#ifndef SERENITY
|
|
int bootsec = -1;
|
|
int currsec = time(NULL);
|
|
struct utmpx* ent;
|
|
@@ -432,6 +440,9 @@ void os::Posix::print_uptime_info(outputStream* st) {
|
|
if (bootsec != -1) {
|
|
os::print_dhm(st, "OS uptime:", (long) (currsec-bootsec));
|
|
}
|
|
+#else
|
|
+ st->print("OS uptime: not implemented");
|
|
+#endif
|
|
}
|
|
|
|
static void print_rlimit(outputStream* st, const char* msg,
|
|
@@ -470,7 +481,9 @@ void os::Posix::print_rlimit_info(outputStream* st) {
|
|
|
|
print_rlimit(st, ", THREADS", RLIMIT_THREADS);
|
|
#else
|
|
+#ifndef SERENITY
|
|
print_rlimit(st, ", NPROC", RLIMIT_NPROC);
|
|
+#endif
|
|
#endif
|
|
|
|
print_rlimit(st, ", NOFILE", RLIMIT_NOFILE);
|
|
@@ -638,7 +651,11 @@ void os::dll_unload(void *lib) {
|
|
}
|
|
|
|
jlong os::lseek(int fd, jlong offset, int whence) {
|
|
+#ifdef SERENITY
|
|
+ return (jlong) ::lseek(fd, offset, whence);
|
|
+#else
|
|
return (jlong) BSD_ONLY(::lseek) NOT_BSD(::lseek64)(fd, offset, whence);
|
|
+#endif
|
|
}
|
|
|
|
int os::fsync(int fd) {
|
|
@@ -646,7 +663,11 @@ int os::fsync(int fd) {
|
|
}
|
|
|
|
int os::ftruncate(int fd, jlong length) {
|
|
- return BSD_ONLY(::ftruncate) NOT_BSD(::ftruncate64)(fd, length);
|
|
+#ifdef SERENITY
|
|
+ return ::ftruncate(fd, length);
|
|
+#else
|
|
+ return BSD_ONLY(::ftruncate) NOT_BSD(::ftruncate64)(fd, length);
|
|
+#endif
|
|
}
|
|
|
|
const char* os::get_current_directory(char *buf, size_t buflen) {
|
|
diff --git a/src/hotspot/os/posix/signals_posix.cpp b/src/hotspot/os/posix/signals_posix.cpp
|
|
index 2c020a794..9f3316f5b 100644
|
|
--- a/src/hotspot/os/posix/signals_posix.cpp
|
|
+++ b/src/hotspot/os/posix/signals_posix.cpp
|
|
@@ -552,6 +552,8 @@ public:
|
|
#define JVM_HANDLE_XXX_SIGNAL JVM_handle_aix_signal
|
|
#elif defined(LINUX)
|
|
#define JVM_HANDLE_XXX_SIGNAL JVM_handle_linux_signal
|
|
+#elif defined(SERENITY)
|
|
+#define JVM_HANDLE_XXX_SIGNAL JVM_handle_serenity_signal
|
|
#else
|
|
#error who are you?
|
|
#endif
|
|
@@ -933,8 +935,10 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
|
|
{ SIGFPE, FPE_FLTRES, "FPE_FLTRES", "Floating-point inexact result." },
|
|
{ SIGFPE, FPE_FLTINV, "FPE_FLTINV", "Invalid floating-point operation." },
|
|
{ SIGFPE, FPE_FLTSUB, "FPE_FLTSUB", "Subscript out of range." },
|
|
+#ifndef SERENITY
|
|
{ SIGSEGV, SEGV_MAPERR, "SEGV_MAPERR", "Address not mapped to object." },
|
|
{ SIGSEGV, SEGV_ACCERR, "SEGV_ACCERR", "Invalid permissions for mapped object." },
|
|
+#endif
|
|
#if defined(AIX)
|
|
// no explanation found what keyerr would be
|
|
{ SIGSEGV, SEGV_KEYERR, "SEGV_KEYERR", "key error" },
|
|
@@ -942,11 +946,13 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
|
|
#if defined(IA64) && !defined(AIX)
|
|
{ SIGSEGV, SEGV_PSTKOVF, "SEGV_PSTKOVF", "Paragraph stack overflow" },
|
|
#endif
|
|
+#ifndef SERENITY
|
|
{ SIGBUS, BUS_ADRALN, "BUS_ADRALN", "Invalid address alignment." },
|
|
{ SIGBUS, BUS_ADRERR, "BUS_ADRERR", "Nonexistent physical address." },
|
|
{ SIGBUS, BUS_OBJERR, "BUS_OBJERR", "Object-specific hardware error." },
|
|
{ SIGTRAP, TRAP_BRKPT, "TRAP_BRKPT", "Process breakpoint." },
|
|
{ SIGTRAP, TRAP_TRACE, "TRAP_TRACE", "Process trace trap." },
|
|
+#endif
|
|
{ SIGCHLD, CLD_EXITED, "CLD_EXITED", "Child has exited." },
|
|
{ SIGCHLD, CLD_KILLED, "CLD_KILLED", "Child has terminated abnormally and did not create a core file." },
|
|
{ SIGCHLD, CLD_DUMPED, "CLD_DUMPED", "Child has terminated abnormally and created a core file." },
|
|
@@ -967,11 +973,17 @@ static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t
|
|
const struct {
|
|
int code; const char* s_code; const char* s_desc;
|
|
} t2 [] = {
|
|
+ { SIGTRAP, "SIGTRAP", "SIGTRAP FIXME" },
|
|
+ { SIGBUS, "SIGBUS", "SIGBUS FIXME" },
|
|
+ { SIGILL, "SIGILL", "Illegal opcode FIXME." },
|
|
+ { SIGSEGV, "SIGSEGV", "SIGSEGV FIXME" },
|
|
+#ifndef SERENITY
|
|
{ SI_USER, "SI_USER", "Signal sent by kill()." },
|
|
{ SI_QUEUE, "SI_QUEUE", "Signal sent by the sigqueue()." },
|
|
{ SI_TIMER, "SI_TIMER", "Signal generated by expiration of a timer set by timer_settime()." },
|
|
{ SI_ASYNCIO, "SI_ASYNCIO", "Signal generated by completion of an asynchronous I/O request." },
|
|
{ SI_MESGQ, "SI_MESGQ", "Signal generated by arrival of a message on an empty message queue." },
|
|
+#endif
|
|
// Linux specific
|
|
#ifdef SI_TKILL
|
|
{ SI_TKILL, "SI_TKILL", "Signal sent by tkill (pthread_kill)" },
|
|
diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp
|
|
index 9b8e667f9..4e9a5f0e6 100644
|
|
--- a/src/hotspot/share/runtime/os.cpp
|
|
+++ b/src/hotspot/share/runtime/os.cpp
|
|
@@ -155,7 +155,7 @@ char* os::iso8601_time(jlong milliseconds_since_19700101, char* buffer, size_t b
|
|
// No offset when dealing with UTC
|
|
time_t UTC_to_local = 0;
|
|
if (!utc) {
|
|
-#if defined(_ALLBSD_SOURCE) || defined(_GNU_SOURCE)
|
|
+#if (defined(_ALLBSD_SOURCE) || defined(_GNU_SOURCE)) && !defined(SERENITY)
|
|
UTC_to_local = -(time_struct.tm_gmtoff);
|
|
#elif defined(_WINDOWS)
|
|
long zone;
|
|
@@ -1502,6 +1502,7 @@ size_t os::page_size_for_region_unaligned(size_t region_size, size_t min_pages)
|
|
}
|
|
|
|
static const char* errno_to_string (int e, bool short_text) {
|
|
+#ifndef SERENITY
|
|
#define ALL_SHARED_ENUMS(X) \
|
|
X(E2BIG, "Argument list too long") \
|
|
X(EACCES, "Permission denied") \
|
|
@@ -1579,6 +1580,9 @@ static const char* errno_to_string (int e, bool short_text) {
|
|
X(ETXTBSY, "Text file busy") \
|
|
X(EWOULDBLOCK, "Operation would block") \
|
|
X(EXDEV, "Cross-device link")
|
|
+#else
|
|
+ #define ALL_SHARED_ENUMS(X) ENUMERATE_ERRNO_CODES(X)
|
|
+#endif
|
|
|
|
#define DEFINE_ENTRY(e, text) { e, #e, text },
|
|
|
|
diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp
|
|
index 7eaaa9db9..50591f707 100644
|
|
--- a/src/hotspot/share/runtime/os.hpp
|
|
+++ b/src/hotspot/share/runtime/os.hpp
|
|
@@ -468,7 +468,7 @@ class os: AllStatic {
|
|
// need special-case handling of the primordial thread if it attaches
|
|
// to the VM.
|
|
static bool is_primordial_thread(void)
|
|
-#if defined(_WINDOWS) || defined(BSD)
|
|
+#if defined(_WINDOWS) || defined(BSD) || defined(SERENITY)
|
|
// No way to identify the primordial thread.
|
|
{ return false; }
|
|
#else
|
|
diff --git a/src/hotspot/share/runtime/semaphore.hpp b/src/hotspot/share/runtime/semaphore.hpp
|
|
index 0e19c101d..afc007e7a 100644
|
|
--- a/src/hotspot/share/runtime/semaphore.hpp
|
|
+++ b/src/hotspot/share/runtime/semaphore.hpp
|
|
@@ -28,7 +28,7 @@
|
|
#include "memory/allocation.hpp"
|
|
#include "utilities/globalDefinitions.hpp"
|
|
|
|
-#if defined(LINUX) || defined(AIX)
|
|
+#if defined(LINUX) || defined(AIX) || defined(SERENITY)
|
|
# include "semaphore_posix.hpp"
|
|
#elif defined(BSD)
|
|
# include "semaphore_bsd.hpp"
|
|
diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp
|
|
index 082a3272c..65157b52e 100644
|
|
--- a/src/hotspot/share/utilities/globalDefinitions.hpp
|
|
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp
|
|
@@ -1209,5 +1209,9 @@ template<typename K> bool primitive_equals(const K& k0, const K& k1) {
|
|
return k0 == k1;
|
|
}
|
|
|
|
+#ifdef SERENITY
|
|
+#define MAX2(a,b) ((a)>(b)?(a):(b))
|
|
+#define alloca(p) __builtin_alloca(p)
|
|
+#endif
|
|
|
|
#endif // SHARE_UTILITIES_GLOBALDEFINITIONS_HPP
|
|
diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
|
|
index 30cca9ee7..7cac45142 100644
|
|
--- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
|
|
+++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
|
|
@@ -48,7 +48,7 @@
|
|
#include <limits.h>
|
|
#include <errno.h>
|
|
|
|
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
|
|
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(SERENITY)
|
|
#include <inttypes.h>
|
|
#include <signal.h>
|
|
#ifndef __OpenBSD__
|
|
@@ -79,7 +79,7 @@
|
|
#define NULL_WORD NULL
|
|
#endif
|
|
|
|
-#if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
|
|
+#if !defined(LINUX) && !defined(_ALLBSD_SOURCE) && !defined(SERENITY)
|
|
// Compiler-specific primitive types
|
|
typedef unsigned short uint16_t;
|
|
#ifndef _UINT32_T
|
|
@@ -111,7 +111,7 @@ typedef uint64_t julong;
|
|
// checking for nanness
|
|
#if defined(__APPLE__)
|
|
inline int g_isnan(double f) { return isnan(f); }
|
|
-#elif defined(LINUX) || defined(_ALLBSD_SOURCE)
|
|
+#elif defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(SERENITY)
|
|
inline int g_isnan(float f) { return isnan(f); }
|
|
inline int g_isnan(double f) { return isnan(f); }
|
|
#else
|
|
diff --git a/src/hotspot/share/utilities/ostream.cpp b/src/hotspot/share/utilities/ostream.cpp
|
|
index 04995064f..e25c3a429 100644
|
|
--- a/src/hotspot/share/utilities/ostream.cpp
|
|
+++ b/src/hotspot/share/utilities/ostream.cpp
|
|
@@ -1065,7 +1065,7 @@ bufferedStream::~bufferedStream() {
|
|
|
|
#ifndef PRODUCT
|
|
|
|
-#if defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE)
|
|
+#if defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE) || defined(SERENITY)
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|