Added xdebug server setup code

Summary: This diff adds a class "XDebugServer" that represents an xdebug remote
debugging server. The server is attached and detached in `ext_xdebug.cpp`
similar to the `XDebugProfiler`.

This diff also adds support for taking in config settings using the
environment variable `XDEBUG_CONFIG`. This is necessary for supporting
all the server options php5 xdebug does.

I've also changed the request local data to be thread local. Attaching
the server (in the next diff) revealed some bugs in the current
implementation.

Depends on D1471865.

Reviewed By: @ptarjan

Differential Revision: D1472286
Make sure to free memory used for CodeGenFixups

Summary: std::vector::clear() doesn't reduce its capacity.
Use the swap trick instead.

Some of these are maps or sets, so don't really need this treatment,
but we could change representations, so easier to just do all of them.

Reviewed By: @swtaarrs

Differential Revision: D1481874
Fix bug with idx() for the HHVM open source build

Summary: An assertion (func != nullptr) triggers on the HHVM OSS build when idx() is
not defined and an <?hh file tries to call idx().

This diff fixes the issue by updating the bytecode emitter so that it only
emits the Idx instruction if systemlib defines idx().

Reviewed By: @sgolemon

Differential Revision: D1474391
Fix places where kStrMapKind was not a case along with kIntMapKind and kMixedKind

Reviewed By: @paroski

Differential Revision: D1483939
Make the logic for raising checked array warnings clearer

Summary: Make it explcit in places that we are raising warnings because the templated
array kind is either `kIntMapKind` or `kStrMapKind`. The `!= kMixedKind` checks
should be reserved for behavior that both `kIntMapKind` and `kStrMapKind` should
exhibit.

It worked previously because in array-data.cpp we don't ever instantiate the
templated version with the "wrong" kind because of the different DISPATCH_XXX
macros.

Reviewed By: @elgenie

Differential Revision: D1478372
Checked map-like arrays should not warn for array_merge

Summary: Renumber is only called in the following places:

* array-common.cpp | ArrayCommon::Dequeue | Remove key then renumber (dequeue should already warn/downgrade and is only used by APCLocalArray and NVTWrapper)
* empty-array.cpp | EmptyArray::Merge | Calls MixedArray::Copy(elems) then renumber them (array_merge shouldn't warn)
* type-array.cpp | Array::mergeImpl | If rhs is empty, m_px->renumber() (array_merge shouldn't warn)

In all the places, we don't need to raise a warning, and in fact we don't want
to. This was an oversight by yours truly.

If we do want to raise warnings at a later point (since array_merge does not
support Collections) the proper way to do it would be in f_array_merge, but not
in ::Renumber.

Reviewed By: @elgenie

Differential Revision: D1478885
Allow colons in search queries

Summary: To allow for queries like "Class::" which should return the methods associated with that class

Reviewed By: @joelbeales

Differential Revision: D1482602
Functorize Search Services

Summary: This refactors all the search stuff to be generic, separating the AST parsing part from the rest. There's no real logic changes.

It works like this now

searchUtils (shared stuff between trie and fuzzy)
^
trieSearchService  and fuzzySearchService (generic)
^
searchService (generic, talks to fuzzy/trie search service when appropriate)
^
hackSearchService (ast parsing stuff and entry point)

Future steps: get search out of parsing and into it's own package and hook more cleanly.

Reviewed By: @jwatzman

Differential Revision: D1482567
Use hooks to attach search in hack

Summary: This adds parsing hooks to make it so parsing doesn't need to depend on search.

Then, moved search to it's own folder/'package'.

Reviewed By: @jwatzman

Differential Revision: D1484661
typechecker: UNSAFE_Construct

Summary: ... to allow explicit escape of `<<ConsistentConstruct>>`. In
 the absence of a "## // decl ## *this* declaration" syntax, this is
 better than the alternative of making entire class hierarchies
 type-unsound.

Reviewed By: @jwatzman

Differential Revision: D1481454
typechecker: typing new static() [3/3]

Summary: `new static` is now allowed only on where the class hierarchy
 has required consistently compatible constructor signatures due to
 either properties of the class/`__construct` method, or due to the
 use of the `<<ConsistentConstruct>>` attribute.

Reviewed By: @jwatzman

Differential Revision: D1466669
Don't double close `fd' in readFileAsString()

Summary: This seems bad.

Reviewed By: @bertmaher

Differential Revision: D1485614
Don't insert code on critical edges in IRBuilder::insertLocalPhis

Summary: This was indirectly causing the refcount-opts failure we're seeing in
lots of places. When inserting a LdLoc on an incoming edge to create a phi
node, we have to defer the insertion until after splitting critical edges.

Reviewed By: @bertmaher

Differential Revision: D1485470
Delete vtsc_syscall code

Summary: I can't seem to find any system on which this actually exists. I also
made XHPROF_FLAGS_VTSC behave identically to XHPROF_FLAGS_CPU and
renamed the vtsc() function in this file to avoid confusion. I didn't
remove the PHP-facing flag altogether because some user code still
refers to it.

I still need to figure out if the fallback getrusage() implementation
works well.

Reviewed By: ptarjan, dreiss

Differential Revision: D1481441
Fix sample profiler output; make it more efficient

Summary: Open-source xhprof's sampling profiler outputs an array of
strings mapping to strings. We were outputting strings mapping to
singleton string => int arrays, and the int was always 1. This brings it
in line with open source xhprof.

I also changed the internal storage from a hash table to a vector of
timestamps and stacks, and delayed the conversion of timestamps to
strings until profiling ends. This should lower the profiling overhead,
and has the added bonus that the samples come out in sorted order with
no extra work (open-source xhprof does this too).

Reviewed By: @ptarjan

Differential Revision: D1484272
Document the PHP profilers

Summary: This is everything I've gleaned from studying and modifying
ext_hotprofiler.cpp. I haven't looked at or documented the xdebug
profiler at all, since I'm not sure what state of done-ness it's in.

Reviewed By: @ptarjan

Differential Revision: D1482303
Unbreak open source build on ocaml 3.12

Summary: I went over the ocaml 3.12 manual to make sure that was the only Hashtbl function we were using that we couldn't.

Fixes: https://github.com/facebook/hhvm/issues/339

Reviewed By: @jwatzman

Differential Revision: D1484895
Imported unit tests from php 5.5.15

Summary: This imports the tests from php 5.5.15 up from 5.5.11

Reviewed By: @fredemmott

Differential Revision: D1481430
added a new Config::Bind that works for ini settings

Summary: There was no good way to variables to ini settings that did not automatically enable them for config.hdf. Now there is a Config::Bind function that will bind an ini setting to a variable using the value specified in the ini file or the a given default otherwise. The main difference between this Config::Bind and the old/other one is that it does not prepend "hhvm." on the front and does not override the ini setting with a hdf setting.

D1474476 depends on this diff and had a clean run. Given that this diff runs no new code it seems safe to override failures.

Reviewed By: @ptarjan

Differential Revision: D1463584
Corrected the serialization and unserialization of DateTime

Summary: Our implementation of `__sleep` and `__wakeup` for `DateTime` were wrong. This diff brings them up to par with PHP.

Fixes #2753

Reviewed By: @ptarjan

Differential Revision: D1354608