Add bounds checks so that PDO doesn't try to get a column that doesn't exist

Summary: Fixes "Fatal error: Unexpected object type Unknown." errors when calling
fetchColumn() with an invalid column number"

Closes https://github.com/facebook/hhvm/pull/4400

Reviewed By: @JoelMarcey

Differential Revision: D1724093

Signature: t1:1724093:1417921026:3564604feca0969908bc2dedb26098c1397a44b3
Fix some bugs when CreateCont's FunctionSuspendHook throws

Summary: When the JIT is on, it leaks the continuation object.  With or without
the JIT on, it was tearing down a frame had already been teleported to the heap
(e.g. the ExtraArgs struct).  (With EnableObjDestructCall on this should
presumably be able to segv by double-freeing---but barring that I'm not sure
how the generator would be reachable yet.)

Unfortunately fixing the leak confuses refcount opts into thinking there /is/ a
leak.  I'm not sure whether we still inline "outer generator" functions---if
not it's not worth running refcount opts in any translations that contain
CreateCont.  Even if we do, we have way fewer generators than we used to, so
let's just give up on the pass when we see this opcode.

Reviewed By: @swtaarrs

Differential Revision: D1709115
Fix suspend hook during Yield and YieldK

Summary: Check the surprise flags before we do anything else, so we don't need
the unusual catch block usage.

Reviewed By: @bertmaher

Differential Revision: D1709193
Use makeExitSlow in binaryArith, SetOpL, IncDecL

Summary: It was doing the same thing manually.

Reviewed By: @alexmalyshev

Differential Revision: D1709117

Signature: t1:1709117:1417241570:6e3a63ba1bce8030fdd51b05f6d1fbf0ef8129a6
Restructure FPushCtor{,D} to not use unusual catch blocks

Summary: Also makes it raise errors in the same order as the interpreter.

Reviewed By: @alexmalyshev

Differential Revision: D1709254
Remove catch blocks that pass 'extra spills' to makeCatch

Summary: The makeCatch with extra spills is suspect, because if you spill to a
different depth than your marker, the unwinder won't see the values.  After a
bit of digging around, the current use cases started to make some sense to me,
though: it looks like we're mostly using this trick to tell things to the
refcount validator about what values are consumed on the catch (and in the case
of FPushClsMethod it's actually kinda to lie to it, because the stores it sees
are not actually visible to the unwinder, because they're below the top of the
stack, and we actually do end up with a mismatched stack depth after its
SpillStack).

I don't think that this diff is a fundamentally better way to do this vs doing
this work in catch traces somehow.  And I could also imagine us switching back
again later if we change things so we always re-enter at the maxStackCells
depth (so we don't need the special updateMarkers when we're using prelive
actrecs before advancing bcOff, among other things).  Also, after this change
the unwinding code here is still much more subtle than I'd like (although maybe
in slightly fewer ways---since only the updateMarker/arPreliveOverwriteCells
mechanism is going on now).

But I think that there are a couple things to recommend the change for now,
though: the fact that sometimes the makeCatch 'extra spills' made things
visible to the unwinder and sometimes it didn't seems too surprising---either
it should always work or we shouldn't have it---so this diff removes the whole
mechanism; putting these stores in C++ should save a marginal amount of
generated code size in unwind blocks (meh); and most relevant for what I'm
doing: making these catch blocks 'simple' fits them more easily into the
automatic-generation of catch blocks thing, which we need to make catch block
in-states (except stacks for now) always come from right before the
instructions that actually can throw.

Reviewed By: @markw65

Differential Revision: D1709295
Remove NewPackedArray (and fpushCufArray optimization), neither happen anymore

Summary: This code is dead, since NewPackedArray is now only used for arrays
larger than kPackedCapCodeThreshold (which is huge).  We probably should
consider reimplementing the fpushCufArray optimization to work with the new
InitPackedArray scheme (we may need to add some kind of BlessPackedArray opcode
to bag up the values if we want to do the optimization at parse time still).
That seems kinda like a lockdown thing---I will make a task and reference this
diff as a starting point/reference if folks are ok with removing it for now.

Reviewed By: @markw65

Differential Revision: D1709296

Signature: t1:1709296:1417725906:8315ff5dbeb5ff536575d253e1e626294633e5f1
Only compile ClsCnsD into literals for persistent classes

Summary: If the class is not persistent or a context parent, we're most likely
in non-repo mode (sandboxes), where this could lead to code that always
side-exits if you're editing the file that defines the class.  Mainly removing
this is just to simplify the code though (this code path is difficult to test
and shouldn't buy anything for repo mode, so let's remove it).

Reviewed By: @bertmaher

Differential Revision: D1709411

Signature: t1:1709411:1417642010:81e0c256e305d96559e94bf4c5388397caaa8312
Make ClsCnsD use irb->ifThen instead of its "special side-exit" block

Summary: I think we didn't have ifThen yet when I first added this makeSideExit
junk to ClsCnsD.  This does the same thing, but is simpler.  That DelayedMarker
crazy-stuff can go away too.

Reviewed By: @bertmaher

Differential Revision: D1709418

Signature: t1:1709418:1417500394:13ea94d551c02146a4bb3f8aaabb5189bd4f37d9
Use ifThen instead of makeExitWarn in Div and Mod

Summary: No more need for makeExitWarn.

Reviewed By: @bertmaher

Differential Revision: D1709440
Use ifThen to implement strTestResult exits in ht-minstr

Summary: Simplifies the code in emitSideExits.

Reviewed By: @alexmalyshev

Differential Revision: D1709457
Fix bug relating to m_curWhere in ir-builder (by removing m_curWhere)

Summary: When you pushed a block without providing an iterator, it would set
m_curWhere to the back of a block instead of using folly::none, which was
presumably just a bug.  (It breaks things when appendInstruction needed to make
new blocks.)  But apparently nothing needs this curWhere stuff after D1709457,
so instead of fixing it we can just delete it.

Reviewed By: @swtaarrs

Differential Revision: D1709556

Signature: t1:1709556:1417468647:69af083ae52e3645856286a7526d37ad70471d57
Refactor builtinCall code

Summary: A few changes to try to make the code easier to understand; mostly
splitting things into subroutines and a helper class, and removing some
redundancies.  Also changes param coerce exit creation to use ifThen, and not
emit an eager reg sync before the ReqBindJmp (it's unclear why it was doing
that)---instead use makeExit to make the exit.

There is one functional change here that maybe I should undo---this moves part
of the coerce exit from frozen to unused.

Reviewed By: @paulbiss

Differential Revision: D1710649

Signature: t1:1710649:1417817722:6b6966d0c93070b7b7a5c37d13c2a628cb8c62da
Fix some interpreter vs. jit discreptancies for builtin call decref orders

Reviewed By: @markw65

Differential Revision: D1713937

Signature: t1:1713937:1417568877:a05259e8ab8e3d4f44d23d7b2b27a1473cf498e5
Refer to APCLocalArray as Apc rather than Shared

Summary: Rename "Shared" to "Apc" in various enums and method names.

Reviewed By: @jdelong

Differential Revision: D1724306

Signature: t1:1724306:1417979602:39e36af15309e215c53da2209a373bac96add171
Moved UserFile casting error back to sock_array_to_fd_set().

Summary: Moved UserFile's fd casting error back to sock_array_fd_set() function
to fix two errors in vfsstream's framework test -
vfsStreamWrapperSetOptionTestCase::setBlockingDoesNotWork and
vfsStreamWrapperSetOptionTestCase::removeBlockingDoesNotWork,
which is introduced in commit 17e0756.
Closes https://github.com/facebook/hhvm/pull/4401

Reviewed By: @JoelMarcey

Differential Revision: D1724140

Signature: t1:1724140:1418002744:d68376b4ccff6183c90b10f91f72fc98974f68d7
Name of DateTime extension should be date

Summary: `extension_loaded("date")` should be `true`
`extension_loaded("datetime")` should be `false`
Fixes #4403

Reviewed By: @paulbiss

Differential Revision: D1724162

Signature: t1:1724162:1418000963:d4dd6b8ab074ec07fb3e896fcbad6153d22b39a3
Add 64-bit packing and unpacking

Summary: PHP 5.6.3 added 64-bit flags for packing and unpacking. It was noticed that we
haven't supported this yet. So now we are.

Fixes #4296

Reviewed By: @paulbiss

Differential Revision: D1696014

Signature: t1:1696014:1418001230:10f4fe28b4ced5d925d254b256dd209bbc6068b0
Update vfsstream to v1.4.0

Summary: Update framework test to use vfsstream v1.4.0.
Remove vfsStreamWrapperWithoutRootTestCase from blacklist.
Closes https://github.com/facebook/hhvm/pull/4402

Reviewed By: @JoelMarcey

Differential Revision: D1724142

Signature: t1:1724142:1418011683:f757f792574d0e886129375d8edd821a9f6388da