Fix logging

Summary: We were clearing some of the stats before logging them

Reviewed By: @jano

Differential Revision: D1637551
Remove tc-space reporting of astubs

Summary: Astubs hasn't existed for almost 6 months now, so it's about time to
retire this stat.  We can always synthesize it in ODS if needed.

Reviewed By: @ottoni

Differential Revision: D1631327
Use operator= instead of clear to reset MM.m_instances

Summary: clear() doesn't guarantee to release the underlying storage of the
map, whereas operator= with a new empty map should.
Only do this if m_trackingInstances, to avoid construction unless needed.

Reviewed By: @shai-d

Differential Revision: D1631356
Use operator= instead of clear to reset xmlErrorVec

Summary: clear() doesn't free storage, so this could grow steadily over time.

Reviewed By: @edwinsmith

Differential Revision: D1632303
backport PHP bugfix #43540

Summary: We need to properly set newlength.

See:
- https://github.com/php/php-src/commit/898ff10dc0f799ecf997cb3c64a96f2751884187
- https://bugs.php.net/bug.php?id=43540
Closes https://github.com/facebook/hhvm/pull/4014

Reviewed By: @ptarjan

Differential Revision: D1626102

Pulled By: @fredemmott
Fix incorrect LOCK_UN for user-land stream wrappers

Summary: We were passing native LOCK_UN value, but PHP's value differs.
These should be probably switched to k_* once constants idl is ported.

Closes #3887.
Closes https://github.com/facebook/hhvm/pull/4034

Reviewed By: @fredemmott

Differential Revision: D1630986
Fix highlight_string function for proper highlighting - #3160

Summary: This should resolve #3160.
Closes https://github.com/facebook/hhvm/pull/3959

Reviewed By: @fredemmott

Differential Revision: D1624101
Port fixes for EXIF bugs from PHP

Summary: Official fixes PHP bugs 60150 and 65873, plus extra line breaks. This is
just to be prudent, I haven't found an actual security vulnerability in
HHVM. In the case of 65873, reproduction depends on allocator details,
and HHVM's allocator is probably not vulnerable at present.

Submitted on behalf of a third-party: The PHP Group
Source: http://svn.php.net/viewvc/?view=revision&revision=319534
Source: https://github.com/php/php-src/commit/cbcf6e1880e35ed7cd052e127b037eee7cef61c9
License: version 3.01 of the PHP license

Closes: #1154
Closes https://github.com/facebook/hhvm/pull/4020

Reviewed By: @fredemmott

Differential Revision: D1627130

Pulled By: @paulbiss
Add Histogram of NoInfo sizes to ArrayTracer

Reviewed By: @edwinsmith

Differential Revision: D1636990
Add remaining CALL_OPCODEs for ARM

Summary: In theory, anything that's a CALL_OPCODE on x64 should be the same on
ARM and it should work without problems. I just copied the whole
CALL_OPCODE section from code-gen-x64.cpp and it seems to have worked.
(That resulted in a lot of reordering, so the best way to see what's
changed is to concentrate on the removed PUNT_OPCODEs.)

Reviewed By: @edwinsmith

Differential Revision: D1637822
Fix memory leak in WSDL parser

Summary: The document tree for the WSDL and referenced XSD-s was not deleted
after parsing.
Closes https://github.com/facebook/hhvm/pull/4045

Reviewed By: @fredemmott

Differential Revision: D1635060
Special-case idx

Summary: `idx` is pretty easy to type, depending on the number of
arguments. Let's do it.

Reviewed By: @elgenie

Differential Revision: D1606308
Fix some emitPropSpecialized code relating to intermediate property accesses

Summary: It turns out that this code doesn't seem to have been running anymore,
since we weren't getting any appropriate knownCls values through to
getPropertyOffset for intermediate prop operations on nullable object types.
Also, this tweaks needFirstRatchet to avoid some unnecessary control flow on
the first prop dim even if we don't know the type of the property (but know the
type of the base).

Reviewed By: @alexmalyshev

Differential Revision: D1625428
Non-member function organization for simplifier

Summary: Remove member-function-per-opcode design.

Advantages:

  - Adding a new simplify method doesn't involve changing simplifier.h, which
    means it doesn't change ir-builder.h, which means you don't wait 60seconds
    for hhbc-translator.o to build.

  - You can add private helpers without forward declaring them.

  - If simplifier ever gets too big, we can split it easily.  (The state struct
    and helper methods go to some -internal header, and then you can sprinkle
    the simplify routines into several .cpps.)

Disadvantages:

  - You have to say "env" all over the place.  (I got used to this pretty quick
    in hhbbc but it's definitely not an upside.)

I'd like to do this to hhbc-translator, but I thought I'd do simplifier first
because it was small enough to do quickly, and to make sure there's consensus.

Reviewed By: @edwinsmith

Differential Revision: D1632329
Rename simplifier.{h,cpp} to simplify.{h,cpp}

Summary: Assuming we do D1632329 a Simplifier isn't a nouny thing now, it's a
procedure.  So verb the filename.

Reviewed By: @mxw

Differential Revision: D1632525
Remove isRefCounted; fix a bug in simplifier xorBoolImpl

Summary: isRefCounted really means maybeCounted, which we have in Type.  And in
xorImpl we needed to check that the sources can't be doubles, not that they
aren't known to be doubles.  (As alexanderm pointed out in the task.)

Disable it for arrays and objects even though we don't have an example it
breaks, because the burden of proof should be on it being correct.

Reviewed By: @alexmalyshev

Differential Revision: D1633947
Clean up in hhbbc dce module

Summary: Been meaning to do this for a bit: convert the visitation away from
object-with-overload-per-bytecode design.

Reviewed By: @alexmalyshev

Differential Revision: D1633438
Disable xdebug_get_declared_vars in RepoAuthoritative mode

Summary: xdebug functions aren't apparently not generally useful in repo auth
mode, and we don't have this function hooked up to the disallowed dynamic funcs
mechanism.  Since get_defined_vars already exists let's just disable this one
in repo for now.

Reviewed By: @ptarjan

Differential Revision: D1638826
Enable -fglobal-dce and -fremove-unused-locals in hhbbc by default

Summary: For some reason I forgot that I meant to look at doing this when
turning off postOptimize.  The pass was off originally because I wanted to
think about it some more and was worried about the default implementation being
correct for bytecodes that aren't explicitly supported---it really just relies
on the mayReadLocalSet being correct from the normal abstract interpreter,
which I feel pretty confident about now.

This also turns on unused local variable removal, so we don't need to do
-fno-insert-assertions on test/quick/lotsa-locals.php (because hhbbc just
removes all the locals after constant propagating them into var_dump).  Found
and fixed a bug in this---it was willing to remove parameter locals.

Reviewed By: @jano

Differential Revision: D1633779
Support for SetOpL and IncDecL in hhbbc global dce

Reviewed By: @jano

Differential Revision: D1634176