Fix closure var_export

Summary: Just export the name of the class to avoid infinite recursion.

Fixes #4176

Reviewed By: @fredemmott

Differential Revision: D1668260

Signature: t1:1668260:1415405711:bc1f17b7b39fc980cdff4ae8a4637fcdee085784
If there is no socket error, return an empty string

Summary: Right now we return `NULL`. PHP 5.x returns an empty string. Let's be compatible.

Fixes #3066

Reviewed By: @markw65

Differential Revision: D1668138

Signature: t1:1668138:1415410047:7339d837f79e4bda755cf5cbc2d8c716b5635c19
ftell() for sockets shouldn't be supported. So always return 0.

Summary: Right now, for sockets, we return the number of bytes written to the socket when we call
`ftell()`. But this shouldn't be the case.

See ESPIPE ... http://pubs.opengroup.org/onlinepubs/009695399/functions/ftell.html

PHP 5.x returns 0 when calling `ftell()` on a socket, so that's what I propose we doo.

This is a one line change, which can be the scariest. :)

Let me know if I am off base, but this does fix an HHVM OSS issue.

Fixes #3018

Reviewed By: @sgolemon

Differential Revision: D1668651

Signature: t1:1668651:1415413974:5c040e68e2b4ca1f7a206eef6eca35f54eac12b0
Test runner should print correct options to re-run failing tests

Summary: We were just printing `test/run <testname` even if options were provided. This fixes that.

Fixes #3916

Reviewed By: @paulbiss

Differential Revision: D1665442

Signature: t1:1665442:1415498351:98ea82d6286410ea07a28e4c7641bce59848fdd2
Updated the package version in CMakeLists.txt

Summary: This should be `3.4.0` in the 3.4 branch.
Closes https://github.com/facebook/hhvm/pull/4181

Reviewed By: @JoelMarcey

Differential Revision: D1669153

Signature: t1:1669153:1415514126:b9abcf702f328ac51c6ead9966b5d43238d788fe
Move MInstrState from C++ stack to RDS header

Summary: Move MInstrState to be with the other VM registers in the RDS header,
rather than reserving space for it on the native stack in enterTCHelper. This
is one step on the way to allowing arbitrary rsp manipulations during
tracelets. I also removed MInstrState's tvVal and tvResult members since
they've been unused for a while.

Reviewed By: @jasone

Differential Revision: D1665434
Only ignore hashbang line in cli mode

Summary: @​see https://github.com/php/php-src/blob/master/sapi/cli/php_cli.c#L606
Closes https://github.com/facebook/hhvm/pull/4183

Reviewed By: @JoelMarcey

Differential Revision: D1669155

Signature: t1:1669155:1415548679:cbc90bcbd8331cd54018590dab2747f7d6a28813
Improve fix for issue #4111

Summary: Closes https://github.com/facebook/hhvm/pull/4180

Reviewed By: @JoelMarcey

Differential Revision: D1669151

Signature: t1:1669151:1415548684:b89950d6e0f02fa8a4fc4bc0a9b17d4fb5835a07
issue,4156: xml skip white option also skips new lines'\n' charachters a...

Summary: ...s well,By avoiding this php and hhvm now behave the same.
Closes https://github.com/facebook/hhvm/pull/4185

Reviewed By: @JoelMarcey

Differential Revision: D1669156

Signature: t1:1669156:1415548942:aee891116a06f9eedc66c65ca4491785b3e0c443
Fix fribidi dependency includes

Summary: Fribidi depends on glib, but we're not adding the header file include dirs into our paths.  This makes cmake find glib for us.  Without this, the build fails to find glib.h (on gentoo) and halts.
Closes https://github.com/facebook/hhvm/pull/4187

Reviewed By: @JoelMarcey

Differential Revision: D1669177

Signature: t1:1669177:1415549048:7bff25565005cd0ec28326c41e48f561f5061775
GetPrimaryIP is IPv4 only

Summary: GetPrimaryIP uses gethostbyname which is IPv4 only.  Now we cache
both the IPv4 and IPv6 address of the host so SERVER_ADDR can be set based
on the request being made.  Without this change, $_SERVER['SERVER_ADDR']
on IPv6 only hosts would return the hostname instead of an ipaddress
for xbox-server and libevent-server.  Unfortunately with libevent-server,
access to the remote client fd would allow getting the server's
address, but it is not, so use this hack for now.

Also, retire safe_inet_ntoa in favor of folly:IPAddress

Reviewed By: @bmatheny

Differential Revision: D1658651

Signature: t1:1658651:1415566504:ab034dbef2e19613b4d1fc14899c4df852158e96
Don't leak HashContexts

Summary: HashContext is allocated via the global operator new,
and it contains a std::shared_ptr, so we need the default
sweep behavior, which is "delete this".

Reviewed By: @bertmaher

Differential Revision: D1668713

Signature: t1:1668713:1415417867:13da80e72cce887104b547e737fbbd37fcbd52cc
Initial support for "$obj->:xhp-attr" syntax

Summary: This diff adds initial support for "$obj->:xhp-attr" syntax. As a first
step, this syntax will desugar to "$obj->getAttribute('xhp-attr')" to
support using the new "$obj->:xhp-attr" syntax to read attributes from XHP
objects.

Future plans include supporting "$obj->:xhp-attr" syntax for writing to
attributes on XHP objects and incorporating XHP attributes more with the
core runtime (ex. storing attributes inline inside the object similar to
normal object properties), but this will come later.

Reviewed By: @elgenie

Differential Revision: D1641268
Fix bug with "list($this) = .."

Summary: In some cases, trying to assign to "$this" via list assignemnt can cause
HHVM's bytecode emitter to encounter errors. This diff fixes the bytecode
emitter errors and makes HHVM match PHP5's behavior.

Reviewed By: @elgenie

Differential Revision: D1667214

Signature: t1:1667214:1415391466:d4ca1852a2ddc3ac560949d049f27c8c55c40b83
Remove unnecessary wrapper functions from ext_collections

Summary: Now that HHVM doesn't use the mangle map scheme for extensions defined in
.idl.json files, we can eliminate a bunch of unnecessary wrapper functions
in ext_collections.

Reviewed By: @jdelong

Differential Revision: D1665279

Signature: t1:1665279:1415492122:752981f56cace95bed4163612ca6710bf1fded46
Don't use Sweepable for APCLocalArray

Summary: Keep track of APCLocalArrays using a dedicated list in MemoryManager,
similar to how we track APC strings. This makes APCLocalArray not
use Sweepable, which devirtualizes it and reduces sizeof from 64 to 40.

Reviewed By: @jdelong

Differential Revision: D1669231

Signature: t1:1669231:1415548069:e617e85f2866d031f9dc313ccc69420d3d19f3ba
Add thread type and pagelets started functions

Summary: Caveat: I have close to no idea what I'm doing here. Don't
hesitate to tell me if everything is wrong, ugly, or will explode.

Add some very basic instrumentation around pagelet requests.
Currently we don't have any idea how many pagelets a request starts or
(AFAICT) a way to tell whether a request is a pagelet, besides looking
for PHP implementation details like parts of the request query string.

1) ##hphp_thread_type()## -- what kind of thread is this request running
in? Returns an int from ##enum class ThreadType## or -1 if we can't work
it out. There is an existing function (##getThreadTypeName()##,
https://fburl.com/65216334) but this returns strings with spaces, which
are a pain for dyno logs.

2) ##pagelet_server_tasks_started()## -- return the count of pagelets
started in this request. I didn't do this in PHP as there are already
two places in which we start pagelets (GraphBatchAsyncWorkItem and
PageletServerFuture) and two places in HHVM to start pagelets
(pagelet_server_task_start and fb_gen_pagelet). Instrumenting the server
is easier than making sure all the callsites in PHP track this.

I added both of these as functions and not access log parameters so we
can easily add them to xenon and other profilers.

Reviewed By: @bertmaher

Differential Revision: D1667021
Add pcntl_sigprocmask

Summary: fixes facebook/hhvm#4160

pthread_sigprocmask seems most correct given HHVM's model, however for both PHP-FastCGI and HHVM, the mask will leak cross-request

Reviewed By: @paulbiss

Differential Revision: D1667740

Signature: t1:1667740:1415399505:d7edad8e22ba9c8063800c98adf284ffe886f360
Use Func::destroy to clean up elements of the pseudomain cache

Summary: Funcs in the pseudomain cache are allocated by clone -- it seems like
they should be deallocated by destroy, rather than just deleted.  (ASAN
complains about the mismatch between malloc'ing the Func and deleting it.)

Reviewed By: @markw65

Differential Revision: D1668805

Signature: t1:1668805:1415417063:efd7495176f15d82660cd10037d5a0d54b52588c
Embed HNI in runtime_test

Summary: runtime_test currently only contains systemlib. We need to also include all the HNI extensions. This is blocking DateTime + collection HNI conversion.

Reviewed By: @sgolemon

Differential Revision: D1668323