EZC: Fix count() and conversion to boolean of ProxyArray

Summary: Fix JIT versions of count() and conversion of array to boolean, so that they work with ProxyArray. In both cases, duplicate the logic in ArrayData::size() -- if the sign bit of the size field is unset, use that field, otherwise call vsize().

The resulting generated machine code for conversion to boolean is along the lines of:

  mov    0x4(%rdi),%eax
  test   %eax,%eax
  js     0xf80049b
  setne  %al

where 0xf80049b is the slow path. This is similar to the machine code I previously reported for ArrayData::size() in code review of 1717e028f18 (see #3065).

Added test case which previously failed.
Closes https://github.com/facebook/hhvm/pull/3811

Reviewed By: @ptarjan

Differential Revision: D1568919
Fix nl2br support for carriage returns.

Summary: nl2br() now matches PHP to support prepending of html new lines on carriage returns in addition to newlines.  We also handle special cases when there is a carriage return beside a newline; each pair only get one html new line instead of two.

Fixes #3815

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

Reviewed By: @ptarjan

Differential Revision: D1571327
Move register hints to the vasm instruction macros.

Summary: @jasone and I both have run into bugs with the way the register hinting
code is organized. This adds DH and UH macros (def hint, use hint)
that avoid needing the nasty switch, and don't require all those
instructions to have identical operand names.

Reviewed By: @swtaarrs

Differential Revision: D1570915
Don't allow split before phidef in the same block.

Summary: If a phidef caused another interval to be split and spilled,
the split position could be just before the phidef in the same
block, which is illegal. Fix the nearestSplitPosition to
be the start of the block, which forces copies to the edge.

Added an assert that checks we don't try to copy two different
intervals to the same physical register along the same edge.
(which fires before this fix).

Reviewed By: @alexmalyshev

Differential Revision: D1568347
Better errors on runtime generics.

Summary: Closes https://github.com/facebook/hhvm/issues/3711

Reviewed By: @jwatzman

Differential Revision: D1565849
SSA for ExtendsClass and LdFuncCachedU, enable asserts in vasm-check.cpp

Summary: This is the last of the conversions; vasm is required to be SSA now.

Reviewed By: @alexmalyshev

Differential Revision: D1502355
Require SSA in vasm-fold-imms

Summary: Remove the workaround

Reviewed By: @alexmalyshev

Differential Revision: D1571744
Bumping `ProxyManager` version to a version that correctly handles HHVM's `Closure::bind()` support

Summary: Closes https://github.com/facebook/hhvm/pull/3824

Reviewed By: @fredemmott

Differential Revision: D1571955
Remove keyType assert in getKeyType()

Summary: We've talked about removing this assert in the past and I think it's
finally time for it to go. It's caught some real bugs but we're in a much
better place wrt weird types now. In the case of the new test I added, keyType
was {Int|Dbl} on ARM, since the AddO was getting interpOned.

Reviewed By: @edwinsmith

Differential Revision: D1570728
Make numStackArgs() assert in ARM codegen more verbose

Summary: This is triggering intermittently in some framework test runs and we
have no idea why. This will help debug.

Reviewed By: @ptarjan

Differential Revision: D1570865
hh_ide.js - Reduce memory usage

Summary: We're starting to bleed here again on Chrome webworker memory usage.

This will bring us down a bunch.

Idea is: If we're adding a file in the background that's only a dependency, we don't keep the it in the parser heap, or the file contents hashtable.

We don't call any other functions on that file unless it gets hh_add_file'd later.

In another diff, I'm going to remove the file contents hashtable all together.

Reviewed By: @pikatchu

Differential Revision: D1567415
TRACE_PUNT when refcount optimizer can't handle a region

Summary: In this case, the JIT was retrying the translation without bytecode
control flow, but that doesn't work in general because the region may
not be a trace.

Reviewed By: @alexmalyshev

Differential Revision: D1571163
Get rid of ClassInfoVM and MethodInfoVM

Summary: These are hangovers from when most runtime functions were implemented
in terms of them.

Reviewed By: @jdelong

Differential Revision: D1570176
Fix lto build

Summary: Even though we forced a fake call to const_load, and marked it
EXTERNALLY_VISIBLE, the lto build still optimized the call away
and then gold's --gc-sections option caused it to be removed.

I tried NEVER_INLINE, and it didn't help; apparently g++ notices that
its a no-op, and doesn't bother calling it (which I suppose is not the same
as inlining it).

This just forces a reference to its address, which makes it stick around.

Reviewed By: @edwinsmith

Differential Revision: D1571856
ArrayObject::exchangeArray should always return an array

Summary: It would return the object, if an object was used. PHP however returns an array nevertheless.
Closes https://github.com/facebook/hhvm/pull/3819

Reviewed By: @ptarjan

Differential Revision: D1570374
make trailing commas optional in format_hack

Summary: now all the tests pass and generate php that parses correctly
Depends on D1567229

Reviewed By: @paroski, @pikatchu, @elgenie

Differential Revision: D1568966
Make Either<> use a configurable tag bit---APC can't use the low order bit

Summary: Some file-backed deserialization is broken in trunk because we're
trying to steal the low bit to tell if something is file-backed.  But the data
is only byte aligned.  Use the high bit instead.

Reviewed By: @swtaarrs, @mclarkelauer

Differential Revision: D1573026
Cleanup thisReturn()

Summary: GuardLoc and friends don't define a new FP anymore.

Reviewed By: @alexmalyshev

Differential Revision: D1572128
FrameState::startBlock should take a LocalStateHook

Summary: It'll null out local values if it enters a loop header, so we want to
pass in a LocalStateHook so that it can clear its locals too.

Fix refcount-opts so that it correctly consumes all locals when
startBlock nulls them out.

Reviewed By: @swtaarrs

Differential Revision: D1550496
Typing of single-argument array_filter

Summary: Here is a pretty common patten: you use an API to load a bunch of stuff, some of it may come back as null due to circumstances beyond your control, so you stick it into array_filter... and we're blind, going from array of strongly typed things to an unknown type.

Here is a proposal to improve the situation by hardcoding (some part) of the array_filter behavior into the type-checker. See the unit tests for example of how I imagine it working. It changes type of array_filter, depending on the type of arguments, to one of the following:

function(array): array
function(Container<?Tv>): array<mixed, Tv>
function(KeyedContainer<Tk, ?Tv>): array<Tk, Tv>

Reviewed By: @elgenie

Differential Revision: D1447846