Exposed ProfilerFactory for use in external profilers

Summary: This diff moves `ProfilerFactory` in ext_hotprofiler.cpp into the header
ext_hotprofiler.h with the `Profiler` definition.

Right now it is possible for an extension to define a profiler by just
including ext_hotprofiler.h, but there is no exposed unified way to attach it
to a thread. If one wanted to attach a profiler to a thread they would
essentially be duplicating the code currently in `ProfilerFactory`-- but
also they would have to synchronize the state of the request's `ProfilerFactory`
with their own.

Now an external profiler would just have to call `s_profiler_factory->start(...)`
and `s_profiler_factory->stop(...)` to start/stop profiling.

I've also removed the requirement that `ProfilerFactory::start` be called with
`RuntimeOptions::EnableHotProfiler` as it may not be necessary for external
profilers. Finally `ProfilerFactory::start` now returns a boolean indicating
whether or not it succeeded.

Reviewed By: @ptarjan

Differential Revision: D1434395
Changed xdebug config setting from size_t to uint64_t

Summary: In issue #3227 compiling failed due to XDebugExtension::FramebufSize having type
size_t because Config::Bind does not have a definition for size_t. We didn't run
into this issue when testing or compiling internally. But the user
compiled on mac osx, where `size_t` expanded to `long unsigned int` and
`uint64_t` expanded to `long long unsigned int`.

This diff changes the configuration option to have type uint64_t, which should
fix the error.

Reviewed By: @ptarjan

Differential Revision: D1452470
update lz4
Improve positions on enum error messages

Summary: Fix the error messages when an enum constant isn't an int or a string to actually point to the offending constant and not just where the type came from (which could be far away).

Reviewed By: jwatzman, eletuchy

Differential Revision: D1451013
folly::Singleton, a class for managing singletons

Summary: Singletons are surprisingly tricky in a codebase where
libraries depend on one another.  folly::Singleton hopes to make this
process more reliable by ensuring object creation happens in a safe
order, that destruction is possible, and that singletons are created
on-demand.

The basic fbcode use intention is to invoke registration completion in
initFacebook, so users need only declare singletons via
Singleton<ClassName> in their .cpp files.

This diff converts a couple of singletons to this model.

Reviewed By: @fugalh

Differential Revision: D1404231
Revert D1404231, folly::Singleton, a class for managing singletons

Summary: Broke hhvm open source builds.  Reverting.

Reviewed By: @JoelMarcey

Differential Revision: D1453096
Hide benign git error when running fbmake

Summary: hphp has a prerun command that runs before *every* fbmake. It runs git
to try to compute a hash for the hphp directory. Since their hash computation is
somewhat git specific, and would be difficult to port to Mercurial, let's just
hide the error that it produces for now.

Reviewed By: @sid0

Differential Revision: D1450699
Retry tracelet selection if inlining fails

Summary: Apparently, if we have a nested callstack a() -> b() -> c(), our
decision of whether or not we can possibly inline c()---depth and cost
limits notwithstanding---varies depending on whether we consider the
toplevel caller to be b() or c().

Since inlining decision-making no longer has access to the whole
callstack context, and instead just looks at a single caller-callee
pair, we need to detect these failures explicitly in RegionFormer::go()
and trigger retry.

Reviewed By: @ottoni

Differential Revision: D1452237
Remove numLocals argument from FrameState constructor

Summary: Just get it from the func argument.

Reviewed By: @alexmalyshev

Differential Revision: D1452686
Use RC files for embedded data on windows

Summary: Use windows apis on cygwin mingw and msvc builds to embed php in rc files as rcdata
That's the best way to do blobs in windows C/C++
This code is entirely contained in ifdefs for windows os's

Reviewed By: @sgolemon

Differential Revision: D1420865
Cygwin/Windows cmake build fixes

Summary: Alterations to cmake files to make building with cmake successful with cygwin, contains both generic "windows' fixes and cygwin specific ones

Reviewed By: @sgolemon

Differential Revision: D1420857
Refactor ArgumentInfo and expose on the command line

Summary: Moved Argument info to use TypingHooks and made a command line API for it.

No promises on a stable API here yet, so I left the description empty so that lots of people don't start using it.

This is purely cleanup with regard to the logic. I haven't made any real changes.

Reviewed By: @jwatzman

Differential Revision: D1450096
Drop some unused fields from typing_env

Summary: Drop pclasses and pfuns from Typing_env.env, since they are never read from.

Reviewed By: @elgenie

Differential Revision: D1453086
Add a bunch more backticks
Relax restrictions on the typing of class constant shape field names.

Summary: Relax the restrictions on what types class constants can have when used as shape field names. Previously, they were restricted to being int or string (and not even a type alias for them). We now use the same logic that we use for enum constants, where newtypes are acceptable as long as the actual underlying type is an int or a string. We also have to stop just doing direct structural comparison of types, now that they can be things other than just int and string. We also thread env through more of the related code, now.

Reviewed By: eletuchy, jwatzman

Differential Revision: D1451612
Implemented xdebug profiling/tracing enabling

Summary: This diff implements the hooks required to start profiling and tracing in
xdebug. Actually outputting the collected tracing/profiling data is not
yet implemented.

This diff is huge, I apologize for that. I didn't want to send out
another tracing/profiling diff that didn't include tests, and the
"be able to start profiling/tracing" goal turned out to require a
lot more than anticipated: this relies on D1433761, D1434395, D1437218,
and D1423763.

Both xdebug tracing and profiling can be started automatically via ini
settings or via get/post/cookie triggers. Starting and stopping tracing
be done programatically.

For profiling and tracing, the user can specify an output filename that can
be formatted using xdebug-specific format characters.
A big chunk of this diff implements this, but it's not complicated.

The profiler will also be used for collecting memory usage and start/stop
times for functions, so the profiler can be started/stopped by the
xdebug `collect_memory` and `collect_time` ini settings.

Ensuring that I could meet all of these needs is one of the reasons it was
hard to split this diff up. But if this needs to be split up, I understand.
The easiest thing to do would be to split the file name formatting into
a separate diff.

Reviewed By: @ptarjan

Differential Revision: D1438290
Support typing `->send` for `Generator`

Summary: Pretty easy now that the rest of the machinery is in place.
Most of this diff is just getting the error messages nice :)

Reviewed By: @elgenie

Differential Revision: D1451042
Corrected the var_dump output for Exception class

Summary: The debug dump of Exception was wrong mainly because of cosmetic issues such as extra and instance variable order

Reviewed By: @ptarjan

Differential Revision: D1434164
Have isMainExit() default to the last main block if it can't find an exit.

Summary: Since we can have regions that end in an instruction with a taken edge
to an unlikely block (Jmp, RaiseWarning), we want to scan through all
main blocks first looking for an obvious exit, and then resort to
using the last block if it can't find one.

Reviewed By: @ottoni

Differential Revision: D1445507
Revert "Kill IRBuilder::blockIsIncompatible"

Summary: This reverts commit f378609add8a2a025aed41a68b62b95a45f1cad1.

Reviewed By: bertrand, jdelong

Differential Revision: D1454780