Commit 0899da36 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Add support for the QNX operating system.

This patch contains contributions from the following members of the
BlackBerry Web Technologies team:

Eli Fidler <efidler@blackberry.com>
Konrad Piascik <kpiascik@blackberry.com>
Jeff Rogers <jrogers@blackberry.com>
Cosmin Truta <ctruta@blackberry.com>
Peter Wang <peter.wang@torchmobile.com.cn>
Xiaobo Wang <xiaobwang@blackberry.com>
Ming Xie <mxie@blackberry.com>
Leo Yang <leoyang@blackberry.com>

R=bmeurer@chromium.org, jkummerow@chromium.org

Review URL: https://codereview.chromium.org/61153009

Patch from Cosmin Truta <ctruta@blackberry.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18430 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ffb5eb6e
......@@ -11,6 +11,7 @@ Igalia, S.L.
Joyent, Inc.
Bloomberg Finance L.P.
NVIDIA Corporation
BlackBerry Limited
Akinori MUSHA <knu@FreeBSD.org>
Alexander Botero-Lowry <alexbl@FreeBSD.org>
......
......@@ -45,7 +45,7 @@
'variables': {
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
OS=="netbsd" or OS=="mac"', {
OS=="netbsd" or OS=="mac" or OS=="qnx"', {
# This handles the Unix platforms we generally deal with.
# Anything else gets passed through, which probably won't work
# very well; such hosts should pass an explicit target_arch
......@@ -99,7 +99,7 @@
['(v8_target_arch=="arm" and host_arch!="arm") or \
(v8_target_arch=="mipsel" and host_arch!="mipsel") or \
(v8_target_arch=="x64" and host_arch!="x64") or \
(OS=="android")', {
(OS=="android" or OS=="qnx")', {
'want_separate_host_toolset': 1,
}, {
'want_separate_host_toolset': 0,
......@@ -186,6 +186,32 @@
}],
# 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
# or OS=="netbsd"'
['OS=="qnx"', {
'target_defaults': {
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
'-fno-exceptions' ],
'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti' ],
'conditions': [
[ 'visibility=="hidden"', {
'cflags': [ '-fvisibility=hidden' ],
}],
[ 'component=="shared_library"', {
'cflags': [ '-fPIC' ],
}],
],
'target_conditions': [
[ '_toolset=="host" and host_os=="linux"', {
'cflags': [ '-pthread' ],
'ldflags': [ '-pthread' ],
'libraries': [ '-lrt' ],
}],
[ '_toolset=="target"', {
'cflags': [ '-Wno-psabi' ],
'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
}],
],
},
}], # OS=="qnx"
['OS=="win"', {
'target_defaults': {
'defines': [
......
......@@ -357,7 +357,7 @@
},
}],
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
or OS=="netbsd"', {
or OS=="netbsd" or OS=="qnx"', {
'conditions': [
[ 'v8_no_strict_aliasing==1', {
'cflags': [ '-fno-strict-aliasing' ],
......@@ -368,7 +368,7 @@
'defines': [ '__C99FEATURES__=1' ], # isinf() etc.
}],
['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
or OS=="netbsd" or OS=="mac" or OS=="android") and \
or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
(v8_target_arch=="arm" or v8_target_arch=="ia32" or \
v8_target_arch=="mipsel")', {
# Check whether the host compiler and target compiler support the
......@@ -390,7 +390,7 @@
'clang%': 0,
},
'conditions': [
['(OS!="android" or clang==1) and \
['((OS!="android" and OS!="qnx") or clang==1) and \
nacl_target_arch!="nacl_x64"', {
'cflags': [ '<(m32flag)' ],
'ldflags': [ '<(m32flag)' ],
......@@ -504,7 +504,8 @@
},
},
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
OS=="qnx"', {
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
'-Wnon-virtual-dtor', '-Woverloaded-virtual',
'<(wno_array_bounds)' ],
......
......@@ -88,6 +88,7 @@
// V8_OS_NETBSD - NetBSD
// V8_OS_OPENBSD - OpenBSD
// V8_OS_POSIX - POSIX compatible (mostly everything except Windows)
// V8_OS_QNX - QNX Neutrino
// V8_OS_SOLARIS - Sun Solaris and OpenSolaris
// V8_OS_WIN - Microsoft Windows
......@@ -127,6 +128,9 @@
# define V8_OS_BSD 1
# define V8_OS_OPENBSD 1
# define V8_OS_POSIX 1
#elif defined(__QNXNTO__)
# define V8_OS_POSIX 1
# define V8_OS_QNX 1
#elif defined(_WIN32)
# define V8_OS_WIN 1
#endif
......
......@@ -27,8 +27,13 @@
// CPU specific code for arm independent of OS goes here.
#ifdef __arm__
#ifdef __QNXNTO__
#include <sys/mman.h> // for cache flushing.
#undef MAP_TYPE
#else
#include <sys/syscall.h> // for cache flushing.
#endif
#endif
#include "v8.h"
......@@ -57,13 +62,15 @@ void CPU::FlushICache(void* start, size_t size) {
return;
}
#if defined (USE_SIMULATOR)
#if defined(USE_SIMULATOR)
// Not generating ARM instructions for C-code. This means that we are
// building an ARM emulator based target. We should notify the simulator
// that the Icache was flushed.
// None of this code ends up in the snapshot so there are no issues
// around whether or not to generate the code when building snapshots.
Simulator::FlushICache(Isolate::Current()->simulator_i_cache(), start, size);
#elif V8_OS_QNX
msync(start, size, MS_SYNC | MS_INVALIDATE_ICACHE);
#else
// Ideally, we would call
// syscall(__ARM_NR_cacheflush, start,
......
......@@ -30,6 +30,8 @@
#if V8_LIBC_GLIBC || V8_OS_BSD
# include <cxxabi.h>
# include <execinfo.h>
#elif V8_OS_QNX
# include <backtrace.h>
#endif // V8_LIBC_GLIBC || V8_OS_BSD
#include <stdio.h>
......@@ -64,6 +66,26 @@ static V8_INLINE void DumpBacktrace() {
}
}
free(symbols);
#elif V8_OS_QNX
char out[1024];
bt_accessor_t acc;
bt_memmap_t memmap;
bt_init_accessor(&acc, BT_SELF);
bt_load_memmap(&acc, &memmap);
bt_sprn_memmap(&memmap, out, sizeof(out));
i::OS::PrintError(out);
bt_addr_t trace[100];
int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace));
i::OS::PrintError("\n==== C stack trace ===============================\n\n");
if (size == 0) {
i::OS::PrintError("(empty)\n");
} else {
bt_sprnf_addrs(&memmap, trace, size, const_cast<char*>("%a\n"),
out, sizeof(out), NULL);
i::OS::PrintError(out);
}
bt_unload_memmap(&memmap);
bt_release_accessor(&acc);
#endif // V8_LIBC_GLIBC || V8_OS_BSD
}
......
......@@ -33,6 +33,9 @@
#if V8_OS_POSIX
#include <unistd.h> // sysconf()
#endif
#if V8_OS_QNX
#include <sys/syspage.h> // cpuinfo
#endif
#include <algorithm>
#include <cctype>
......@@ -78,6 +81,8 @@ static V8_INLINE void __cpuid(int cpu_info[4], int info_type) {
#elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS
#if V8_OS_LINUX
#if V8_HOST_ARCH_ARM
// See <uapi/asm/hwcap.h> kernel header.
......@@ -249,6 +254,8 @@ static bool HasListItem(const char* list, const char* item) {
return false;
}
#endif // V8_OS_LINUX
#endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
CPU::CPU() : stepping_(0),
......@@ -328,7 +335,11 @@ CPU::CPU() : stepping_(0),
has_sahf_ = (cpu_info[2] & 0x00000001) != 0;
#endif
}
#elif V8_HOST_ARCH_ARM
#if V8_OS_LINUX
CPUInfo cpu_info;
// Extract implementor from the "CPU implementer" field.
......@@ -438,7 +449,34 @@ CPU::CPU() : stepping_(0),
// We don't support any FPUs other than VFP.
has_fpu_ = has_vfp_;
#elif V8_OS_QNX
uint32_t cpu_flags = SYSPAGE_ENTRY(cpuinfo)->flags;
if (cpu_flags & ARM_CPU_FLAG_V7) {
architecture_ = 7;
has_thumbee_ = true;
} else if (cpu_flags & ARM_CPU_FLAG_V6) {
architecture_ = 6;
// QNX doesn't say if ThumbEE is available.
// Assume false for the architectures older than ARMv7.
}
ASSERT(architecture_ >= 6);
has_fpu_ = (cpu_flags & CPU_FLAG_FPU) != 0;
has_vfp_ = has_fpu_;
if (cpu_flags & ARM_CPU_FLAG_NEON) {
has_neon_ = true;
has_vfp3_ = has_vfp_;
#ifdef ARM_CPU_FLAG_VFP_D32
has_vfp3_d32_ = (cpu_flags & ARM_CPU_FLAG_VFP_D32) != 0;
#endif
}
has_idiva_ = (cpu_flags & ARM_CPU_FLAG_IDIV) != 0;
#endif // V8_OS_LINUX
#elif V8_HOST_ARCH_MIPS
// Simple detection of FPU at runtime for Linux.
// It is based on /proc/cpuinfo, which reveals hardware configuration
// to user-space applications. According to MIPS (early 2010), no similar
......@@ -448,6 +486,7 @@ CPU::CPU() : stepping_(0),
char* cpu_model = cpu_info.ExtractField("cpu model");
has_fpu_ = HasListItem(cpu_model, "FPU");
delete[] cpu_model;
#endif
}
......
......@@ -66,7 +66,8 @@
],
}],
['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \
or OS=="openbsd" or OS=="solaris" or OS=="android")', {
or OS=="openbsd" or OS=="solaris" or OS=="android" \
or OS=="qnx")', {
'sources': [ 'd8-posix.cc', ]
}],
[ 'OS=="win"', {
......
......@@ -130,6 +130,13 @@ uint64_t OS::TotalPhysicalMemory() {
return 0;
}
return static_cast<uint64_t>(memory_info.dwTotalPhys);
#elif V8_OS_QNX
struct stat stat_buf;
if (stat("/proc", &stat_buf) != 0) {
UNREACHABLE();
return 0;
}
return static_cast<uint64_t>(stat_buf.st_size);
#else
intptr_t pages = sysconf(_SC_PHYS_PAGES);
intptr_t page_size = sysconf(_SC_PAGESIZE);
......@@ -247,7 +254,7 @@ void* OS::GetRandomMmapAddr() {
size_t OS::AllocateAlignment() {
return getpagesize();
return static_cast<size_t>(sysconf(_SC_PAGESIZE));
}
......
This diff is collapsed.
......@@ -59,6 +59,10 @@ int signbit(double x);
# endif
#endif
#if V8_OS_QNX
#include "qnx-math.h"
#endif
// Microsoft Visual C++ specific stuff.
#if V8_CC_MSVC
......
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_QNX_MATH_H_
#define V8_QNX_MATH_H_
#include <cmath>
#undef fpclassify
#undef isfinite
#undef isinf
#undef isnan
#undef isnormal
#undef signbit
using std::lrint;
#endif // V8_QNX_MATH_H_
......@@ -35,7 +35,10 @@
#include <pthread.h>
#include <signal.h>
#include <sys/time.h>
#if !V8_OS_QNX
#include <sys/syscall.h>
#endif
#if V8_OS_MACOSX
#include <mach/mach.h>
......@@ -45,6 +48,7 @@
&& !V8_OS_OPENBSD
#include <ucontext.h>
#endif
#include <unistd.h>
// GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
......@@ -266,7 +270,11 @@ class SignalHandler : public AllStatic {
struct sigaction sa;
sa.sa_sigaction = &HandleProfilerSignal;
sigemptyset(&sa.sa_mask);
#if V8_OS_QNX
sa.sa_flags = SA_SIGINFO;
#else
sa.sa_flags = SA_RESTART | SA_SIGINFO;
#endif
signal_handler_installed_ =
(sigaction(SIGPROF, &sa, &old_signal_handler_) == 0);
}
......@@ -415,7 +423,17 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]);
state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]);
state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]);
#endif // V8_OS_SOLARIS
#elif V8_OS_QNX
#if V8_HOST_ARCH_IA32
state.pc = reinterpret_cast<Address>(mcontext.cpu.eip);
state.sp = reinterpret_cast<Address>(mcontext.cpu.esp);
state.fp = reinterpret_cast<Address>(mcontext.cpu.ebp);
#elif V8_HOST_ARCH_ARM
state.pc = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_PC]);
state.sp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_SP]);
state.fp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_FP]);
#endif // V8_HOST_ARCH_*
#endif // V8_OS_QNX
#endif // USE_SIMULATOR
sampler->SampleStack(state);
#endif // V8_OS_NACL
......
......@@ -155,7 +155,7 @@
'test-macro-assembler-mips.cc'
],
}],
[ 'OS=="linux"', {
[ 'OS=="linux" or OS=="qnx"', {
'sources': [
'test-platform-linux.cc',
],
......
......@@ -29,6 +29,10 @@
#include "v8.h"
#if V8_OS_POSIX
#include <sys/time.h> // NOLINT
#endif
#include "cctest.h"
#if V8_OS_WIN
#include "win32-headers.h"
......
......@@ -811,6 +811,43 @@
],
},
],
['OS=="qnx"', {
'link_settings': {
'target_conditions': [
['_toolset=="host" and host_os=="linux"', {
'libraries': [
'-lrt'
],
}],
['_toolset=="target"', {
'libraries': [
'-lbacktrace', '-lsocket'
],
}],
],
},
'sources': [
'../../src/platform-posix.cc',
],
'target_conditions': [
['_toolset=="host" and host_os=="linux"', {
'sources': [
'../../src/platform-linux.cc'
],
}],
['_toolset=="host" and host_os=="mac"', {
'sources': [
'../../src/platform-macos.cc'
],
}],
['_toolset=="target"', {
'sources': [
'../../src/platform-qnx.cc'
],
}],
],
},
],
['OS=="freebsd"', {
'link_settings': {
'libraries': [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment