summaryrefslogtreecommitdiff
path: root/chromium/base
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-03-08 13:07:32 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-03-08 13:40:10 +0000
commit818d9aed569afd192f6d4f6d9b28b72912df8b93 (patch)
treefa30cbdffa3e8fdc09dbbe37ffc0a721b40fced1 /chromium/base
parent66a2147d838e293f4a5db7711c8eba4e6faaaf0f (diff)
downloadqtwebengine-chromium-818d9aed569afd192f6d4f6d9b28b72912df8b93.tar.gz
BASELINE: Update Chromium to 65.0.3325.151
Change-Id: I3c71dd500483eb29491ac3eee4123714dda52da9 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base')
-rw-r--r--chromium/base/allocator/partition_allocator/spin_lock.cc18
-rw-r--r--chromium/base/files/file_util.h6
-rw-r--r--chromium/base/files/file_util_posix.cc33
-rw-r--r--chromium/base/memory/shared_memory.h9
-rw-r--r--chromium/base/memory/shared_memory_fuchsia.cc3
-rw-r--r--chromium/base/memory/shared_memory_helper.cc7
-rw-r--r--chromium/base/memory/shared_memory_mac.cc1
-rw-r--r--chromium/base/memory/shared_memory_nacl.cc3
-rw-r--r--chromium/base/memory/shared_memory_posix.cc3
-rw-r--r--chromium/base/memory/shared_memory_win.cc3
10 files changed, 50 insertions, 36 deletions
diff --git a/chromium/base/allocator/partition_allocator/spin_lock.cc b/chromium/base/allocator/partition_allocator/spin_lock.cc
index c30d6cd43ad..fd062c33b4a 100644
--- a/chromium/base/allocator/partition_allocator/spin_lock.cc
+++ b/chromium/base/allocator/partition_allocator/spin_lock.cc
@@ -10,6 +10,8 @@
#include <sched.h>
#endif
+#include "base/threading/platform_thread.h"
+
// The YIELD_PROCESSOR macro wraps an architecture specific-instruction that
// informs the processor we're in a busy wait, so it can handle the branch more
// intelligently and e.g. reduce power to our core or give more resources to the
@@ -67,6 +69,9 @@ void SpinLock::LockSlow() {
// critical section defaults, and various other recommendations.
// TODO(jschuh): Further tuning may be warranted.
static const int kYieldProcessorTries = 1000;
+ // The value of |kYieldThreadTries| is completely made up.
+ static const int kYieldThreadTries = 10;
+ int yield_thread_count = 0;
do {
do {
for (int count = 0; count < kYieldProcessorTries; ++count) {
@@ -77,8 +82,17 @@ void SpinLock::LockSlow() {
return;
}
- // Give the OS a chance to schedule something on this core.
- YIELD_THREAD;
+ if (yield_thread_count < kYieldThreadTries) {
+ ++yield_thread_count;
+ // Give the OS a chance to schedule something on this core.
+ YIELD_THREAD;
+ } else {
+ // At this point, it's likely that the lock is held by a lower priority
+ // thread that is unavailable to finish its work because of higher
+ // priority threads spinning here. Sleeping should ensure that they make
+ // progress.
+ PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
+ }
} while (lock_.load(std::memory_order_relaxed));
} while (UNLIKELY(lock_.exchange(true, std::memory_order_acquire)));
}
diff --git a/chromium/base/files/file_util.h b/chromium/base/files/file_util.h
index 780bb22cbf5..cd8a1ba5953 100644
--- a/chromium/base/files/file_util.h
+++ b/chromium/base/files/file_util.h
@@ -185,6 +185,12 @@ BASE_EXPORT bool ReadFileToStringWithMaxSize(const FilePath& path,
// Returns true iff |bytes| bytes have been successfully read from |fd|.
BASE_EXPORT bool ReadFromFD(int fd, char* buffer, size_t bytes);
+// Performs the same function as CreateAndOpenTemporaryFileInDir(), but returns
+// the file-descriptor directly, rather than wrapping it into a FILE. Returns
+// -1 on failure.
+BASE_EXPORT int CreateAndOpenFdForTemporaryFileInDir(const FilePath& dir,
+ FilePath* path);
+
// The following functions use POSIX functionality that isn't supported by
// Fuchsia.
#if !defined(OS_FUCHSIA)
diff --git a/chromium/base/files/file_util_posix.cc b/chromium/base/files/file_util_posix.cc
index 27cd58a9df3..d2eb4531d8e 100644
--- a/chromium/base/files/file_util_posix.cc
+++ b/chromium/base/files/file_util_posix.cc
@@ -142,19 +142,6 @@ std::string TempFileName() {
#endif
}
-// Creates and opens a temporary file in |directory|, returning the
-// file descriptor. |path| is set to the temporary file path.
-// This function does NOT unlink() the file.
-int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) {
- AssertBlockingAllowed(); // For call to mkstemp().
- *path = directory.Append(base::TempFileName());
- const std::string& tmpdir_string = path->value();
- // this should be OK since mkstemp just replaces characters in place
- char* buffer = const_cast<char*>(tmpdir_string.c_str());
-
- return HANDLE_EINTR(mkstemp(buffer));
-}
-
#if defined(OS_LINUX) || defined(OS_AIX)
// Determine if /dev/shm files can be mapped and then mprotect'd PROT_EXEC.
// This depends on the mount options used for /dev/shm, which vary among
@@ -165,7 +152,8 @@ bool DetermineDevShmExecutable() {
bool result = false;
FilePath path;
- ScopedFD fd(CreateAndOpenFdForTemporaryFile(FilePath("/dev/shm"), &path));
+ ScopedFD fd(
+ CreateAndOpenFdForTemporaryFileInDir(FilePath("/dev/shm"), &path));
if (fd.is_valid()) {
DeleteFile(path, false);
long sysconf_result = sysconf(_SC_PAGESIZE);
@@ -540,6 +528,17 @@ bool ReadFromFD(int fd, char* buffer, size_t bytes) {
#if !defined(OS_NACL_NONSFI)
+int CreateAndOpenFdForTemporaryFileInDir(const FilePath& directory,
+ FilePath* path) {
+ AssertBlockingAllowed(); // For call to mkstemp().
+ *path = directory.Append(TempFileName());
+ const std::string& tmpdir_string = path->value();
+ // this should be OK since mkstemp just replaces characters in place
+ char* buffer = const_cast<char*>(tmpdir_string.c_str());
+
+ return HANDLE_EINTR(mkstemp(buffer));
+}
+
#if !defined(OS_FUCHSIA)
bool CreateSymbolicLink(const FilePath& target_path,
const FilePath& symlink_path) {
@@ -668,7 +667,7 @@ bool CreateTemporaryFile(FilePath* path) {
FilePath directory;
if (!GetTempDir(&directory))
return false;
- int fd = CreateAndOpenFdForTemporaryFile(directory, path);
+ int fd = CreateAndOpenFdForTemporaryFileInDir(directory, path);
if (fd < 0)
return false;
close(fd);
@@ -676,7 +675,7 @@ bool CreateTemporaryFile(FilePath* path) {
}
FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
- int fd = CreateAndOpenFdForTemporaryFile(dir, path);
+ int fd = CreateAndOpenFdForTemporaryFileInDir(dir, path);
if (fd < 0)
return nullptr;
@@ -688,7 +687,7 @@ FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) {
AssertBlockingAllowed(); // For call to close().
- int fd = CreateAndOpenFdForTemporaryFile(dir, temp_file);
+ int fd = CreateAndOpenFdForTemporaryFileInDir(dir, temp_file);
return ((fd >= 0) && !IGNORE_EINTR(close(fd)));
}
diff --git a/chromium/base/memory/shared_memory.h b/chromium/base/memory/shared_memory.h
index 2ab7870f4f0..2eb9ee29223 100644
--- a/chromium/base/memory/shared_memory.h
+++ b/chromium/base/memory/shared_memory.h
@@ -189,11 +189,10 @@ class BASE_EXPORT SharedMemory {
// identifier is not portable.
SharedMemoryHandle handle() const;
- // Returns the underlying OS handle for this segment. The caller also gets
- // ownership of the handle. This is logically equivalent to:
- // SharedMemoryHandle dup = DuplicateHandle(handle());
- // Close();
- // return dup;
+ // Returns the underlying OS handle for this segment. The caller takes
+ // ownership of the handle and memory is unmapped. This is equivalent to
+ // duplicating the handle and then calling Unmap() and Close() on this object,
+ // without the overhead of duplicating the handle.
SharedMemoryHandle TakeHandle();
// Closes the open shared memory segment. The memory will remain mapped if
diff --git a/chromium/base/memory/shared_memory_fuchsia.cc b/chromium/base/memory/shared_memory_fuchsia.cc
index 15211d9fbac..4036bf6f2e1 100644
--- a/chromium/base/memory/shared_memory_fuchsia.cc
+++ b/chromium/base/memory/shared_memory_fuchsia.cc
@@ -138,9 +138,8 @@ SharedMemoryHandle SharedMemory::handle() const {
SharedMemoryHandle SharedMemory::TakeHandle() {
SharedMemoryHandle handle(shm_);
handle.SetOwnershipPassesToIPC(true);
+ Unmap();
shm_ = SharedMemoryHandle();
- memory_ = nullptr;
- mapped_size_ = 0;
return handle;
}
diff --git a/chromium/base/memory/shared_memory_helper.cc b/chromium/base/memory/shared_memory_helper.cc
index 91893d335e2..f98b734fb7f 100644
--- a/chromium/base/memory/shared_memory_helper.cc
+++ b/chromium/base/memory/shared_memory_helper.cc
@@ -41,13 +41,12 @@ bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options,
// A: Because they're limited to 4mb on OS X. FFFFFFFUUUUUUUUUUU
FilePath directory;
ScopedPathUnlinker path_unlinker;
- ScopedFILE fp;
if (!GetShmemTempDir(options.executable, &directory))
return false;
- fp.reset(base::CreateAndOpenTemporaryFileInDir(directory, path));
+ fd->reset(base::CreateAndOpenFdForTemporaryFileInDir(directory, path));
- if (!fp)
+ if (!fd->is_valid())
return false;
// Deleting the file prevents anyone else from mapping it in (making it
@@ -60,10 +59,10 @@ bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options,
readonly_fd->reset(HANDLE_EINTR(open(path->value().c_str(), O_RDONLY)));
if (!readonly_fd->is_valid()) {
DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed";
+ fd->reset();
return false;
}
}
- fd->reset(fileno(fp.release()));
return true;
}
diff --git a/chromium/base/memory/shared_memory_mac.cc b/chromium/base/memory/shared_memory_mac.cc
index e2735f7f963..0a233e5fb02 100644
--- a/chromium/base/memory/shared_memory_mac.cc
+++ b/chromium/base/memory/shared_memory_mac.cc
@@ -229,6 +229,7 @@ SharedMemoryHandle SharedMemory::handle() const {
SharedMemoryHandle SharedMemory::TakeHandle() {
SharedMemoryHandle dup = DuplicateHandle(handle());
+ Unmap();
Close();
return dup;
}
diff --git a/chromium/base/memory/shared_memory_nacl.cc b/chromium/base/memory/shared_memory_nacl.cc
index 442c0360f29..4bcbb547d38 100644
--- a/chromium/base/memory/shared_memory_nacl.cc
+++ b/chromium/base/memory/shared_memory_nacl.cc
@@ -117,9 +117,8 @@ SharedMemoryHandle SharedMemory::handle() const {
SharedMemoryHandle SharedMemory::TakeHandle() {
SharedMemoryHandle handle_copy = shm_;
handle_copy.SetOwnershipPassesToIPC(true);
+ Unmap();
shm_ = SharedMemoryHandle();
- memory_ = nullptr;
- mapped_size_ = 0;
return handle_copy;
}
diff --git a/chromium/base/memory/shared_memory_posix.cc b/chromium/base/memory/shared_memory_posix.cc
index f9d71f4739c..d3163e5a640 100644
--- a/chromium/base/memory/shared_memory_posix.cc
+++ b/chromium/base/memory/shared_memory_posix.cc
@@ -336,9 +336,8 @@ SharedMemoryHandle SharedMemory::handle() const {
SharedMemoryHandle SharedMemory::TakeHandle() {
SharedMemoryHandle handle_copy = shm_;
handle_copy.SetOwnershipPassesToIPC(true);
+ Unmap();
shm_ = SharedMemoryHandle();
- memory_ = nullptr;
- mapped_size_ = 0;
return handle_copy;
}
diff --git a/chromium/base/memory/shared_memory_win.cc b/chromium/base/memory/shared_memory_win.cc
index 5540004730b..cf06dd39c76 100644
--- a/chromium/base/memory/shared_memory_win.cc
+++ b/chromium/base/memory/shared_memory_win.cc
@@ -373,9 +373,8 @@ SharedMemoryHandle SharedMemory::handle() const {
SharedMemoryHandle SharedMemory::TakeHandle() {
SharedMemoryHandle handle(shm_);
handle.SetOwnershipPassesToIPC(true);
+ Unmap();
shm_ = SharedMemoryHandle();
- memory_ = nullptr;
- mapped_size_ = 0;
return handle;
}