summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2022-11-15 14:43:01 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2022-11-16 07:54:42 +0000
commit1cf88f1e0504dd99992018d882633291bcce36c8 (patch)
tree434328ac6b2aa4e6bab3310b50a87227237f30c9
parentadb0e43b4a0c79ef565b7fa3ff05936bf2f194a5 (diff)
downloadqtwebengine-chromium-1cf88f1e0504dd99992018d882633291bcce36c8.tar.gz
[Backport] [PA] Remove inline assembly
This CL removes some inline assembly from `PartitionRoot::RawFree()` when building under MSVC. A small MSVC-specific kludge is added to hopefully prevent optimization of the store instruction, but it is not certain to work and needs verification. Bug: 1351310 Change-Id: If86346f943a07167a1af75132ad6d5efddc23e60 Review-URL: https://chromium-review.googlesource.com/c/chromium/src/+/3874547 Cr-Commit-Position: refs/heads/main@{#1043308} Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/443565 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--chromium/base/allocator/partition_allocator/partition_root.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/chromium/base/allocator/partition_allocator/partition_root.h b/chromium/base/allocator/partition_allocator/partition_root.h
index f4be80bfb06..34cfe5ae24e 100644
--- a/chromium/base/allocator/partition_allocator/partition_root.h
+++ b/chromium/base/allocator/partition_allocator/partition_root.h
@@ -1336,6 +1336,14 @@ PA_ALWAYS_INLINE void PartitionRoot<thread_safe>::RawFree(
RawFree(slot_start, slot_span);
}
+#if defined(COMPILER_MSVC) && !defined(__clang__)
+// MSVC only supports inline assembly on x86. This preprocessor directive
+// is intended to be a replacement for the same.
+//
+// TODO(crbug.com/1351310): Make sure inlining doesn't degrade this into
+// a no-op or similar. The documentation doesn't say.
+#pragma optimize("", off)
+#endif
template <bool thread_safe>
PA_ALWAYS_INLINE void PartitionRoot<thread_safe>::RawFree(uintptr_t slot_start,
SlotSpan* slot_span) {
@@ -1370,15 +1378,16 @@ PA_ALWAYS_INLINE void PartitionRoot<thread_safe>::RawFree(uintptr_t slot_start,
// OS page. No need to write to the second one as well.
//
// Do not move the store above inside the locked section.
-#if defined(__clang__) || defined(COMPILER_GCC)
+#if !(defined(COMPILER_MSVC) && !defined(__clang__))
__asm__ __volatile__("" : : "r"(slot_start) : "memory");
-#else
- _ReadBarrier();
#endif
::partition_alloc::internal::ScopedGuard guard{lock_};
FreeInSlotSpan(slot_start, slot_span);
}
+#if defined(COMPILER_MSVC) && !defined(__clang__)
+#pragma optimize("", on)
+#endif
template <bool thread_safe>
PA_ALWAYS_INLINE void PartitionRoot<thread_safe>::RawFreeBatch(