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