Introduce arraykey type

Summary: The keys of Hack collections only allow ints or strings at runtime. The
type checker is currently unaware of this restriction. Keys for PHP
arrays also have this restriction, with the addition that floats and
nulls will be implicitly converted to either ints or strings, something
we probably do not want in Hack.

This is the inspiration of the arraykey type. It is simply a union type
of int and string so Hack is aware of what valid array/Collection keys
are.

I still need to add HHVM support, and update the hhi files for
collections to use these types but I will do so in follow up diffs.

Reviewed By: @jwatzman, @elgenie

Differential Revision: D1543856
fix fgets bug & redis sockReadLine bug

Summary: doc for ``fgets`` from php.net::

    Reading ends when length - 1 bytes have been read, or a newline (which is included in the return value), or an EOF (whichever comes first). If no length is specified, it will keep reading from the stream until it reaches the end of the line.

3 situation when fgets return:

1. read got '\n'
2. eof
3. read length-1 bytes

**but in the code, there is one more situation** ::

         m_writepos = filteredReadToBuffer();
         m_readpos = 0;
         if (bufferedLen() == 0) {
           break;                              /////////////////////////  if read got 0 bytes
         }

Socket::readImpl (hphp/runtime/base/socket.cpp) may return 0 bytes if ``poll`` got timeouted.

so fgets may return a string not endwith '\n'

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

Reviewed By: @sgolemon

Differential Revision: D1552835
Fix segfault in readline_clear_history

Summary: One test remaining.
Closes https://github.com/facebook/hhvm/pull/3724

Reviewed By: @sgolemon

Differential Revision: D1548684
Allow .ini and .hdf files to be specified to the HHVM wrapper.

Summary: I like using the HHVM wrapper (hhvm_wrapper.php). I like being able to specify
configuration files to HHVM. Let's marry the two together.

Reviewed By: @ptarjan

Differential Revision: D1514597
Make segfaults during .skipif still run the test

Summary: *sigh* I spent a day trying to figure out why this was ok on my machine. It turned out it WAS segfaulting on my machine just the test runner ignores segfaults during the .skip phase and says all the tests passed. :(

I can't wait to see what fails in testing...

Reviewed By: @JoelMarcey

Differential Revision: D1547980
Get rid of -Wno-uninitialized

Summary: This is a pretty useful warning. Turn it back on and fix the fallout.
It's amazingly limited damage, considering what usually happens when
warnings aren't turned on.

Reviewed By: @markw65

Differential Revision: D1547861
Make Type::rawVal() work whenever Type::isConst() returns true

Summary: And clean up a number of places that had special handling for cases rawVal() didn't work despite isConst() being true.

Also, kill hasRawVal().

Reviewed By: @edwinsmith, @alexmalyshev, @bertmaher

Differential Revision: D1548617
Make guard relaxation work with unreachable code

Summary: Guard relaxation was relying on the simplifier + preoptimizer during
IR generation to eliminate unreachable code due to type-checks that
will always fail.  Such dependence is undesirable, and there are
special cases where the simplifier + preoptimizer aren't able to
eliminate unreachable code anyway.  This diff makes guard relaxation
more robust, so that it doesn't crash in such cases.

Reviewed By: @edwinsmith

Differential Revision: D1551777
mark checkCalls DEBUG_ONLY to appease -Wunused

Reviewed By: @oyamauchi

Differential Revision: D1552578
support for (co/contra)variant generics

Summary: Generics in Hack are invariant by default. What that means is that if
a function takes a X<A> it cannot be used with an X<B> (where A is subtype of B).
There are quite a few programming languages that allow this (they use different notations: in/out, +/- or ? extends).
Some others choose to just be covariant everywhere and be unsound (dart, typescript).

I pushed back on that feature because it's complicated, and I seriously doubt that most programmers understand it.
However, we have deep class hierarchies to deal with, that leads to complex subtyping relations and it makes
generics painful to use.
We have gotten to the point where we periodically modify the type-checker to hard-code the name of a class
that should be covariant ...

Because of that: Here comes covariant support for Hack!

Reviewed By: @elgenie

Differential Revision: D1445708
Move MemoryManager::refreshStatsImpl out of the header

Summary: Since MM is included by the world it's hard to iterate on this code
rapidly.  This function doesn't appear to be perf critical (and is too big for
inlining to make a huge difference anyways), so move it to the cpp file and
declare the boolean template specializations explicitly.

Reviewed By: @edwinsmith

Differential Revision: D1552525
Bind the resource limits to a local static for ini_xxx capabilities

Summary: Developing the "bad ini setting diff" led me to this. Let's bind these to actual ini settings.

Reviewed By: @ptarjan

Differential Revision: D1550734
Add minimal hdf support to test runner

Summary: I want to be able to specify a `testname.php.hdf` file along with a `testname.php.ini` file. The `.hdf` does not have as much "clout" as the .ini ... it is either there or it isn't. It does not search directories for one.

Reviewed By: @ptarjan

Differential Revision: D1554401
Allocate uncounted strings with malloc.

Summary: APC strings are uncounted but not static, and consume a lot of
low-memory. This pressure can be bad in general, but especially
when the treadmill stalls.

Reviewed By: @markw65

Differential Revision: D1554596
Remove "after vasm-auto" trace

Summary: Seems too noisy.

Reviewed By: @edwinsmith

Differential Revision: D1554221
Introduce several vasm trace levels

Summary: Level 1 prints only initial vasm.  Level 2 will print initial only
vasm and vasm + x64 interleaved after we have that.  Other stuff is higher
levels.

Reviewed By: @edwinsmith

Differential Revision: D1554256
Analyze/optimize pseudomains in hhbbc

Summary: We need to have a pass that determines which static properties can be
modified by the program (including public ones), which means we need to see
possible changes to static properties in pseudomains.  The easiest way to do
this is to analyze psuedomains like anything else.  (This also should help with
more clearly seeing the differences in the repo stats when hphpc's inferTypes
and postOptimize are off, since most of the bytecode changes are currently in
pseudomains.)

Reviewed By: @alexmalyshev

Differential Revision: D1545270
Don't allow setting static properties via reflection in RepoAuthoritative mode.

Reviewed By: @markw65

Differential Revision: D1550898
Don't warn if HDF files don't end in .hdf

Summary: `raise_warning()` was causing issues with current HDF files that don't have a `.hdf` suffix.
So, let's just allow any non-`.ini` file be assumed a `.hdf` file for now.

Reviewed By: @alexmalyshev

Differential Revision: D1554485