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
VirtualHost.<name>.Pattern matches host not paths

This allows Patterns with a leading ^ to match.

Pattern ^www.example.com$

Closes #1463

Reviewed By: @markw65

Differential Revision: D1114114

Pulled By: @scannell
Fix preg_quote not escaping dashes

Fix preg_quote not escaping dashes

Closes #1440
Closes #1441

Reviewed By: @elgenie

Differential Revision: D1111976

Pulled By: @scannell
In FastCGI the server address could not be set

Due to a bug in the FastCGI server the start up of the server with
a specific IP address was not possible.
Example:
hhvm --config /etc/hhvm/server.hdf -m server -vServer.Type=fastcgi -vServer.IP=127.0.0.1 -vServer.Port=9100

Before bugfix:

netstat -tulpen|grep 9100
> tcp6       0      0 :::9100                 :::*                    LISTEN
After bugfix:

netstat -tulpen|grep 9100
> tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN

Closes #1467

Reviewed By: @ptarjan

Differential Revision: D1114159

Pulled By: @scannell
If HttpServer can't bind ports, go directly to _Exit(1)

Apparently this code was just returning while leaving a bunch
of threads running, which is pretty bad.

Reviewed By: @markw65

Differential Revision: D1111881
apc_inc/dec should return false on failure

Return false instead of 0 when failure occured while calling
apc_inc or apc_dec.

Closes #1472
Closes #1473

Reviewed By: @dariorussi

Differential Revision: D1114169

Pulled By: @scannell
Fix memory leak in pdo_parse_params

Fixed memory leak after executing PDOStatement::execute() with bound parameters. Also removed unnecessary copying of result query string.

Test case (I don't know whether it can be tested with Travis because it requires MySQL connection):

<?php
$pdo = new PDO('mysql:dbname=test;host=localhost', 'root', '');
$data = str_repeat('a', 1000000);

for ($n = 0; $n < 50; $n++) {
    $stmt = $pdo->prepare('SELECT :data = 1');
    $stmt->bindValue(':data', $data);
    $stmt->execute();
    $stmt = null;
    echo sprintf("%dM\n", memory_get_usage(true) / 1048576);
}

Closes #1459

Reviewed By: @ptarjan

Differential Revision: D1113187

Pulled By: @scannell
Fix spurious conversion notice in method_exists

Arrays can't possibly pass a method/class check as they convert
to array (a reserved keyword) so don't bother toString-ing in that case.

Closes #1475

Reviewed By: @ptarjan

Differential Revision: D1114192