Add YieldMethodDefaults builtin hhi file to fbcode

Reviewed By: @elgenie

Differential Revision: D1367262
Fix refcounting opts for bc control flow

Summary: With bytecode control flow, refcounts won't necessarily match
at a merge point, but they should obey the conditions described in the
comment on Value::merge.

Reviewed By: @edwinsmith

Differential Revision: D1363640
Corrected strtok for when tokenizer fails at the end of the string

Summary: `strtok` did not consider tokenizer failures resuling from eof after trying to tokenize.

Fixes #2860

Reviewed By: @ptarjan

Differential Revision: D1367181
remove mtime and prefetch

Summary: A long long time ago, the hack server was using message passing to implement the shared heap.
Back then, it was faster to batch the messages. Because of that, we were keeping the set of
classes and functions used by a node in the previous run to prefetch them the next time.
All of this is completely useless today, since we use shared memory, batching is not helping
what so ever!

Reviewed By: @elgenie

Differential Revision: D1365410
make SimpleXML boolean casts even faster

Summary: This is a follow up to PR #2855.

When we need to build our element's child tree (sxe_get_prop_hash) to
determine if it casts to true/false, we can get away with bailing after
finding the first element.

In my small Magento siege tests these result in significant
improvements:

Before:
Transactions:               1551 hits
Transaction rate:           51.79 trans/sec
Lowest response time:       97ms
Callgrind:                  http://i.imgur.com/npxMo0q.png

After:
Transactions:               1730 hits
Transaction rate:           58.43 trans/sec
Lowest response time:       89ms
Callgrind:                  http://i.imgur.com/Dgojb9Y.png
Closes #2868

Reviewed By: @ptarjan

Differential Revision: D1368727

Pulled By: @JoelMarcey
Tolerate running this test from the hphp/ subdir

Summary: These ffile arguments were assuming the test was being run from outside
the hphp directory. This now tolerates both; any arguments that don't
exist are ignored.

Reviewed By: @swtaarrs

Differential Revision: D1369011
Update failing test expectation to match output

Reviewed By: @ptarjan

Differential Revision: D1368793
Use unsafe vmReg access in fcallHelper

Summary: We have just synced the registers in setupAfterPrologue, but the
regState is DIRTY as we are going to return to the JIT. Use unsafe
vmReg access.

Reviewed By: @swtaarrs

Differential Revision: D1365123
Fix eval bug when running drupal. Match PHP5 behavior.

Summary: This fix is needed for https://drupal.org/node/2270509
See also #2708
Closes #2840
Fixes #2023

Reviewed By: @markw65

Differential Revision: D1361667

Pulled By: @JoelMarcey
SOAP fixes

Summary: These are 2 separate commits because technically they are different issues, but the 55323 test depends on the o_set fix as well.
Closes #2866

Reviewed By: @ptarjan

Differential Revision: D1369057

Pulled By: @JoelMarcey
Fix mysql_free_result and is_resource for localized mysql results

Summary: Follow-up to facebook/hhvm#1946 - MySQL.Localize (fbonly option) currently doesn't free results when told to, or have a working is_resource.

Reviewed By: @ptarjan

Differential Revision: D1364320
Allow vtable-style dispatch on abstract instance methods

Summary: This was disabled, going back to the initial implementation
in tx64.  Abstract methods have method slots that behave the same when
overriden as normal methods, so maybe this dates back to before we had
bytecode bodies for the "base" abstract methods (to implement "pure
virtual called" errors)?  This diff only enables it for non-static
methods.

Reviewed By: @ottoni

Differential Revision: D1366913
hhbbc main(): better error message if the input repo doesn't exist

Summary: Right now it hits an assertion failure in FuncEmitter.

Reviewed By: @dariorussi

Differential Revision: D1367724
Fix a race condition in hh_add.

Summary: Fixed a documented race condition in hh_add in the Hack lockfree hashtable. If two threads try to insert the same data, and both try to grab the same slot, the one that fails could return before the one that won writes the (char*)1 sigil indicating that it is filling in the value. The solution is to still try to write the value in in this case.

Reviewed By: @gabelevi

Differential Revision: D1361974
Fix build flakiness

Summary: A change in fbstring interacts badly with jemalloc's
MAP_UNINITIALIZED mode, which bit us in Scanner::Scanner.

This fixes the issue by passing around std::strings instead of
char*'s obtained from std::string::c_str().

Reviewed By: drussi, bsimmers

Differential Revision: D1368857
Use an array for id caching instead of using libxml2's private pointer

Summary: A past contributed commit used libxml2's private pointer to store past instances for caching in order to maintain instances.
This diff changes this approach to a use the global node cache map.

Fixes #2772

Reviewed By: @ptarjan

Differential Revision: D1367960
Initialize vm-exit return for resumable ActRecs in advance

Summary: Currently we set return address as vm-exit per every async function
resume. Initialize it only once when it is constructed.

Reviewed By: aravind

Differential Revision: D1369502
Don't spill everything for FCallBuiltin

Summary: This diff tries to minimize saving FCallBuiltin arguments to the stack.  It takes a similar approach to emitNativeImplInlined, which is to leave only the pass-by-ref args on the stack, and create a custom catch block to handle the clean up.  The code is subtly different from NativeImplInlined, because the args are already on the eval stack coming in, and handling that takes some care.  There's still probably too much copypasta in this diff, but I didn't come up with any clean division that I liked better -- feel free to suggest some.

Reviewed By: @jdelong

Differential Revision: D1358809
Use logarithmically spaced size classes for "smart" allocation.

Summary: Use logarithmically spaced size classes for "smart" allocation
(smartMallocSize(), smartSizeClass(), etc.), rather than quantum-spaced
size classes.  Additionally, increase the limit for smart allocation
from 2^11 to 2^21 (same as the slab size).

For sizes up to 4096, use a 256-byte lookup table to convert request
size to size class index, which is ~50% faster than directly computing
the size class index.  Allocation requests larger than 4096 are a
miniscule proportion of total requests, so direct computation allows for
generality without sacrificing speed, nor requiring a huge lookup table.

Preallocate a small number of additional regions whenever slabAlloc() is
entered in order to amortize the cost of leaving the fast path of
freelist recycling.

Reviewed By: @edwinsmith

Differential Revision: D1336072
Move ExecutionContext::m_firstAR to VMRegs::firstAR

Summary: Need to update firstAR from JIT on a hot path (switch of currently
running async function). It's much easier to do if it's in RDS.

FirstAR should be eventually killed altogether, but it is not easy yet.

Reviewed By: @swtaarrs

Differential Revision: D1370326