EZC: Fix copying of ProxyArray

Summary: 342b1193 introduced several bugs into ProxyArray::Copy and the handling
of "copy" parameters in handlers. I did not realise that Copy() gives a
refcount of zero whereas Make() gives a refcount of 1, and so I
introduced a lot of different ways to get invalid refcounts out of EZC.

* Revert the change to ProxyArray::Copy()
* When a handler is called with copy=true, take this as an opportunity
  to deproxy the array, since the EZC layer itself has no such calls.
  Prior to 342b1193, these handlers just had assert(!copy).
* Revert the change to the first half of ProxyArray::PlusEq()
* In zBoxAndProxy(), incref the result of copy() before decrefing the
  source, to avoid releasing the ArrayData when copy() returns the same
  pointer instead of making a copy. A comment array-data.cpp advises
  that this is possible.
* Added an assert to ProxyArray::Make() which previously failed.
* Added a test case which previously failed.
Closes #3049

Reviewed By: @ptarjan

Differential Revision: D1407639

Pulled By: @JoelMarcey
Update gdb/hhvm.py for recent ProxyArray layout change

Summary: Closes #3050

Reviewed By: @ptarjan

Differential Revision: D1407641

Pulled By: @JoelMarcey
collections: Vector::addAllKeysOf

Summary: ... forgot to add this method when adding Set::addAllKeysOf.

Reviewed By: @billf

Differential Revision: D1409650
Remove unused "Cleanup" shutdown function type

Reviewed By: jan, smith

Differential Revision: D1397106
Add a few try/catch blocks in SCOPE_EXITs in the runtime

Summary: Audited all of them to see if any could throw.  Mostly we're doing it
right.  They must always be nothrow because they are implemented as
destructors.

Reviewed By: @jano

Differential Revision: D1397107
Remove some old options (ThrowBadTypeExceptions, ThrowMissingArguments, etc)

Summary: This is apparently an old hphpc thing that deviated from php behavior
(presumably for performance?  Maybe it was part of HardTypeHints?).  Nothing
sets them to true anywhere, and it doesn't really control all the
warnings/exceptions one would expect anymore, so let's delete them.

Reviewed By: @alexmalyshev

Differential Revision: D1401231
Remove InjectedStackTrace runtime option

Summary: Legacy, and always set to true.

Reviewed By: @alexmalyshev

Differential Revision: D1401800
Remove ServerStackTrace runtime option

Summary: Unused.

Reviewed By: @bertmaher

Differential Revision: D1401845
Revert "Fixed casting Closure to Array"

Summary: It was causing a flib test to fail with infinite recursion, but this
wasn't being reported by sandcastle because of a bug in how we reported that
error (being fixed soon).

Reviewed By: @bertmaher

Differential Revision: D1410241
Reduce the number of exception types

Summary: It makes it too hard understand how we handle exceptions.  (Take a
look at handle_exception_helper in program-functions.cpp.)

Some notes:

  - Whenever we constructed a FatalErrorException from ExecutionContext's
    handleError, we apparently computed an extra PHP stack trace from the
    default ExtendedException constructor, and then threw it away.

  - m_handled was unused in Exception.  m_what is weird but I'm leaving it for
    now (it is a bit odd to add a newline character).

  - raise_error's ternary about whether to throw or not if the user error
    handler recovered had no effects, because the error handler wasn't even
    invoked there.  (We don't invoke the error handler on a fatal until after
    the entire eval stack is torn down.)

  - ExitException::ExitCode is a static member, shared across the request
    threads.  This means the exit callback might sometimes get incorrect exit
    codes in server mode if other request threads are concurrently doing Exit
    opcodes.  This looks like it was a hack for CLI mode: because it's hard to
    communicate anything useful to callers of hphp_invoke.  (I will try to make
    that fixable later.)

Stuff for later:

  - ParseTimeFatalException and AnalysisTimeFatalException probably have no
    reason to derive from Exception, but I'm not sorting that out yet.

  - FatalErrorException, ExtendedException, and Exception probably should all
    be combined into one class, but it requires sorting out 3 remaining
    subclasses (probably an enum is better than our rethrowing stuff).

  - We should stop throwing Object for user exceptions and have another,
    independent, std::exception subclass for that.

Reviewed By: @ptarjan

Differential Revision: D1404996
Remove defaulted args in hphp_invoke and hphp_invoke_simple

Summary: Necessary before possibly modifying hphp_invoke.  It's only slightly
less dangerous after this diff.

Reviewed By: @elgenie

Differential Revision: D1405000
Refactor running psp hooks so it's not part of hphp_context_exit

Summary: Rather than sending a bool into the function---I want to make it
easier to deal with PSP as a separate step so we can possibly change whether it
runs after a request ends with a fatal.  The final defaulted arg was also only
for the PSP code, and the shutdown arg was always passed true.  I am changing
the RPCRequestHandler not to call the post-psp debugger hook because I think it
was probably actually not intentionally doing so (since it doesn't run psp).

Also removed the ExecutionContext* argument: hphp_session_exit seems to be
willing to assume we're doing it to g_context, and I think we can afford the
extra load from TLS.

Reviewed By: @jano

Differential Revision: D1405002
Fix signature compatibility checks for __construct

Summary: Before this diff, HHVM would only perform signature compat checks for
__construct if an implemented interface contained a __construct decl.
This diff fixes HHVM to also perform signature compat checks for
__construct if an abstract parent class contains an abstract __construct
decl.

Reviewed By: eletuchy, ptarjan

Differential Revision: D1409958
argument unpacking: adding FCallUnpack

Summary: Basic functionality for Implementing https://wiki.php.net/rfc/argument_unpacking

 Limitations:
  - no traversal of non-containers (that needs an FPassUnpack)
  - no implementation of multiple calls
  - no FCallD equivalent for determining function exactly
  - no splat calls to functions that have ref params

Reviewed By: andrewparoski, ptarjan

Differential Revision: D1281749
Clear line when reporting no errors

Summary: "No errors!" message overwrites part, not all of, preceding
carriage-returny spinner message displayed during server warmup.
Clear to end of line to make it less visually confusing.

Reviewed By: @aryx

Differential Revision: D1405593
Don't emit UnboxPtr when doing a SetProp with a RAT that's a Cell.

Summary: We already do this for CGetProp, but not SetProp.

Reviewed By: @jdelong

Differential Revision: D1396123
merge in missing LIBJSONC_LIBRARY

This was in our internal repo but not open source for some reason.
sync test changes
Added Twital test suite

Summary: Twital is a small "plugin" for Twig that adds some sugar syntax, which makes its templates similar to PHPTal or AngularJS.
Closes #3067

Reviewed By: @fredemmott

Differential Revision: D1411056

Pulled By: @LiraNuna
Move sucessful tests from zend/bad to zend/good

Summary: This diff is the result of executing two scripts in combination with the output from D1385647.
This script is moving a single file:

  <?php
  $test = $argv[1];
  $dest = str_replace('zend/bad', 'zend/good', dirname($test)) . '/';

  system('git mv ' . $test . '* ' . $dest);

This script simply runs the above script in a loop over the success-list file generated by executing `./hphp/test/run hphp/test/zend/bad`:

  while read test;
  do echo $test
    move_passing $test
  done < ~/passing

Reviewed By: fredemmott, joelm

Differential Revision: D1386355