Fix threading issues with fb_intercept

The first time we call a method, we add its flag to the
intercept table (so it can be enabled by future calls to intercept)
and then set the flag based on whether or not its intercepted in
the current thread.

That leaves a hole where thread a could call intercept,
thread b could call the function (setting the flag to zero,
because its not intercepted in thread b), and then thread a
would behave as if the function were not intercepted.

Fixed by using adding a flag to the global table to say whether
or not its ever been intercepted, and initializing the method's
flag from there.

Reviewed By: @jdelong

Differential Revision: D1039463
Made fb_rename_function to not allow renaming to "extract".

fb_rename_function will not allow renaming to "extract".

Reviewed By: @jdelong

Differential Revision: D1041497
Move functioning Zend test

Move functioning Zend test

Closes #1246

Reviewed By: @ptarjan

Differential Revision: D1041989

Pulled By: @scannell
fix ProxyArray::Escalate

this was a copy-paste bug that eagle-eye-@edwinsmith found

Reviewed By: @jdelong

Differential Revision: D1040832
Make ReflectionParameter not completely wrong

@dariorussi what is this crazyness? Do you have a rewrite of this class? This is 100% insane.

Reviewed By: @dariorussi

Differential Revision: D1041883
Use sign bit for static ref count

Switches to using the sign bit to indicate that a refCount
is static, and rewrites the various decRef sequences to be:

  if (count == 1) release();
  else if (count > 1) --count;

Adds runtime options to allow experimentation with the exact strategy;
 - whether to load the count into a register (if one is available)
 - whether to use if (!--count) release(); if we don't need a static check
 - whether to skip using the register and just emit --count if we know
   its not static, and can't hit zero.

Also switcher various other static-bit checks to do byte tests on the
high byte, rather than word tests on the entier value.

Reviewed By: @edwinsmith

Differential Revision: D1012547
Refactor SingleTest

SingleTest was a bit unwieldly. This hopefully refactors it a bit nicer. Also, found some output bugs that may have affected our runs.

Next is to sort the expect files so that we can change them without monster diffs

Reviewed By: @ptarjan

Differential Revision: D1041553
Move sort comparators returning bools warning under HH syntax

Fixes a lot of errors in doctrine2.

Reviewed By: @ptarjan

Differential Revision: D1041273
Streamline tvDupFlattenVars

Some callsites always pass nullptr, and some always pass non-null.
Also, we can make the whole thing smaller by rearranging the cases.

Reviewed By: @markw65

Differential Revision: D1041950
Ensure ext_hotprofiler always closes main() with the data from when profiling was turned off

When we run out of log space while profiling, we close out the dangling stack with the last entry we have. This under-represents the functions left on the stack, which is fine, but also (sometimes greatly) under-represents main(), which is a pseudo-function intended to represent the entire profiling run. This change ensures that we always close out main() with data from when profiling was turned off, even if we run out of trace space.

Reviewed By: @swtaarrs

Differential Revision: D1040813
Remove null check from AtomicSmartPtr::operator->

I saw code doing null checks on the m_preClass in
target-cache.cpp's wouldCall(), but it turned out to be unreachable
code.

Reviewed By: @dariorussi

Differential Revision: D1039739
Streamline method cache helpers

Make the fast path of the method cache slow path do a little
less work.

This was in part to see if the wouldCall logic could get simple enough
to make it a fast path unique stub in ahot.  This version of the code
was simple enough for me to translate to a unique stubs, which I tried
last night (the theory was that getting it on the first page of ahot
could help iTLB/icache), but it was in the noise.  I only did
methodCacheSlowPath(), so maybe it would only help if the whole thing
was pulled over, but I'm inclined to think that this suggests idea of
trying to move hot helpers to ahot stubs isn't very promising.

Reviewed By: @markw65

Differential Revision: D1039748
stop reporting negative numbers for memory

We were calling `newSlab` at statup and then `hphp_session_init` promptly calls `resetStats` setting it to 0. It looks like we should clear the stats when we clear the slab. That's a little scary for now, so I'm going to just make it non-zero.

Reviewed By: @jdelong

Differential Revision: D1041217
Allow generation of hack types in hhvm thrift extension

Look for a "format" key in the thrift spec array for collections (maps, vectors, sets). If the value is "collection", construct a Map/Vector/Set object rather than an array.

Reviewed By: @andrewcox

Differential Revision: D1025009
Codegen for ConvArrToBool fast path

If it's not an NVTW, it's really quick to convert an array to a bool: is
m_size nonzero? The cold path is still a call to C++.

We can argue about codegen if you want. I could have the C++ helper
return a bool, get that into the dest register, and then jump over the
setcc, or do what I've done here.

Reviewed By: @edwinsmith

Differential Revision: D1040912
Slightly relax FPushFunc's locals-destroying semantics

If the call has no arguments, it can't destroy locals, even if it's a
call to extract().

Reviewed By: @jdelong

Differential Revision: D1042425
Remove RTLD_DEEPBIND from dlopen() call

It confuses TLS objects.

Closes #1174

Reviewed By: @scannell

Differential Revision: D1009729
Remove dead file
Update folly submodule

Remove duplicate IOBufQueue from folly build
Implement Fast CGI support

Split the monolithic functions preparing special variables such
as $_REQUEST or $_SERVER into multiple functions to enable feeding of
data from multiple sources. In case of FastCGI protocol, the values are
sent by the web server.

Import parts of proxygen and thrift.

Added #ifdef's to allow compilation with an unpatched version
of libevent library.

Reviewed By: @ptarjan

Differential Revision: D988737
Differential Revision: D1008756
Differential Revision: D1021808
Differential Revision: D1035231