summaryrefslogtreecommitdiff
path: root/chromium/base/task/common/task_annotator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/base/task/common/task_annotator.cc')
-rw-r--r--chromium/base/task/common/task_annotator.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/chromium/base/task/common/task_annotator.cc b/chromium/base/task/common/task_annotator.cc
index 2d420b5fd6a..4c6e9117e28 100644
--- a/chromium/base/task/common/task_annotator.cc
+++ b/chromium/base/task/common/task_annotator.cc
@@ -16,6 +16,7 @@
#include "base/threading/thread_local.h"
#include "base/trace_event/base_tracing.h"
#include "base/tracing_buildflags.h"
+#include "build/build_config.h"
#if BUILDFLAG(ENABLE_BASE_TRACING)
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_mojo_event_info.pbzero.h" // nogncheck
@@ -131,6 +132,26 @@ void TaskAnnotator::RunTaskImpl(PendingTask& pending_task) {
if (g_task_annotator_observer)
g_task_annotator_observer->BeforeRunTask(&pending_task);
std::move(pending_task.task).Run();
+#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_X86_FAMILY)
+ // Some tasks on some machines clobber the non-volatile XMM registers in
+ // violation of the Windows ABI. This empty assembly language block with
+ // clobber directives tells the compiler to assume that these registers
+ // may have lost their values. This ensures that this function will not rely
+ // on the registers retaining their values, and it ensures that it will
+ // restore the values when this function ends. This is needed because the
+ // code-gen for at least one caller of this function in official builds relies
+ // on an XMM register (usually XMM7, cleared to zero) maintaining its value as
+ // multiple tasks are run, which causes crashes if it is corrupted, since
+ // "zeroed" variables end up not being zeroed.
+ // The third-party issue is believed to be fixed but will take a while to
+ // propagate to users which is why this mitigation is needed.
+ // For details see https://crbug.com/1218384
+ asm(""
+ :
+ :
+ : "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12",
+ "%xmm13", "%xmm14", "%xmm15");
+#endif
tls->Set(previous_pending_task);