mark 'xhp' a valid extension

Summary: Fixes #2652

Reviewed By: @fredemmott

Differential Revision: D1325365
Disable test/slow/ext_socket/select_feof.php

Summary: It's flaky due to depending on timing.

Reviewed By: @alexmalyshev

Differential Revision: D1327920
fix behavior of headers_sent in CLI mode

Summary: Headers are considered to be sent if any body has been sent.

Fixes facebook/hhvm#2220

Reviewed By: @ptarjan

Differential Revision: D1325097
Enable collection buffer sharing for Map

Summary: This diff enables collection buffer sharing for Map. To enable buffer
sharing it was necessary to make some adjustments to how iterators work
for Maps.

Naively sprinkling calls to check for an immutable buffer at the beginning
every mutating method made things a bit inefficient, so I spent some time
to refactor some of the core operations such as add(), set(), grow(), and
reserve().

This diff is stacked on top of D1318651.

Reviewed By: @dariorussi

Differential Revision: D1324858
Make frame elision slightly more conservative

Summary: recurse.php was crashing because we were eliminating the DefInlineFP's
but not the SpillFrame's of the inlined recursive calls. These are
frames written to the stack but not linked into the AR chain. When the
unwinder tried to unwind from the eventual stack overflow fatal, it
would encounter these frames and try to unwind them as TVs.

What this diff does is to block the elision of any DefInlineFP if its
corresponding SpillFrame is used more than twice: once by the
DefInlineFP we're considering, and once by its corresponding
DefInlineSP.

I think this makes us slightly more conservative than we need to be -- I
believe it is valid sometimes to eliminate a DefInlineFP without
eliminating its corresponding SpillFrame, as long as we know there will
be no unwinding within the region where this gap exists.

Reviewed By: @jdelong

Differential Revision: D1326900
Implement ConcatN opcode

Summary: Introduces a ConcatN opcode for when we concatenate a small, fixed
number of strings, as well as IR ConcatStrN instructions for each
supported value of n.

As is, only HHBBC generates these, and currently only when all operands
are known to be strings.  The heuristic for the rewrites is very basic,
but should catch some common use cases.

As part of this implementation, we add a stack of "sources" to
HHBBC::State, which tracks the opcode that produced each value on the
evaluation stack.

Reviewed By: @jdelong

Differential Revision: D1281404
Fix configs for xhp tests

Summary: test/run doesn't look for hdfs anymore

Reviewed By: @fredemmott

Differential Revision: D1328240
variadics: teach hphpc frontend about variadics

Summary: ... to get rid of spurrious 'Too many arguments' and 'Not
 enough arguments' repo mode errors triggered by misinterpretation.
 As far as I can tell, there are no other effects besides ##CodeError.js## output.

Reviewed By: @paroski

Differential Revision: D1321385
Clean up ActRec methods for accessing m_this and m_cls

Summary: I did this for my refcounting $this diff that got scrapped but I think
it's worth keeping. There's only one use of this macro so all it was doing was
obfuscating the code. I also constified some magic constants.

Reviewed By: @jdelong

Differential Revision: D1320001
Fix refcount-opts for DecRefThis

Summary: It didn't know that DecRefThis consumes $this. This was exposed when I
temporarily disabled preOptimizeDecRefThis.

Reviewed By: @alexmalyshev

Differential Revision: D1320028
Fix refcount-opts for $this in static functions

Summary: The changes to refcount-opts.cpp are sufficient to fix the crash but I
decided to do a little related cleanup. I properly implemented the null $this
fatal for This and CheckThis and changed preOptimizeLdThis to generate cleaner
code in cases like this. It won't help perf but the resulting code is much less
embarrassing.

Reviewed By: @alexmalyshev

Differential Revision: D1321977
Profile which DecRefs are likely to go to zero

Summary: During profiling translations, we track which DecRefs end up going to
zero and calling destroy. During an optimize translation, the release path is
only put in astubs if the DecRef is very unlikely to go to zero. All DecRef* IR
instructions corresponding to a specific bytecode offset are all treated the
same right now; it's possible we could do better by splitting them out.

Reviewed By: @ottoni

Differential Revision: D1322919
Tolerate multiple closure classes with the same name in hhbbc

Summary: There's some bug causing multiple closure classes with the
same name (and AttrUnique) to be in the repo.  Tolerate it for now
instead of asserting.

Reviewed By: @swtaarrs

Differential Revision: D1324898
Fix not_implemented() macro

Summary: not_reached() is not appropriate to use in cases where the code may
actually be reached due to a developer error, since it does not emit an
abort, rather it signals to the compiler that optimisations may be made
assuming the code is never reached, such as omitting RET instructions.

Reviewed By: @jdelong

Differential Revision: D1311090

Pulled By: @JoelMarcey
define the xhp tokens

Summary: Closes #2669

Reviewed By: @JoelMarcey

Differential Revision: D1328912
Profile array kinds for ArrayGet

Summary: During profiling translations, track the kind of Arrays.
During optimize phase, if the arrays are monomorphically of kPackedKind,
then use PackedArrayGet instead of ArrayGet.

Reviewed By: @ottoni

Differential Revision: D1323238
bzdecompress conversion to smart_malloc

Summary: Convert bzdecompress to smart_malloc

Reviewed By: @edwinsmith

Differential Revision: D1323900
Fix a bug in Type::operator== for WaitH types

Summary: I ran some perflabs in dbgo and they hit an assert type.  The
problem was with code storing WaitH<Foos> into a local instead of
awaiting it immediately, then having a control flow join that did the
await---the merge_into implementation uses operator== and decided they
were the same since they were all wait handles.

Reviewed By: @edwinsmith

Differential Revision: D1328006
JIT VerifyParamType of interfaces comprising native types

Summary: Some interfaces are implemented by native types.  If the
typehint is one of these and the tracelet guard says it matches, no
need to do anything.

Reviewed By: @ottoni

Differential Revision: D1328831
Fix socket_strerror for host errors

Summary: Fixes facebook/hhvm#2667

Based on https://github.com/php/php-src/blob/af6c11c5f060870d052a2b765dc634d9e47d0f18/ext/sockets/sockets.c#L558

Reviewed By: @ptarjan

Differential Revision: D1327875