RBTrace should be NNT

Summary: I missed this when making CallsNative imply MayRaiseError.

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

Reviewed By: @bertmaher

Differential Revision: D1442287
target 3.3

Summary: 3.2 is out

Reviewed By: @JoelMarcey

Differential Revision: D1443788
Add an opt_map function to Utils and change a bunch of code to use it

Summary: Add a function for ordinary mapping over options to Utils and replace the option maps that I found with it.

I looked for option maps with: grep -r -- 'Some [a-z]* -> Some'

Reviewed By: @elgenie

Differential Revision: D1442431
Improve error messages through instantiation

Summary: During generic instantiation, we'd drop part of the position
information on the floor. This information can be quite useful, to be
lead through a potentially long path of generic instantiations to the
place that things actually ended up incompatible. This diff tracks the
location of all those instantiations and prints them as part of the
error message. In some cases, this can lead to a somewhat longer error
message, but it's IMO worth it to have the added information -- in some
pathological situations, there would way too little error info. More
error info is always better, right?

This came up when trying to work on async generators, since I think I
want to make `Continuation` a type alias for `Generator`, and
incompatibilities are painful to read without this information (see unit
test).

Reviewed By: @elgenie

Differential Revision: D1439540
A few small hhbbc tweaks

Summary: - reduce BoxR to BoxRNop
   - constprop CGetS
   - reduce InstanceOf to InstanceOfD in one more case
   - allow dce to remove AGetC

Reviewed By: @elgenie

Differential Revision: D1415312
Always mark Closure classes as NoOverride

Summary: Closures cannot be extended, so we can mark them as NoOverride even in
non-repo modes.

Reviewed By: @jdelong

Differential Revision: D1442144
Remove XMLWriter test temporarily

Summary: Seems relatively harmless, likely cauesd by HNI conversion. Will investigate reverting this immediately.

```
[fredemmottdevbig076 ~/fbcode/hphp/test] php5 quick/builtin_extension_XMLWriter.php | grep -i startattributens
  string(16) "startAttributeNs"
  string(16) "startAttributeNs"
[fredemmottdevbig076 ~/fbcode/hphp/test] hhvm quick/builtin_extension_XMLWriter.php | grep -i startattributens
  string(16) "startAttributens"
  string(16) "startAttributens"
```

Reviewed By: bsimmers, ptarjan

Differential Revision: D1444383
clean up libxml/dom/simplexml

Summary: - Move 2 php_libxml_* functions to their appropriate place to
  reflect Zend (libxml extension).
- Call these functions from SimpleXML to properly clean up after
  ourselves, which earlier was incorrect assumed to be entirely
  handled by xmlFreeDoc in sweeps.
- Don't NULL out node->doc, this should only be done at refcount 0 to
  prevent double frees. XML extensions take care of this themselves.

There's still a bunch of work needed to be done: SimpleXML and
DOMDocument share a lot more functionality that should eventually be
moved to libxml as well.

That will be a gradual process however, and this change plugs a leak in
the meantime.

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

Reviewed By: @ptarjan

Differential Revision: D1443782
Implement shapes with class constant fields.

Summary: Add support for using class constants as field names in shapes to Hack. Shapes must either use all class constants or all strings. Class constants can either be ints or strings, but must all be the same. This doesn't include extending HHVM to support them.

Reviewed By: jwatzman, eletuchy

Differential Revision: D1377943
Readd xmlwriter quick test

Summary: Was only failing on my machine due to a local build issue. Doesn't seem to be a problem on sandcastle, or on mine after a clean build

Reviewed By: @ptarjan

Differential Revision: D1444452
Hack: fix inconsistency where hh_client takes file name instead of content

Summary: Only two that take file name are: `--color`, `--type-at-pos`. On the other hand `--auto-complete` and `--outline` take stdin.

Reviewed By: @joelbeales

Differential Revision: D1444286
Hack: hh_client --type-as-pos --json

Summary: Because I want to implement "Jump to definition" functionality.

There are several implementations of `pos_to_json` I tried to merge them into
a single one.

Reviewed By: @joelbeales

Differential Revision: D1444642
ReflectionClass support for class requirements

Summary: ... patterned after getInterface(Name)s and getTrait(Name)s

Reviewed By: @jdelong

Differential Revision: D1443833
typechecker: exclude synthetic __construct from compat check

Summary: Having an interface support a constructor via 'require extends X'
 does not mean that all implementers of the interface must have the
 same compatible constructor signature. The code surrounding
 constructors is rife with some unnecessary complexity and due for a
 refactor.

Reviewed By: @jwatzman

Differential Revision: D1443530
Backtrace generation has been moved out of the execution context and into a new class, BackTrace

Summary: There are several diffs out that currently add arguments to the debugBacktrace function (D1405194, D1407595). With both the proposed diffs and the current arguments to debugBacktrace, the function will have around 10 optional arguments. To keep the code base readable it seems reasonable to create a class that handles the creation of backtraces. While there are a lot of lines of code in this diff, almost all changes are a direct copy of the old debugBacktrace function.

Reviewed By: @jdelong

Differential Revision: D1412812
rework hhvm tests in framework runner

Summary: this stops the same test running simultaneously multiple times.

Reviewed By: @ptarjan

Differential Revision: D1444509
change lz4compress etc. to lz4_compress for php compatibility

Summary: The php implementation of lz4 compress/decompression has method names lz4_compress and lz4_decompress. HPHP supplies lz4compress and lz4decompress (without spaces). The causes an issue with compatibility of code when running on PHP or HHVM.

https://github.com/kjdev/php-ext-lz4
https://github.com/colinmollenhour/credis/issues/19
https://github.com/colinmollenhour/Cm_RedisSession/issues/31

This renames those methods to lz4_compress, lz4_decompress and lz4_hccompress

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

Reviewed By: @fredemmott

Differential Revision: D1435396
Fix segfault in substr_replace

Summary: If the 'start' and 'length' arrays were the wrong length, we would walk
off the end of them. Even apart from that, the behavior if they weren't
arrays was wrong: you have to convert them to ints and use those always.

Reviewed By: @edwinsmith

Differential Revision: D1421668
Lock the session file when opening it

Summary: This seems to be a copy+paste mistake from https://github.com/php/php-src/blob/master/ext/session/mod_files.c#L157-L168.

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

Reviewed By: @ptarjan

Differential Revision: D1438629
Add ExactObj/SubObj tracking to JIT::Type

Summary: Allows us to specialize an Object type as being exactly a class C,
or a subtype of class C.

Reviewed By: bertrand, bsimmers

Differential Revision: D1389235