OSX changes, next round

- fix merge issues
- remove platform-specific neo defines that were getting pulled in everywhere
- fix asm alignment directive on OSX
Esse commit está contido em:
Daniel Sloof
2013-07-10 10:03:50 -07:00
commit de Sara Golemon
commit 948040f7d8
15 arquivos alterados com 76 adições e 219 exclusões
+4
Ver Arquivo
@@ -291,9 +291,13 @@ bool AccessLog::genField(std::ostringstream &out, const char* &format,
break;
case 'd':
{
#ifdef CLOCK_THREAD_CPUTIME_ID
struct timespec now;
gettime(CLOCK_THREAD_CPUTIME_ID, &now);
out << gettime_diff_us(transport->getCpuTime(), now);
#else
return false;
#endif
}
break;
case 'h':
@@ -32,7 +32,9 @@
#include "hphp/runtime/base/time/datetime.h"
#include "hphp/runtime/debugger/debugger.h"
#include "hphp/util/alloc.h"
#ifndef __APPLE__
#include "hphp/util/service_data.h"
#endif
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
@@ -44,10 +46,13 @@ AccessLog HttpRequestHandler::s_accessLog(
&(HttpRequestHandler::getAccessLogThreadData));
HttpRequestHandler::HttpRequestHandler()
: m_pathTranslation(true),
m_requestTimedOutOnQueue(ServiceData::createTimeseries(
: m_pathTranslation(true)
#ifndef __APPLE__
,m_requestTimedOutOnQueue(ServiceData::createTimeseries(
"requests_timed_out_on_queue",
{ServiceData::StatsType::COUNT})) {
{ServiceData::StatsType::COUNT}))
#endif
{
}
void HttpRequestHandler::sendStaticContent(Transport *transport,
@@ -146,7 +151,9 @@ void HttpRequestHandler::handleRequest(Transport *transport) {
if (gettime_diff_us(queueTime, now) > requestTimeoutSeconds * 1000000) {
transport->sendString("Service Unavailable", 503);
#ifndef __APPLE__
m_requestTimedOutOnQueue->addValue(1);
#endif
return;
}
}
@@ -48,7 +48,9 @@ public:
private:
bool m_pathTranslation;
#ifndef __APPLE__
ServiceData::ExportedTimeSeries* m_requestTimedOutOnQueue;
#endif
bool handleProxyRequest(Transport *transport, bool force);
void sendStaticContent(Transport *transport, const char *data, int len,
+8 -1
Ver Arquivo
@@ -1238,7 +1238,9 @@ ServerStatsHelper::ServerStatsHelper(const char *section,
: m_section(section), m_instStart(0), m_track(track) {
if (RuntimeOption::EnableStats && RuntimeOption::EnableWebStats) {
Timer::GetMonotonicTime(m_wallStart);
#ifdef CLOCK_THREAD_CPUTIME_ID
gettime(CLOCK_THREAD_CPUTIME_ID, &m_cpuStart);
#endif
if (m_track & TRACK_HWINST) {
m_instStart = HardwareCounter::GetInstructionCount();
}
@@ -1247,12 +1249,17 @@ ServerStatsHelper::ServerStatsHelper(const char *section,
ServerStatsHelper::~ServerStatsHelper() {
if (RuntimeOption::EnableStats && RuntimeOption::EnableWebStats) {
timespec wallEnd, cpuEnd;
timespec wallEnd;
Timer::GetMonotonicTime(wallEnd);
#ifdef CLOCK_THREAD_CPUTIME_ID
timespec cpuEnd;
gettime(CLOCK_THREAD_CPUTIME_ID, &cpuEnd);
#endif
logTime("page.wall.", m_wallStart, wallEnd);
#ifdef CLOCK_THREAD_CPUTIME_ID
logTime("page.cpu.", m_cpuStart, cpuEnd);
#endif
if (m_track & TRACK_MEMORY) {
MemoryManager *mm = MemoryManager::TheMemoryManager();
+2
Ver Arquivo
@@ -67,7 +67,9 @@ Transport::~Transport() {
void Transport::onRequestStart(const timespec &queueTime) {
m_queueTime = queueTime;
Timer::GetMonotonicTime(m_wallTime);
#ifdef CLOCK_THREAD_CPUTIME_ID
gettime(CLOCK_THREAD_CPUTIME_ID, &m_cpuTime);
#endif
/*
* The hardware counter is only 48 bits, so reset this at the beginning
* of every request to make sure we don't overflow.
+1 -1
Ver Arquivo
@@ -498,7 +498,7 @@ StatCache::NodePtr StatCache::getNode(const std::string& path, bool follow) {
node->setPath(path);
return node;
#else
return nullptr;
return NodePtr(nullptr);
#endif
}
+1 -1
Ver Arquivo
@@ -18,7 +18,7 @@
#define incl_HPHP_STAT_CACHE_H_
#ifdef __linux__
#include <sys/inotify.h>
#include <sys/inotify.h>
#endif
#include "tbb/concurrent_hash_map.h"
+13 -2
Ver Arquivo
@@ -294,8 +294,12 @@ tv_to_cycles(const struct timeval& tv, int64_t MHz)
static inline uint64_t
to_usec(int64_t cycles, int64_t MHz, bool cpu_time = false)
{
#ifdef CLOCK_THREAD_CPUTIME_ID
static int64_t vdso_usable =
Util::Vdso::ClockGetTimeNS(CLOCK_THREAD_CPUTIME_ID);
#else
static int64_t vdso_usable = -1;
#endif
if (cpu_time && vdso_usable >= 0)
return cycles / 1000;
@@ -305,10 +309,12 @@ to_usec(int64_t cycles, int64_t MHz, bool cpu_time = false)
static esyscall vtsc_syscall("vtsc");
static inline uint64_t vtsc(int64_t MHz) {
#ifdef CLOCK_THREAD_CPUTIME_ID
int64_t rval = Util::Vdso::ClockGetTimeNS(CLOCK_THREAD_CPUTIME_ID);
if (rval >= 0) {
return rval;
}
#endif
if (vtsc_syscall.num > 0) {
return syscall(vtsc_syscall.num);
}
@@ -1640,8 +1646,13 @@ void f_xhprof_frame_end() {
void f_xhprof_enable(int flags/* = 0 */,
CArrRef args /* = null_array */) {
#ifdef HOTPROFILER
if (vtsc_syscall.num <= 0 &&
Util::Vdso::ClockGetTimeNS(CLOCK_THREAD_CPUTIME_ID) == -1) {
#ifdef CLOCK_THREAD_CPUTIME_ID
bool missingClockGetTimeNS =
Util::Vdso::ClockGetTimeNS(CLOCK_THREAD_CPUTIME_ID) == -1;
#else
bool missingClockGetTimeNS = true;
#endif
if (vtsc_syscall.num <= 0 && missingClockGetTimeNS) {
flags &= ~TrackVtsc;
}
if (flags & TrackVtsc) {
+18 -10
Ver Arquivo
@@ -15,19 +15,27 @@
#define CFI(x) .cfi_##x
#define CFI2(x, y) .cfi_##x y
#define CFI3C(x, y, z) .cfi_##x y##, z
#define ETCH_ALIGNMENT .align 16
#define ETCH_SECTION .section .text
#define ETCH_NAME(x) x
#define ETCH_LABEL(x) .L##x
#else
#define CFI(x) /* not used on OSX */
#define CFI2(x, y) /* not used on OSX */
#define CFI3C(x, y, z) /* not used on OSX */
#define ETCH_ALIGNMENT .align 4 // on OSX this is 2^value
#define ETCH_SECTION .section .text,
#define ETCH_NAME(x) _##x
#define ETCH_LABEL(x) .L##_##x
#endif
///////////////////////////////////////////////////////////////////////////////
#if defined(__x86_64__)
.byte 0
.align 16
.section .text
.globl enterTCHelper
enterTCHelper:
ETCH_ALIGNMENT
ETCH_SECTION
.globl ETCH_NAME(enterTCHelper)
ETCH_NAME(enterTCHelper:)
// Prologue
CFI(startproc) // amongst other things, cfa reg is now rsp, and offset is 8
push %rbp
@@ -64,14 +72,14 @@ enterTCHelper:
* must be kept in sync with REQ_BIND_CALL in abi-x64.h.
*/
cmpl $0x1, 0x0(%rcx)
jne .LenterTCHelper$jumpToTC
lea .LenterTCHelper$serviceReqLabel(%rip), %rax
jne ETCH_LABEL(enterTCHelper$jumpToTC)
lea ETCH_LABEL(enterTCHelper$serviceReqLabel(%rip)), %rax
push %rax
push 0x8(%r15)
jmp *%rdx
.LenterTCHelper$jumpToTC:
ETCH_LABEL(enterTCHelper$jumpToTC:)
call *%rdx
.LenterTCHelper$serviceReqLabel:
ETCH_LABEL(enterTCHelper$serviceReqLabel:)
add $0x280, %rsp // kReservedRSPScratchSpace
CFI2(adjust_cfa_offset, -0x280)
@@ -82,14 +90,14 @@ enterTCHelper:
// Copy the values passed from jitted code into *infoPtr
mov %rdi, 0x0(%rbx)
test %rdi,%rdi
jnz .LenterTCHelper$copyReqArgs
jnz ETCH_LABEL(enterTCHelper$copyReqArgs)
CFI(remember_state)
pop %rbp
CFI2(restore, rbp)
CFI2(adjust_cfa_offset, -8)
ret
.LenterTCHelper$copyReqArgs:
ETCH_LABEL(enterTCHelper$copyReqArgs:)
CFI(restore_state)
mov %rsi, 0x8(%rbx)
mov %rdx, 0x10(%rbx)
+13 -17
Ver Arquivo
@@ -21,6 +21,14 @@
#include "hphp/runtime/base/builtin_functions.h"
#include "hphp/runtime/base/stats.h"
#ifndef __APPLE__
#define ASM_HELPER_ALIGNMENT ".align 16\n"
#define ASM_HELPER_FUNC_NAME(name) #name
#else
#define ASM_HELPER_ALIGNMENT ".align 4\n" // on OSX this is 2^value
#define ASM_HELPER_FUNC_NAME(name) "_" #name
#endif
namespace HPHP {
namespace Transl {
@@ -78,7 +86,7 @@ static_assert(rStashedAR == reg::r15,
"__fcallHelperThunk needs to be modified for ABI changes");
asm(
".byte 0\n"
".align 16\n"
ASM_HELPER_ALIGNMENT
".globl __fcallHelperThunk\n"
"__fcallHelperThunk:\n"
#if defined(__x86_64__)
@@ -89,11 +97,7 @@ asm(
"mov %r15, %rdi\n"
"cmp %r15, %rbp\n"
"jne 1f\n"
#ifndef __APPLE__
"call fcallHelper\n"
#else
"call _fcallHelper\n"
#endif
"call " ASM_HELPER_FUNC_NAME(fcallHelper) "\n"
"jmp *%rax\n"
// fcallHelper may call doFCall. doFCall changes the return ip
// pointed to by r15 so that it points to TranslatorX64::m_retHelper,
@@ -107,11 +111,7 @@ asm(
// a number of c++ frames. The new actrec is linked onto the c++
// frames, however, so switch it into rbp in case fcallHelper throws.
"xchg %r15,%rbp\n"
#ifndef __APPLE__
"call fcallHelper\n"
#else
"call _fcallHelper\n"
#endif
"call " ASM_HELPER_FUNC_NAME(fcallHelper) "\n"
"xchg %r15,%rbp\n"
"push 0x8(%r15)\n"
"jmp *%rax\n"
@@ -179,7 +179,7 @@ TCA fcallHelper(ActRec* ar) {
asm (
".byte 0\n"
".align 16\n"
ASM_HELPER_ALIGNMENT
".globl __funcBodyHelperThunk\n"
"__funcBodyHelperThunk:\n"
#if defined(__x86_64__)
@@ -190,11 +190,7 @@ asm (
* need to worry about stack parity
*/
"mov %rbp, %rdi\n"
#ifndef __APPLE__
"call funcBodyHelper\n"
#else
"call _funcBodyHelper\n"
#endif
"call " ASM_HELPER_FUNC_NAME(funcBodyHelper) "\n"
"jmp *%rax\n"
"ud2\n"
#elif defined(__AARCH64EL__)
+1 -9
Ver Arquivo
@@ -17,10 +17,6 @@
#include "hphp/util/compatibility.h"
#include "hphp/util/vdso.h"
#if defined(__APPLE__)
# include <mach/mach_time.h>
#endif
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
@@ -59,11 +55,7 @@ int dprintf(int fd, const char *format, ...) {
int gettime(clockid_t which_clock, struct timespec *tp) {
#if defined(__APPLE__)
if (which_clock == CLOCK_THREAD_CPUTIME_ID) {
tp->tv_sec = 0;
tp->tv_nsec = mach_absolute_time();
return 0;
}
// XXX: OSX doesn't support realtime so we ignore which_clock
struct timeval tv;
int ret = gettimeofday(&tv, nullptr);
tp->tv_sec = tv.tv_sec;
+1
Ver Arquivo
@@ -27,6 +27,7 @@ namespace HPHP {
#if defined(__APPLE__)
char *strndup(const char* str, size_t len);
int dprintf(int fd, const char *format, ...) ATTRIBUTE_PRINTF(2,3);
typedef int clockid_t;
#endif
int gettime(clockid_t which_clock, struct timespec *tp);
-170
Ver Arquivo
@@ -18,13 +18,6 @@
#ifndef incl_HPHP_CS_CONFIG_H_
#define incl_HPHP_CS_CONFIG_H_ 1
/* Enable support for HTML Compression (still must be enabled at run time) */
#define HTML_COMPRESSION 1
/* Enable support for X Remote CGI Debugging */
/* #undef ENABLE_REMOTE_DEBUG */
/********* SYSTEM CONFIG ***************************************************/
/* autoconf/configure should figure all of these out for you */
@@ -46,179 +39,16 @@
/* Does your system have the mkstemp() call? */
#define HAVE_MKSTEMP 1
/* Does your system have regex.h */
#define HAVE_REGEX 1
/* Does your system have pthreads? */
#define HAVE_PTHREADS 1
/* Does your system have lockf ? */
#define HAVE_LOCKF 1
/* Does your system have Berkeley DB v2 ? */
/* #undef HAVE_DB2 */
/* Enable support for gettext message translation */
/* #undef ENABLE_GETTEXT */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* Define to 1 if you have the `drand48' function. */
#define HAVE_DRAND48 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <features.h> header file. */
#define HAVE_FEATURES_H 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the `gmtime_r' function. */
#define HAVE_GMTIME_R 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the `localtime_r' function. */
#define HAVE_LOCALTIME_R 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mktime' function. */
#define HAVE_MKTIME 1
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the `putenv' function. */
#define HAVE_PUTENV 1
/* Define to 1 if you have the `rand' function. */
#define HAVE_RAND 1
/* Define to 1 if you have the `random' function. */
#define HAVE_RANDOM 1
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the `strftime' function. */
#define HAVE_STRFTIME 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strspn' function. */
#define HAVE_STRSPN 1
/* Define to 1 if you have the `strtod' function. */
#define HAVE_STRTOD 1
/* Define to 1 if you have the `strtok_r' function. */
#define HAVE_STRTOK_R 1
/* Define to 1 if you have the `strtol' function. */
#define HAVE_STRTOL 1
/* Define to 1 if you have the `strtoul' function. */
#define HAVE_STRTOUL 1
/* Define to 1 if `tm_zone' is member of `struct tm'. */
#define HAVE_STRUCT_TM_TM_ZONE 1
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1
/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
`HAVE_STRUCT_TM_TM_ZONE' instead. */
#define HAVE_TM_ZONE 1
/* Define to 1 if you don't have `tm_zone' but do have the external array
`tzname'. */
/* #undef HAVE_TZNAME */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <varargs.h> header file. */
/* #undef HAVE_VARARGS_H */
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the `wait3' system call. Deprecated, you should no
longer depend upon `wait3'. */
#define HAVE_WAIT3 1
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
/* #undef TM_IN_SYS_TIME */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef mode_t */
/* Define to `long' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef pid_t */
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */
#endif /* incl_HPHP_CS_CONFIG_H_ */
-4
Ver Arquivo
@@ -20,10 +20,6 @@
#include "hphp/util/base.h"
#include "hphp/util/compatibility.h"
#ifdef __APPLE__
typedef int clockid_t;
#endif
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
+2 -1
Ver Arquivo
@@ -18,6 +18,7 @@
#define incl_HPHP_UTIL_VDSO_H
#include "hphp/util/base.h"
#include "hphp/util/compatibility.h"
#include "hphp/util/util.h"
namespace HPHP { namespace Util {
@@ -27,7 +28,7 @@ class Vdso {
public:
Vdso();
~Vdso();
static int64_t ClockGetTimeNS(int clk_id);
static int ClockGetTime(int clk_id, timespec *ts);