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
Serialize resource

Summary: Fixes #4162

Resources should be serialized as `0` int, or boolean `0` if not a valid resource.

Reviewed By: @JoelMarcey

Differential Revision: D1665854

Signature: t1:1665854:1415336794:f955fc3b238961c2e4096d176525fec593feb335
support for php_serialize fixes #4153

Summary: This resolves #4153
Closes https://github.com/facebook/hhvm/pull/4158

Reviewed By: @sgolemon

Differential Revision: D1664260

Signature: t1:1664260:1415406608:4156e3a93123110a4a71c3fbe79eaa37c54d791c
Sendmail

Summary: Support ```sendmail_path``` in ```php.ini``` and use the standard sendmail path ```/usr/lib/sendmail``` rather than expecting it to be on the user's ```PATH``` which it often isn't.
Closes https://github.com/facebook/hhvm/pull/4138

Reviewed By: @sgolemon

Differential Revision: D1664106

Signature: t1:1664106:1415406718:669cbb275b7e2acdb2d5378f02a850b030cccf53
ocamlbuild build for Hack open source

Summary: This replaces (most of) the open source build for Hack by a much simpler
ocamlbuild-based one.

Main points of interest:
* Build itself is straightforward and looks a lot like the Flow one
* I did NOT do the JS build - just fixed up an existing breakage. Not really sure how to make that one more maintainable
* Updated the test runner so we don't have to list test directories in two places

Reviewed By: @jwatzman

Differential Revision: D1654465

Signature: t1:1654465:1415402598:72396c4eac1cb02aa652b72ae9ff62a701571d22
Convert `else if` to `elseif` in the lexer

Summary: Patterns like the following create deep AST tree and can
potentially overflow our parser's depth limits (See #2699).

  if (expr) {} else if (expr) {} else if (expr() {} else {}

  IfStatement
    IfBranchStatement
    IfStatement
      IfBranchStatement
        IfStatement
          IfBranchStatement
            ...etc...

By interpreting "else"{WHITESPACE}*"if" as T_ELSEIF we're
able to keep such chains flat.

  IfStatement
    IfBranchStatement
    IfBranchStatement
    IfBranchStatement
    ...etc...

Has the very minor side-effect of making token_get_all()
return T_ELSEIF rather than T_ELSE T_WHITESPACE T_IF as expected,
but that should be a matter of academic purity rather than
anything functional.  I look forward to regretting these words.

Closes #2699

Reviewed By: @paulbiss

Differential Revision: D1666431

Signature: t1:1666431:1415344521:9373b9a139c6ece1eff955742d91204ea7ee58bc
Limit ASIO session timeout to request timeout

Summary: We've seen requests get stuck on timedwait's in asio.  It's not
totally clear why they're getting stuck, but regardless it seems that we
shouldn't wait longer than the request timeout for something to return.

Reviewed By: @jano

Differential Revision: D1665567

Signature: t1:1665567:1415390539:e39ea95cfd07bc41781b198c7ef87c36db84fbec