Fix OSX warning

Summary: Fix incorrect printf flag that generates warning on OSX

Reviewed By: @ptarjan

Differential Revision: D1353078
take get_next_char() from php5

Summary: Closes #2775

Reviewed By: @fredemmott

Differential Revision: D1353935
Add some hhir docs to hackers-guide, move Type information from ir.spec

Summary: This adds a few more lines about the HHBC -> HHIR translation process
and ports the ir.specification section about Type to hackers-guide. It wasn't a
straight cut & paste: I changed some of the notation and wording to be more
consistent with its new surroundings.

Reviewed By: @edwinsmith

Differential Revision: D1349713
Refactor event hooks

Summary: - split FunctionEnter into FunctionCall and FunctionResume
- split FunctionExit into FunctionReturn, FunctionUnwind and FunctionSuspend
- propagate fault explicitly all the way down to FunctionUnwind
- simplify FunctionReturn related hacks (no opcode checks, no try/catch)
- do not try to intercept FunctionResume (it doesn't make much sense, we were lucky not to crash there before)
- FunctionReturn always reports returned value (i.e. not Generator or WaitHandle)
- exceptions are reported only via FunctionUnwind (i.e. not when exiting destructor that did not fail but happened to be executed during unwinding of other exception)

Reviewed By: @markw65

Differential Revision: D1351093
Re-enable CheckSurprise on FunctionExit

Summary: After recent refactorings, it's safe to throw exceptions from
FunctionExit. So, let's give CheckSurprise a try. If we do it as the
first thing, it will take care of pending exceptions and we don't need
to check them.

Reviewed By: @markw65

Differential Revision: D1351116
setup the machinery for ini_get to work

Summary: This introduces a new api, `Config::Bind` which takes the param by reference instead of returning the value. This way we can remember the location for future `ini_get` calls.

This diff doesn't move any of the api users over, I want to do that in smaller chunks so they are easier to revert if they cause issues since they'll be read pipeline chanes.

Reviewed By: @fredemmott

Differential Revision: D1348849
Don't duplicate the dispatch loop just for RetC profiling

Summary: For the interpreter-based warmup profiling, we just call
shouldProfile() in each bytecode's implementation. I see no reason why RetC
should be any different.

Reviewed By: @edwinsmith

Differential Revision: D1350436
Ref-count fixes for async functions

Summary: CreateAFWH does not consume locals anymore. The instructions
that do the copying: StCell and CopyCells consume the local
references.

StCell already consumed its input. Howevever, if its input came
from a LdLoc from before the CreateAFWH, then CreateAFWH would consume
the local input, and StCell woudl have no references to consume.

Reviewed By: @jano

Differential Revision: D1353625
Have the unknown flag error be called

Summary: Closes #2793

Reviewed By: @ptarjan

Differential Revision: D1354089

Pulled By: @JoelMarcey
Fixed flags clang to (-Os) optimized indents #2717 #2756

Summary: Fixed flags clang to (-Os) line: 15-16
referenced #2717 and #2756
Closes #2796

Reviewed By: @ptarjan

Differential Revision: D1354547

Pulled By: @JoelMarcey
RecursiveIteratorIterator->rewind() should not call endChildren() every iteration

Summary: Fixes (at least) a bad zend test
Closes #2790

Reviewed By: @fredemmott

Differential Revision: D1352904

Pulled By: @JoelMarcey
Convert AsyncFunctionWaitHandle related event hooks to use onFunctionExit hook

Summary: We are checking all these hooks on the hot path. Move them to work via
onFunctionExit hook.

Reviewed By: @billf

Differential Revision: D1347878
Prepare child for establishing dependency from within Await opcode

Summary: When awaiting a WaitHandle from resumed async function, the child
WaitHandle must be prepared for establishing dependency:

- if the child WaitHandle is not associated with the currently running scheduler, it must be imported; this will throw if cross-scheduler cycle is formed
- a cycle check must be performed

This preparation is currently done after await returns back control to
the scheduler. If an exception occurs, the failing await is resumed and
exception rethrown.

Let's do this from within the Await opcode so that in this unlikely
case, unnecessary reentry is saved. What is perhaps more important, this
brings us closer to avoiding unnecessary scheduler reentries.

Reviewed By: @billf

Differential Revision: D1347381
Refactor parent wakeup

Summary: Once a WaitHandle is finished, it needs to wake up all its parents.
Obtain pointer to the parents before the result is set (so that we can
union m_resultOrException with m_firstParent+m_nextParent).

We can't move m_firstParent to the union yet because RetC opcode sets
result before giving the control back to the scheduler.

Reviewed By: @billf

Differential Revision: D1348077
Return Variant() instead of converting from String

Summary: Save a tiny bit of work by returning Variant() when we return
String nulls which are just going to get converted to init_null anyway.

Reviewed By: @markw65

Differential Revision: D1354288
Fix var_export for empty objects

Summary: fixes facebook/hhvm#2798

A default-constructed HPHP::Array is uninit null until something is added to it - so don't use the default constructor

Reviewed By: ptarjan, liranuna

Differential Revision: D1354510
Undo AUnused if translation fails

Reviewed By: @markw65

Differential Revision: D1351976
Rename AStubs -> ACold and AUnused -> AFrozen

Reviewed By: @ottoni

Differential Revision: D1343230
Fix server-mode tests, add -vEval.JitRequireWriteLease

Summary: Without the RequireWriteLease option, many of the tests are just
skipping the JIT entirely because they can't get the write lease. And a recent
change to how config files are handled was disabling server mode for all tests.

I also changed it to rerun a test in CLI mode if it fails in server mode. I'm
seeing occasional crashes (real bugs that I have yet to debug) that are
truncating the output for concurrently running tests without making the curl
command fail. Re-running the test in CLI mode will eliminate these spurious
failures, at the expense of masking some tests that are truly broken in server
mode. The verbose output indicates when this happens to allow some kind of
visibility into it.

Reviewed By: @markw65

Differential Revision: D1349388
Union m_resultOrException with m_firstParent+m_nextParent

Summary: Update RetC to load m_firstParent before setting m_resultOrException.
Union m_resultOrException with m_firstParent+m_nextParent and save 16
bytes per BlockableWaitHandle object.

Reviewed By: @billf

Differential Revision: D1348095