Use aligned version of hash function when safe

Summary: I am assuming that std::string::c_str() and HPHP::String::data() always give aligned addresses.

I don't see a failure. But sandcastle has been postponing some tests for many hours now.

Reviewed By: @markw65

Differential Revision: D1725993

Signature: t1:1725993:1418080027:b7628914ad44582976748d138c53db43ddc48028
Use a custom implementation of strtoll for unserialize

Summary: We can do better than the standard libc strtoll for unserialize, both
because we can avoid the plt, and because unserialize doesn't need all the edge
conditions (overflow doesn't need to be defined in any particular way, there's
no need AFAIK to handle leading + or whitespace).

Reviewed By: @ottoni

Differential Revision: D1722763

Signature: t1:1722763:1417817958:a1b96780879ce4400b30fe39b21523b171ba5bd9
Apply code skew to code alignment.

Summary: When we emit code starting at an address that is not cache line
aligned, we need to pass to LLVM the skew in alignment.
LLVM uses the aligment e.g. when generating code for smashable
instructions.

Reviewed By: @swtaarrs

Differential Revision: D1724732
Move disabled unit tests to runtime/test.

Summary: There were a number of unit tests under test/ext/test_cpp_base.cpp that were disabled because they were a part of TestLibEventServer.  I've moved them over to runtime/test and converted them to gtest.

Reviewed By: @markw65

Differential Revision: D1722753
Add Hack typing to array_keys

Summary: There's also a diff for `array_values` forthcoming. The resultant hack errors all look reasonable.

Quirks found:

1. `array_keys(Set {'foo'})` doesn't typecheck, since Set doesn't implement KeyedContainer. Use `array_values(Set{'foo'})` instead.
2. `array_keys(shape('stuff' => 'morestuff'))` doesn't typecheck, and possibly never will.
3. `array_keys('foo')` logs an error and returns `null`. I assume we're okay with this.

Reviewed By: @dlreeves

Differential Revision: D1661290

Signature: t1:1661290:1418145186:2ead1ade24806ea0a1923a1534f8f6c0dcf178b5
Implement smashable jump service requests in llvm backend

Summary: Fairly straightforward, except for the fact that the jumps aren't
actually smashable yet due to a bug in llvm's assembler (or how we're using
it). The bindjcc1st/2nd vasm instructions are implemented with a local jcc
going to REQ_BIND_JMP stubs because we can't emit smashable jccs yet.

I moved the global function name table into TCMemoryManager to keep the size
from growing indefinitely with each translation, since we need to generate
names for certain stubs that are unique for each translation.

Reviewed By: @maksfb

Differential Revision: D1717035
Initial cleanup of ObjectData

Summary: * Moves all inline ObjectData methods out of object-data.h, and into
  object-data-inl.h

* Renames implementsIterator() to isIterator() to match is*Collection().

* Gets rid of the o_ prefix on o_getClassName(), o_getId(), and o_instanceof().

* Deletes a few unnecessary methods such as getAttributes(), setAttributes().

Reviewed By: @edwinsmith

Differential Revision: D1707226

Signature: t1:1707226:1417042506:3be85673baf9cd215b506fbf52533733ac9d4c96
Make newlines in http headers a fatal error.

Summary: Make newlines in http headers a fatal error.

Reviewed By: @markw65

Differential Revision: D1720703
Define proper constants for CURLOPT and friends

Summary: I can never recall our inference story on constants, but we
don't infer these to ints, so explicitly declare as `const int`.

Reviewed By: @int3

Differential Revision: D1725225

Signature: t1:1725225:1418089362:d99d16add218d4b8dd8fdf37f7408c16c2065039
Various llvm backend bugfixes

Summary: This gets us down from 354 failures in test/quick to 36, most of which
are unaligned native stack assertions. I turned some assertions into punts and
fixed a bunch of bugs - I think it's important to make sure the stuff we are
translating is solid before spending too much more time expanding coverage.

- Visit blocks in RPO instead of the codegen layout order. If a frozen block
  branched to a cold block we'd previously see the cold successor first and try
  to use values that weren't yet defined.
- Add a movretaddr to be used in the traceRet return assertion sequence,
  avoiding a load into %rsp.
- Add loadzbq, loadzlq, and movzbq instructions to pass more precise type
  information to llvm. Final codegen is unaffected; we still emit
  loadzbl/loadl/movzbl in the x64 backend.
- Punt on unsupported ConditionCodes instead of asserting. We intend to support
  them so it's not a bug if they're in the Vunit.
- bitcast all inputs to floating point operations to doubles. This works around
  the fact that the vasm load instruction doesn't indicate the type of what
  it's loading (just the size).
- Emit the stack adjustment from BeginCatch in the lowering phase instead of
  code-gen-x64.cpp. llvm handles this kind of adjustment itself.
- Fix support for CppCall::Destructor calls - we were jumping to the jump table
  instead of loading the address from it. I also cleaned up how we access it in
  llvm, creating a properly typed GlobalVariable for it. Finally, rather than
  directly referencing argNumToRegName[1] in the CppCall we create for it, use
  a Vreg for the type register. This required moving Vreg to its own header
  since vasm-x64.h needs to include cpp-call.h.
- Clean up how Bool values are dealt with in vasm, ensuring that they're always
  i8 in llvm. Types are still i64; I may clean that up in the future. This also
  required adding a CallDest::Bool type to make sure llvm zero-extends bool
  helper return values when needed.
- Add a ldimmb instruction for byte-sized constants, and a corresponding
  makeConst(bool) overload.
- Convert call in emitCheckSurpriseFlagsEnter to vcall.
- Reorganize LocRecs data structures to tolerate non-contiguous locrecs.

There are a few other minor issues I didn't call out in the list that should be
clear from the code changes.

Reviewed By: @edwinsmith

Differential Revision: D1725756
Use custom AssemblyAnnotationWriter to improve vasm/llvm printing

Summary: Rather than attaching a vasm string to every single llvm instruction,
use DebugLoc to attach an id to each instruction. This id is an index into a
vector of strings, which we use to print each vasm instruction once, before
each group of llvm instructions it produced (just like what we do for
hhbc/hhir/vasm printouts).

Reviewed By: @jasone

Differential Revision: D1726105

Signature: t1:1726105:1418085918:759ed72e211e99f66bba2cb05fc71163207b50c2
Add more functions to the hh_single prelude

Summary: Tracking down a bug, wanted to have these available. Didn't add
newlines to avoid rerecording every test with a line number in the
prelude :\

Reviewed By: @int3

Differential Revision: D1728992
Autostart hh_server when doing `hh_client prolog`.

Summary: Basically just copypasta of the logic in hh build

Reviewed By: @jwatzman

Differential Revision: D1724674

Signature: t1:1724674:1418080627:f5785df6465f878398cd3d071632b98b508005f9
Implement unit test scaffold.

Reviewed By: @jwatzman

Differential Revision: D1724680

Signature: t1:1724680:1418080893:6f85e42ea320c5c21fd592eedcb822365cb7ed59
Split PrologMain into two files.

Summary: Similar to how we organize the other features -- separate the
I/O & formatting from the computation of the underlying data.

Reviewed By: @jwatzman

Differential Revision: D1724682

Signature: t1:1724682:1418083900:5b00dd6f89e64ea95ea7d504d63a191f48ef2e57
Cherry-pickable fix for {N,}Same array bug

Summary: This is a very simple fix; I'll see what can be done better in another
diff.

Reviewed By: @markw65

Differential Revision: D1728829
Rename typeArithSetOp to typeSetOp

Summary: All the other type-arith.h functions just have 'type' as a prefix.

Reviewed By: @alexmalyshev

Differential Revision: D1728841
Rename type-arith.{h,cpp} to type-ops.{h,cpp}

Summary: I'm going to add a type comparison function, and having a whole new
module for type-comparisons doesn't seem needed yet.  (Can split later if both
get bigger.)

Reviewed By: @alexmalyshev

Differential Revision: D1728858
Add type{N,}Same, to do {N,}Same on types; handle staticness correctly

Summary: We can't just directly use couldBe the way the old code did, because
the type system doesn't exactly map to php "same" semantics.  The old code was
also confused about calling couldBe twice: couldBe is symmetric.

Reviewed By: @alexmalyshev

Differential Revision: D1728880
Add a comment explaining why interp-minstr couldBe(sempty()) use is safe

Summary: An audit of couldBe wrt accidently asking about reference countedness
only found this case, which is correct right now because TStr.couldBe(sempty())
is true.  Explain it in a comment; we'll have to change it if we do the
mentioned task.

Reviewed By: @edwinsmith

Differential Revision: D1728928