Add WaitHandle::result() method

Summary: Similar to join(), however if the handle is
still pending, result() will throw an exception rather
than block until the handle is done.

Reviewed By: @jano

Differential Revision: D1716446

Signature: t1:1716446:1417642842:987cf32a898a274275ed5793ea37fcc31e14500a
Use make_shared instead of shared_ptr constructor in getLocation

Summary: With ASAN enabled hphp dies trying to build www, with the error:
```
The process has exhausted 8192MB for size class 48.
```

The culprit turns out to be shared_ptr control blocks, since we have a ton of
shared_ptrs. Using make_shared allocates the object and control block in a
single allocation, so it spreads the size classes around.  This is probably a
good change to make everywhere, but getLocation by itself accounts for like 40%
of the shared_ptrs.

Reviewed By: @edwinsmith

Differential Revision: D1716116
PersistentResourceStore only stores SweepableResourceData

Summary: Tighten up the API, remove dead size() method, pass std::strings
instead of c-strings.

Reviewed By: @markw65

Differential Revision: D1715896
Match PHP5 handling of invalid multibyte sequences in htmlentities()

Summary: PHP 5 will skip multiple bytes in some cases when it encounters an invalid byte
in a multibyte sequence.

Fixes #3583

{sync, type="child", parent="internal", parentrevid="1696516", parentrevfbid="1520912944847080", parentdiffid="5819025"}

Reviewed By: @fredemmott

Differential Revision: D1696516

Signature: t1:1696516:1417551745:4e56c4ce4e017c2815a66e55bd082f0d982403c7
Fix some typos and grammaros hphp/doc/php.extension.compat.layer.

Summary: The content still smells as an "as planned" document, rather than as
an "as built" document.
Closes https://github.com/facebook/hhvm/pull/4346

Reviewed By: @​svcscm

Differential Revision: D1707235

Pulled By: @fredemmott
Eliminate some stores in pushVMState

Summary: gcc wasn't able to do this optimization automatically, so it was
writing the VMState object to the stack then copying it to the TinyVector. I also
tried adding emplace_back() to TinyVector and using that, but the generated
code wasn't quite as compact as this solution.

This makes VM reentry cheaper and reduces (but doesn't eliminate) the effect of
D1665434.

Reviewed By: @jasone

Differential Revision: D1713106
Remove extra headers from runtime/base/types.h

Summary: It was pulling in stuff like util/mutex.h and not using them, just kill
them and add new includes to whoever breaks.

Move out FuncIdSet into prof-data.h, which was the only user of
it. I suspect OffsetSet is similar in how it's only used by
region-selection, but that'll be for a later diff.

Also move the litstr comment, it somehow got pushed above the collection
type stuff.

Reviewed By: @edwinsmith

Differential Revision: D1704241

Signature: t1:1704241:1416955147:a78d134d03a8ee04010b68805f050a7fd8be497e
Group fields of File, Socket, and SSLSocket

Summary: Put all the field decls together at the end of the class, reorder
a few of them so they pack better, and simplify initialization
where possible. No functionality changes.

Reviewed By: @jdelong

Differential Revision: D1719063
Remove util/hash-map-typedefs.h include from base/types.h

Summary: Making base/types.h even cheaper. Moves OffsetSet to vm/hhbc.h. Adds
includes of util/functional.h and util/hash-map-typedefs.h where needed.

Reviewed By: @swtaarrs

Differential Revision: D1705088

Signature: t1:1705088:1416963206:fb0d6bae9f22f8b0e2fb6b28406b6fd4bb509927
Register the rest of the Stream constants via HNI

Summary: We only had a few registered. Let's register the rest before tackling some of
the stream issues (e.g. 2146) that exist.

Reviewed By: @nigelchanyk

Differential Revision: D1696698

Signature: t1:1696698:1417565276:75aefb7120331f1284692b405bbf62aa9670e51c
typechecker: move Exception hierarchies to their own hhi file

Summary: ... including adding ErrorException

Reviewed By: @jwatzman

Differential Revision: D1714559

Signature: t1:1714559:1417631878:f0ed4e4590c534692476fed588dc40fde710c1b7
let travis cache packages retrieved via apt-get to speedup built

Summary: see http://docs.travis-ci.com/user/caching/#Caching-Ubuntu-packages
Closes https://github.com/facebook/hhvm/pull/4383

Reviewed By: @​svcscm

Differential Revision: D1719093

Pulled By: @fredemmott
Support for declarations and inheritance

Summary: Type constants is an alternative to using generic type parameters that
is restricted in such a way that Hack can reason about their types
statically. This diff is an initial version that adds support for:

* Initial syntax that will likely change
* Representing these declarations in the named and typed AST
* Type checks around inheritance and extension

In the naming phase there are three checks I want to call out that I
added.

1. Forgetting to assign a type to a non-abstract type constant
2. Attempting to assign a type parameter to a type constant
3. Using a non-local type parameter in the definition of a type constant

I added all of these checks as part of the nastCheck phase

Here are things that I plan on working on in future diffs:
* Creating a new type so Class::Typeconst can appear in typed positions
* Updating error messages specifically around inheritance
* Support for type params
* Allow co/contravariance annotations
* Finalize syntax

Reviewed By: @jwatzman

Differential Revision: D1633644
Cache the hash table in APCIterator

Summary: Original APCIterator calls ConcurrentTableSharedStore::getEntriesInfo(),
which does not really guarantee the same iteration order
even when no insertion/deletion happens. It also has efficiency problems (which
is not addressed in this diff).
With this diff, we should at least have a consistent view if we do not change
the table. Deletion of APC entries matching a regex should work, too.

Reviewed By: @markw65

Differential Revision: D1703741
Remove operator-> from StrNR

Summary: String and StrNR are value types rather than smart ptrs.

Reviewed By: @jdelong

Differential Revision: D1718859

Signature: t1:1718859:1417730320:bed07e3e642404baf1092d14612c99cf0542dd15
Fix the typing of ternary expressions.

Summary: We should not unify the branches directly, but instead wrap
them in a Tunresolved first. This is similar to what we do in
Typing_lenv.intersect.

Reviewed By: @jwatzman

Differential Revision: D1699380
typechecker: SPL file-related hhis

Reviewed By: @vener91

Differential Revision: D1670457
typechecker: ZipArchive hhi

Reviewed By: @vener91

Differential Revision: D1670279
typechecker: Imagick hhi

Reviewed By: @jwatzman

Differential Revision: D1715530
Remove disabled knownPrologue optimization for Call opcode

Summary: It's been disabled for a while, so the code is untested,
We need to do some refactoring of BindCall to enable SSATmps
that can span calls, and it will be easier to do without
worrying about this optimization.

Reviewed By: @jasone

Differential Revision: D1718904

Signature: t1:1718904:1417708381:d8c319e38c6a7830e93fb5975d8de920a30fd8b0