Proper implementation of subtypeOf, strictSubtypeOf and couldBe over class hierarchies

Make class hierarchies take part in subclass and could be relationships

Reviewed By: @jdelong

Differential Revision: D1146681
Don't return any RepoAuthTypes unless we're in WholeProgram mode

Bsimmers found a case where hphpc says something has
KindOfString (implying InitNull or String), but it could be
KindOfUninit.  In whole program mode, hphpc correctly finds out it
could be unset, but not in normal mode.  I didn't really try to dig in
to why, but let's just disable it unless we're in RepoAuthoritative
mode.

Reviewed By: @swtaarrs

Differential Revision: D1144005
Promote bases to array before possibly throwing in Emptyish cases

This is what zend does, and it also simplifies dealing with
the types that need to propagate across exception edges in HHBBC.  (It
may also give better types in non-exceptional code when catch blocks
can fall through.)  Also just seems like more sensible behavior.

Reviewed By: @swtaarrs

Differential Revision: D1149589
Maybe fix an issue in JIT::Type::toRuntimeType

If you do

  (Type::Obj.specialize(something)|Type::InitNull).toRuntimeType(),

you'll hit an assertion in the RuntimeType because it expects to be an
object if you set a class on it.  I started hitting this with hhbbc,
presumably because I finally rebased past turning on pgo mode.

Reviewed By: @swtaarrs

Differential Revision: D1148390
Normalize doc formatting.

Normalize doc formatting to use 80 columns, and only one space after
periods.

Reviewed By: @scannell

Differential Revision: D1151957
Revert "Remove dests of jumps"

Assertion failures in PHPUnit - possibly also the sandbox tests asserts too

Reviewed By: @jdelong

Differential Revision: D1152137
Fix the composer.json md5 check

We have just been comparing the md5 of a static file name string instead of the actual contents of the file. That's not good.

Also remove Mockery.php since it is cookie cutter.

Reviewed By: @fredemmott

Differential Revision: D1152295
Rewrite PHINQ select clauses into client parts and server parts.

LINQ select clauses can contain arbitrary source language expressions. These cannot always be evaluated on the query server, so the clauses passed to the query provider need to be sanitized and the query provider needs to be given a way to turn the tuples that come from the query server into the values specified by the original select clause. This is done by rewriting query expressions during parse time so that the serialized code model for the query expression is sanitized and a new lambda function and associated closure expression is constructed for use in the code generated by the query expression.

The overall scheme is now something like this: Given
  $r = FROM $r in $t WHERE $r->c == $someValue SELECT new SomeObject($r->d, ($r->e).'foo');
we end up generating roughly
  $r = $t->executeQuery("FROM $r in __query_param0__ WHERE $r->c == __query_param1__ SELECT tuple($r->d, $r->e);", $__query_result_row__ ==> new SomeObject($__query_result_row__->r::d, $__query_result_row__->r::e.'foo'), $someValue);

The value that ends up in $r is up to the query provider, but the expectation is that whenever and however it ends up producing result elements, they are turned into SomeObject instances via calls to the provided closure.

Reviewed By: @paroski

Differential Revision: D1151254
Easy accessors for ActRec

Provide a unified means for accessing parameters
from extension implementations where they take an ActRec.

For example:

  TypedValue* HHVM_FN(foo)(ActRec* ar) {
    String firstArg(getArg<KindOfString>(ar, 0));
    int64_t secondArg = getArg<KindOfInt64>(ar, 1, 42);
    Variant thirdArg(getArg<KindOfAny>(ar, 2));
    // etc...
  }

Or:

  TypedValue* HHVM_FN(bar)(ActRec* ar) {
    int64_t a, b;
    double c = 3.1415926535;
    StringData* d = s_DefaultValue.get();
    if (!parseArgs(ar, "ll|ds", &a, &b, &c, &d)) {
      ar->m_r.m_type = KindOfNull;
      return &ar->m_r;
    }
    // etc...
  }

Reviewed By: @WizKid

Differential Revision: D1122887
Don't let KindOfUninit pass nullable VerifyParamTypes

Nullable typehints that are nullable because of defaulted
parameters should still work the same with this, because the DV init
entry point for the parameter will set the local to an initialized
null before jumping back to the main entry point (which has the
VerifyParamType opcodes).  This changes runtime behavior for ?Foo
hints, but hopefully nothing is relying on being able to omit the
argument entirely right now.

Reviewed By: @elgenie

Differential Revision: D1131777
Add total JIT structure size counter

Adds total JIT structure size counter for better ODS tracking

Reviewed By: @jasone

Differential Revision: D1151317
Expose peak alloc counter from MemoryManager

Add a peak alloc counter for MemoryManager to be picked up in
ODS

Reviewed By: @jasone

Differential Revision: D1151491
Tidy up print methods

Add a shortcut for printing IRUnit so you don't have to type
so much into gdb, and organize the methods so they're easier to find
and match the order in the header.

Reviewed By: @ottoni

Differential Revision: D1153032
Add a catch block to ArraySet

It can throw.

Reviewed By: @jdelong

Differential Revision: D1153287
Make subobj() and subcls() return an exact type when the class is final

When a class is no_override there is no reason to have subobj or subcls for that type as that would be less precise that the class ever requires

Reviewed By: @jdelong

Differential Revision: D1151069
Remove JmpIs{N,}Type opcodes

Facebook: Not sure why I didn't just do this earlier ...

Reviewed By: @bertmaher

Differential Revision: D1149431
Remove source code examples from bytecode.specification

It seems like it's better to just use Eval.DumpBytecode (or
Eval.DumpHhas) for this.  Some of the examples aren't actually how we
compile things.  Anyone disagree?

Reviewed By: @swtaarrs

Differential Revision: D1143996
Analyze closure bodies in the class context they actually run in

Closure bodies run in the context of the class that allocated
them.  Previously, we were giving up on private and static property
inference in any class that allocated closures because we couldn't see
the closure bodies as part of class-at-a-time analysis (and couldn't
take their effects into account).  This diff hooks that up, and also
adds links between inner and outer generators (which should probably
be helpful for other things later).

After this diff, we still give up on classes containing closures that
contain yield.  Classes with async function closures are working in a
slightly strange way: we essentially only analyze the "eager" version
for its effects on $this and self.  I think this is fine for now, but
it's relying on a bunch of undocumented invariants (essentially it's
relying on the fact that the two function bodies "do the same thing"):
@jano is planning to combine the bytecode bodies for async functions so
we probably don't need to worry too about documenting all that in the
spec until the implementation stabilizes more.

Reviewed By: @bertmaher

Differential Revision: D1143994
Add a missing catch block for RaiseError in UnsetM elem

Hit this checkCfg with P4782738 in hhbbc.  (Not a problem for
hphpc, since it doesn't tell us the static property is a string.)

Reviewed By: @swtaarrs

Differential Revision: D1144250
Support more cases for type inference on member instruction intermediate dims

After this diff, we still give up on everything for private
properties if the initial base is a global, dynamic local, or dynamic
class sprop.  But intermediate dims now never switch the base to
folly::none on their own.

Reviewed By: @edwinsmith

Differential Revision: D1145256