Compute FPI PrepKinds using method names in hhbbc

Summary: This is one thing hphpc still does that hhbbc doesn't.  But the code
that sets Expression::RefValue into the context bits is incorrect if you don't
run the inferTypes pass, so we can't use it if we want to stop doing that.
Redoing the optimization here is pretty easy.

Reviewed By: @edwinsmith

Differential Revision: D1443303
Add more reduce() cases for FPassR and FPassV

Summary: The cases here were less complete than I thought (I forgot I left some
out because reduce() doesn't support nesting, but it can't really use that
anyway).  Surprisingly this seems to get rid of all of the FPassV opcodes in
www (after D1444820 added some).

Reviewed By: @jano

Differential Revision: D1445476
Support nested uses of reduce() in hhbbc

Summary: The implementation of reduce and impl claim you aren't allowed to nest
opcodes that do reduce calls, but the code was doing it anyway.  In practice we
were never hitting the case, but we do after turning off FPassC/V changes in
emitter.cpp, so now we should support it, which isn't too hard.

Reviewed By: @edwinsmith

Differential Revision: D1447745
Compute AttrNoOverride functions in hhbbc instead of using hphpc's version

Summary: The bits coming in claim that private functions that are overridden
have AttrNoOverride.  So, let's throw the incoming bits away and recompute it
here.

Reviewed By: @jano

Differential Revision: D1444777
Disable FPassC and FPassV lowering in emitter.cpp

Summary: They apparently can make incorrect transformations, and if you turn
off inferTypes and postOptimize even more so (because Expression::RefValue is
apparently invalid without those passes).  Hhbbc now mostly does the same
FPI-passing optimizations (a little more conservatively, but hopefully also
more correctly), so if it's in the noise in perflab let's switch.

Reviewed By: @edwinsmith

Differential Revision: D1444820
Share more code in FCall* opcodes, fix a bug in FCallArray and FCallUnpack

Summary: Neither FCallArray nor FCallUnpack were properly handling functions
that never return (the latter copied the bug from the former).  This wasn't a
problem 'in practice' for FCallArray because currently it never has a resolved
func on the ActRec right now (because FPushCuf doesn't try to figure out which
func you're calling), but it was possible to cause hhbbc to crash with an
unpacking call to a function that can't return.  Fix this while setting up the
code to share a little more of the logic.

This diff also makes it so FCall (non-D) with a known resolved func will try to
look up the return type.  This can happen with the new kind of name-only
function resolution from D1443303, but currently they don't ever produce return
types better than TInitGen, so it's a no-op for now.

Reviewed By: @elgenie

Differential Revision: D1448343
Remove a few no-longer-needed emitter WholeProgram things

Reviewed By: @alexmalyshev

Differential Revision: D1451034
Improve hhbbc's behavior for builtin return types

Summary: If we don't know the type, we can still apparently check AttrReference
to avoid an UnboxR.  Also, apparently the returnType is set even for non-HNI
builtins.

Reviewed By: @jano

Differential Revision: D1454754
Split some of whole-program.cpp into subroutines

Summary: Separating some small amount of refactoring out of a diff that didn't
work.  (This function was too big.)

Reviewed By: @alexmalyshev

Differential Revision: D1459003
Pass duplicate flag to SNI Initial Handler Callback

Summary: LibEventServer's SNI handling is primitive and requires a separate file per Subject Alt Name, but a server could load all the SAN's from the first callback invocation for a given cert.  Pass a flag that indicates whether the callback has already been invoked on the same underlying cert.

Reviewed By: @markw65

Differential Revision: D1462765
help git out by marking non-utf8 files

Summary: This came up when @swtaarrs had a diff which didn't apply. the `.diff` file from github thought it was a text file and issued a non-utf8 file which we couldn't `json_encode` it without mangling it.

I made this with:

  for f in `find . -type f`; do iconv -f utf8 $f > /dev/null 2>&1; if [ $? -ne 0 ]; then echo $f -diff >> .gitattributes; fi; done

Reviewed By: @JoelMarcey

Differential Revision: D1463749
Fix for bad_shell_exec failing depending on the user's shell

Summary: Different shells have different error messages, which trips up
this test case. Switches the test case to a regex covering the
two cases I've seen.

Eg:
```
~/hhvm(branch:master) » echo $SHELL
/usr/bin/zsh

~/hhvm(branch:master) » hphp/hhvm/hhvm hphp/test/run hphp/test/slow/ext_process/bad_shell_exec.php
Running 1 tests in 1 threads

FAILED
1 tests failed
(╯°□°）╯︵ ┻━┻
: hphp/test/slow/ext_process/bad_shell_exec.php
002+ sh: 1: /invalid_path/: not found
002- sh: /invalid_path/: No such file or directory
```

Closes https://github.com/facebook/hhvm/pull/3103

Reviewed By: ptarjan, joelm, fredemmott

Differential Revision: D1435381

Pulled By: svcscm
Define Nast.FGenerator

Summary: Determining if something is a generator is a PITA (we have to
traverse the body), but we're already doing it, in two different places
no less, so let's bite the bullet and flatten that down during naming
into Nast.FGenerator.

Reviewed By: @elgenie

Differential Revision: D1463077
Add module dependency resolution

Summary: For extensions which rely on other extensions.
E.g.: For class hierarchies.

Load/InitM/InitT occur in dependency order
Shutdown/Unload occer in reverse dependency order

Example
  class CurlExtension : public Extension {
   public:
    const DependencySet getDeps() const override {
      return DependencySet { "asio" };
    }
    void moduleInit() override {
      /* Contains code which depends on Asio like:
      class CurlWaitHandle extends WaitHandle {
      }
      */
      loadSystemlib();
    }
  };

Reviewed By: @ptarjan

Differential Revision: D1462817
Provide backup utf8 sanitizer when UConverter is unavailable

Summary: UConverter is PHP >= 5.5, which folks may not have
Provide a basic UTF-8 validator implementation to passthrough
valid sequences and transform all others to
U+FFFD REPLACEMENT CHARACTER

Closes #3307

Reviewed By: @LiraNuna

Differential Revision: D1465029
Fix issues with empty, chunked response

Summary: We call sendRaw at the end of a request, which normally causes
headers to be sent (if they haven't already been sent), and does other
"response started" things. If the response is empty, and chunked encoding
has been requested, we skip sending it.

The result is that onSendEnd fails to close the request, and the client
is left dangling until it times out.

Always send, even if the payload is empty.

Reviewed By: afrind

Differential Revision: D1461250
Remove documented overflow inconsistency

Summary: Docs were stale, we've supported the same overflow behavior as PHP5 for
a while now.

Reviewed By: @swtaarrs

Differential Revision: D1465473
Mark SplFileObject_setCsvControl_error001.php as flaky

Summary: what it says on the tin

Reviewed By: @edwinsmith

Differential Revision: D1465647
typechecker: rename function "type" to fun_kind

Summary: when writing a "typechecker" program that "checks" "types",
 naming fields "type" creates the impression that their contents are
 the very "types" that are being checked, which is a "bad" "idea". More
 seriously, whether a function is async/sync/generator is pretty
 central to the typechecking that we do on its contents.

Reviewed By: msullivan, jwatzman

Differential Revision: D1463796
remove trigger_error from sncompress

Summary: These are hilariously causing a 20% perf regression. I'll put them back once I can migrate us.

Reviewed By: @JoelMarcey

Differential Revision: D1462853