Make VIXL use CodeBlock

This lets vixl::Assembler and HPHP::X64Assembler have something
resembling the same interface.

Including data-block.h from vixl exposed a bunch of header issues, so I
cleaned some of it up -- removing dependencies on boost and including
unistd.h in one place.

Reviewed By: @jdelong

Differential Revision: D971335
Interface abstract method reflection bug.

Changed FuncEmitter to mark interface methods as abstract.

Reviewed By: @ptarjan

Differential Revision: D970228
Implementing stream_context_get_options() et al.

Added parameter StreamContext* m_context in the File class. Implemented
function f_stream_context_*() functions mostly by delegating to
appropriate methods added in StreamContext class.

Reviewed By: @ptarjan

Differential Revision: D967885
make stream_select() return buffered reads

If we previously read something into a buffer, but userland didn't consume it yet, we need to pretend that `stream_select()` has data. I took inspiration (and the comment) from php.

Reviewed By: @markw65

Differential Revision: D972453
Rework the Zend compat layer to be more robust

This diff reworks the PHP extension compat layer to be more robust by
taking steps to reconcile the difference between mainstream PHP's way and
HHVM's way of representing program values and operating on program values.
This includes the shape of the object graph in the heap (what points to
what), how refcounting is done and how "reffiness" is handled, how copy-
on-write semantics are honored, and how values are stored into arrays.

One of the core ideas here is that HHVM supports "boxing" a program value
via the RefData type and that there's a reasonably clean mapping between
PHP's object graph and HHVM's object graph (when HHVM program values are
"boxed") that maps PHP "zval" objects onto HHVM RefData objects. For the
purposes of a compat layer for PHP extensions, it makes sense to use
RefData to represent "zvals". Of course, it is unreasonable to box every
program variable in HHVM since this would hurt performance. However, we
can make things work by boxing program values lazily as needed in the
right places to ensure that Zend PHP extensions only deal with boxed
values. Along the way I also fixed a bug where we were leaking all of
the arguments that were passed to Zend PHP extension functions.

The next issue involves "reffiness". At present, HHVM RefDatas are treated
as "reffy" when their refcount is 2 or greater, while Zend PHP zvals have a
separate flag (independent of the refcount) that indicates whether they
should be treated as "reffy". Zend PHP extensions are capable of setting
two or more program variable to point to the same zval where the zval's
"reffy" flag is set to false. In such cases, the program variables share
the zval using copy-on-write semantics, where the zval must be copied
before making a modification. To make this work, we need to change RefData
somehow so that we can keep track of whether copy-on-write is needed when
the refcount is 2 or greater. Adding "reffy" flag directly poses some
challenges in terms of performance, because it means that when a value's
refcount decreases from 2 to 1 we'll need to make sure the "reffy" flag
gets cleared. I was able to avoid this by adding two flags (m_cow and m_z)
and creating a scheme that maps the 3-tuple (m_count, m_cow, m_z) to the
2-tuple (realRefcount, reffy). Under this scheme decRef continues to work
as it does today, decrementing the m_count field and calling a helper
m_count reaches zero. Another neat thing about this scheme is that m_cow is
set to 1 iff copy-on-write would be required before modifying m_tv. (NOTE:
This diff does not implement copy-on-write yet for these cases, it will be
addressed in a later diff.)

Another issue is the relationship between strings/arrays and the
zvals/RefDatas that point to them. Under Zend PHP, it is assumed that a
zval exclusively owns the string or array and that nothing else points to
the string/array. A consequence of this is that Zend PHP extensions do not
perform any copy-on-write checks with the string or array's refcount before
modifying the string/array. HHVM on the other hand supports sharing strings
and arrays between multiple RefDatas and/or program variables. Thus, we
need some way to protect against Zend PHP extensions modifying a string or
array when its refcount is 2 or greater. This is achieved by putting checks
in the right places to lazily make a copy of the string or array (when
refcount >= 2) so that Zend PHP extensions only deal with strings and
arrays with a refcount of 1.

Finally, the Zend PHP APIs for adding values to an array are a little
different. Zend PHP extensions pass a zval to the API, and the appropriate
array slot is set to point at the zval. The API does not increment the
zval's refcount; it is the caller's responsibility to do this is needed.
New APIs were added to HphpArray to address this need.

With this in place, the next things to go after would be (1) Fixing up how
the Zend compat layer deals emulating Zend PHP string macros and
operations, this may require adding a new KindOfZStr type if StringData
can't be adapted without hurting HHVM performance; (2) Adding checks in the
right places to make a copy of a RefData if m_cow is 1, I've found most the
places where this is needed and it doesn't look like these checks will
noticably hurt performance; (3) improving support for resource types and
object types defined by Zend PHP extensions and interoperability with HHVM
extension classes, HHVM resources, and user-defined pure-PHP classes.

Reviewed By: @ptarjan

Differential Revision: D966781
Write a script to help automate the running of PHP OSS Framework unit tests

This is an initial verison of a script that will allow us to unit test all
of the OSS PHP frameworks that we care about for parity. A more detailed
summary is available at the top of the code, but here are some highlights:

- Autodownload of frameworks; not added to our official repo
- Mulit-process test runs
- Full phpunit stats in a file after each run
- Summary file for all tests run showing pass percentage. Appended with latest
  result for multiple test runs of a given framework. Initial inspiration for
  this file was for our MPK TV parity chart population.

Future:

- Integration with our "test/run" infrastructure
- Special case frameworks that don't use PHPUnit
- Enhance the script to allow "diff" stats that specify what changed from the
  previous run of a test of a framework to the current test (beyond pass
  percentage). For example, what tests caused the pass percentage to increase
  or decrease.

New Files for this diff:

- oss_framework_test_script: The script
- phpunit.phar: Used to actually run the phpunit tests for each framework
- composer.phar: Used for installing framework dependencies for phpunit
- sample_multiple_test_config.cfg: A sample configuration file to run multiple, but
  not necessarily all testsi

NOTE: I am only including 3 of the OSS frameworks as part of the code for this diff.
When this diff is accepted, I will send out another diff with the rest added. Having
just 3 makes for easier initial testing.

Another note: I removed the comment that command_line_lib does not support options with
arguments. It does. I am using that functionality in this script.

THANKS TO @ptarjan for process ideas from both running the tests and getting through
the proxy!

Reviewed By: @ptarjan

Differential Revision: D971897
make callCustomInstanceInit require there be an __init__

I'm debuggin a thing that throws `Exception` subclasses and I saw this method is always protected by checking a bit on the `Class*`.

Reviewed By: @jdelong

Differential Revision: D973603
Remove HHVM_FBMAKE override of system/constants.h path

The old build system is dead.

Reviewed By: @ptarjan

Differential Revision: D972026
stop using static string in zend compat layer

I didn't know how to do this properly. Drew taught me.

Reviewed By: @paroski

Differential Revision: D974161
Fix read overflow in xbuf_format_converter

xbuf_format_converter uses appendstring which currently
assumes its input is a null-terminated string and copies the NULL. The
result ends up being correct even though what xbuf_format_converter
passes to it isn't null-terminated because each extra byte is
overwritten by subsequent calls and the last byte is manually set to
NULL at the end of the function, but it's still trying to potentially
read garbage.

This caused three different extension tests to fail because of their use
of vspprintf which ultimately calls xbuf_format_converter.

Reviewed By: @edwinsmith

Differential Revision: D973694
Implemented SPL RegexIterator

Draft implementation of SPL RegexIterator

Closes #504
Closes #1061

Reviewed By: @ptarjan

Differential Revision: D972519

Pulled By: @scannell
Strip local paths and copy hphp.tab.cpp to hphp/compiler/parser
Allow traits to implement interfaces

Add runtime support for implementing interfaces from traits.

e.g. if a class C uses a trait T that implements an interface I, then C is a subtype of I.

Reviewed By: @paroski

Differential Revision: D969512
Support arbitrary expressions inside empty()

PHP 5.5 now supports arbitrary expressions inside the empty() construct. We want to match Zend's behaviour.

For the newly supported cases, empty(E) is equivalent to !(E).

Reviewed By: @paroski

Differential Revision: D966136
Split repo test runs into two

Summary: RepoAuthoritative test runs take longer than normal so split
them into two in order to avoid triggering the Travis timeouts

Reviewed By: @ptarjan