Convert XLS m_pending to priority_queue

Simpler than explicitly doing heap operations on a vector.

Reviewed By: @swtaarrs

Differential Revision: D1106561
fix preg segfault

`php_pcre_replace` isn't guaranteed to return a String or Boolean. Lets just proxy the result back if it isn't a string instead of assuming and segfaulting the async tier.

Reviewed By: @markw65

Differential Revision: D1106633
Add parser support for language integrated query expressions.

This diff adds syntax to hphp.y, context sensitive keywords to hphp.ll, AST classes, a dummy emitter that just turns a query expression into a serialized CodeModel, as well as several test cases that exercise all options in the syntax and tests that the new keywords can still be used outside of queries.

The PHP syntax is exactly the same as the C# syntax.

There is significant restriction not present in C#, but necessary to get rid of shift reduce conflicts in Bison, namely: a query expression can only appear on the right hand side of an assignment to simple variable and as the expression of a return statement.

The need for making the "from" keyword context sensitive also precludes changing the syntax of "from $row in $table" to a more PHP compatible "from $table as $row", since $row can be any kind of expressions and hence does not provide enough context for the scanner to determine that the from token starts a query.

A query expression compiles to a call looking a bit like
   $rc = $c->executeQuery("serialized ast for normalized query expression", argvector);
   foreach ($rc as $re) { yield some_expression_containing($re); }
The $c is the value of the expression in the first from clause. The serialized ast represent the query expression after all parts of it that can be executed locally have been removed. Argvector is a vector of values that were computed locally. $rc is collection of tuples received from the query engine. The "foreach" turns the tuples into values as specified by the select clause.

This diff does not complete the implementation of code generation for query expressions. Specifically, the ast is not normalized, the argvector is null and the foreach is missing. I would like to get this diff out as is now in order to enable people to write query providers and test them with actual query expressions.

Reviewed By: @paroski

Differential Revision: D1088496
Misc tweaks/fixes

- aprof needs 6 digits just like a
- return the proper sizes for the admin port check-health command
- make an assert in emitVerifyParamType more useful

Reviewed By: @bertmaher

Differential Revision: D1103500
Loosen assert in emitVerifyParamType

This should unbreak the legacy region selector in opt builds while I
try to figure out why it's firing.

Reviewed By: @edwinsmith

Differential Revision: D1105296
Add catch trace to RaiseWarning in emitDiv

Anything that can throw must have a catch trace.

Reviewed By: @bertmaher

Differential Revision: D1106629
Properly split host:/path/to/socket strings

We weren't properly splitting the mysql socket form of connect
strings when ipv6 support was added.  The net result was a string of the
form:

localhost:/path/to/socket

was trying to open the socket 'path/to/socket' rather than
'/path/to/socket'

Reviewed By: @ptarjan

Differential Revision: D1107623
Use base 10 for bytecode offsets in CFG printer

Since TRACE=printir uses base 10, I prefer using it here too.
But feel free to veto.

Reviewed By: @ottoni

Differential Revision: D1106785
Allocate intervals individually

Looking at XLS trace dumps, most units have a lot less
intervals than SSATmp ids.  Allocating them separately
should save a bunch of memory, but also avoid any hazards
from std::vector moving them during register allocation.
(which happened to me once, w/out a reserve call).

Reviewed By: @jdelong

Differential Revision: D1107035
Fix crash when a custom init function throws

Classes derived from exception have a custom-instance-init
method which gets called before the constructor. It can throw (eg
if a timeout occurs), so allocObj needs a catch trace, and allocObjFast
shouldn't be called on classes derived from Exception.

Reviewed By: @edwinsmith

Differential Revision: D1107437
Trigger Optimize retranslations at all function entries

This diff changes things so that Profile translations for all function
entries (normal entry plus DV funclets) trigger Optimize
retranslations in PGO mode.  This fixes the PGO mechanism for
irregular functions (e.g. array_map) that don't follow the defunct
bytecode rule that DV funclets fall-through one into another and then
into the function's main entry (function base).

Also did a few cleanups along the way.

Reviewed By: @bertmaher

Differential Revision: D1108164
hhvm: initial implementation of the php_odbc API

Reviewed By: @ptarjan

Differential Revision: D1058022
Make unix_odbc support optional
Fix LdThis in unbound closure bodies

Loading $this will always fail in these, but we shouldn't dump core
while processing the unreachable code.

Reviewed By: @ottoni

Differential Revision: D1107377
fix leak in iter_next_apc for string keys

We were inc-ref'ing keys one too many

Reviewed By: @jdelong

Differential Revision: D1108033
str_replace counts fail to accumulate with arrays

The $count parameter of str_replace is supposed to return the total
number of string replacements performed. This was only working correctly
when both $search and $subject were strings. When either or both are
arrays, the counts need to accumulate across all replacements. The code,
as written, was only returning the replacement count for the last pair
of values.

Closes #1383

Reviewed By: @ptarjan

Differential Revision: D1106935

Pulled By: @scannell
Resource To Array Conversion

Converted resource to an array contatining the resource

Reviewed By: @ptarjan

Differential Revision: D1107620
Migrate Set to the HH namespace.

Move the Set collection class to the HH namespace.

So now get_class(new Set()) === "HH\Set".

The auto-import mechanism in place makes the change transparent most of the
time (e.g. developers can simply use "Set" in their code), but the namespace
shows up in some cases, serialization being a notable one.

Depends on D979471.

Reviewed By: @elgenie

Differential Revision: D1081929
Better match Zend finfo

NULL is allowed for some string parameters in some functions of finfo. In fact, NULL is the default value. e.g., http://php.net/manual/en/function.finfo-open.php

Our current implementation did not allow nullable strings. We would get errors like:

HipHop Fatal error: Argument 1 passed to foo() must be an instance of string, null given in /tmp/strtest.php on line 4

Make these string nullable (e.g. ?string)

phpbb was running into this issue using finfo

Reviewed By: @ptarjan

Differential Revision: D1107796
filter_var snapshot (take 2)

Unrevert the filter_var diff. Also fix a bug where it isn't snapshotted in the request path.

Reviewed By: @JoelMarcey

Differential Revision: D1104270