skipif tests should not be in good/

Summary: All of the skipped tests lived in good/ even though they were skipped because they are unsupported (win32, 32bit, etc)

Reviewed By: @ptarjan

Differential Revision: D1471420
Pass InliningDecider by reference in tracelet selector

Summary: We disable inlining and try again if the tracelet gets broken while
still inlining, but the InliningDecider was copied into RegionFormer. We need
to store a reference instead, so the change persists across calls to
RegionFormer::go().

Reviewed By: @mxw

Differential Revision: D1469299
Clean up handling of Obj types

Summary: - Type::operator& wasn't properly combining exact and sub Obj types
- NewInstanceRaw now returns an exact Obj type
- CustomInstanceInit doesn't take a Cls src so being DAllocObj was nonsense
- optimizedCallGetClass was doing different things depending on the opcode the
  object came from, and this was causing behavioral differences between
  inlining analysis and translation. I changed it to do something more generic
  that should be faster anyway, which allows restoring of an assert in
  selectTracelet. It can't be an always_assert like it used to until the
  remaining issues in prod are sorted out.

Reviewed By: @alexmalyshev

Differential Revision: D1469306
Use size_t for string length parameters which are checked against MaxSize

Summary: A common pattern is to reserve space with the ReserveString mode of the
String constructor and then to put data directly into the string buffer
with memcpy() etc. The reserve length was an int, which led to
truncation and exploitable integer overflow for many callers. Added four
test cases demonstrating exploitable heap overflows due to the use of
ReserveString.

There is generally very little performance benefit to using a smaller
type in an argument, since 64-bit alignment is used when passing
parameters on the stack, and 64-bit registers are reserved when passing
in registers. This is in contrast to object storage where there is a
clear rationale for the use of 32-bit types.

So:
* Use size_t for length in all variants of StringData::Make().
* In the version of StringData::Make() which takes a null-terminated
  string with implicit length, do not truncate the return value of
  strlen().
* Use size_t for length in reserve(), shrink() and escalate(), since
  these call the modified StringData::Make() and so can benefit from
  64-bit size checking.
* StringData::setSize() is the one exception; it still uses int, on the
  basis that it is non-throwing, and making it throw would probably mean
  making it  non-inline. In the four test cases, StringData::setSize()
  is called with a smaller size than the one used for the preceding
  StringData::Make(), so it is safe in those cases.

Also:
* Fix a bug in allocFlatForLen() where the length could overflow before
  it was checked against MaxSize. If len is approx. UINT_MAX-2, then
  uint32_t(sizeof(StringData)+len+1) would be a small integer less than
  StringData::MaxSize.
* Fix integer truncation in f_utf8_encode(). If the input string is
  slightly larger than 1GB, data.size()*4 would be a small positive
  integer. Casting to size_t allows the error to be trapped by
  StringData::Make().

Reviewed By: @edwinsmith

Differential Revision: D1431966
Fix heap overflow in sql_regcase() for input >1GB

Summary: Rewrote it using StringBuffer, since that seems to be the standard
way.

Reviewed By: @bertmaher

Differential Revision: D1434342
don't emit all the skipped tests for fbmake

Summary: This breaks phabricator having 5k skipped things clogging up our results.

Reviewed By: @bertmaher

Differential Revision: D1472058
fixed an error in the hphpize.cmake file

Summary: LIBDIR was repeated twice. The first one should have been PREFIX

Reviewed By: @ptarjan

Differential Revision: D1471149
gperftools include file don't find

Summary: google/profiler.h don't find

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

Reviewed By: @ptarjan

Differential Revision: D1470627

Pulled By: svcscm
Add LibGMP extension

Summary: I've recreated the PHP gmp extension with HNI.  I believe it to be working well, but this is the first extension I've written so any and all criticism of my C-code is encouraged.

This extensions supports all GMP functions, and constants, with the exception of gmp_random.

I have submitted a CLA in the past; it might be under "ian@ my github username" (CA -> .ca); I had to submit it a few times last time around, so hopefully it's properly on record this time; if it's not, let me know.

Cheers

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

Reviewed By: @ptarjan

Differential Revision: D1470423

Pulled By: @sgolemon
Print current approx typechecking position on SIGUSR1

Summary: When some code being typechecked causes pathological behavior
in the typechecker, it can be useful to figure out approximately where
in the codebase we are checking. Right now, this involves a lot of
one-off logging being manually added, so let's do something a little
more clever. Every time we typecheck an expression, record its position,
and then on SIGUSR1, print that out. The envisoned use case is to attach
to a runaway proccess with gdb, look at the backtrace, and kill it with
SIGUSR1 to try and figure out WTF is going on.

We may ultimately want to expand this into something more general,
notably including things other than typing, but this is good enough for
now -- the 3-4 cases of runaway workers I've seen have all been in
typing.

This also kills `Typing.debug` since it was only used in one place, was
potentially confusing with the new data I'm adding, and was of dubious
utility (blocking `hh_show` in server mode).

Reviewed By: @elgenie

Differential Revision: D1467911
Fix usage of field_key/value in yield

Summary: This wasn't morally doing the right thing, even though the
current usages of `field_key` and `field_value` don't let you trigger
it. The type of an array field key and a `yield $x => $y` field key are
different mechanics, and the logic in the latter to determine whether a
missing `$x` is implicitly null or an int doesn't apply to arrays.

Reviewed By: @jano

Differential Revision: D1471174
Add useful test file for loops.

Summary: Saved my life several times now.

Reviewed By: @bertmaher

Differential Revision: D1470875
Revert "Prototype of general host health monitor."

Summary: This reverts commit e29c52bace619495459fa887cc7001fec794aa89. It's
breaking the OSS version of hhvm.

Reviewed By: @alexmalyshev

Differential Revision: D1472677
Fixed tempnam() creates paths with '//'

Summary: Sync with PHP's implementation

Closes #3313

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

Reviewed By: @ptarjan

Differential Revision: D1470642

Pulled By: svcscm
Fix bug with HashCollection::shrink()

Summary: This fixes a crashing bug related to HashCollection::shrink() where in some
cases it was allocating insufficient capacity and overrunning the buffer.

Reviewed By: @elgenie

Differential Revision: D1472072
Find and move good zend tests in the bad folder

Summary: This script finds good test in the zend/bad folder and moves them to zend/good

I ran it and included the moved tests in here.

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

Reviewed By: @sgolemon

Differential Revision: D1444261

Pulled By: svcscm
Remove reflection hacks for primitive typehints

Summary: When updating how primitive typehints worked, some hacks were done to strip
the "HH\" prefix from the output of various refleciton methods. These hacks
shouldn't be needed anymore. This diff removes the hacks and fixes up
ReflectionParameter::getClass() to be aware of the 'num', 'resource',
'mixed', and 'void' typehints.

Reviewed By: @elgenie

Differential Revision: D1253815
Changed grammar mistakes @rkulagowski found in --help

Summary: Fixes #3334

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

Reviewed By: sgolemon, ptarjan

Differential Revision: D1471012

Pulled By: svcscm