Replace malloc with smart versions (zend-string)

Summary: Some more conversions.

Reviewed By: @scannell

Differential Revision: D1302545
Use m_mainCode or m_stubsCode in cg instead of mcg->code

Summary: Within codegen I think it makes sense to be consistent about
how we refer to main/stubs, particularly if we want to experiment with
changing where each goes.

Reviewed By: aravind

Differential Revision: D1305258
Get this thing compilable by clang

Summary: A lot of the warnings/errors that fired came from several places, and I
used my discretion and sometimes decided on different solutions in
different places.

- Code that trips Wparenthesis-equality and Wtautological-compare arises
  naturally and legitimately from some macro expansions, and clang isn't
  smart enough to recognize this. I mostly opted to turn these off via
  build flags.

- I tried to avoid turning warnings off via pragmas, since those require
  ugly ifdef blocks or more build flags to ignore unknown pragmas. I
  mostly left that for generated lexer code (-Wno-null-conversion) or
  for ext_zend_compat code that I was too afraid to mess with.

Rundown of the rest of the changes:

- extern "C" functions have restrictions on what user-defined types can
  be used as their return type. This motivated the change to
  hphp_compiler_serialize_code_model_for.

- Unused-constant and unused-function warnings: some of them I deleted,
  some of them I put UNUSED on. I put UNUSED on constants that seemed to
  be part of a series.

- Unused private fields are mostly straightforward to remove.

- hhbbc had some lambdas with not-quite-deducible return types.

- reinterpret_cast isn't constexpr. There was one isolated instance and
  a whole nest of instances in the array pseudovirtual dispatch system.
  I replaced these with inline definitions of these functions; the
  linker should be able to fold their identical implementations together
  (which is the point of the original reinterpret_cast trick).

Reviewed By: @jdelong

Differential Revision: D1307442
Allow empty return in generators in <?hh

Summary: Let's start deprecating "yield break" in favor of "return".

Step 1: allow empty return in generators in <?hh

Reviewed By: @elgenie

Differential Revision: D1306815
Merge Static{Result,Exception}WaitHandles into StaticWaitHandle

Summary: Actual class of Static{Result,Exception}WaitHandles is never used and
their memory representation is the same. Let's simplify the code and
merge them together.

Reviewed By: @jdelong

Differential Revision: D1305115
Introduce WaitHandle::Kind

Summary: Introduce 4-bit WaitHandle::Kind to be used in a follow up diff that
de-virtualizes WaitableWaitHandle hierarchy.

Store it in o_subclassData.u8[0] together with state (each of them
occupies 4 bits). Avoid extra loads/stores by specializing setState()
methods per each final WaitHandle.

Kill STATE_NEW, as a WaitHandle never stays in this state. Set the
correct state explicitly during WaitHandle initialization. Move
setState(STATE_BLOCKED) from blockOn() to the callers (or replace by
asserts when already in STATE_BLOCKED). Inline trivial
setResult()/setException() methods.

Reviewed By: @jdelong

Differential Revision: D1305591
Devirtualize c_WaitableWaitHandle

Summary: Save 16 bytes per each c_WaitableWaitHandle (pointer to vtable +
padding).

Reviewed By: @jdelong

Differential Revision: D1306031
Re-enable recurse.php without frame elision

Summary: I haven't been able to repro this test failure locally. I'm reenabling
here with frame elision off, to establish whether that's the real
problem.

I also changed the name of the function because it was conflicting with
HH\fun, a Hack function that converts a string to a "function reference"
(really a string, but specially tracked by Hack). I don't think that
could have been causing crashes, but this confused the hell out of me
during debugging.

Reviewed By: @alexmalyshev

Differential Revision: D1309345
Fix escalateForSort in APLLocalArray

Summary: escalateForSort was returning a packed array when the APCLocalArray was packed

Reviewed By: @jdelong

Differential Revision: D1308833
Don't mark async functions and generators as MayUseVV

Summary: Async functions and generators no longer use set of 2 functions that
make it hard to deduct whether ExtraArgs/VarEnv is needed or not.

Marking them as MayUseVV by default is no longer necessary. Drop it.

Reviewed By: @jdelong

Differential Revision: D1306879
Audit existing isAsync() / isGenerator() calls

Summary: Introduce more granular methods on Func:

- isAsyncFunction()
- isAsyncGenerator()
- isNonAsyncGenerator()
- isResumable()

Audit existing isAsync() / isGenerator() calls and update them based on
their intent. Allows safe introduction of async generators.

Reviewed By: @jdelong

Differential Revision: D1307331
variadics: more compact representations for func num(Variadic)Params

Summary: Uses the least significant bit to represent the fact that numParams
 and numNonVariadicParams differ by 1. A shift then allows accessing
 both numNonVariadicParams and numParams.

Reviewed By: @jdelong

Differential Revision: D1271773
Remove prototype for function that doesn't exist

Reviewed By: @bertmaher

Differential Revision: D1308483
Use String in php_pcre_replace

Reviewed By: @scannell

Differential Revision: D1305897
Tweak MixedArray::findForInsert

Summary: Right now, when inserting a new element into a MixedArray, we try to
insert into the first hash-probe slot that is either a Tombstone or
Empty. This means that we have to separately keep track of the first
free slot.

If deletes aren't too common, the first free slot should already
be the Empty slot, so we can do away with tracking this
slot separately.

Reviewed By: @edwinsmith

Differential Revision: D1310553
Avoid string copying in Transport::sendRawLocked

Summary: Transport::sendRawLocked, prepareResponse, and prepareHeaders do not need to
make copies of their parameter data. Add new StringHolder class that
holds a reference to either a (char *, len) pair or a folly::IOBuf.

Reviewed By: @markw65

Differential Revision: D1308178
rename dumpTrace to printUnit

Summary: they aren't traces anymore

Reviewed By: @ottoni

Differential Revision: D1310883
Revert "Revert "Infer types of closure local variables, including captured variables""

Summary: After D1300423.

Reviewed By: @swtaarrs

Differential Revision: D1300437
Bring back closure name hashes

Summary: Closure names are required to be unique---right now an
assertion will fail in non-repo mode in hhbc-translator for CreateCl
if you have non-unique functions that are defined in different files
and create closures.  It looks like it can also potentially call the
wrong closure.  In WholeProgram mode, the emitter is trying to fix up
the names to be globally unique, but there is some kind of race that I
can't reproduce causing occasional issues when hhbbc builds www
(non-unique classes marked with AttrUnique).

Reviewed By: @billf

Differential Revision: D1300423
Make tuple() as efficient as array()

Summary: Rewrite it in the lexer instead of making function calls.

Reviewed By: @elgenie

Differential Revision: D1305592