v8-7.4.288.28.patchset revision 38923bdb
1From 4bfe04b667ac9f15961d55291e88e85282b0fe51 Mon Sep 17 00:00:00 2001
2From: Calvin Hill <calvin@hakobaito.co.uk>
3Date: Tue, 12 Feb 2019 12:51:52 +0000
4Subject: Haiku platform support.
5
6
7diff --git a/BUILD.gn b/BUILD.gn
8index d52d806..92ec21c 100644
9--- a/BUILD.gn
10+++ b/BUILD.gn
11@@ -603,7 +603,7 @@ config("toolchain") {
12     }
13   }
14 
15-  if (is_clang) {
16+  if (is_clang && !is_haiku) {
17     cflags += [
18       "-Wmissing-field-initializers",
19 
20@@ -3228,6 +3228,11 @@ v8_component("v8_libbase") {
21       "src/base/debug/stack_trace_fuchsia.cc",
22       "src/base/platform/platform-fuchsia.cc",
23     ]
24+  } else if (is_haiku) {
25+    sources += [
26+      "src/base/debug/stack_trace_posix.cc",
27+      "src/base/platform/platform-haiku.cc",
28+    ]
29   } else if (is_mac) {
30     sources += [
31       "src/base/debug/stack_trace_posix.cc",
32@@ -3524,6 +3529,13 @@ if (is_fuchsia && !build_with_chromium) {
33 
34 group("v8_fuzzers") {
35   testonly = true
36+
37+  if(host_os == "haiku"){
38+    data_deps = []
39+  }
40+
41+  if (host_os != "haiku") {
42+
43   data_deps = [
44     ":v8_simple_json_fuzzer",
45     ":v8_simple_multi_return_fuzzer",
46@@ -3535,6 +3547,8 @@ group("v8_fuzzers") {
47     ":v8_simple_wasm_compile_fuzzer",
48     ":v8_simple_wasm_fuzzer",
49   ]
50+  }
51+
52 }
53 
54 if (is_component_build) {
55diff --git a/include/v8config.h b/include/v8config.h
56index e30a582..9e65520 100644
57--- a/include/v8config.h
58+++ b/include/v8config.h
59@@ -61,6 +61,7 @@
60 //  V8_OS_CYGWIN        - Cygwin
61 //  V8_OS_DRAGONFLYBSD  - DragonFlyBSD
62 //  V8_OS_FREEBSD       - FreeBSD
63+//  V8_OS_HAIKU         - Haiku
64 //  V8_OS_FUCHSIA       - Fuchsia
65 //  V8_OS_LINUX         - Linux
66 //  V8_OS_MACOSX        - Mac OS X
67@@ -96,6 +97,9 @@
68 # define V8_OS_BSD 1
69 # define V8_OS_FREEBSD 1
70 # define V8_OS_POSIX 1
71+#elif defined(__HAIKU__)
72+# define V8_OS_HAIKU 1
73+# define V8_OS_POSIX 1
74 #elif defined(__Fuchsia__)
75 # define V8_OS_FUCHSIA 1
76 # define V8_OS_POSIX 1
77diff --git a/src/base/debug/stack_trace_posix.cc b/src/base/debug/stack_trace_posix.cc
78index ed602af..58b3b5d 100644
79--- a/src/base/debug/stack_trace_posix.cc
80+++ b/src/base/debug/stack_trace_posix.cc
81@@ -25,14 +25,15 @@
82 #include <string>
83 #include <vector>
84 
85-#if V8_LIBC_GLIBC || V8_LIBC_BSD || V8_LIBC_UCLIBC || V8_OS_SOLARIS
86+#if V8_LIBC_GLIBC || V8_LIBC_BSD || V8_LIBC_UCLIBC || V8_OS_SOLARIS || V8_OS_HAIKU
87 #define HAVE_EXECINFO_H 1
88 #endif
89 
90-#if HAVE_EXECINFO_H
91+#if defined(HAVE_EXECINFO_H)
92 #include <cxxabi.h>
93 #include <execinfo.h>
94 #endif
95+
96 #if V8_OS_MACOSX
97 #include <AvailabilityMacros.h>
98 #endif
99diff --git a/src/base/platform/platform-haiku.cc b/src/base/platform/platform-haiku.cc
100new file mode 100644
101index 0000000..86bf945
102--- /dev/null
103+++ b/src/base/platform/platform-haiku.cc
104@@ -0,0 +1,48 @@
105+// Copyright 2012 the V8 project authors. All rights reserved.
106+// Use of this source code is governed by a BSD-style license that can be
107+// found in the LICENSE file.
108+
109+// Platform-specific code for Haiku goes here. For the POSIX-compatible
110+// parts, the implementation is in platform-posix.cc.
111+
112+#include <pthread.h>
113+#include <semaphore.h>
114+#include <signal.h>
115+#include <stdio.h>
116+#include <stdlib.h>
117+#include <sys/resource.h>
118+#include <sys/time.h>
119+
120+#include <errno.h>
121+#include <fcntl.h>  // open
122+#include <stdarg.h>
123+#include <strings.h>    // index
124+#include <sys/mman.h>   // mmap & munmap
125+#include <sys/stat.h>   // open
126+#include <sys/types.h>  // mmap & munmap
127+#include <unistd.h>     // sysconf
128+
129+#include <cmath>
130+
131+#undef MAP_TYPE
132+
133+#include "src/base/macros.h"
134+#include "src/base/platform/platform-posix-time.h"
135+#include "src/base/platform/platform-posix.h"
136+#include "src/base/platform/platform.h"
137+
138+namespace v8 {
139+namespace base {
140+
141+TimezoneCache* OS::CreateTimezoneCache() {
142+  return new PosixDefaultTimezoneCache();
143+}
144+
145+std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
146+  return std::vector<SharedLibraryAddress>();
147+}
148+
149+void OS::SignalCodeMovingGC() {}
150+
151+}  // namespace base
152+}  // namespace v8
153diff --git a/src/base/platform/platform-posix.cc b/src/base/platform/platform-posix.cc
154index e7edbf5..387290c 100644
155--- a/src/base/platform/platform-posix.cc
156+++ b/src/base/platform/platform-posix.cc
157@@ -60,7 +60,7 @@
158 #include <sys/resource.h>
159 #endif
160 
161-#if !defined(_AIX) && !defined(V8_OS_FUCHSIA)
162+#if !defined(_AIX) && !defined(V8_OS_FUCHSIA) && !defined(__HAIKU__)
163 #include <sys/syscall.h>
164 #endif
165 
166@@ -76,6 +76,14 @@ extern int madvise(caddr_t, size_t, int);
167 #endif
168 #endif
169 
170+#if defined(__HAIKU__)
171+extern "C" int posix_madvise(void*, size_t, int);
172+#endif
173+
174+#if defined(__HAIKU__)
175+#define MADV_FREE POSIX_MADV_DONTNEED
176+#endif
177+
178 #ifndef MADV_FREE
179 #define MADV_FREE MADV_DONTNEED
180 #endif
181@@ -127,7 +135,7 @@ int GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
182 int GetFlagsForMemoryPermission(OS::MemoryPermission access) {
183   int flags = MAP_PRIVATE | MAP_ANONYMOUS;
184   if (access == OS::MemoryPermission::kNoAccess) {
185-#if !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX
186+#if !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX && !V8_OS_HAIKU
187     flags |= MAP_NORESERVE;
188 #endif  // !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX
189 #if V8_OS_QNX
190@@ -356,6 +364,8 @@ bool OS::DiscardSystemPages(void* address, size_t size) {
191   int ret = madvise(address, size, MADV_FREE_REUSABLE);
192 #elif defined(_AIX) || defined(V8_OS_SOLARIS)
193   int ret = madvise(reinterpret_cast<caddr_t>(address), size, MADV_FREE);
194+#elif defined(__HAIKU__)
195+  int ret = posix_madvise(address, size, MADV_FREE);
196 #else
197   int ret = madvise(address, size, MADV_FREE);
198 #endif
199@@ -367,6 +377,8 @@ bool OS::DiscardSystemPages(void* address, size_t size) {
200 // imply runtime support.
201 #if defined(_AIX) || defined(V8_OS_SOLARIS)
202     ret = madvise(reinterpret_cast<caddr_t>(address), size, MADV_DONTNEED);
203+#elif defined(__HAIKU__)
204+    ret = posix_madvise(address, size, MADV_FREE);
205 #else
206     ret = madvise(address, size, MADV_DONTNEED);
207 #endif
208diff --git a/src/libsampler/sampler.cc b/src/libsampler/sampler.cc
209index eb804a7..cd3c2bb 100644
210--- a/src/libsampler/sampler.cc
211+++ b/src/libsampler/sampler.cc
212@@ -12,7 +12,7 @@
213 #include <sys/time.h>
214 #include <atomic>
215 
216-#if !V8_OS_QNX && !V8_OS_AIX
217+#if !V8_OS_QNX && !V8_OS_AIX && !V8_OS_HAIKU
218 #include <sys/syscall.h>  // NOLINT
219 #endif
220 
221@@ -20,7 +20,7 @@
222 #include <mach/mach.h>
223 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
224 // and is a typedef for struct sigcontext. There is no uc_mcontext.
225-#elif !V8_OS_OPENBSD
226+#elif !V8_OS_OPENBSD && !V8_OS_HAIKU
227 #include <ucontext.h>
228 #endif
229 
230@@ -469,6 +469,16 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) {
231   state->sp = reinterpret_cast<void*>(mcontext.mc_r13);
232   state->fp = reinterpret_cast<void*>(mcontext.mc_r11);
233 #endif  // V8_HOST_ARCH_*
234+#elif V8_OS_HAIKU
235+#if V8_HOST_ARCH_IA32
236+  state->pc = reinterpret_cast<void*>(mcontext.eip);
237+  state->sp = reinterpret_cast<void*>(mcontext.esp);
238+  state->fp = reinterpret_cast<void*>(mcontext.ebp);
239+#elif V8_HOST_ARCH_X64
240+  state->pc = reinterpret_cast<void*>(mcontext.rip);
241+  state->sp = reinterpret_cast<void*>(mcontext.rsp);
242+  state->fp = reinterpret_cast<void*>(mcontext.rbp);
243+#endif  // V8_HOST_ARCH_*
244 #elif V8_OS_NETBSD
245 #if V8_HOST_ARCH_IA32
246   state->pc = reinterpret_cast<void*>(mcontext.__gregs[_REG_EIP]);
247diff --git a/test/BUILD.gn b/test/BUILD.gn
248index 70c8b51..073ff09 100644
249--- a/test/BUILD.gn
250+++ b/test/BUILD.gn
251@@ -7,6 +7,16 @@ import("../gni/v8.gni")
252 group("gn_all") {
253   testonly = true
254 
255+ # Don't build tests for Haiku yet
256+
257+  if(host_os != "haiku"){
258+    data_deps = []
259+  }
260+
261+  deps = []
262+
263+  if (host_os != "haiku") {
264+
265   data_deps = [
266     "benchmarks:v8_benchmarks",
267     "intl:v8_intl",
268@@ -34,6 +44,8 @@ group("gn_all") {
269       "unittests:unittests",
270     ]
271   }
272+ }
273+
274 }
275 
276 ###############################################################################
277diff --git a/tools/mb/mb.py b/tools/mb/mb.py
278index cbb5b5d..3238a7a 100755
279--- a/tools/mb/mb.py
280+++ b/tools/mb/mb.py
281@@ -832,12 +832,15 @@ class MetaBuildWrapper(object):
282       subdir, exe = 'linux64', 'gn'
283     elif self.platform == 'darwin':
284       subdir, exe = 'mac', 'gn'
285+    elif self.platform == 'haiku1':
286+      subdir, exe = 'haiku','gn'
287+      gn_path = "/bin/gn"
288     else:
289       subdir, exe = 'win', 'gn.exe'
290 
291     arch = platform.machine()
292     if (arch.startswith('s390') or arch.startswith('ppc') or
293-        self.platform.startswith('aix')):
294+	  self.platform.startswith('aix') or self.platform.startswith('haiku')):
295       # use gn in PATH
296       gn_path = 'gn'
297     else:
298-- 
2992.19.1
300
301