Kill unnecessary t___construct() methods

Summary: The t___construct() methods were required by hphpc (it would not compile
without them). Since these methods were declared as private, they were
unreachable. The root class of all WaitHandles still defines constructor
as private, which should in theory stop invalid attempts to construct
objects. In practice, it doesn't (and didn't) help, as HHVM tries to build
object first, then decide whether constructor can be called and when
not, destroy the object. That doesn't work well with extension classes,
as they often cannot handle weird state in their destructor. This this
does not have any effect on this behavior and is completely orthogonal.

Also, __construct() was kept in StaticWaitHandle and
ExternalThreadEventWaitHandle due to a buggy design of gen-ext-hhvm,
which emits constructors and destructors only if there is at least one
method. Fix of that bug is out of scope of this diff.

Reviewed By: @billf

Differential Revision: D1346810
Introduce ResumableWaitHandle

Summary: Async generators are going to introduce another type of WaitHandle that
can be resumed and requires queueing/scheduling facilities of
AsioContext. Let's abstract that away into ResumableWaitHandle.

Reviewed By: @billf

Differential Revision: D1346825
Introduce AsyncIterator interface

Summary: Introduce AsyncIterator interface that will be implemented by
AsyncGenerator.

Reviewed By: @jdelong

Differential Revision: D1346800
Avoid unnecessary writes to AsyncFunctionWaitHandle::m_child

Summary: AsyncFunctionWaitHandle::m_child contains valid pointer only in
STATE_SCHEDULED or STATE_BLOCKED. This pointer was checked for null only
in the constructor when were were in one of these 2 states. Kill this
check as it always succeeds.

Do not set m_child to null when transitioning to STATE_SUCCEEDED ot
STATE_FAILED, or when constructing the wait handle -- the value is set
in initialize().

Reviewed By: @jdelong

Differential Revision: D1346943
Make ob_clean and ob_end_clean call handler

Summary: fixes facebook/hhvm#2723

Reviewed By: @ptarjan

Differential Revision: D1346965
collections: expose reserve() for Set and Map

Summary: ... it's already exposed for vector. This might make sense to
 expose for **all** collections: should Imm{Vector|Set|Map}
 noop reserve, or perhaps throw exceptions?

Reviewed By: @paroski

Differential Revision: D1328988
collections: add (Imm)Vector::fromKeysOf

Summary: To eliminate the intermediate array allocated as part of the
 ##new Vector(array_keys($x))## pattern. While ##keys## exist on (some)
 of the collection types, arrays don't have methods, and ##keys##
 doesn't know when an immutable is required. This also provides for
 symmetry with sets ({D1328928})

Reviewed By: @billf

Differential Revision: D1328932
collections: Set::addAllKeysOf

Summary: Straight-forward replacement for ## $set->addAll(array_keys($something)) ##.

Reviewed By: @billf

Differential Revision: D1336533
Fix OSS build as a result of memcached HNI conversion

Summary: Fix forward declaration compilation error given by gcc in open source

Reviewed By: @fredemmott

Differential Revision: D1346695
jit: always native_call {Class|Trait|Interface}Exists helper

Summary: ... instead of punting to the interpreter when we can't
 determine type information. The builtin version we end up calling
 (string) and (bool) casts the name and autoload params, which
 bytecode can do just fine.

Reviewed By: @jdelong

Differential Revision: D1337358
make {Class|Trait|Interface}Exists a single bytecode

Summary: ... it might've made sense to make three IR opcodes for these
 three cases, but having three bytecodes that are exactly the same
 is excessive.

Reviewed By: @jdelong

Differential Revision: D1343606
Cleaned HipHop prefix in error messages

Summary: I don't want to bust out a rap when I encounter an error ;-)

Also changed `Recoverable Fatal error` to `Catchable Fatal error` so it matches php
Closes #2747

Reviewed By: @fredemmott

Differential Revision: D1346698

Pulled By: @JoelMarcey
Only define SID when needed

Summary: SID was defined regardless if there was a session or not. PHP only defines it if needed, so should we

Fixes #1915
Fixes #2705

Reviewed By: @fredemmott

Differential Revision: D1337456
don't rely on SplPriorityQueue::__construct being called

Summary: Closes #1695

Reviewed By: @fredemmott

Differential Revision: D1342533
Fix pcre cache to not fatal when full

Summary: So pcre cache can only hold 96x1024 items, when we hit full we raise an
error. From what I can see there isn't a good reason we can't just
continue.

If one is doing 98,304 unique regular expressions you probably don't
care about regular expression caching.

Since we're using AtomicHashArray we can't purge anything without adding
a lock and we'd probably want to do LRU rather than what PHP does which
is FIFO eviction.

Also changed the code to check Folly's full parameter rather than
relying on calling .size().

Reviewed By: @ptarjan

Differential Revision: D1168192
Optimize checks in iter_next_packed also

Summary: I realized I could play the same trick as D1340787 for
iter_next_packed.

Reviewed By: aravind

Differential Revision: D1343589
Create a CodeGenFixups class

Summary: Create a CodeGenFixups class, to hold temporary information that will eventually be put in global tables. Put m_pendingFixups, m_pendingCatchTraces and a newly created m_pendingJmpTransIDs there.

The goal is to have a single place to hold information that may need to be fixed up if we modify the generated code before committing it (eg by relocating it, or by peephole optimizations). Also, these are things that must not go into the global tables if we end up rolling back.

Reviewed By: @ottoni

Differential Revision: D1347532
Fix clang build

Summary: thats it

Reviewed By: @dariorussi

Differential Revision: D1348180
Get rid of SmashTarget

Summary: The SmashTarget is a short lived, malloced data block that gets passed
to handlePrimeCacheInit, telling it how to smash the call. The information it
contains is the address of the movq instruction that needs smashing, and the
return address of the handlePrimeCacheInit method.

We can find the return address by inspecting the stack, and then we can
pass in the offset from that to the movq instead of passing in the address
of a SmashTarget.

In addition to avoiding the malloced data, this has the nice effect of making
all the code position independent too.

Reviewed By: @mxw

Differential Revision: D1348201
Fix crash on missing trait in RepoAuthoritative mode

Summary: At some point we stopped checking up front that
traits exist in RepoAuthoritative mode. But we still assume
that Unit::lookupClass will find them, and crash if not.

This checks every trait, and fatals if it doesn't exist.

Reviewed By: @dariorussi

Differential Revision: D1348353