Fix ini files based on new normalization

Summary: D1511106 gaves a newer normalization technique. We need to modify some of our ini files
to reflect that.

Reviewed By: @paulbiss

Differential Revision: D1512797
Makes <<__Memoize>> work for top-level functions

Summary: It's a little silly to apply <<__Memoize>> to a top-level function with zero args, but with this diff the attribute can be tagged to every kind of function we want to build for. That way, as I add args it will work for all of them.

For tests, I couldn't actually figure out how to apply user attributes to inline functions without it being a syntax error. If you know how to do it I'll add a test.

While working on this diff I found that locals from the implementation were incorrectly also being emitted as locals in the memoization wrapper. This diff fixes that issue.

Reviewed By: @jano, @elgenie

Differential Revision: D1506790
Remove vasm dead code

Summary: This stuff was needed during transition, but now it's dead.

Reviewed By: @alexmalyshev

Differential Revision: D1513877
Implemented xdebug feature_get and feature_set commands

Summary: This diff implements the xdebug remote debugging commands feature_get
and feature_set. Like the name implies, these allow you to get and set
the features supported by remote debugging.

These are the first commands intended to be sent/received when starting
a debugging session, so these are important. Right now the results are
identical to xdebug (which is a lie because not all features are implemented).

Each command is also considered a feature, so this required me to implement the
stubs for each remote debugging command, which is why this diff is so large.
Most of the code is boilerplate, the most of the added logic is in the feature
get and feature set commands.

In this diff I also move `XDebugServer::initDbgp` and `XDebugServer::deinitDbgp`
into `XDebugServer::attach` and `XDebugServer::detach`. This way commands can
assume `XDEBUG_GLOBAL(Server)` always exists. It was nonintuitive that it
didn't, so I felt this was important for maintenance purposes.

Reviewed By: @ptarjan

Differential Revision: D1502891
Imported xdebug xml variable exporting and implemented xdebug eval + condition breakpoints

Summary: This diff was primarily intended to implement eval and condition breakpoints.
To do so, however, you need to be able to output the resulting variable in
an xml format. So a large part of this diff is pulling in the xdebug variable
xml exporting functions.

The imported code has been heavily rewritten to support hhvm internals, pretty
much only the flow and the function names remain. Tthe code is really ugly,
primarily due to the xml api so I've put added a note to refactor once the
xdebug xml api has been refactored.

I've also only imported the xml related exporting functions. Importing the rest
of the file would take too much time, but it isn't overly difficult. It will need
to be done for xdebug var_dump.@paulbiss is working on importing some other
parts of the file.

This took a while to import, but after this the commands should all fall in
place.

Reviewed By: @ptarjan

Differential Revision: D1507246
Fix XHPROF_FLAGS_NO_BUILTINS

Summary: We were totally ignoring this flag. Add the right checks for it.

I also realized that with EnableRenameFunction off, builtins will never
be profiled because we call builtins via FCallBuiltin, which doesn't do
surprise checks. I documented this behavior in profiling.md.

Reviewed By: @ptarjan

Differential Revision: D1509142
Refactor NativeFuncCaller

Summary: Get rid of the class, and add an int-only specialization.

This is only a minor perf win (~ +0.2%)
but it sets the stage for D1505459 to
not be a horrendous regression (~ -1.0%)
but rather wind up roughly perf-neutral.

Reviewed By: @elgenie

Differential Revision: D1512802
Enable variadics for HNI functions/methods

Summary: Declare a function using the usual variadic syntax with no type

  <<__Native>>
  function foo(int $a, float $b, ...$c): void;

Then take the variadics args as a const Array&:

  void HHVM_FUNCTION(foo, int64_t a, double b, const Array& c) {...}

Profit.

Note that this version does not include FCallBuiltin support,
but since the old IDL version of variadic functions didn't either,
that's not going to make anything any worse.

I think I can add FCallBuiltin support later, but I'd rather
make that a separate diff.

Reviewed By: @elgenie

Differential Revision: D1505459
Convert v?s?printf() to HNI using Variadics

Summary: This helps test D1505459 by actually
exercising the variadic support in Native::callFunc()

Reviewed By: @elgenie

Differential Revision: D1512815
Make DataType covariant

Summary: We want to beable to have `MyThingDataType::at()->impl()` be typed as `MyThingDataType` while having `MyThingDataType::at()` typed as `DataType<Tk, Tv>`.
The solution is to pass `this` out of `::at` so that the return type is `DataType<Tk, Tv, this>`. This allows `impl()` to return the base class. In order to do this I need `DataType` and `DataTypeImplProvider` to be covariant. This diff hacks hack to think they are until we have a better solution.

Reviewed By: @jwatzman

Differential Revision: D1515044
Error numbers

Summary: This diff associates a unique integer with each error.
The error message now includes that error number and the error kind.
There are 4 kinds of errors: Parsing, Naming, NastCheck or Typing.

One can guess the error kind from the error code:
1000 < Parsing errors
2000 < Naming errors
3000 < NastCheck errors
4000 < Typing errors

Reviewed By: @elgenie

Differential Revision: D1514275
Custom path to the installed folder

Summary: Makes it possible selection of configuration folder hhvm, the default folder configuration nailed to the `/etc/hhvm/` but it's only for Linux justified.

ref: facebook/hhvm#3197
Closes https://github.com/facebook/hhvm/pull/3517

Reviewed By: @ptarjan

Differential Revision: D1505433
Add --git-mv,-g option to move_good_tests

Summary: This could ease move good tests, when there are many tests
passed, git don't know that, or I have to do extra work to
commit them
Closes https://github.com/facebook/hhvm/pull/3464

Reviewed By: @ptarjan

Differential Revision: D1502241
Implement APCIterator

Summary: Implement a basic version of APCIterator
I tried to match most of php, but
it does not match php5 completely due to for example not implemented functions.
Inheriting from this class most likely won't exactly match php due to valid() calls in some methods etc.

However this is an implementation that passes all (but one) zend tests and thus matches general php behaviour
It works in all basic usages.

I use apc_cache_info() as the interface between C++ implementation and PHP
That function spits out all the information that our APC implementation has implemented

Currently unsupported is:

 * most of the format flags due to them not being implemented at all in C++
 * * working flags are: type, key, value, mem_size, ttl
 * chunk_size does nothing, because I don't save the data in my class
 * list because not implemented in C++ (I believe)
 * filehits cache not implemented in C++

Closes #406
Closes https://github.com/facebook/hhvm/pull/3443

Reviewed By: @ptarjan

Differential Revision: D1492232
Only emit specialized PackedArrayGet when array may be packed

Summary: Also, make the IR correct by inserting an AssertType after the dynamic check.

Reviewed By: @bertmaher

Differential Revision: D1513530
Fix CVE-2014-3597 Possible segfault in DNS response overrun

Summary: Validate dlen at every turn. Leave no overrun unchecked.

Ref: https://bugs.php.net/bug.php?id=67717

Reviewed By: @ptarjan

Differential Revision: D1512572
Put bytecode control flow on a build flag

Summary: We want to be able to test these via build flags.

Reviewed By: @ottoni

Differential Revision: D1514992
Don't shrink String arguments to trim() in place

Summary: The jit expects to decref the arguments to trim() after the call, and
expects to be able to keep the pointers to the args in callee-save registers
across the call.  This assumption causes a problem in the test case, in which
an argument with a single reference is shrunk in-place during trim.  The shrink
allocates a new, smaller buffer, and frees the old one (because it has a refcount
of 1).  The jit isn't aware of this, and also tries to decref and free the
argument.

This diff fixes the problem by always wrapping the possibly-shrunken StringData
to be returned in a new String.

Reviewed By: @markw65

Differential Revision: D1515837
hphp: avoid potential buffer read-overrun

Summary: * hphp/runtime/ext_zend_compat/php-src/main/network.cpp:
When the source string has length >= bufsize, php_socket_strerror (with
a non-NULL buffer) would fail to NUL-terminate the result buffer. Write
an explicit NUL byte to ensure that.  Currently, no caller of this
function exercises the affected code paths, because the "buf"
parameter is always NULL.

Reviewed By: @ptarjan

Differential Revision: D1463545
Fix int32 overflow in TimeZone::offset()

Summary: There is an integer overflow which is causing garbage to be returned from TimeZone::offset()

Reviewed By: @scannell, @jasone

Differential Revision: D1514780