From 69ac4bd4218746255b079f33b8c8312b073cb582 Mon Sep 17 00:00:00 2001 From: Edwin Smith Date: Fri, 23 Oct 2015 08:07:21 -0700 Subject: [PATCH] Add VMRegAnchor before collect() Summary: Otherwise vmregs are stale, and we'll miss roots when GC is entered from JIT code. Also force callee-saved registers to spill so the C++ stack scan will see them. Reviewed By: ricklavoie Differential Revision: D2572012 fb-gh-sync-id: a978f4c7795dd6ebf76466f965df02b84f1a5ec7 --- hphp/runtime/base/heap-scan.h | 1 + hphp/runtime/base/memory-manager-defs.h | 1 + hphp/runtime/base/thread-info.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/hphp/runtime/base/heap-scan.h b/hphp/runtime/base/heap-scan.h index 4490beacf65..aed29d66c7a 100644 --- a/hphp/runtime/base/heap-scan.h +++ b/hphp/runtime/base/heap-scan.h @@ -269,6 +269,7 @@ template void scanRoots(F& mark) { TI().scan(mark); // C++ stack mark.where("cpp-stack"); + asm volatile("" : : : "rbx", "r12", "r13", "r14", "r15"); auto sp = stack_top_ptr(); mark(sp, s_stackLimit + s_stackSize - uintptr_t(sp)); // C++ threadlocal data, but don't scan MemoryManager diff --git a/hphp/runtime/base/memory-manager-defs.h b/hphp/runtime/base/memory-manager-defs.h index de3f5786638..014cc647004 100644 --- a/hphp/runtime/base/memory-manager-defs.h +++ b/hphp/runtime/base/memory-manager-defs.h @@ -187,6 +187,7 @@ template void BigHeap::iterate(Fn fn) { auto size = hdr->hdr_.kind == HeaderKind::Hole || hdr->hdr_.kind == HeaderKind::Free ? hdr->free_.size() : MemoryManager::smallSizeClass(hdr->size()); + assert(size % 16 == 0); hdr = (Header*)((char*)hdr + size); if (hdr >= slab_end) { assert(hdr == slab_end && "hdr > slab_end indicates corruption"); diff --git a/hphp/runtime/base/thread-info.cpp b/hphp/runtime/base/thread-info.cpp index 682dbc7d6a6..fc5e7d3d84f 100644 --- a/hphp/runtime/base/thread-info.cpp +++ b/hphp/runtime/base/thread-info.cpp @@ -29,6 +29,7 @@ #include "hphp/runtime/base/rds.h" #include "hphp/runtime/base/surprise-flags.h" #include "hphp/runtime/ext/process/ext_process.h" +#include "hphp/runtime/vm/vm-regs.h" namespace HPHP { /////////////////////////////////////////////////////////////////////////////// @@ -212,6 +213,7 @@ size_t check_request_surprise() { } } if (do_GC) { + VMRegAnchor _; MM().collect("surprise"); } if (do_signaled) { -- 2.11.4.GIT