Add Type::subtypeOf and SSATmp::isA()

Smith has been pointing out that most places where we do
exact type equality comparisons should probably go away.  We'd like to
be able to have types like Obj(Foo*) as a subtype of Obj (if we have
traces with known instance types), and think of ConstInt(1) as a
subtype of Int.  The intention is we'll start using isA() or
Type::subtypeOf() in most places that currently are using
Tag::operator==.  Putting this up as its own diff (pieces taken from
pending diffs by @smith and @bsimmers) since I want it in InstanceOfD.
Move hphpc compilation files to src/legacy
Make hphp work without HPHP_HOME/src/system

hphp used to parse the php files under src/system/classes, and
src/system/global.

  - use systemlib.php instead of src/system/classes (when it exists).
  - explicitly generate the contents of s_variables, since we already
    had assertions about exactly what was supposed to be there
  - build s_constants from g_class_map (this is ok, because when we're
    building the system files, we bypass this code altogether).
Include systemlib.php in repo-authoritative repos

his makes the embedded-repo binaries completely standalone
ext_asio extension

This adds ext_asio extension that reimplements Preparer in C++. The
semantics are preserved as much as possible.

Known changes in semantics:
- cycle detection was improved: once cycle is detected, C++ preparer
  does not fail the whole prep() call, but removes one edge of the cycle
  and injects an exception
- context tracking was improved: C++ preparer maintains stack of entered
  contexts and once context is exited, it is actively eliminated; as a
  result, invariant is maintained that if wait handle A is blocked by
  wait handle B, the context of B must be at least as specific as the
  context of A (i.e. if you prep(A), all dependencies are guaranteed to
  be imported into the context; if that context dies, all remaining wait
  handles are moved to the parent context); this was not always the case
  in a rare situations in PHP preparer

Implementation improvements:
- PHP preparer had only ResultToken (now StaticResultWaitHandle) and
  AsyncContinuation (now ContinuationWaitHandle); a new types of wait
  handles were introduced:
- GenArrayWaitHandle abstracts away the functionality of waiting for an
  array of dependencies previously implemented as part of
  AsyncContinuation
- SetResultToRefWaitHandle separates functionality of multiple result
  destinations, previously part of AsyncContinuation
- StaticExceptionWaitHandle was introduced
- wait handles are now structured in a tree that implements various
  abstract concepts (WaitableWaitHandle, BlockableWaitHandle, etc.),
  useful for later introduction of wait handles that can wait for I/O
  operations

Not implemented:
- Teak profiling is currently incompatible
- we plan to introduce better profiling support that will combine sync
  and async stack traces
- before improved profiling is available, we plan to collect Teak
  samples using PHP preparer
Update generated_files.sh to use new --hphp mode hhvm
Fix writes to aliased files

Before each write we would seek to the current position,
as maintained by the File itself. But another File could
be open on the same stream, and could have moved the
current position. Make the seeks relative to the stream's
own pointer.
Fix sticky eof on PlainFile

Once a PlainFile hit eof, we would never clear it - even though
we could be writing to it through a different file handle (or
another process could be writing to it).

This clears the eof flag on every read (it will immediately get
set again if the file didnt grow).
Delete atomic_add

Instead of rolling our own atomic operations, we should use the C++11 ones. I'm
planning to get the other ones too (inc, dec, cas), but I'm doing them in
separate diffs to keep the diffs manageable-sized, and bisectable in case
something breaks.

The C++11 atomic ops let you specify the memory ordering semantics you want. Our
implementation of atomic_add was equivalent to memory_order_relaxed (i.e. no
memory barriers of any kind), so I stayed with that, for the most part, when
converting. I think this is OK: a lot of the usages are manipulating counters,
and aren't used to synchronize threads. The one exception is
PhpFile::m_refCount, for which I added acquire/release barriers as appropriate.

Also, ARM has a different definition of what's atomically accessible.
Add Trace::punt

Running a debug build with TRACE=punt:1 will dump stats at
the end of each request about which punts are dynamically important.
Delete atomic_cas

Relatively easy, and I didn't come across any suspicious activity while I was at
it.

There are two forms of CAS in the library: weak and strong. The difference is
that the weak version is allowed to spuriously fail; i.e. not do the CAS even
though the atomic variable has the expected value.

On x64 there is no difference in the underlying implementation, but on ARM there
is, because ARM has no atomic-CAS instruction. So the distinction now matters to
us. I've followed the guidance from the docs, which is: "When a
compare-and-exchange is in a loop, the weak version will yield better
performance on some platforms. When a weak compare-and-exchange would require a
loop and a strong one would not, the strong one is preferable." (The ARM
implementation of strong-CAS actually has a loop in it, is why.)
Fix memory error in ConstInstruction constructor

We're creating a corrupt IRInstruction by saving a pointer to an
argument that's only valid for the lifetime of the ConstInstruction
constructor, rather than the lifetime of the ConstInstruction itself.
Beginnings of a generic vector translator for hhir

This diff includes the basic outline for an IR vector
translator, as well as some minor changes to the rest of the system to
support it. Only a limited number of CGetMs are actually supported
right now; more complete support will come in diffs to follow.
Support for InstanceOfD translations

Implement InstanceOfD for HHIR, with most of the tx64
optimizations to it.  Currently leaves branch fusion disabled since it
appears to be too aggressive in some grepping of DumpIR on a repo
sandbox.
Cleanups to tracebuilder, irfactory and simplifier.

Cleaned up tracebuilder and simplifier. Moved simplifications
from tracebuilder to simplifier. Collected all the state tracking code
in one place in tracebuilder. Added runtime options flags to control
CSE and simplification during parsing, to disable parse-time
optimizations and to enable running them as a separate pass. Cleaned
up irfactory.
Fix onAssignNew to do proper ref handling

Fix for the following code snippet:

<?php
function f() {
  $y = 123;
  $x =& $y;
  $x =& new stdclass;
  // Zend outputs false, HPHP outputs true
  var_dump(is_object($y));
}
f();
Prohibit pcntl_exec() in multi-threaded mode.

Prohibit pcntl_exec() in multi-threaded mode, because otherwise file
handles related to repos can survive across exec with file locks held,
resulting in effective deadlock.
Warn when trying to index a scalar as if it were an array

We want to produce a warning when someone tries to access a scalar as if it were an array.  So, for example:
$x = 5;
$x[0];  // Bad.
This warning should be suppressed for list assignments where the RHS is false, though, because it's common to return FALSE in place of a list when there are no more values (e.g., mysql_fetch_array).  So:
$x = FALSE;
$foo = $x[0];  // warning
list($foo) = $x;  // no warning.

To support this behavior I've introduced a new member operation to the bytecode, EQ, which is exactly like EI but is quiet about warnings.  List assignment is then translated using EQ.
Pull xed disassembling logic out into a class

Right now it's just used as a special case in ir.cpp
Add RuntimeOption::EvalJitCompareHHIR

This is meant to help compare code quality between hhir and
tx64. If hhir successfully translates a tracelet, it will be
retranslated with tx64. If the code from hhir is larger than the code
from tx64, the bytecode and disassembly for both translations will be
logged. Only the hhir tracelet is put in the SrcDB, and the cursors of
a and astubs are rewound to reuse the space from the tx64 translation.