Fix race condition in DebuggerProxy start/stop

Summary: hphpd is sometimes crashing while calling pollSignal() on an already
destructed DebuggerProxy from an AsyncFunc.  (This manifests as a pure
virtual call to ThriftBuffer::flushImpl()).

It looks like there's a potential race condition where we might stop the
proxy and clean it up after we've added it to the Debugger's map, but
before we've actually started it up.  Let's fix this and hope it fixes
the crash also.

Reviewed By: @markw65

Differential Revision: D1468019
Fix LowPtr load in codegen

Summary: Use emitLdLowPtr().

Reviewed By: @swtaarrs

Differential Revision: D1475166
Support stream wrappers in XML parser extensions, add external entity loader

Summary: * Support stream wrappers in SimpleXML, DOM and XMLReader input and
  output filenames.
* Rename libxml_input_buffer() to libxml_create_input_buffer().
* Implement userspace function libxml_set_streams_context(), was
  previously missing.
* Since the VM can now be re-entered during parsing, with libxml2 in the
  call stack with -fomit-frame-pointer, all XML parsing functions must
  be protected with SYNC_VM_REGS_SCOPED().
* In DOMDocument, don't do File::TranslatePath() on input filenames,
  since they can now be URLs, and translation is now redundant with that
  done by FileStreamWrapper.
* In simplexml_load_file(), call xmlReadFile() instead of
  f_file_get_contents(), so that the libxml default stream context is
  used. Almost fixes test/zend/bad/ext/libxml/tests/bug54440.php, except
  for a minor error handling issue that should be dealt with by GitHub
  PR #2376.
* In stream_context_create(), return a default stream context resource
  when the options fail validation, instead of returning false. This
  matches the PHP behaviour and makes
  hphp/test/zend/bad/ext/libxml/tests/bug63389.php pass.
* Move passing tests to hphp/test/zend/good
* Add test.xml, copied from PHP 5.6.0-dev, needed by a passing test.
* Add an external entity loader. This allows the use of "data:" and
  "compress.zlib:" in entities and URIs.

Since loading external entities exposes a number of security issues including
remote shell execution, it's disabled by default (except for the data: protocol
which isn't actually external). The new config option is documented in
doc/inconsistencies.

Closes: #2329
Closes: #2829

Reviewed By: @ptarjan

Differential Revision: D1468180
fixed using []s in ini settings

Summary: Ini setting arrays were not being incremented properly when the push back syntax was used i.e. extensions[] = "foo.so". The folly::dynamic isInt() function does not check if a type can be converted to an it only if it is currently an int. Unfortunately, there does not appear to be a way to test this other than trying to convert the string to an int and catching the error. It appears there are two options, either we catch the exception (what I implemented) or we just insert the new key as an int. The latter seems like a poor choice because when the setting is later Get()ed any user defined numerical offsets will conflict with our internal numbers and one of the two would dissapear.

Reviewed By: @ptarjan

Differential Revision: D1474402
Revert "Optimize APC objects and collections by defining an APCCollection class and increasing the number of APCObject vs serialized objects"

Summary: This reverts commit 9678712bfce1bdd3b607feb7dd2328410dc45331.

This is being reverted because it doesn't quite respect the behavior for
__sleep().

Reviewed By: alexanderm, bertrand, smith

Differential Revision: D1475357
Force OOM check on large smart allocations

Summary: smartEnlist is used to add large smart allocations that don't
fit within the slabs. When using jemalloc, we account for these using
the per-thread stats, but they don't show up in m_usage. This
effectively means if the largest blocks are on that path, until we are
using enough of tracked, slab-based object allocations to go over max
bytes (which could be a long time) jemalloc might have overflowed but
this is invisible to us.

Technically there is still a hole here, since something outside of the
memory manager could have overflowed jemalloc's per-thread accounting,
but this fixes one obvious source. #4836461 would help us seal it
entirely.

Reviewed By: @jasone

Differential Revision: D1475090
Fix lookupCnsU

Summary: Looking up constants with fallback was broken since the return value
would never be filled in.  This was breaking composer init.

Reviewed By: @markw65

Differential Revision: D1472130
Fix error for (Recursive)CachingIterator::ctor's param 1

Summary: Fixed the TODO

Was this from when HipHopSyntax wasn't available?
Closes https://github.com/facebook/hhvm/pull/3351

Reviewed By: @elgenie

Differential Revision: D1475170

Pulled By: svcscm
typechecker: cleaner variable names in sub_type

Summary: ... when both args have the same type and order matters,
 the names matter as well; ##ty1## and ##ty2## don't communicate
 much about their presumed subtype relationship.

Reviewed By: @jwatzman

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

Summary: Enforce "descendants of this class must have compatible
 `__construct` declarations", due to either properties of the
 class/`__construct` method, or due to the use of the
 `<<ConsistentConstruct>>` attribute.

Reviewed By: @jwatzman

Differential Revision: D1466669
Disable flaky zend test

Summary: Depends on timing.  I don't know how this can fail to run in <1
second, but it did on my diff.

Reviewed By: @ptarjan

Differential Revision: D1477602
Mark OSS tests as skipped if there's any infra issues

Summary: These fail when there's internet conenctivity issues. Given they fail in large batches a retry doesn't seem like a worthwhile approach (as each framework is effecitvely a retry for downloading phpunit).

Also, removed __FILE__ from the error message as it always said utils.php :p

Reviewed By: @ptarjan

Differential Revision: D1476671
Free each function's ProfTransRec after optimizing it

Summary: And don't allocate a ProfTransRec for non-profiling translations.

Reviewed By: @bertmaher

Differential Revision: D1477165
cmake installations should no longer put files in hphp and now put them in hhvm

Summary: When installing hhvm all the lib files should now be in lib.../hhvm rather than lib.../hphp.

Reviewed By: @ptarjan

Differential Revision: D1477442
Stop doing sketchy guard optimization in pushStLoc

Summary: I feel this optimization has always been a little dodgy, but it hasn't
bitten us until we started trying to jit loops.

The high-level overview is that the loosened guards resulting from
passing DataTypeGeneric here cause breakage when it happens inside a
loop, if the truth value of the condition the loop is guarding changes
inside the loop.

Reviewed By: @swtaarrs

Differential Revision: D1473217
Implement RecursiveCallbackFilterIterator

Summary: Fixes #1894
Closes https://github.com/facebook/hhvm/pull/3350

Reviewed By: @LiraNuna

Differential Revision: D1475169

Pulled By: svcscm
Fix out-of-tree builds rebuilding too much

Summary: This fixes out-of-tree builds rebuilding things that are already built.  I believe this was missing from 3f3ee1aab336d2194ca79871810e6abdbdf5717b
Closes https://github.com/facebook/hhvm/pull/3354

Reviewed By: @LiraNuna

Differential Revision: D1475785

Pulled By: svcscm
Add cygwin to ifdef blocks

Summary: | data |Several places that are already checking for apple need to also check for cygwin, since the workarounds (such as turning off jit or disabling some elfwriter code) are the same for both OS's

Some of these may need to be expanded even more - it may be helpful in the future to define a "linux" for
not apple, not bsd, not windows in cygwin, mingw, or msvc flavors to avoid really convoluted ifdef lines

Reviewed By: @JoelMarcey

Differential Revision: D1464299
Windows header fun

Summary: Windows headers are not well behaved

VOID
STRICT
ERROR

are all defined - this finds the places where they clash and undefs them if necessary after the includes (sigh)

also fixes a header included twice that was making lint angry

Reviewed By: @JoelMarcey

Differential Revision: D1459782
Add locking for each test

Summary: We've talked about problems when the same test is run many times in parallel. In repo mode it is almost certainly going to fail. Adding file level locking should solve this problem.

In my incredibly unscientific tests, this doesn't add any extra time over not having it. 1 minute 8 seconds average over 10 runs with and without it.

Reviewed By: @markw65

Differential Revision: D1474426