Adjust the encoding m_pos uses when pointing past the last element

Summary: This diff changes the way arrays encode m_pos when it points past the last
element. Before, ArrayData::invalid_index (-1) was used. This diff changes
it to uses a non-negative value that is greater than the position of the
last element (if there is a last element). This allows PackedArrays and
MixedArrays to set m_pos to 0 initially, and then they never need to update
m_pos when a new element is added.

Reviewed By: @edwinsmith

Differential Revision: D1430872
hh --auto-complete --json: add details about function types @override-unit-failures

Summary: I am not sure if this is a good layout for json output.

This is one of my first ocaml diffs, any comments about anything are welcome :)

Reviewed By: @joelbeales

Differential Revision: D1428333
Entry blocks have an extra predecessor, part 2

Summary: Similar to D1412834, we weren't counting the extra predecessor that
entry blocks have in JIT::Block.

Reviewed By: @ottoni

Differential Revision: D1425851
Fix asserts with Mov codegen.

Summary: 1. XLS won't allocate registers for InitNull, but it isn't treated as
a const, so we'd die when trying to do Type::rawVal() in cgMov().

2. t2:StkPtr = Mov t1:StkPtr is legal, but we weren't handling Mov in
forceAlloc().

3. cgMov wasn't handling the dest register being InvalidReg.

Reviewed By: @ottoni

Differential Revision: D1425846
Minor code cleanup

Summary: Thats it

Reviewed By: @bertmaher

Differential Revision: D1431103
Introduce NvGetIntConverted so IntMap array can warn on converted numeric string keys

Summary: IntMap array is an array with only integer keys, that does not support
converting numeric string keys to integer keys. It instead raises a warning
when such a thing occurs. This diff adds to ArrayFunctions a function to
warn on such occurrences, but all other ArrayKinds will just delegate to
NvGetInt without warning.

Reviewed By: @paroski

Differential Revision: D1428302
Turn on numeric string key warnings for IntMap arrays

Summary: IntMap array is an array with only integer keys, that does not support
converting numeric string keys to integer keys. It instead raises a warning.

This diff handles jit code paths that silently convert string keys to integer keys.

Reviewed By: @paroski

Differential Revision: D1427621
Fix lz4uncompress

Summary: the library function lz4_uncompress will keep reading input bytes
until it produces the specified number of output bytes (if it doesn't produce
exactly the right number of output bytes, it returns a failure code).

hphp/test/slow/ext_zlib/ext_zlib.php has a test for invalid input. That was
reading beyond the end of the input string, and, given the right garbage
bytes, could actually succeed.

Switch to lz4_decompress_safe, which specifies how long the input string is, and
a maximum number of output bytes.

Reviewed By: @dariorussi

Differential Revision: D1432804
Fix Map and Set iterator logic

Summary: The iterator logic for Maps and Sets was keeping track of the current
element using byte offsets instead of indicies, which was intended to be a
micro-optimization to make iter_key() and iter_value() slightly faster.
However, it turns out that ArrayIter truncates the upper 32-bits, so the
byte offset scheme won't work for huge collections with more than 178956970
elements.

This diff changes the Map and Set iterator logic to use indices instead of
byte offsets. This has the added advantage that it matches how MixedArray's
iterator logic works.

Reviewed By: @paulcavallaro

Differential Revision: D1428664
Fixed build failed because of incompatible libzip version

Summary: After the commit 3652634dc09bf3d6d533a8c3dc46cd9bd5f6ce4b upgraded libzip, we are required 0.11+ (The version is not updated I proposed another PR for that)

This patch add lipzip version detection and fallback to bundled libzip
when incompatible libzip found.

Closes #3177

Closes #3178
Created from: https://github.com/facebook/hhvm/pull/3178

Reviewed By: @ptarjan

Differential Revision: D1432747
Fix an assertion when iterating collections

Summary: iterInit for collections assumed (and asserted) that valOut was
not KindOfRef, but nothing was enforcing that.

Reviewed By: @dariorussi

Differential Revision: D1431817
Plumb Asm& through to ifThen()'s lambda function

Summary: All the other if-then-else assembler functions pass the Assembler
down to the lambda functions passed in, except this one.  Clean
it up and remove duplicated code.

Reviewed By: @bertmaher

Differential Revision: D1428732
Add ezpublish-kernel to framework tests

Summary: Closes #3119

Reviewed By: @ptarjan

Differential Revision: D1431397

Pulled By: @fredemmott
Optimize APC objects and collections by defining an APCCollection class and increasing the number of APCObject vs serialized objects

Summary: Allow collections in APC to be stored holding an uncounted or APC array. Also extend conditions under which an APCObject is created.

Reviewed By: @elgenie

Differential Revision: D1417525
Add memory protector to hhvm thread scheduler.

Summary: Introduced an outstanding memory checker thread on each proxygen server
instance. This memory protector periodically check the current actual
free memory, once it is lower than some configured threshold, a flag will
be marked so that new coming requests will be quened until that flag is
reset.

Once the free memory amount become back above the threshold, the
protector flag is reset. Meanwhile, the memory protector will
perform some extra "notify"s to the job queue, so that previous
queued jobs can be sweep up shortly.

The following parameters are configurable by hdf:

MemoryThreshold: the threshold of free memory, default as 512MB.

MemoryCheckFreq: the frequency of memory checking, default as 3s

QueuedJobsReleaseRate: the rate of extra "notify"s to release
previous queued jobs, default as 3, which means giving the job queue
3 notifies every secs, here P = QueuedJobsReleaseRate.

Reviewed By: @markw65

Differential Revision: D1396273
packed arrays in asio

Reviewed By: @elgenie

Differential Revision: D1413413