Make DOMDocument::getElementById actually return DOMElement

We were blindly returning a DOMText object for
DOMDocument::getElementById when it should return a DOMElement.

Reviewed By: @ptarjan

Differential Revision: D967622
Add toVector(), toMap(), toStableMap(), toSet() methods to collections

These methods provide a convenient way to materialize a lazy iterable into
a concrete collection, or to convert from one collection type to another.
Doing "$x->toX()" is equivalent to "new X($x)" (where $x is an Iterable
and 'X' is a collection type), but it's nice to have for the chaining use
case, ex:

  $v = $m->lazy()
         ->map(..)
         ->filter(..)
         ->toVector();

Reviewed By: @elgenie

Differential Revision: D978191
Add XboxServer support for asio events

This allows us to treat XboxTasks as external threads in the ASIO
framework.

We template the ServerTaskEvent class so that it may be used in the
future with other similar server interfaces, e.g. PageletServer.  We
expose XboxTransport for use in ServerTaskEvent.

Storing a Transport * in ServerTaskEvent instead of a Resource

Template; expose the Transport type from the Server

Also parametrize the Transport class

Expose XboxTransport

Reviewed By: @jano

Differential Revision: D975697
put back test 537

@markw65 confirmed we shouldn't expect the warning in repo mode. Either I disable the test in repo mode or make the warning optional. I went with optional.

Reviewed By: @elgenie

Differential Revision: D978593
Maintain linked list correctly in Sweepable

In a more complex scenarios where sweep() may unregister() other
Sweepables, linked list was not maintained correctly.

Imagine this example:

  HEAD <-> A <-> B <-> C <-> HEAD

If sweep(A) calls unregister(B) and unregister(A), the following
happens:

  // Sweepable::SweepAll delists A:
  HEAD <-> B <-> C <-> HEAD
  HEAD <- A -> B

  // and calls sweep(A), which calls unregister(B):
  HEAD <-> C <-> HEAD
  B <-> B
  HEAD <- A -> B

  // then unregister(A) that uses invalid pointers from A, creating this mess:
  HEAD <-> B -> B
  HEAD <- C <-> HEAD
  A <-> A

  // Sweepable::SweepAll then tries to incorrectly sweep(B), which
  // crashes stuff

After this diff, Sweepable::SweepAll delists stuff correctly:

  // Sweepable::SweepAll delists A:
  HEAD <-> B <-> C <-> HEAD
  A <-> A

  // and calls sweep(A), which calls unregister(B):
  HEAD <-> C <-> HEAD
  B <-> B
  A <-> A

  // then unregister(A) does nothing:
  HEAD <-> C <-> HEAD
  B <-> B
  A <-> A

  // so Sweepable::SweepAll can correctly continue with sweep(C)

Reviewed By: bertrand

Differential Revision: D979013
Keep source location table in memory so that source line number to byte code offset lookups don't hit the SQL database

Hitting the SQL database with at least two queries every time the debugger needs to map from source line number to byte code offset, or vice versa, makes no sense. This diff adds a table to Unit that can be used instead of the database. Note that when running in repo authoritative mode, the table will be empty because a) it is created lazily when a unit is loaded form the repo and b) in this mode, the repo does not contain the source line information needed for this table. This does not matter too much because we don't support debugging when running in repo authoritative mode.

Note, this diff does not remove all uses of the SQL database. That will be done in a follow up diff.

Reviewed By: @mikemag

Differential Revision: D978834
Don't try to unlink a non-existent repo

This'll throw spurious warnings on fresh checkouts

Reviewed By: @ptarjan

Differential Revision: D979499
Fix ~AutoloadHandler to never access its smart members

We potentially create the AutoloadHandler during repro
creation, from various work threads.  (Things are set up enough to
call builtins.)  Then we shutdown the execution context and then run
OnThreadExit handlers.  ~AutoloadHandler can access the memory manager
after it is destructed, triggering the post delete assertions.

Reviewed By: @markw65

Differential Revision: D979498
Remove one of the emitLea overloads

We don't need both.  The 3-arg one is also nicer in a lot of
code-gen situations because it checks for InvalidReg.

Reviewed By: @edwinsmith

Differential Revision: D976482
Don't allocate empty memory for empty FixedVectors

Reviewed By: drussi

Differential Revision: D976486
Move InsertStaticString to unnamed namespace

It's not supposed to be public, and I accidentally left it in
string-data.h

Reviewed By: @edwinsmith

Differential Revision: D977555
Refactor SNI support

The SNI code was married to LibEventServer, which made it incompatible with ProxygenServer.  Moved all the libevent specific code into LibEventServer, which actually simplified the Server::enableSSL interface I think.

Reviewed By: @paroski

Differential Revision: D966945
Update NEWS for Bobotie release.

Winged it.

Reviewed By: @jdelong

Differential Revision: D979021
Push CodeBlock->Asm boundary down into CodeGenerator

I finally figured out what the problem was when I tried to do this
before: comparing Asms for identity by taking addresses doesn't fly
anymore. You have to compare their bases. I grepped for "&m_as" and
"&as" and fixed everything I found.

Now, CodeGenerator takes CodeBlocks in its ctor. It still has Asm
members, but I think that's OK -- CodeGenerator is a pretty short-lived
object already, so the Asms inside it are transitively short-lived.

Reviewed By: @jdelong

Differential Revision: D978477
Remove view() method from collections, also remove Vector::sort()

The view() method has been phased out in favor of lazy() (which does the
same thing but is more obvious to developers). Let's remove it.

Also, the Vector::sort() method has been deprecated for a while and was
abandoned in favor of making the regular sort builtin functions work with
collections, let's get rid of that too while we're at it.

Reviewed By: drussi

Differential Revision: D979375
Deprecate boost::shared_ptr

Replacing boost::shared_ptr with std::shared_ptr.

Reviewed By: @andralex

Differential Revision: D932119
Add toKeysArray() and toValuesArray() to all collection types

Map and StableMap already have these APIs, let's add them to Vector, Set,
and Pair for consistency.

Reviewed By: @elgenie

Differential Revision: D979552
Fix traits bug with instance props that use collection literal initializers

This fixes a traits bug involving instance props that use collection literal
initializers. Instances of a class are not supposed to share the collection;
they are supposed to each get their own copy.

Reviewed By: @andralex

Differential Revision: D979933
Fix emalloc and spprintf

emalloc(n, size, offset) was ignoring the size and offset params,
and underallocating.

spprintf() wasn't allocating & copying the null terminator byte.

Reviewed By: @jdelong

Differential Revision: D979798
requestInit shouldn't clear Arrays again

On requestInit, if Arrays are null inited and reset during
shutdown, they shouldn't need to be reset again (it will just end up
doing redundant work) so just assert the expectation is the case.

Reviewed By: @markw65

Differential Revision: D978681