Detect references in foreach properly

Summary: Previously we would occasionally misdetect various constructs (e.g. $$foo) as
reference variables in foreach statements.

Fixes #4154

Reviewed By: @JoelMarcey

Differential Revision: D1664006

Signature: t1:1664006:1415379641:f0f3c61d02c8d89ae49396161e73fdc2110b0859
Prohibit alternate closing tags in Hack files

Summary: ?> is already disallowed, %> and </script> should be as well.

Closes #3830

Reviewed By: @fredemmott

Differential Revision: D1665178

Signature: t1:1665178:1415316647:014b9c93c860f0af9af08df2e20e3152930dadcf
Emit CheckFoo instead of GuardFoo if the region entry block is a loop header.

Summary: Also rename a lot of stuff named "unprocessedPred" as "loopHeader".

This can generate suboptimal translations as we'll have loopy PGO
translations with no retranslate exits. The plan going forward is to
have an post-processing pass to fix these translations up, but for now,
let's just get this correct.

Reviewed By: @jdelong

Differential Revision: D1666300
Use AsyncServerSocket not TAsyncServerSocket

Summary: The latter is the old thrift typedef. This cuts dependencies.

Reviewed By: @djwatson

Differential Revision: D1647318
Fix callback parameters in memcached

Summary: Pass the Memcached object to the callback function. Also fix a problem with the
HNI type annotations.

Fixes #2797

Reviewed By: @JoelMarcey

Differential Revision: D1665298

Signature: t1:1665298:1415380054:eaff8585b1327a7d8ad95655234ed0690b550656
Fix a race freeing an APCHandle

Summary: Two threads could call realDecRef at the same time, both
could see m_count == 2, both would do --m_count, but neither would
notice that it hit zero.

Reviewed By: @edwinsmith, @jdelong

Differential Revision: D1666696

Signature: t1:1666696:1415373702:cf7828aed349a11d03d031e9f443b8712b31e380
fix socket get_path

Summary: Running the server over a sufficiently long root path
would cause an insta-crash due to a substring error in
the function that derives a socket path from root and
username. This is a simple fix.

Reviewed By: @gabelevi

Differential Revision: D1663068

Signature: t1:1663068:1415392614:c71cab26d02625aa4cb9e18e0c60073e9df0b7e1
Add some more Memcached constants

Summary: We were missing some constants, so I added them.

`RES_SERVER_TEMPORARILY_DISABLED` was a bit hard to find actually. I found a blog that
seemed reasonable for the value. That is commented in the code.

Fixes #3880

Reviewed By: @paulbiss

Differential Revision: D1666329

Signature: t1:1666329:1415344594:2244b3bb58c2cb113982f5d583b63f7521cd0f36
Allow mysqli objects to be passed into the mysqli_result constructor

Summary: Currently we only allow resources to be passed to `mysqli_result::__construct`. Apparently there is an undocumented feature that allows `mysqli` objects to also be passed in as well. In fact, it seems PHP 5.x pretty much allows anything to be passed to the constructor and it will just warn that properties aren't available and move on. I didn't go that far.

Fixes #2082

Reviewed By: @paulbiss

Differential Revision: D1663326

Signature: t1:1663326:1415332481:de9b5479c64e476b8801efe4ae3bcb84698fcfcf
Provide mechanism to "blacklist" tests that must be run serially

Summary: @​swtaarrs noticed that `ext_memcached` tests couldn't be run in parallel because
of key collisions. So, we now have a way to make sure they (and other tests that
we deem "parallel challenged") to always run serially.

Note: This could slow the test runner down just a bit, of course, when running these
tests. However, with memcached off, there is not a really big noticeable difference. Right now I found 5 memcached tests that have to be run this way. The slowness will be more
noticeable with the fewer tests you run that include the serial ones, since we have to
reduce the number of threads. However, for large test sets, there should be minimal
differences since we maxed the number of threads anyway.

Fixes #3884

Reviewed By: @paulbiss

Differential Revision: D1666135

Signature: t1:1666135:1415344877:5bfdad4d0bf63ed3019f17846d66b34ea35782e1
Fix branch shrinking code

Summary: The branch shrinking code assumed that if it was
possible to shrink a branch in the source of the relocation,
then it was possible in the destination. Thats not true because
some instructions need special treatment at page boundaries,
which can cause nops to be inserted.

The solution is to iterate, marking the failed ones wide. Since
its possible that a branch was already emitted in narrow form by
code gen, and it may no longer be possible after relocation,
also add code to widen branches when necessary.

This exposed bugs in the rewind code, when an exception is thrown
from relocate, so fix those too.

Reviewed By: @edwinsmith

Differential Revision: D1664748
fix ubuntu 12.04 compilation error on clientCheck.ml

Summary: ```
Linking CXX static library libhphp_analysis.a
[ 39%] Built target hphp_analysis
File "clientCheck.ml", line 266, characters 30-314:
Error: This expression has type string but an expression was expected of type
         ('a, out_channel, unit) format =
           ('a, out_channel, unit, unit, unit, unit) format6
make[5]: *** [clientCheck.cmx] Error 2
make[4]: *** [rec.opt] Error 1
make[3]: *** [opt] Error 2
make[2]: *** [hphp/hack/CMakeFiles/hack] Error 2
make[1]: *** [hphp/hack/CMakeFiles/hack.dir/all] Error 2
make: *** [all] Error 2
```
Closes https://github.com/facebook/hhvm/pull/4172

Reviewed By: @jwatzman

Differential Revision: D1667392

Signature: t1:1667392:1415395945:9498622a05067d6cffca64fe706d2e2d0ac3a4cb
TEventBase -> folly::EventBase

Summary: This is now in folly

Reviewed By: @djwatson

Differential Revision: D1665731

Signature: t1:1665731:1415392441:28f793e0b87eb6c7ffbabb9343ebbcf3afcd8d0b
Remove WorkerThread shim

Summary: This has moved.

Reviewed By: @viswanathgs

Differential Revision: D1667183

Signature: t1:1667183:1415397345:438b6a5c4208ca4b928dc83790125aaa010a65a5
Yes, I am a clown

Summary: Remove var_dump from test runner

Reviewed By: @alexmalyshev

Differential Revision: D1667837

Signature: t1:1667837:1415399766:80cadc3b2737db0bce04969074b3338b7f3d4e47
Print hashbang line in included pseudomains

Summary: Adds a function to conditionally print hashbang lines appearing in PHP files
that were included (while still not printing the hashbang line from the first
pseduomain run).

Fixes #1502

Reviewed By: @fredemmott

Differential Revision: D1664574

Signature: t1:1664574:1415307532:54c2030252ae38cffe0b06c934156403e9edd659
Use int64_t (not int) for HNI return types

Summary: PHP ints are 64-bits, so returning a 32-bit int from these functions
could plausibly leave garbage in the upper bits.

Reviewed By: @alexmalyshev

Differential Revision: D1667234

Signature: t1:1667234:1415389306:75519adb48962f2de087a84932724cea3b40b512
Use rVmSp that can be allocated to any reg.

Summary: Lower new vasm instructions for manipulating rVmSp.

Reviewed By: @edwinsmith

Differential Revision: D1666041

Signature: t1:1666041:1415359506:76118451512a34da6f85b42d476a5b52a4580840
Make LLVM emit direct calls (name-based lookup).

Summary: use named functions when creating call instructions to force
LLVM emit direct calls. Use small code model and static reloc mode.

Reviewed By: @swtaarrs

Differential Revision: D1642410
Target 3.5

Summary: 3.4 branch is cut.

Reviewed By: @JoelMarcey, @ptarjan

Differential Revision: D1664249

Signature: t1:1664249:1415307240:2d52166a259646bf00fef1d78b0e44c410047657