Use req::Optional when we need exact scanning.
commit3d2ea815ac8de1cf63e99ece8acd2d8272c49a4e
authorEdwin Smith <smith@fb.com>
Sun, 20 Aug 2017 20:27:05 +0000 (20 13:27 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Sun, 20 Aug 2017 20:35:00 +0000 (20 13:35 -0700)
treef081edcbf9d3430f33acec35b7aa7a60af7692c4
parent19ab70e2d0148ca7efbb05bf022d28bd85249920
Use req::Optional when we need exact scanning.

Summary:
The internal layout of folly::Optional<T> doesn't declare
an instance of T; it uses aliged_storage or something similar,
so we must conservative-scan it. Convert the uses that require
exact scanning to req::Optional<T>, which is a trivial subclass
that adds a custom scanner. (if hasValue() then scan T).

This conversion exposed a bug where during processing ini
options, a few RequestLocal<T> instances were initialized,
but not correctly shut down when we reset ExecutionContext.
(fixed by calling context->onRequestShutdown()).

While debugging that problem, I noticed the ThreadLocal<T> instances
for MemoryManager and LocalSettings were being initialized before
type_scan, causing their memoized tyindex to be incorrect. Fixed
that by explicitly restoring their tyindex after type_scan init.

Reviewed By: ricklavoie

Differential Revision: D5630672

fbshipit-source-id: 9a3c93942efff88283d9ecee5db3676cc0e6fd41
hphp/runtime/base/ini-setting.cpp
hphp/runtime/base/intercept.cpp
hphp/runtime/base/program-functions.cpp
hphp/runtime/base/req-containers.h
hphp/runtime/base/stream-wrapper-registry.cpp
hphp/runtime/ext/curl/curl-resource.h
hphp/runtime/ext/intervaltimer/ext_intervaltimer.cpp
hphp/runtime/ext/mysql/mysql_common.cpp
hphp/runtime/ext/mysql/mysql_common.h
hphp/runtime/ext_zend_compat/hhvm/zend-request-local.h
hphp/util/thread-local.h