summaryrefslogtreecommitdiff
path: root/deps/v8/src/base
diff options
context:
space:
mode:
authorMichaƫl Zasso <targos@protonmail.com>2018-05-31 11:11:57 +0200
committerMyles Borins <mylesborins@google.com>2018-06-01 09:58:27 +0200
commit352a525eb984b8fa2d6f0f6fd68395e6a080bba4 (patch)
treea105ae93f8fd8f533cce19a429f1b6e95d6e11ca /deps/v8/src/base
parentfaf449ca0490f5371dc6cbbc94a87eb697b00fcc (diff)
downloadandroid-node-v8-352a525eb984b8fa2d6f0f6fd68395e6a080bba4.tar.gz
android-node-v8-352a525eb984b8fa2d6f0f6fd68395e6a080bba4.tar.bz2
android-node-v8-352a525eb984b8fa2d6f0f6fd68395e6a080bba4.zip
deps: update V8 to 6.7.288.43
PR-URL: https://github.com/nodejs/node/pull/19989 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/base')
-rw-r--r--deps/v8/src/base/compiler-specific.h10
-rw-r--r--deps/v8/src/base/debug/stack_trace_posix.cc7
-rw-r--r--deps/v8/src/base/debug/stack_trace_win.cc13
-rw-r--r--deps/v8/src/base/flags.h86
-rw-r--r--deps/v8/src/base/ieee754.cc10
-rw-r--r--deps/v8/src/base/logging.h18
-rw-r--r--deps/v8/src/base/macros.h82
-rw-r--r--deps/v8/src/base/platform/condition-variable.h2
-rw-r--r--deps/v8/src/base/platform/mutex.h4
-rw-r--r--deps/v8/src/base/platform/platform-aix.cc10
-rw-r--r--deps/v8/src/base/platform/platform-cygwin.cc4
-rw-r--r--deps/v8/src/base/platform/platform-posix-time.cc4
-rw-r--r--deps/v8/src/base/platform/platform-posix-time.h2
-rw-r--r--deps/v8/src/base/platform/platform-posix.cc7
-rw-r--r--deps/v8/src/base/platform/platform-solaris.cc5
-rw-r--r--deps/v8/src/base/platform/platform-win32.cc35
-rw-r--r--deps/v8/src/base/platform/platform.h14
-rw-r--r--deps/v8/src/base/platform/semaphore.h2
-rw-r--r--deps/v8/src/base/template-utils.h19
-rw-r--r--deps/v8/src/base/timezone-cache.h4
-rw-r--r--deps/v8/src/base/utils/random-number-generator.h21
21 files changed, 222 insertions, 137 deletions
diff --git a/deps/v8/src/base/compiler-specific.h b/deps/v8/src/base/compiler-specific.h
index 1858caa047..75f89298f1 100644
--- a/deps/v8/src/base/compiler-specific.h
+++ b/deps/v8/src/base/compiler-specific.h
@@ -16,16 +16,6 @@
#define ALLOW_UNUSED_TYPE
#endif
-
-// Annotate a function indicating the caller must examine the return value.
-// Use like:
-// int foo() WARN_UNUSED_RESULT;
-#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT
-#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-#else
-#define WARN_UNUSED_RESULT /* NOT SUPPORTED */
-#endif
-
// Tell the compiler a function is using a printf-style format string.
// |format_param| is the one-based index of the format string parameter;
// |dots_param| is the one-based index of the "..." parameter.
diff --git a/deps/v8/src/base/debug/stack_trace_posix.cc b/deps/v8/src/base/debug/stack_trace_posix.cc
index ec3add1682..51b821bdd1 100644
--- a/deps/v8/src/base/debug/stack_trace_posix.cc
+++ b/deps/v8/src/base/debug/stack_trace_posix.cc
@@ -72,6 +72,7 @@ const char kMangledSymbolPrefix[] = "_Z";
const char kSymbolCharacters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
+#if HAVE_EXECINFO_H
// Demangles C++ symbols in the given text. Example:
//
// "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]"
@@ -81,7 +82,6 @@ void DemangleSymbols(std::string* text) {
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
-#if HAVE_EXECINFO_H
std::string::size_type search_from = 0;
while (search_from < text->size()) {
@@ -117,9 +117,8 @@ void DemangleSymbols(std::string* text) {
search_from = mangled_start + 2;
}
}
-
-#endif // HAVE_EXECINFO_H
}
+#endif // HAVE_EXECINFO_H
class BacktraceOutputHandler {
public:
@@ -129,6 +128,7 @@ class BacktraceOutputHandler {
virtual ~BacktraceOutputHandler() {}
};
+#if HAVE_EXECINFO_H
void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
// This should be more than enough to store a 64-bit number in hex:
// 16 hex digits + 1 for null-terminator.
@@ -139,7 +139,6 @@ void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
handler->HandleOutput(buf);
}
-#if HAVE_EXECINFO_H
void ProcessBacktrace(void* const* trace, size_t size,
BacktraceOutputHandler* handler) {
// NOTE: This code MUST be async-signal safe (it's used by in-process
diff --git a/deps/v8/src/base/debug/stack_trace_win.cc b/deps/v8/src/base/debug/stack_trace_win.cc
index 7a7e4f5168..6b22131233 100644
--- a/deps/v8/src/base/debug/stack_trace_win.cc
+++ b/deps/v8/src/base/debug/stack_trace_win.cc
@@ -163,24 +163,11 @@ void DisableSignalStackDump() {
g_dump_stack_in_signal_handler = false;
}
-// Disable optimizations for the StackTrace::StackTrace function. It is
-// important to disable at least frame pointer optimization ("y"), since
-// that breaks CaptureStackBackTrace() and prevents StackTrace from working
-// in Release builds (it may still be janky if other frames are using FPO,
-// but at least it will make it further).
-#if defined(V8_CC_MSVC)
-#pragma optimize("", off)
-#endif
-
StackTrace::StackTrace() {
// When walking our own stack, use CaptureStackBackTrace().
count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, nullptr);
}
-#if defined(V8_CC_MSVC)
-#pragma optimize("", on)
-#endif
-
StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
InitTrace(exception_pointers->ContextRecord);
}
diff --git a/deps/v8/src/base/flags.h b/deps/v8/src/base/flags.h
index 6bdb69319d..3bec12cb88 100644
--- a/deps/v8/src/base/flags.h
+++ b/deps/v8/src/base/flags.h
@@ -75,49 +75,49 @@ class Flags final {
mask_type mask_;
};
-
-#define DEFINE_OPERATORS_FOR_FLAGS(Type) \
- inline Type operator&( \
- Type::flag_type lhs, \
- Type::flag_type rhs)ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \
- inline Type operator&(Type::flag_type lhs, Type::flag_type rhs) { \
- return Type(lhs) & rhs; \
- } \
- inline Type operator&(Type::flag_type lhs, \
- const Type& rhs)ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \
- inline Type operator&(Type::flag_type lhs, const Type& rhs) { \
- return rhs & lhs; \
- } \
- inline void operator&(Type::flag_type lhs, \
- Type::mask_type rhs)ALLOW_UNUSED_TYPE; \
- inline void operator&(Type::flag_type lhs, Type::mask_type rhs) {} \
- inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) \
- ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \
- inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) { \
- return Type(lhs) | rhs; \
- } \
- inline Type operator|(Type::flag_type lhs, const Type& rhs) \
- ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \
- inline Type operator|(Type::flag_type lhs, const Type& rhs) { \
- return rhs | lhs; \
- } \
- inline void operator|(Type::flag_type lhs, Type::mask_type rhs) \
- ALLOW_UNUSED_TYPE; \
- inline void operator|(Type::flag_type lhs, Type::mask_type rhs) {} \
- inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) \
- ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \
- inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) { \
- return Type(lhs) ^ rhs; \
- } inline Type \
- operator^(Type::flag_type lhs, const Type& rhs) \
- ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \
- inline Type operator^(Type::flag_type lhs, const Type& rhs) { \
- return rhs ^ lhs; \
- } inline void \
- operator^(Type::flag_type lhs, Type::mask_type rhs) ALLOW_UNUSED_TYPE; \
- inline void operator^(Type::flag_type lhs, Type::mask_type rhs) { \
- } inline Type \
- operator~(Type::flag_type val)ALLOW_UNUSED_TYPE; \
+#define DEFINE_OPERATORS_FOR_FLAGS(Type) \
+ inline Type operator&( \
+ Type::flag_type lhs, \
+ Type::flag_type rhs)ALLOW_UNUSED_TYPE V8_WARN_UNUSED_RESULT; \
+ inline Type operator&(Type::flag_type lhs, Type::flag_type rhs) { \
+ return Type(lhs) & rhs; \
+ } \
+ inline Type operator&( \
+ Type::flag_type lhs, \
+ const Type& rhs)ALLOW_UNUSED_TYPE V8_WARN_UNUSED_RESULT; \
+ inline Type operator&(Type::flag_type lhs, const Type& rhs) { \
+ return rhs & lhs; \
+ } \
+ inline void operator&(Type::flag_type lhs, \
+ Type::mask_type rhs)ALLOW_UNUSED_TYPE; \
+ inline void operator&(Type::flag_type lhs, Type::mask_type rhs) {} \
+ inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) \
+ ALLOW_UNUSED_TYPE V8_WARN_UNUSED_RESULT; \
+ inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) { \
+ return Type(lhs) | rhs; \
+ } \
+ inline Type operator|(Type::flag_type lhs, const Type& rhs) \
+ ALLOW_UNUSED_TYPE V8_WARN_UNUSED_RESULT; \
+ inline Type operator|(Type::flag_type lhs, const Type& rhs) { \
+ return rhs | lhs; \
+ } \
+ inline void operator|(Type::flag_type lhs, Type::mask_type rhs) \
+ ALLOW_UNUSED_TYPE; \
+ inline void operator|(Type::flag_type lhs, Type::mask_type rhs) {} \
+ inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) \
+ ALLOW_UNUSED_TYPE V8_WARN_UNUSED_RESULT; \
+ inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) { \
+ return Type(lhs) ^ rhs; \
+ } \
+ inline Type operator^(Type::flag_type lhs, const Type& rhs) \
+ ALLOW_UNUSED_TYPE V8_WARN_UNUSED_RESULT; \
+ inline Type operator^(Type::flag_type lhs, const Type& rhs) { \
+ return rhs ^ lhs; \
+ } \
+ inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \
+ ALLOW_UNUSED_TYPE; \
+ inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {} \
+ inline Type operator~(Type::flag_type val)ALLOW_UNUSED_TYPE; \
inline Type operator~(Type::flag_type val) { return ~Type(val); }
} // namespace base
diff --git a/deps/v8/src/base/ieee754.cc b/deps/v8/src/base/ieee754.cc
index 54f7e2e6aa..95b84cf328 100644
--- a/deps/v8/src/base/ieee754.cc
+++ b/deps/v8/src/base/ieee754.cc
@@ -159,11 +159,11 @@ typedef union {
#define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval))
-int32_t __ieee754_rem_pio2(double x, double *y) WARN_UNUSED_RESULT;
-double __kernel_cos(double x, double y) WARN_UNUSED_RESULT;
-int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec,
- const int32_t *ipio2) WARN_UNUSED_RESULT;
-double __kernel_sin(double x, double y, int iy) WARN_UNUSED_RESULT;
+int32_t __ieee754_rem_pio2(double x, double* y) V8_WARN_UNUSED_RESULT;
+double __kernel_cos(double x, double y) V8_WARN_UNUSED_RESULT;
+int __kernel_rem_pio2(double* x, double* y, int e0, int nx, int prec,
+ const int32_t* ipio2) V8_WARN_UNUSED_RESULT;
+double __kernel_sin(double x, double y, int iy) V8_WARN_UNUSED_RESULT;
/* __ieee754_rem_pio2(x,y)
*
diff --git a/deps/v8/src/base/logging.h b/deps/v8/src/base/logging.h
index a21bc5e423..baf6b12ccb 100644
--- a/deps/v8/src/base/logging.h
+++ b/deps/v8/src/base/logging.h
@@ -106,11 +106,25 @@ V8_BASE_EXPORT void SetDcheckFunction(void (*dcheck_Function)(const char*, int,
// Define PrintCheckOperand<T> for each T which defines operator<< for ostream.
template <typename T>
-typename std::enable_if<has_output_operator<T>::value>::type PrintCheckOperand(
- std::ostream& os, T val) {
+typename std::enable_if<
+ !std::is_function<typename std::remove_pointer<T>::type>::value &&
+ has_output_operator<T>::value>::type
+PrintCheckOperand(std::ostream& os, T val) {
os << std::forward<T>(val);
}
+// Provide an overload for functions and function pointers. Function pointers
+// don't implicitly convert to void* but do implicitly convert to bool, so
+// without this function pointers are always printed as 1 or 0. (MSVC isn't
+// standards-conforming here and converts function pointers to regular
+// pointers, so this is a no-op for MSVC.)
+template <typename T>
+typename std::enable_if<
+ std::is_function<typename std::remove_pointer<T>::type>::value>::type
+PrintCheckOperand(std::ostream& os, T val) {
+ os << reinterpret_cast<const void*>(val);
+}
+
// Define PrintCheckOperand<T> for enums which have no operator<<.
template <typename T>
typename std::enable_if<std::is_enum<T>::value &&
diff --git a/deps/v8/src/base/macros.h b/deps/v8/src/base/macros.h
index 9de42131a4..db2f194591 100644
--- a/deps/v8/src/base/macros.h
+++ b/deps/v8/src/base/macros.h
@@ -150,11 +150,6 @@ V8_INLINE Dest bit_cast(Source const& source) {
#define INLINE(declarator) V8_INLINE declarator
#define NO_INLINE(declarator) V8_NOINLINE declarator
-
-// Newly written code should use WARN_UNUSED_RESULT.
-#define MUST_USE_RESULT WARN_UNUSED_RESULT
-
-
// Define V8_USE_ADDRESS_SANITIZER macros.
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
@@ -196,12 +191,68 @@ V8_INLINE Dest bit_cast(Source const& source) {
// TODO(all) Replace all uses of this macro with static_assert, remove macro.
#define STATIC_ASSERT(test) static_assert(test, #test)
-// TODO(rongjie) Remove this workaround once we require gcc >= 5.0
-#if __GNUG__ && __GNUC__ < 5
-#define IS_TRIVIALLY_COPYABLE(T) \
- (__has_trivial_copy(T) && __has_trivial_destructor(T))
+namespace v8 {
+namespace base {
+
+// Note that some implementations of std::is_trivially_copyable mandate that at
+// least one of the copy constructor, move constructor, copy assignment or move
+// assignment is non-deleted, while others do not. Be aware that also
+// base::is_trivially_copyable will differ for these cases.
+template <typename T>
+struct is_trivially_copyable {
+#if V8_CC_MSVC
+ // Unfortunately, MSVC 2015 is broken in that std::is_trivially_copyable can
+ // be false even though it should be true according to the standard.
+ // (status at 2018-02-26, observed on the msvc waterfall bot).
+ // Interestingly, the lower-level primitives used below are working as
+ // intended, so we reimplement this according to the standard.
+ // See also https://developercommunity.visualstudio.com/content/problem/
+ // 170883/msvc-type-traits-stdis-trivial-is-bugged.html.
+ static constexpr bool value =
+ // Copy constructor is trivial or deleted.
+ (std::is_trivially_copy_constructible<T>::value ||
+ !std::is_copy_constructible<T>::value) &&
+ // Copy assignment operator is trivial or deleted.
+ (std::is_trivially_copy_assignable<T>::value ||
+ !std::is_copy_assignable<T>::value) &&
+ // Move constructor is trivial or deleted.
+ (std::is_trivially_move_constructible<T>::value ||
+ !std::is_move_constructible<T>::value) &&
+ // Move assignment operator is trivial or deleted.
+ (std::is_trivially_move_assignable<T>::value ||
+ !std::is_move_assignable<T>::value) &&
+ // (Some implementations mandate that one of the above is non-deleted, but
+ // the standard does not, so let's skip this check.)
+ // Trivial non-deleted destructor.
+ std::is_trivially_destructible<T>::value;
+
+#elif defined(__GNUC__) && __GNUC__ < 5
+ // WARNING:
+ // On older libstdc++ versions, there is no way to correctly implement
+ // is_trivially_copyable. The workaround below is an approximation (neither
+ // over- nor underapproximation). E.g. it wrongly returns true if the move
+ // constructor is non-trivial, and it wrongly returns false if the copy
+ // constructor is deleted, but copy assignment is trivial.
+ // TODO(rongjie) Remove this workaround once we require gcc >= 5.0
+ static constexpr bool value =
+ __has_trivial_copy(T) && __has_trivial_destructor(T);
+
#else
-#define IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value
+ static constexpr bool value = std::is_trivially_copyable<T>::value;
+#endif
+};
+#if defined(__GNUC__) && __GNUC__ < 5
+// On older libstdc++ versions, base::is_trivially_copyable<T>::value is only an
+// approximation (see above), so make ASSERT_{NOT_,}TRIVIALLY_COPYABLE a noop.
+#define ASSERT_TRIVIALLY_COPYABLE(T) static_assert(true, "check disabled")
+#define ASSERT_NOT_TRIVIALLY_COPYABLE(T) static_assert(true, "check disabled")
+#else
+#define ASSERT_TRIVIALLY_COPYABLE(T) \
+ static_assert(::v8::base::is_trivially_copyable<T>::value, \
+ #T " should be trivially copyable")
+#define ASSERT_NOT_TRIVIALLY_COPYABLE(T) \
+ static_assert(!::v8::base::is_trivially_copyable<T>::value, \
+ #T " should not be trivially copyable")
#endif
// The USE(x, ...) template is used to silence C++ compiler warnings
@@ -211,12 +262,15 @@ struct Use {
template <typename T>
Use(T&&) {} // NOLINT(runtime/explicit)
};
-#define USE(...) \
- do { \
- ::Use unused_tmp_array_for_use_macro[]{__VA_ARGS__}; \
- (void)unused_tmp_array_for_use_macro; \
+#define USE(...) \
+ do { \
+ ::v8::base::Use unused_tmp_array_for_use_macro[]{__VA_ARGS__}; \
+ (void)unused_tmp_array_for_use_macro; \
} while (false)
+} // namespace base
+} // namespace v8
+
// Define our own macros for writing 64-bit constants. This is less fragile
// than defining __STDC_CONSTANT_MACROS before including <stdint.h>, and it
// works on compilers that don't have it (like MSVC).
diff --git a/deps/v8/src/base/platform/condition-variable.h b/deps/v8/src/base/platform/condition-variable.h
index 30c19612aa..af00c6e5d5 100644
--- a/deps/v8/src/base/platform/condition-variable.h
+++ b/deps/v8/src/base/platform/condition-variable.h
@@ -57,7 +57,7 @@ class V8_BASE_EXPORT ConditionVariable final {
// spuriously. When unblocked, regardless of the reason, the lock on the mutex
// is reacquired and |WaitFor()| exits. Returns true if the condition variable
// was notified prior to the timeout.
- bool WaitFor(Mutex* mutex, const TimeDelta& rel_time) WARN_UNUSED_RESULT;
+ bool WaitFor(Mutex* mutex, const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT;
// The implementation-defined native handle type.
#if V8_OS_POSIX
diff --git a/deps/v8/src/base/platform/mutex.h b/deps/v8/src/base/platform/mutex.h
index 25f85b907e..59b653d6cd 100644
--- a/deps/v8/src/base/platform/mutex.h
+++ b/deps/v8/src/base/platform/mutex.h
@@ -51,7 +51,7 @@ class V8_BASE_EXPORT Mutex final {
// Tries to lock the given mutex. Returns whether the mutex was
// successfully locked.
- bool TryLock() WARN_UNUSED_RESULT;
+ bool TryLock() V8_WARN_UNUSED_RESULT;
// The implementation-defined native handle type.
#if V8_OS_POSIX
@@ -150,7 +150,7 @@ class V8_BASE_EXPORT RecursiveMutex final {
// Tries to lock the given mutex. Returns whether the mutex was
// successfully locked.
- bool TryLock() WARN_UNUSED_RESULT;
+ bool TryLock() V8_WARN_UNUSED_RESULT;
// The implementation-defined native handle type.
#if V8_OS_POSIX
diff --git a/deps/v8/src/base/platform/platform-aix.cc b/deps/v8/src/base/platform/platform-aix.cc
index 39559552bb..b4bba251aa 100644
--- a/deps/v8/src/base/platform/platform-aix.cc
+++ b/deps/v8/src/base/platform/platform-aix.cc
@@ -39,21 +39,21 @@ namespace base {
class AIXTimezoneCache : public PosixTimezoneCache {
const char* LocalTimezone(double time) override;
- double LocalTimeOffset() override;
+ double LocalTimeOffset(double time_ms, bool is_utc) override;
~AIXTimezoneCache() override {}
};
-const char* AIXTimezoneCache::LocalTimezone(double time) {
- if (std::isnan(time)) return "";
- time_t tv = static_cast<time_t>(floor(time / msPerSecond));
+const char* AIXTimezoneCache::LocalTimezone(double time_ms) {
+ if (std::isnan(time_ms)) return "";
+ time_t tv = static_cast<time_t>(floor(time_ms / msPerSecond));
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
if (nullptr == t) return "";
return tzname[0]; // The location of the timezone string on AIX.
}
-double AIXTimezoneCache::LocalTimeOffset() {
+double AIXTimezoneCache::LocalTimeOffset(double time_ms, bool is_utc) {
// On AIX, struct tm does not contain a tm_gmtoff field.
time_t utc = time(nullptr);
DCHECK_NE(utc, -1);
diff --git a/deps/v8/src/base/platform/platform-cygwin.cc b/deps/v8/src/base/platform/platform-cygwin.cc
index 0d4ec9a10d..ddcdc1a2d3 100644
--- a/deps/v8/src/base/platform/platform-cygwin.cc
+++ b/deps/v8/src/base/platform/platform-cygwin.cc
@@ -66,7 +66,7 @@ uint8_t* RandomizedVirtualAlloc(size_t size, DWORD flags, DWORD protect,
class CygwinTimezoneCache : public PosixTimezoneCache {
const char* LocalTimezone(double time) override;
- double LocalTimeOffset() override;
+ double LocalTimeOffset(double time_ms, bool is_utc) override;
~CygwinTimezoneCache() override {}
};
@@ -80,7 +80,7 @@ const char* CygwinTimezoneCache::LocalTimezone(double time) {
return tzname[0]; // The location of the timezone string on Cygwin.
}
-double CygwinTimezoneCache::LocalTimeOffset() {
+double LocalTimeOffset(double time_ms, bool is_utc) {
// On Cygwin, struct tm does not contain a tm_gmtoff field.
time_t utc = time(nullptr);
DCHECK_NE(utc, -1);
diff --git a/deps/v8/src/base/platform/platform-posix-time.cc b/deps/v8/src/base/platform/platform-posix-time.cc
index 54618810c2..28e6431baf 100644
--- a/deps/v8/src/base/platform/platform-posix-time.cc
+++ b/deps/v8/src/base/platform/platform-posix-time.cc
@@ -18,7 +18,9 @@ const char* PosixDefaultTimezoneCache::LocalTimezone(double time) {
return t->tm_zone;
}
-double PosixDefaultTimezoneCache::LocalTimeOffset() {
+double PosixDefaultTimezoneCache::LocalTimeOffset(double time_ms, bool is_utc) {
+ // Preserve the old behavior for non-ICU implementation by ignoring both
+ // time_ms and is_utc.
time_t tv = time(nullptr);
struct tm tm;
struct tm* t = localtime_r(&tv, &tm);
diff --git a/deps/v8/src/base/platform/platform-posix-time.h b/deps/v8/src/base/platform/platform-posix-time.h
index 3fc1bfd900..4d3373715b 100644
--- a/deps/v8/src/base/platform/platform-posix-time.h
+++ b/deps/v8/src/base/platform/platform-posix-time.h
@@ -13,7 +13,7 @@ namespace base {
class PosixDefaultTimezoneCache : public PosixTimezoneCache {
public:
const char* LocalTimezone(double time_ms) override;
- double LocalTimeOffset() override;
+ double LocalTimeOffset(double time_ms, bool is_utc) override;
~PosixDefaultTimezoneCache() override {}
};
diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc
index f85f7fe942..fee67589b6 100644
--- a/deps/v8/src/base/platform/platform-posix.cc
+++ b/deps/v8/src/base/platform/platform-posix.cc
@@ -491,6 +491,13 @@ int OS::GetCurrentThreadId() {
#endif
}
+void OS::ExitProcess(int exit_code) {
+ // Use _exit instead of exit to avoid races between isolate
+ // threads and static destructors.
+ fflush(stdout);
+ fflush(stderr);
+ _exit(exit_code);
+}
// ----------------------------------------------------------------------------
// POSIX date/time support.
diff --git a/deps/v8/src/base/platform/platform-solaris.cc b/deps/v8/src/base/platform/platform-solaris.cc
index b81895a3fb..477149db1b 100644
--- a/deps/v8/src/base/platform/platform-solaris.cc
+++ b/deps/v8/src/base/platform/platform-solaris.cc
@@ -37,8 +37,7 @@ namespace base {
class SolarisTimezoneCache : public PosixTimezoneCache {
const char* LocalTimezone(double time) override;
- double LocalTimeOffset() override;
-
+ double LocalTimeOffset(double time, bool is_utc) override;
~SolarisTimezoneCache() override {}
};
@@ -51,7 +50,7 @@ const char* SolarisTimezoneCache::LocalTimezone(double time) {
return tzname[0]; // The location of the timezone string on Solaris.
}
-double SolarisTimezoneCache::LocalTimeOffset() {
+double SolarisTimezoneCache::LocalTimeOffset(double time, bool is_utc) {
tzset();
return -static_cast<double>(timezone * msPerSecond);
}
diff --git a/deps/v8/src/base/platform/platform-win32.cc b/deps/v8/src/base/platform/platform-win32.cc
index 3f1a586840..d4aa44f8a7 100644
--- a/deps/v8/src/base/platform/platform-win32.cc
+++ b/deps/v8/src/base/platform/platform-win32.cc
@@ -27,6 +27,10 @@
#include "src/base/timezone-cache.h"
#include "src/base/utils/random-number-generator.h"
+#if defined(_MSC_VER)
+#include <crtdbg.h> // NOLINT
+#endif // defined(_MSC_VER)
+
// Extra functions for MinGW. Most of these are the _s functions which are in
// the Microsoft Visual Studio C++ CRT.
#ifdef __MINGW32__
@@ -111,7 +115,7 @@ class WindowsTimezoneCache : public TimezoneCache {
const char* LocalTimezone(double time) override;
- double LocalTimeOffset() override;
+ double LocalTimeOffset(double time, bool is_utc) override;
double DaylightSavingsOffset(double time) override;
@@ -462,7 +466,9 @@ const char* WindowsTimezoneCache::LocalTimezone(double time) {
// Returns the local time offset in milliseconds east of UTC without
// taking daylight savings time into account.
-double WindowsTimezoneCache::LocalTimeOffset() {
+double WindowsTimezoneCache::LocalTimeOffset(double time_ms, bool is_utc) {
+ // Ignore is_utc and time_ms for now. That way, the behavior wouldn't
+ // change with icu_timezone_data disabled.
// Use current time, rounded to the millisecond.
Win32Time t(OS::TimeCurrentMillis());
// Time::LocalOffset inlcudes any daylight savings offset, so subtract it.
@@ -493,6 +499,13 @@ int OS::GetCurrentThreadId() {
return static_cast<int>(::GetCurrentThreadId());
}
+void OS::ExitProcess(int exit_code) {
+ // Use TerminateProcess avoid races between isolate threads and
+ // static destructors.
+ fflush(stdout);
+ fflush(stderr);
+ TerminateProcess(GetCurrentProcess(), exit_code);
+}
// ----------------------------------------------------------------------------
// Win32 console output.
@@ -1239,6 +1252,24 @@ int OS::ActivationFrameAlignment() {
#endif
}
+#if (defined(_WIN32) || defined(_WIN64))
+void EnsureConsoleOutputWin32() {
+ UINT new_flags =
+ SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
+ UINT existing_flags = SetErrorMode(new_flags);
+ SetErrorMode(existing_flags | new_flags);
+#if defined(_MSC_VER)
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ _set_error_mode(_OUT_TO_STDERR);
+#endif // defined(_MSC_VER)
+}
+#endif // (defined(_WIN32) || defined(_WIN64))
+
// ----------------------------------------------------------------------------
// Win32 thread support.
diff --git a/deps/v8/src/base/platform/platform.h b/deps/v8/src/base/platform/platform.h
index 8a4545c607..4fbc87c4aa 100644
--- a/deps/v8/src/base/platform/platform.h
+++ b/deps/v8/src/base/platform/platform.h
@@ -245,6 +245,8 @@ class V8_BASE_EXPORT OS {
static int GetCurrentThreadId();
+ static void ExitProcess(int exit_code);
+
private:
// These classes use the private memory management API below.
friend class MemoryMappedFile;
@@ -279,6 +281,18 @@ class V8_BASE_EXPORT OS {
DISALLOW_IMPLICIT_CONSTRUCTORS(OS);
};
+#if (defined(_WIN32) || defined(_WIN64))
+V8_BASE_EXPORT void EnsureConsoleOutputWin32();
+#endif // (defined(_WIN32) || defined(_WIN64))
+
+inline void EnsureConsoleOutput() {
+#if (defined(_WIN32) || defined(_WIN64))
+ // Windows requires extra calls to send assert output to the console
+ // rather than a dialog box.
+ EnsureConsoleOutputWin32();
+#endif // (defined(_WIN32) || defined(_WIN64))
+}
+
// ----------------------------------------------------------------------------
// Thread
//
diff --git a/deps/v8/src/base/platform/semaphore.h b/deps/v8/src/base/platform/semaphore.h
index 31aeca3d9b..62c9c93988 100644
--- a/deps/v8/src/base/platform/semaphore.h
+++ b/deps/v8/src/base/platform/semaphore.h
@@ -47,7 +47,7 @@ class V8_BASE_EXPORT Semaphore final {
// Like Wait() but returns after rel_time time has passed. If the timeout
// happens the return value is false and the counter is unchanged. Otherwise
// the semaphore counter is decremented and true is returned.
- bool WaitFor(const TimeDelta& rel_time) WARN_UNUSED_RESULT;
+ bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT;
#if V8_OS_MACOSX
typedef semaphore_t NativeHandle;
diff --git a/deps/v8/src/base/template-utils.h b/deps/v8/src/base/template-utils.h
index 18b50fe70c..07356346ec 100644
--- a/deps/v8/src/base/template-utils.h
+++ b/deps/v8/src/base/template-utils.h
@@ -79,20 +79,13 @@ struct pass_value_or_ref {
decay_t, const decay_t&>::type;
};
+// Uses expression SFINAE to detect whether using operator<< would work.
+template <typename T, typename = void>
+struct has_output_operator : std::false_type {};
template <typename T>
-struct has_output_operator {
- // This template is only instantiable if U provides operator<< with ostream.
- // Its return type is uint8_t.
- template <typename U>
- static auto __check_operator(U u)
- -> decltype(*(std::ostream*)nullptr << *u, uint8_t{0});
- // This is a fallback implementation, returning uint16_t. If the template
- // above is instantiable, is has precedence over this varargs function.
- static uint16_t __check_operator(...);
-
- using ptr_t = typename std::add_pointer<T>::type;
- static constexpr bool value = sizeof(__check_operator(ptr_t{nullptr})) == 1;
-};
+struct has_output_operator<T, decltype(void(std::declval<std::ostream&>()
+ << std::declval<T>()))>
+ : std::true_type {};
namespace detail {
diff --git a/deps/v8/src/base/timezone-cache.h b/deps/v8/src/base/timezone-cache.h
index ff9fde4d15..96ad7bb41f 100644
--- a/deps/v8/src/base/timezone-cache.h
+++ b/deps/v8/src/base/timezone-cache.h
@@ -20,10 +20,8 @@ class TimezoneCache {
// ES #sec-local-time-zone-adjustment
// Local Time Zone Adjustment
//
- // TODO(littledan): Make more accurate with another parameter along the
- // lines of this spec change:
// https://github.com/tc39/ecma262/pull/778
- virtual double LocalTimeOffset() = 0;
+ virtual double LocalTimeOffset(double time_ms, bool is_utc) = 0;
// Called when the local timezone changes
virtual void Clear() = 0;
diff --git a/deps/v8/src/base/utils/random-number-generator.h b/deps/v8/src/base/utils/random-number-generator.h
index 321ce861fb..b4b67970c7 100644
--- a/deps/v8/src/base/utils/random-number-generator.h
+++ b/deps/v8/src/base/utils/random-number-generator.h
@@ -50,9 +50,7 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
// that one int value is pseudorandomly generated and returned.
// All 2^32 possible integer values are produced with (approximately) equal
// probability.
- V8_INLINE int NextInt() WARN_UNUSED_RESULT {
- return Next(32);
- }
+ V8_INLINE int NextInt() V8_WARN_UNUSED_RESULT { return Next(32); }
// Returns a pseudorandom, uniformly distributed int value between 0
// (inclusive) and the specified max value (exclusive), drawn from this random
@@ -60,30 +58,28 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
// one int value in the specified range is pseudorandomly generated and
// returned. All max possible int values are produced with (approximately)
// equal probability.
- int NextInt(int max) WARN_UNUSED_RESULT;
+ int NextInt(int max) V8_WARN_UNUSED_RESULT;
// Returns the next pseudorandom, uniformly distributed boolean value from
// this random number generator's sequence. The general contract of
// |NextBoolean()| is that one boolean value is pseudorandomly generated and
// returned. The values true and false are produced with (approximately) equal
// probability.
- V8_INLINE bool NextBool() WARN_UNUSED_RESULT {
- return Next(1) != 0;
- }
+ V8_INLINE bool NextBool() V8_WARN_UNUSED_RESULT { return Next(1) != 0; }
// Returns the next pseudorandom, uniformly distributed double value between
// 0.0 and 1.0 from this random number generator's sequence.
// The general contract of |NextDouble()| is that one double value, chosen
// (approximately) uniformly from the range 0.0 (inclusive) to 1.0
// (exclusive), is pseudorandomly generated and returned.
- double NextDouble() WARN_UNUSED_RESULT;
+ double NextDouble() V8_WARN_UNUSED_RESULT;
// Returns the next pseudorandom, uniformly distributed int64 value from this
// random number generator's sequence. The general contract of |NextInt64()|
// is that one 64-bit int value is pseudorandomly generated and returned.
// All 2^64 possible integer values are produced with (approximately) equal
// probability.
- int64_t NextInt64() WARN_UNUSED_RESULT;
+ int64_t NextInt64() V8_WARN_UNUSED_RESULT;
// Fills the elements of a specified array of bytes with random numbers.
void NextBytes(void* buffer, size_t buflen);
@@ -91,7 +87,8 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
// Returns the next pseudorandom set of n unique uint64 values smaller than
// max.
// n must be less or equal to max.
- std::vector<uint64_t> NextSample(uint64_t max, size_t n) WARN_UNUSED_RESULT;
+ std::vector<uint64_t> NextSample(uint64_t max,
+ size_t n) V8_WARN_UNUSED_RESULT;
// Returns the next pseudorandom set of n unique uint64 values smaller than
// max.
@@ -103,7 +100,7 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
std::vector<uint64_t> NextSampleSlow(
uint64_t max, size_t n,
const std::unordered_set<uint64_t>& excluded =
- std::unordered_set<uint64_t>{}) WARN_UNUSED_RESULT;
+ std::unordered_set<uint64_t>{}) V8_WARN_UNUSED_RESULT;
// Override the current ssed.
void SetSeed(int64_t seed);
@@ -136,7 +133,7 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
static const int64_t kAddend = 0xb;
static const int64_t kMask = V8_2PART_UINT64_C(0xffff, ffffffff);
- int Next(int bits) WARN_UNUSED_RESULT;
+ int Next(int bits) V8_WARN_UNUSED_RESULT;
static uint64_t MurmurHash3(uint64_t);