Raise warning when calling get_called_class outside of a class

Summary: PHP5 raises a warning when `get_called_class` is called without a class.

Reviewed By: @ptarjan

Differential Revision: D1423243
reword CLA sentence in README.md

Summary: slight change to CLA sentence so ptarjan can test his external reviews hook
Closes #3137
Created from: https://github.com/facebook/hhvm/pull/3137

Reviewed By: @ptarjan

Differential Revision: D1423793
Fix for Redis EVAL / EVALSHA

Summary: phpredis casts nil responses to bool(false), whereas HHVM returns NULL for both
false and nil return values. For example:

    <?php
    $redis = new Redis();
    $redis->connect( '127.0.0.1' );
    var_dump( $redis->evaluate( 'return' ) );
    var_dump( $redis->evaluate( 'return false' ) );

With Zend / phpredis, the output is:

    bool(false)
    bool(false)

With HHVM, it's:

    NULL
    NULL

This patch adds a fix and a test.
Closes #3127

Reviewed By: ptarjan, bsimmers

Differential Revision: D1422528

Pulled By: @fredemmott
De-templatize testimm since IndexedMemoryRef is gone.

Reviewed By: @bertmaher

Differential Revision: D1426437
Replace bogus uses of AttrFinal with AttrNoOverride

Summary: We want to guard on objects that can't be overridden, not if they're
marked final.

Reviewed By: jdelong, mwilliams

Differential Revision: D1425605
Factor out most of tryInline()

Summary: We want to try incorporating inlining in the hottrace selector, with or
without including it still for profiling translations.  We'll start by
just refactoring as much of the decision logic as possible.

Notable logic that we can't just shunt into a function are the inlining
depth checks and the requirement that FPush* not be interpreted.  The
former I'll clean up (right now we do the stack depth and inlining depth
checks differently, which is silly).  The latter we'll try to solve by
just breaking tracelets after an FPush whenever it's interpreted, and
documenting this limitation (and, ideally, fixing it, someday).

Reviewed By: bsimmers, ottoni

Differential Revision: D1405929
Rewrite inlining logic

Summary: Rewrite the inlining decision-making mechanism so that it can be more
easily used with arbitrary tracelet selectors.

This also fixes a bunch of bugs (or at least misbehaviors) in inlining:

- Before, if we were going to inline a stack of calls four-deep, we
  would produce tracelets for the rest of the callstack at each callee,
  which is O(n^2).  Let's do this in O(n) instead.

- Before, when we produced the tracelet for the first callee to analyze
  its shape, we would do so with inlining turned on.  If we had a stack
  of calls five-deep in total (which exceeds the depth limit), the
  tracelet for the first callee would successfully inline four calls,
  but we would fail when trying to inline that back into the original
  caller.  Instead, we should just elect not to inline the fifth-nested
  call.

We also change "inlining cost" to measure the cost of a single inlined
callstack, rather than the total cost of all inlining sites in a single
function.

This is a lot cleaner, and also we get to have a Decider class---who
doesn't want that?

We also get rid of the hot-calling-cold tight cost limit for now, for
two reasons:

  1/ It seems like we should be -more- willing to inline into hotter
     functions.
  2/ We have to track the first-level callee, which is not hard but
     slightly dirty and I didn't do it.

Reviewed By: @swtaarrs

Differential Revision: D1409050
Stop using NormalizedInstruction in InliningDecider

Reviewed By: @ottoni

Differential Revision: D1421846
Code motion in class.cpp

Summary: Just reorder the functions in class.cpp to match the header.  Also
delete some silly and unused private methods, and inline some one-liner
methods that invoke other inlined one-liner methods.

Reviewed By: @jdelong

Differential Revision: D1406173
Error messages related to magic methods

Summary: This diff implements many small error messages thrown around magic methods.

Reviewed By: @ptarjan

Differential Revision: D1423455
Fix autoloading for "type" and "newtype" statements

Summary: If the name on the right hand side of a "type" or "newtype" statement does
not name an existing class/interface/trait or an existing type alias, HHVM
tries both class-autoloading and type-autoloading. The problem is that if
class-autoloading doesn't find anything, HHVM calls the failure callback
before trying type-autoloading, which can cause problems for correct
programs (see the test cases).

This diff fixes HHVM to try both class-autoloading and type-autoloading
before calling the failure callback for "type" and "newtype" statements.

Reviewed By: @elgenie

Differential Revision: D1410570
typechecker: keep track of type params for require extends X<T1, T2, ...>

Summary: ... these were previously being thrown away and replaced with the
 type params of the containing trait and interface, usually working
 simply because the typechecker is (too) tolerant of classes without
 bound type params. The code for this is somewhat involved and
 complicated by the fact that a `require extends Foo<T1, T2>` requires
 the type variables `T1` and `T2` to be substituted juuuuust right in
 each place they're used.

Reviewed By: @jwatzman

Differential Revision: D1410558
add spaces to readme

Summary: Closes #3156
Created from: https://github.com/facebook/hhvm/pull/3156

Reviewed By: @fredemmott

Differential Revision: D1427582
Use timeout from GNU coreutils instead of bash hack

Summary: When using timeout.sh to run tests, test execution hangs until the
"sleep 1" finishes, probably because the monitor process keeps
filehandles open. If you instead use timeout from GNU coreutils, test
execution is about 2.5 times faster -- I measured a drop from 75 to 30
seconds for test/quick.
Closes #3021

Reviewed By: @LiraNuna

Differential Revision: D1427372

Pulled By: @fredemmott
Remove CallHelperInfo (dead code)

Summary: We don't need the return value from cgCallHelper anymore.

Reviewed By: @jasone

Differential Revision: D1426737
libdwarf, libpam, libelf, bootstrap cmake fixes

Summary: First: libdwarf. libdwarf seems to have no problem making breaking
changes and provides no easy way to even test the version you're
building against. I have added two tests in `FindLibDwarf.cmake` to
detect a change to function type signature and to detect the removal
of `dwarf_producer_init_c`. Hopefully this will work on all systems.

The recent change to use more system libraries broke the build of the
`gen-*` bootstrap utilities, as the targets were not updated to use
the system `double-conversion` library and instead attempted to use
the (unbuilt) local one.

Commit 83cbca11c1 made linking to libpam happen only on OSX. This
breaks the build on ArchLinux and openSUSE at least. I reverted this
change given that detecting whether or not you need to link to it is
quite difficult.
Closes #3134

Reviewed By: @ptarjan

Differential Revision: D1427288

Pulled By: @fredemmott
Don't over-consume local values when inlining

Summary: FrameState::forEachLocal includes locals from inlined callers. This is
what we want when we're consuming all locals to leave a trace, but not when
we're processing an instruction that just consumes locals from the current
frame.

Reviewed By: @jdelong

Differential Revision: D1426975
Clean up JIT handling of nop bytecodes

Summary: - Turn (Un)BoxR(Nop) into regular instructions. The assertTypeStack calls
  aren't needed since the next instruction will assert the same types anyway.
- Remove NormalizedInstruction::noOp since it's no longer needed.
- Rename NopDefCls to DefClsNop to be consistent with the other Nop bytecodes.

Reviewed By: @jdelong

Differential Revision: D1426804
Don't save a block's FrameState in FrameState::update

Summary: It's already saved in IRBuilder::finishBlock, so this was redundant.

Reviewed By: @bertmaher

Differential Revision: D1425693
Adjust the encoding m_pos uses when pointing past the last element

Summary: This diff changes the way arrays encode m_pos when it points past the last
element. Before, ArrayData::invalid_index (-1) was used. This diff changes
it to uses a non-negative value that is greater than the position of the
last element (if there is a last element). This allows PackedArrays and
MixedArrays to set m_pos to 0 initially, and then they never need to update
m_pos when a new element is added.

Reviewed By: @edwinsmith

Differential Revision: D1384311