str_replace with empty array should return array

Handle empty array in str_replace like Zend and return an empty
array instead of null.

Closes #1452

Reviewed By: @alexmalyshev

Differential Revision: D1112243

Pulled By: @scannell
Fix preg_match_all requiring three parameters

preg_match_all's third parameter ($matches) should be an optional parameter.

Closes #1451

Reviewed By: @alexmalyshev

Differential Revision: D1112209

Pulled By: @scannell
Add Array to string conversion notice

Add Array to string conversion notice (and RaiseNotice IR
instruction needed to do so when using the JIT)

Closes #1314

Reviewed By: @alexmalyshev

Differential Revision: D1080985

Pulled By: @scannell
Change hasInternalReference to DataWalker and track more info of the object graph

Change, centralized and abstracted data graph walker to collect some info on the data graph for APC

Reviewed By: @jdelong

Differential Revision: D1098889
Separate bits for "non ref count" and "static" types.

Use different bits for static type and ref counted types. Every static type is not ref counted however we want to introduce the concept of a non static type that does not need ref counting.

Reviewed By: @markw65

Differential Revision: D1090994
Clean json_last_error() when parsing non-objects

JSON_parse() regards scalars as a syntax error,
but we have explicit checks for null, true, false,
numerics, and strings.  Clear the error when we return these.

Reviewed By: @scannell

Differential Revision: D1112796
Run a double-quoted json scalar string through the parser

The non-JSON fallback for quoted string values
should still respect JSON string encoding rules like
unicode, and printf-style escape sequences.

Reviewed By: @scannell

Differential Revision: D1112801
Already declared constants should cause a notice

Zend will throw a PHP Notice if you try to re-declare a
constant that has already been declared, but HipHop was throwing a PHP
Warning.

Closes #1456

Reviewed By: @jdelong

Differential Revision: D1112973

Pulled By: @scannell
hhprof should only collect profiles when profiling

HHProf should only collect profiles when profiling instead of
proactively and then only reporting when profiling as this incurs a huge
amount of runtime overhead by default with the runtime option enabled.

Reviewed By: @dariorussi

Differential Revision: D1112865
Prune dead code from compiler/option

Came across this option while cleaning up HPHP_HOME,
looks to be completely dead.

Reviewed By: @ptarjan

Differential Revision: D1111937
Fix Curl Upload Failure

hhvm will callback the compiled php read function to parse the
file to be uploaded. During this process, a file instead of a file
descriptor id should be passed into the hphp VM.
The error is caused by sending file->fb() rather than file itself into
the callback function. The actual hphp fread library try to make a dummy
resource after receiving an integer when a ResourceData is excepted.
The dummy resource file then causes a bunch of error which ends up in
the "read function returned funny value".

Reviewed By: @ptarjan

Differential Revision: D1110769
revert some unesessary change in D1110769

I revert some change will block my task in coldstage which
be brought into the master by arc land. This diff is to revert that
and local changes.

Reviewed By: @ptarjan

Differential Revision: D1113815
boost::{enable|disable}_if_c => std::enable_if

apparently std::enable_if is the new C++11 hotness

Reviewed By: @alexmalyshev

Differential Revision: D1112652
Fix a reference counting bug in emitFPushCufOp

If you have a non-persistent class in this code path, we
generate code that fails the reference count validator.  It IncRefs
the $this pointer before generating the conditional branch to the exit
trace for the class not being defined.

Reviewed By: @edwinsmith

Differential Revision: D1113826
Slightly better code gen in a couple of places

I noticed while debugging a production crash that

  testq -1, MemRef

is 3 bytes bigger than

  cmpq 0, MemRef

and is typically interchangable.

While looking for test*s to change, I noticed that we always
do ConvObjToBool, even when we know the Class statically, and know
that the result is going to be true. So added a case to the simplifier.

Reviewed By: @elgenie

Differential Revision: D1109374
Don't redefine ENABLE_GD_TTF if defined

Squashes a warning when building on OSX

Reviewed By: @ptarjan

Differential Revision: D1109786
Use PRId64 instead of ld for uint64_t

Building on OSX warns about ld

Reviewed By: @edwinsmith

Differential Revision: D1109785
Minor refactor of how non-constant hhbbc options are set

The only option that's actually runtime settable right now is
the list of fb_intercept-able functions.  I'm going to want more of
these soon, but the way it was set up was slightly annoying.

This isn't great still---it just moves the place we propagate options
closer to compiler_main.  We don't want these options to actually
exist in Compiler::Option because otherwise we'd have to merge
libhhbbc.a with libhphp_analysis.a, and they don't really fit in
RuntimeOption either.  (Eventually I'd like to just have another
main() for hhbbc with its own option parser---this would also make it
easy to repeatedly run hhbbc on a repo while developing, without
redoing the rest of the production build.)

Reviewed By: @dariorussi

Differential Revision: D1113886
Strengthen checkTmpsSpanningCalls()

Replace preorder walk over dom tree with bottom-up postorder walk,
and merge state along edges.  This catches more violations.
Also, add ContEnter, ignore TakeStack, and StkPtr-typed tmps.

Reviewed By: @swtaarrs

Differential Revision: D1114191
Remove TakeStack instructions after optimizeRefcounts()

They are essentially Nops, inserted to preserve information
from the simplify pass.  They aren't needed anymore after
refcount optimizations; convert them to Nop so dce cleans
them up.

Reviewed By: @swtaarrs

Differential Revision: D1114262