Collecting APC stats unconditionally, particularly size in order to allow better visibility over APC on production machines and generla APC open source API

Summary: Retrieving any APC info is not possible today on server that run into memory issues. This is the inital diff to make that information more transparent

Reviewed By: @markw65

Differential Revision: D1378696
Print how many ir opcodes are in a unit at high trace levels

Reviewed By: @jdelong

Differential Revision: D1380277
More cleanup in func.h

Summary: Continuation of the previous cleanup diff.  In it, we:

- Finish reorganizing Func and outsourcing definitions to func-inl.h.

- Eliminate methods which use only public interfaces and which are only
  called in one source file, and make them into local helper routines.

- Delete the m_id field from SharedData.  This appears to be the Id of
  the FuncEmitter which created the Func, which is just the index of the
  FuncEmitter in the Unit's stack of emitters.  It's not as obvious
  whether this serves a purpose for FuncEmitter, but it certainly
  doesn't for Func.

- Document more things.

Next steps are:

- Separate out FuncEmitter and FuncRepoProxy.
- Do some cleanup on Class, and maybe Unit.
- Isolate the Class and Func creation logic into a separate module.

Reviewed By: @alexmalyshev

Differential Revision: D1381031
allow context-sensitive usage of enum helper functions

Summary: The Enum functions in www currently use get_called_class() to
 get a string, then that string to look up the class. Instead, make a
 null classname look up the Class* from the ActRec.

Reviewed By: @jdelong

Differential Revision: D1370812
OS X port of Hack

Summary: There are two things that needed to be ported: inotify and libelf. I
would separate them into different diffs, but that would be tricky to test
since both are needed to build.

==FSEvents port of inotify==
The best API I could find for FSEvents works by adding a watch for a file path,
running a run loop, and then executing a callback when something has changed.
Since the run loop is blocking, I spawn a pthread to run the loop. The main
thread and the run loop thread communicate using a couple pipes and some
lockless linked lists.

Why pipes? Well, there is an API to schedule a callback with the runloop when a
FD is ready to be read. Furthermore, the ocaml code needs to be able to select
some other sockets at the same time it is waiting for fsevents.

Why linked lists? Serializing and deserializing the data in the pipes would be
a pain, and this works fine.

==getsectbyname port of the libelf stuff==
For the most part this is straightforward. The one really annoying thing is
that the apple API, `getsectbyname()`, is a little naive in returning memory
addresses. OS X seems to have ASLR on by default, so the addresses returned
cause segfaults (though of course it works in `lldb` since by default debuggers
tend to disable ASLR). My workaround was to sneak a `-no_pie` argument through
to the linker.

Reviewed By: @jwatzman

Differential Revision: D1378021
Make sure bump_pce->extra is nonnull

Summary: https://github.com/facebook/hhvm/issues/2925

Fixes #2925
Closes #2927

Reviewed By: @ptarjan

Differential Revision: D1380876

Pulled By: @JoelMarcey
LookupCnsE needs a catch block

Reviewed By: @alexmalyshev

Differential Revision: D1381275
Fix bug in preOptimizeAssertTypeOp, tighten up typeMightRelax logic

Summary: preOptimizeAssertTypeOp has some logic to avoiding inserting redundant
AssertTypeOps when the source value comes from an AssertTypeOp with an
appropriate typeParam. It was looking at the dest type instead of the typeParam
of the new Assert op and missing out on lots of cases.

typeMightRelax would previously only return false if guard relaxation was off
or if the value was a constant. I've extended it to do the right thing for each
dest type in the opcode table. This prevents us from doing silly things like
keeping around "AssertType<Cell> t4:Str" when t4 comes from a Concat operation.

Together, these two fixes drastically reduce the number of AsssertTypes we end
up emitting into the initial translation. This eliminates some O(n^2) guard
relaxation crap we were running into in the new test. It looks like there's
still something superlinear going on in a different part of the jit so I'll dig
into that next.

Reviewed By: @bertmaher

Differential Revision: D1380326
Add InterpOne support for multiple profile translations with same SrcKey in translateRegion

Summary: We want to support Optimize regions that contain arbitrary
shapes. These regions may be formed from multiple Profile translations
that contain the same bytecode instruction ranges.  The set of
instructions to be InterpOne'd was keyed by SrcKey, and this diff
generalizes it by keying it by ProfSrcKey, which is a pair of
profiling TransID and SrcKey.

Reviewed By: @bertmaher

Differential Revision: D1380158
Fix assert in cse

Summary: The simplifier removes Movs as instruction sources as
it goes along, and as it processes later instructions, it asserts
that this has been done to all previous instructions. But if the
result of simplification is a Mov, and the dst is different from
the input, it would generate a Mov, causing the assert to fire.

Reviewed By: @bertmaher

Differential Revision: D1380875
Fix link.

Summary: Closes #2928

Reviewed By: @ptarjan

Differential Revision: D1381819

Pulled By: @JoelMarcey
Add enum-ish thing for test runner output format

Summary: prep work for fbmake

Reviewed By: @ptarjan

Differential Revision: D1380996
Fix minstrs on KindOfResource bases

Summary: Our switches didn't even have cases for them, so add them in the
appropriate place. Also fail with a better error if something like this happens
again.

Reviewed By: @jdelong

Differential Revision: D1381277
Relocate to arbitrary alignment

Summary: Add more meta data, to allow nops to be stripped, and
padding to be added as originally specified, if we change the
alignment of the code when relocating.

Reviewed By: @jdelong

Differential Revision: D1355815
Eagerly shrink branches

Summary: Eagerly shrink branches as we relocate, as long as we can
prove that the target will be in range.

I decided against trying the optimal solution for now, since its
complicated by the instruction alignment rules. All the necessary
information is available, but I think this will get nearly all the
benefits. Im open to persuasion if anyone thinks differently.

Reviewed By: @swtaarrs

Differential Revision: D1357920
Supports setting compressed value with ext_memcache

Summary: Closes #2929

Reviewed By: @ptarjan

Differential Revision: D1381832

Pulled By: @JoelMarcey
hhi sync for D1365081 and D1362152

Summary: I asked the authors for both of these diffs to sync to fbcode, but
neither did, and the type errors created are blocking D1361818, so I
guess I'll do it.

Reviewed By: campbellmadam

Differential Revision: D1380949
DOMException bug

Summary: DOMException() in zend php doesn't have a separate constructor

Reviewed By: @ptarjan

Differential Revision: D1380837
removing silent_mode

Summary: Silent mode was mostly used by auto-completion to ignore errors.
We are going to change the way the type-checker works and not stop at the first error any more.
In preparation of that diff, I prefer to first remove silent_mode, it makes the rest easier to follow.

Reviewed By: @elgenie

Differential Revision: D1365369
New error system

Summary: This diff introduces a new error system that doesn't throw.
I will adapt the rest of the code in subsequent diffs.

Reviewed By: @jwatzman

Differential Revision: D1372714