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
Remove string type annotation from TarArchiveHandler::path

Summary: HHBBC is failing to infer string for this type, and it blocks
compiling the repo.  I can't find the problem in HHBBC so this is a temporary
workaround.

Reviewed By: @edwinsmith

Differential Revision: D1485401
Initialize memory manager before using it

Summary: A recent re-shuffle of when the thread locals get initialized
on the main thread caused an issue with trying to allocate Strings
before initializing the memory manager.

Reviewed By: @bertmaher

Differential Revision: D1485657
Let status.php response from HHVM include host health level.

Summary: Let the return dictionary of apache_get_config also include
the local host level.

Reviewed By: dmitrip

Differential Revision: D1472139
make calendar_getNow_basic.php less strict

Summary: It failed once in D1479620?id=4763805

Reviewed By: @JoelMarcey

Differential Revision: D1486405
Forgot to remove these files when fixing Liran's diff
added extension_dir and hhvm.extensions options and implementations also added a configuration option for extension_dir

Summary: Added two new ini settings extension_dir and hhvm.extensions. extension_dir is identical to the php extension_dir ini setting and hhvm.extensions is similar to the php ini setting extension except it is an array instead of a repeatable ini setting. Currently, we install extensions from both the config.hdf settings as well as these new ini settings in order to change people's workflow as little as possible. Depends on D1474402, Depends on D1463584

Reviewed By: @ptarjan

Differential Revision: D1474476
Implement a basic version of first-class enums in HHVM.

Summary: Implement a basic version of first-class enums in HHVM. Enums are basically represented as classes, but require special handling to use the underlying type for type checks when used as type hints.

Currently raises a fatal error if the underlying type can't be resolved when the Class is created (because it is a typedef or an enum that hasn't been defined yet). This is kind of unfortunate.

Reviewed By: @paroski

Differential Revision: D1454278
unflakey realpath_basic

Summary: Failed on D1470540?id=4771551

Reviewed By: @LiraNuna

Differential Revision: D1487207
Turn on Eval.EnableObjDestructCall by default

Summary: This was an intentional divergence from PHP5 for performance reasons,
but the default should be compatible. The overhead of this feature is vastly
reduced with D1462739 anyway.

This change by itself would've reduced test coverage of fast object allocaton
paths in the jit, but instead of working around that I just properly
implemented support for EnableObjDestructCall being true. I also removed a
bogus check for it in emitCreateCl. Finally, it exposed a bug in
Class::initSPropHandles where we were incorrectly marking some class's SProp
handles as persistent even if the parent's SProp handle wasn't persistent (this
was causing test/quick/properties4.php to fail).

Reviewed By: @alexmalyshev

Differential Revision: D1466192
Added microseconds to debug_info of DateTime objects

Summary: PHP 5.5.15 added micro-seconds to the debug output of `DateTime` objects incorreclty regressing us on 3 tests.
This diff adds the micro-seconds to the format as well as moves the 'bad' tests to the good directory.

Reviewed By: @ptarjan

Differential Revision: D1486878
Implemented JSON_ERROR_DEPTH for json_encode

Summary: json_encode did not support JSON_ERROR_DEPTH. This diff implements it

Reviewed By: @ptarjan

Differential Revision: D1487343