Export of internal Abseil changes

--
d8ddeda8e52132b908fae89b25f117a055d78c04 by Abseil Team <absl-team@google.com>:

Improve performance of ByteStringFromAscii by changing kHexValue to have -1 in invalid value slots. This way a single load can do both the validation and conversion.

PiperOrigin-RevId: 284167344

--
5037e97e2eaaac8ced9a5290949deda4b43b9ceb by Mark Barolak <mbar@google.com>:

Change the underlying symbol name of Cord to absl::Cord.

PiperOrigin-RevId: 284005429

--
4ef66c72aedf135f2b4fd0ba7a73de6642decfff by Abseil Team <absl-team@google.com>:

Eliminate an unnecessary load when futex is contended in Waiter::Wait()

The first argument to compare_exchange_weak() is a reference and will be
updated upon failure.  There is no need to do an additional load on the
same variable.

PiperOrigin-RevId: 284002752
GitOrigin-RevId: d8ddeda8e52132b908fae89b25f117a055d78c04
Change-Id: Idac68a1901eb8c30050adc3860765b1a6fa085c7
This commit is contained in:
Abseil Team 2019-12-06 05:36:40 -08:00 committed by Mark Barolak
parent d659fe54b3
commit 77f87009a3
5 changed files with 14 additions and 12 deletions

View file

@ -961,7 +961,7 @@ bool Base64UnescapeInternal(const char* src, size_t slen, String* dest,
} }
/* clang-format off */ /* clang-format off */
constexpr char kHexValue[256] = { constexpr char kHexValueLenient[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -977,8 +977,9 @@ constexpr char kHexValue[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
/* clang-format on */ /* clang-format on */
// This is a templated function so that T can be either a char* // This is a templated function so that T can be either a char*
@ -987,8 +988,8 @@ constexpr char kHexValue[256] = {
template <typename T> template <typename T>
void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) { void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
to[i] = (kHexValue[from[i * 2] & 0xFF] << 4) + to[i] = (kHexValueLenient[from[i * 2] & 0xFF] << 4) +
(kHexValue[from[i * 2 + 1] & 0xFF]); (kHexValueLenient[from[i * 2 + 1] & 0xFF]);
} }
} }

View file

@ -18,11 +18,11 @@
#include "absl/strings/internal/str_format/extension.h" #include "absl/strings/internal/str_format/extension.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
class Cord;
class CordReader; class CordReader;
namespace absl { namespace absl {
class Cord;
class FormatCountCapture; class FormatCountCapture;
class FormatSink; class FormatSink;
@ -67,7 +67,7 @@ ConvertResult<Conv::s | Conv::p> FormatConvertImpl(const char* v,
FormatSinkImpl* sink); FormatSinkImpl* sink);
template <class AbslCord, template <class AbslCord,
typename std::enable_if< typename std::enable_if<
std::is_same<AbslCord, ::Cord>::value>::type* = nullptr, std::is_same<AbslCord, absl::Cord>::value>::type* = nullptr,
class AbslCordReader = ::CordReader> class AbslCordReader = ::CordReader>
ConvertResult<Conv::s> FormatConvertImpl(const AbslCord& value, ConvertResult<Conv::s> FormatConvertImpl(const AbslCord& value,
ConversionSpec conv, ConversionSpec conv,

View file

@ -25,10 +25,10 @@
#include "absl/strings/internal/str_format/output.h" #include "absl/strings/internal/str_format/output.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
class Cord;
namespace absl { namespace absl {
class Cord;
namespace str_format_internal { namespace str_format_internal {
class FormatRawSinkImpl { class FormatRawSinkImpl {

View file

@ -28,9 +28,10 @@
#include "absl/base/port.h" #include "absl/base/port.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
namespace absl {
class Cord; class Cord;
namespace absl {
namespace str_format_internal { namespace str_format_internal {
// RawSink implementation that writes into a char* buffer. // RawSink implementation that writes into a char* buffer.
@ -76,7 +77,7 @@ inline void AbslFormatFlush(std::ostream* out, string_view s) {
} }
template <class AbslCord, typename = typename std::enable_if< template <class AbslCord, typename = typename std::enable_if<
std::is_same<AbslCord, ::Cord>::value>::type> std::is_same<AbslCord, absl::Cord>::value>::type>
inline void AbslFormatFlush(AbslCord* out, string_view s) { inline void AbslFormatFlush(AbslCord* out, string_view s) {
out->Append(s); out->Append(s);
} }

View file

@ -136,7 +136,7 @@ bool Waiter::Wait(KernelTimeout t) {
bool first_pass = true; bool first_pass = true;
while (true) { while (true) {
int32_t x = futex_.load(std::memory_order_relaxed); int32_t x = futex_.load(std::memory_order_relaxed);
if (x != 0) { while (x != 0) {
if (!futex_.compare_exchange_weak(x, x - 1, if (!futex_.compare_exchange_weak(x, x - 1,
std::memory_order_acquire, std::memory_order_acquire,
std::memory_order_relaxed)) { std::memory_order_relaxed)) {
@ -313,7 +313,7 @@ bool Waiter::Wait(KernelTimeout t) {
bool first_pass = true; bool first_pass = true;
while (true) { while (true) {
int x = wakeups_.load(std::memory_order_relaxed); int x = wakeups_.load(std::memory_order_relaxed);
if (x != 0) { while (x != 0) {
if (!wakeups_.compare_exchange_weak(x, x - 1, if (!wakeups_.compare_exchange_weak(x, x - 1,
std::memory_order_acquire, std::memory_order_acquire,
std::memory_order_relaxed)) { std::memory_order_relaxed)) {