Don't spill everything for FCallBuiltin

Summary: This diff tries to minimize saving FCallBuiltin arguments to the stack.  It takes a similar approach to emitNativeImplInlined, which is to leave only the pass-by-ref args on the stack, and create a custom catch block to handle the clean up.  The code is subtly different from NativeImplInlined, because the args are already on the eval stack coming in, and handling that takes some care.  There's still probably too much copypasta in this diff, but I didn't come up with any clean division that I liked better -- feel free to suggest some.

Reviewed By: @jdelong

Differential Revision: D1358809
Use logarithmically spaced size classes for "smart" allocation.

Summary: Use logarithmically spaced size classes for "smart" allocation
(smartMallocSize(), smartSizeClass(), etc.), rather than quantum-spaced
size classes.  Additionally, increase the limit for smart allocation
from 2^11 to 2^21 (same as the slab size).

For sizes up to 4096, use a 256-byte lookup table to convert request
size to size class index, which is ~50% faster than directly computing
the size class index.  Allocation requests larger than 4096 are a
miniscule proportion of total requests, so direct computation allows for
generality without sacrificing speed, nor requiring a huge lookup table.

Preallocate a small number of additional regions whenever slabAlloc() is
entered in order to amortize the cost of leaving the fast path of
freelist recycling.

Reviewed By: @edwinsmith

Differential Revision: D1336072
Move ExecutionContext::m_firstAR to VMRegs::firstAR

Summary: Need to update firstAR from JIT on a hot path (switch of currently
running async function). It's much easier to do if it's in RDS.

FirstAR should be eventually killed altogether, but it is not easy yet.

Reviewed By: @swtaarrs

Differential Revision: D1370326
Clean up ActRec flags

Summary: Enum does not make sense here. Still keeping them around as bits.

Reviewed By: @jano

Differential Revision: D1369961
Clean up some ir state merging issues

Summary: I traced a test failure on D1365041 to the fact that we weren't always
propagating state between blocks when we needed to. The biggest issue is that
the done_block in IRBuilder::cond wasn't empty when we appended it, so we
weren't loading up its saved state. I added an assert that we can't enter a
block with predecessors unless it also has saved incoming state, which caught a
bigger issue with how IRBuilder::getKnownTypes() works. This has always been
pretty sketchy, so I fixed it properly by making it its own, full pass over the
IR after all optimizations are finished.

removeGuard() in guard-relaxation.cpp has been eliminated because it was
causing more state propagation issues and hasn't been needed ever since we made
the Check/AssertType opcodes intersect their input and type params.

Reviewed By: @ottoni

Differential Revision: D1369383
Don't call analyze() unless we need the Tracelet

Summary: This should cut down jit time overhead in the tracelet selector.

Reviewed By: @ottoni

Differential Revision: D1370433
Disable test/slow/collection_classes/frozen_map/cow_large.php

Summary: We need to keep master green

Reviewed By: @jdelong

Differential Revision: D1370851
Changed warning to notice for acces on non-object error

Summary: Fixes: #1905

This is similar to #1949. I don't get bad tests for current master.
Closes #2746

Reviewed By: @fredemmott

Differential Revision: D1369945

Pulled By: @JoelMarcey
Fix behavior of Redis client

Summary: Because HHVM forces auto_detect_line_ending to be enabled (which is a separate
bug), if a CRLF is split across two TCP packets, fgets() is liable to get
confused and assume that the stream uses CR line ending. As a result, the
return value of Redis::sockReadLine() is liable to have either a trailing CR or
a leading LF, both of which are corruptions. This causes the client to throw an
exception, complaining of a protocol error.

The behavior of fgets() is documented here:
http://www.php.net/manual/en/function.fgets.php#101963

The Redis protocol spec affirms that responses terminate with CRLF and are
guaranteed not to contain either CR or LF in the response body:
http://redis.io/topics/protocol
Closes #2874

Reviewed By: @ptarjan

Differential Revision: D1370933

Pulled By: @JoelMarcey
Elaborate namespace defs during parsing

Summary: Instead of having each caller to the parser need to remember to
call the namespace function, just do it in the parser. This is important
since it completely eliminates `Namespace` and `NamespaceUse` from the
AST, and basically everyone else will `assert false` if they see it.
(Notably, the JS typechecker was basically completely broken with
namespaces due to this.)

In an ideal world, these would be two different types and the OCaml
typechecker would yell at us for getting this wrong, but defining a
whole new AST for this seems like overkill.

Reviewed By: @elgenie

Differential Revision: D1369259
killed mtime globals + get_parent_class

Summary: We keep the time when a class was created but this information is not used anywhere.
The function get_parent_class was used for JS generation, but since we killed the
prototype, it's not used anymore.

Reviewed By: eletuchy, jwatzman

Differential Revision: D1369765
Fix ARM buffer space check

Summary: We were checking for available buffer space _after_ emitting code/data.

Reviewed By: @oyamauchi

Differential Revision: D1369455
Make array<some-supertype> usable in strict

Summary: Now that we allow arrays in strict, as long as they are fully
annotated, it makes sense to relax the "heterogeneous array" error,
which prevents you from writing `array<mixed>` or even
`array<someinterface>` (see test case) which are both useful things to
do, particularly the latter.

This does leave some cruft with regards to how this is handled in
partial mode due to www errors and upgrade/migration concerns, see code
comment.

Reviewed By: @elgenie

Differential Revision: D1368101
Fix argument order for --php

Summary: fixes facbeook/hhvm#2773

Reviewed By: liranuna, joelm

Differential Revision: D1369846
Disable vixl stack junk filling for non-debug builds.

Summary: hhvm creates a lot of short-lived vixl simulator instances when
simulating ARM, and much of the creation overhead is due to vixl
junk-filling 512 KiB of simulated stack.  Disable junk filling in
non-debug builds, for a major performance improvement (5-30X in extreme
cases).

Reviewed By: @oyamauchi

Differential Revision: D1371583
Initial (disabled) support for call-context sensitive return type inference

Summary: This is some initial support for a way of inferring return
types from functions without type hints, or which would be generics
functions in hack, etc.  The idea is to recursively invoke the type
inference algorithm at callsites, to possibly get more information
about the callee based on argument types at the call.

Reviewed By: @swtaarrs

Differential Revision: D1363519
Don't read freed locals in debugBacktrace when leaving a builtin

Summary: debugBacktrace has some logic to avoid reading locals after they've
been freed while returning, by checking for certain bytecodes at m_pc. This
didn't cover the case where we're returning from a builtin since the pc points
to NativeImpl. Just adding a case for NativeImpl seemed like overkill since
that's the case during the entire builtin, so just check the flag on the ActRec
that's conveniently set by the function exit hook.

Reviewed By: @jano

Differential Revision: D1371047
Fix hhir guard relaxation for specialized types

Summary: DataTypeSpecialized by itself isn't a strong enough constraint: we
also need to know which specific class the caller wants or if they want an
ArrayKind. This diff adds support for storing this information in
TypeConstraint and all the associated machinery.

The problem was using DataTypeSpecialized to constraint a CheckType<Packed> on
an array that already had a RepoAuthType::Array in its type: the source type
was already specialized so we thought it was safe to not constrain the
CheckType, leading to a not necessarily Packed array being given to
LdPackedArrayElem. To prevent this from happening undetected in the future, I
added support for array kinds to the IR opcode table.

Reviewed By: @jdelong

Differential Revision: D1369432
Change PostorderSort for slightly better codegen

Summary: If we have something like this (where none of the blocks involved are
cold):

        B12
  (next)|  \(taken)
        v   \
        B13  B14
        |   /
        v  /
        B15

our rpo sort algorithm would return 12, 14, 13, 15. This caused the generated
code to look something like this:

  B12
    Jcc -> B14
    Jmp -> B13
  B14
    Jmp -> B15
  B13
  B15

By flipping the order of next and taken in this situation, it's still a valid
postorder walk, but the resulting code has two jumps instead of three:

  B12
    Jcc -> B14
  B13
    Jmp -> B15
  B14
  B15

Reviewed By: @jdelong

Differential Revision: D1365041
Properly support $php_errormsg in the JIT

Summary: Any instruction that can raise an error can modify this local, even
when we're not in pseudomains. analyze() was mostly handling this but hhir had
no knowledge of it, breaking the tracelet selector and potentially leading to
subtle bugs in PGO mode.

Reviewed By: @bertmaher

Differential Revision: D1370271