implement VASM emitTLSLoad for non-fast TLS

Summary: emitGetGContext unconditionally calls into emitTLSLoad(..., ..., Vreg)
which didn't previously exist when fast-TLS was unavailable.
Closes https://github.com/facebook/hhvm/pull/3537

Reviewed By: @edwinsmith

Differential Revision: D1509101
Fix kernel version detection for x.y kernels

Summary: Some version of debian is shipping 3.14-1.

Fixes #3513

Reviewed By: @ptarjan

Differential Revision: D1503114
Implement linearSearch for ConstVector.

Summary: @​override-unit-test-failures

Add linearSearch to Pair, which implements ConstVector.

Reviewed By: @paroski

Differential Revision: D1505950
Limit curl timeout to remaining request timeout

Summary: A request shouldn't be able to curl with a greater timeout than the
request itself.

Reviewed By: @markw65

Differential Revision: D1505729
increase the precision of constants

Summary: I have no idea why we were shortening these. I took the new version from ext/standard/php_math.h

Fixes #3529
@​tarjantest

Reviewed By: @paulbiss

Differential Revision: D1507921
Fix DOMText::split to not error on null object pointer

Summary: It tried to add an orphan even when no DomDocument was set. Also porting bug 52656.

Also add an alias to DOMText::isWhitespaceinElementContent
It was renamed to isElementContentWhitespace in the current wc3 recommendation
See http://www.w3.org/TR/DOM-Level-3-Core/core.html#Text3-isElementContentWhitespace

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

Reviewed By: @ptarjan

Differential Revision: D1506179
Make normalize work for (nearly) all the things

Summary: Our normalize function handled the common case of "AbcDef.GhiJklMno" very well,
where we would end up with `abc_def.ghi_jkl_mno`.

But when it came to something like "SSLPort", we would end up with `sslport` instead
of `ssl_port` or "HHIRNumFreeRegs" would be `hhirnum_free_regs`

This diffs hopefully handles 99.9% of the cases now. We may want to make `-` into `_`
or something (e.g. "xdebug-not-done.enable"). That should be easy and can be done
separately.

Reviewed By: @ptarjan

Differential Revision: D1511106
fbcode: __x__-protect all __attribute__ keywords, mechanically

Summary: The first (and sometimes 2nd) argument to __attribute__
should begin and end with "__". If it does not, then it
is at risk of conflicting with user cpp-defined symbols.
Don't do that.  This change mechanically corrects most
such violations in fbcode.  A companion change (see parent task)
adds a lint rule to help keep things clean going forwards.

Define this function to filter the list of file names to which
we will apply the transformations. First, ensure we modify only
C and C++ sources.  The second process excludes a few directories
that appear to contain third-party code:

  filter() {
    grep -E '\.(c|h|cc|cpp|hpp)$' | grep -vE \
      '^external/|/unbound/|/gearmand_|(3rd|third.)party|/external/libevent'
  }

then, run this command,

  git grep -l __attribute__ | filter \
    | xargs perl -pi -e 's/(__attribute__ *)\(\(( *[^_]\w+)/$1((__${2}__/g'

inducing changes like this, for each such keyword:

  -} __attribute__((packed));
  +} __attribute__((__packed__));

That got all but the __format__ archetype arguments like this:
__attribute__((__format__(printf.  That final "printf"
keyword should have the "__" prefix and suffix, too.

Run this command to transform those remaining uses:

  git grep -l '__attribute__.*__format' | filter | xargs perl -pi -e \
    's/(__attribute__ *\(\(__format__ *)\( *(printf|scanf|strftime|strfmon)/$1(__${2}__/g'

That command induces changes like this:

  -static inline int __attribute__ ((__format__ (printf, 3, 4)))
  +static inline int __attribute__ ((__format__ (__printf__, 3, 4)))

This exercise is useful to avoid spurious name-space conflicts,
especially when the unprotected keyword is used in a header file.

Reviewed By: @Gownta

Differential Revision: D1508983
Fix the warning raised when calling a function with too few arguments

Summary: Fixes #3336.

Well, it doesn't give exactly the same output as PHP does, but now the output is (hopefully) correct.
Closes https://github.com/facebook/hhvm/pull/3347

Reviewed By: @ptarjan

Differential Revision: D1506565

Pulled By: @fredemmott
Support the namespace "namespace"

Summary: This seems pretty weird, since it refers to the current
namespace, but it's easy enough to implement. Also take the opportunity
to fix a comment which was full of lies.

Reviewed By: @elgenie

Differential Revision: D1510411
PHPUnit Updates

Summary: This updates phpunit-selenium from 1.3.3 to 1.4.1, phpunit from 4.2.0 to 4.2.2, and instantiator from 1.1.1 to 1.1.2.
Closes https://github.com/facebook/hhvm/pull/3549

Reviewed By: @fredemmott

Differential Revision: D1511365
Some improvements to the RegionDesc API

Summary: I started with the motivation of making it more efficient to search
arcs incident to a particular block, and then ended up cleaning up
some other stuff as well.

Reviewed By: @edwinsmith

Differential Revision: D1505074
Remove duplicate bindings

Summary: There were cases where we double bound config settings, which is wasteful. I have to imagine these were leftovers that were needed before we had `Config::IniName` and `Config::normalize`.

I left the ones that had custom getters and settings for `IniSetting::Bind`

Also, there are few other stragglers that I am going to look at for another diff. Particularly things like `AssertFrequency` and `WarningFrequency` which have `IniSetting::Bind` at the bottom of `runtime-option.cpp` but also have `Config::Bind` for the same settings towards the top.

Reviewed By: @ptarjan

Differential Revision: D1492543
Fix Freetype to look for ft2build.h first

Summary: In the previous configuration, it would find freetype2 for me, but then fail to #include freetype.h through the macro header include.  In this configuration, it finds ft2build.h goes along happily.
Closes https://github.com/facebook/hhvm/pull/3532

Reviewed By: @ptarjan, @sgolemon

Differential Revision: D1508208
Move shape class constant typecheck from declaration to typing

Summary: The check needs to know about available classes and typedefs so
it can look into class constants and see what the typedef's underlying
type is. This means we needed to have completed declaration before doing
the shape class constant check. However, it was placed directly into
declaration itself, and so was sensitive to the order in which classes
were declared, which is nondeterministic. Instead, move it into typing,
when we know that everything has been declared and is available.

Reviewed By: @gabelevi

Differential Revision: D1512071
hash_equals raises a warning on wrong types

Summary: Also moved all good tests

Closes #3477
Closes https://github.com/facebook/hhvm/pull/3479

Reviewed By: @fredemmott

Differential Revision: D1500295
VASM part 6: generate vasm for the whole IRUnit

Summary: Finish converting all the remaining HHIR cg functions to vasm.
This required copying and specializing codeGenImpl(), so I added
that to the BackEnd api. The code duplication with ARM is unfortunate
but I expect it to be temporary; we'll be able to share a lot more
code again once ARM is converted.

Reviewed By: @alexmalyshev

Differential Revision: D1460418