buffer: clean up copy() asserts and tests

Argument checks were simplified by setting all undefined/NaN or out of
bounds values equal to their defaults.

Also copy() tests had a flaw that each buffer had the same bit pattern at
the same offset. So even if the copy failed, the bit-by-bit comparison
would have still been true. This was fixed by filling each buffer with a
unique value before copy operations.
buffer: error and misc cleanup

Changed types of errors thrown to be more indicative of what the error
represents. Also removed a few unnecessary uses of the v8 fully
quantified typename.
buffer: slow buffer copy compatibility fix

Fix issue where SlowBuffers couldn't be passed as target to Buffer
copy().

Also included checks to see if Argument parameters are defined before
assigning their values. This offered ~3x's performance gain.

Backport of 16bbecc from master branch. Closes #4633.
buffer: remove minor Buffer::Copy deoptimizations

* Omit ToObject() call. Buffer::Data() and Buffer::Length() know how
  to deal with Values.

* Don't check if the argument is undefined because it realistically
  never is and undefined->integer coercion achieves the same thing.
addon: Pass module object to NODE_MODULE init function

mainly to allow native addons to export single functions on
rather than being restricted to operating on an existing
object.

Init functions now receive exports as the first argument, like
before, but also the module object as the second argument, if they
support it.

Related to #4634

cc: @rvagg
doc: NODE_MODULE() to pass full `module` to addons

mainly to allow native addons to export single functions on `exports`
rather than being restricted to operating on an existing `exports`
object.

added link to addons repo in docs
doc: fix line wrapping in addons.markdown
stream_wrap: reference handle before uv_write2

Before sending handle to another process using uv_write2(), it should be
referenced to prevent it from being GCed before AfterWrite() will be
called.

see #4599
doc: fix typo in cluster module documentation

Fix a small typo in the cluster.settings documentation.
Revert "stream_wrap: reference handle before uv_write2"

It's segfaulting in release mode and asserting in debug mode:

  #
  # Fatal error in ../../deps/v8/src/api.h, line 297
  # CHECK(allow_empty_handle || that != __null) failed
  #

This reverts commit 99f0b022d528cc350f87150b5ecdf5c903aaeeb1.
stream_wrap: reference handle before uv_write2

Revert commit 7f2a78bf4d494806ccabcccdeb8579dcc4405a8d and fix using
empty symbol handle.
buffer: fix Buffer::Copy regression from 00b4b7b

If the end argument is omitted or not a number, make it default to
the end of the buffer, not zero.

Ideally, it should not matter what it defaults to because the JS shim
in lib/buffer.js should handle that but there are still several places
in node.js core that secrete SlowBuffers, hence Buffer::Copy() gets
called without going through Buffer.prototype.copy() first.
test: fix pummel test out-of-memory errors

Fix the following OOM error in pummel/test-net-connect-memleak
and pummel/test-tls-connect-memleak:

  FATAL ERROR: CALL_AND_RETRY_0 Allocation failed - process out of
  memory

Commit v8/v8@91afd39 increases the size of the deoptimization table
to the extent that a 64M float array pushes it over the brink. Switch
to SMIs so it stays below the limit.

pummel/test-net-connect-memleak is still failing albeit with a different
error this time. Needs further investigation.

  === release test-net-connect-memleak ===
  Path: pummel/test-net-connect-memleak
  -64 kB reclaimed
  assert.js:102
    throw new assert.AssertionError({
          ^
  AssertionError: false == true
      at done [as _onTimeout] (/home/bnoordhuis/src/nodejs/master/
  test/pummel/test-net-connect-memleak.js:48:3)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
      at process._makeCallback (node.js:306:20)
test: move simple/test-http-dns-fail to test/internet

The test times out when the upstream DNS resolver takes too long to
respond.

See #4672.
net: initialize TCPWrap when receiving socket

TCPWrap::Initialize() and PipeWrap::Initialize() should be called before
any data will be read from received socket. But, because of lazy
initialization of these bindings, Initialize() method isn't called.

Init bindings manually upon socket receiving.

See #4669
stream: Correct Transform class backpressure

The refactor in b43e544140ccf68580c02e71c56d19b82e1e1d32 to use
stream.push() in Transform inadvertently caused it to immediately
consume all the written data, regardless of whether or not the readable
side was being consumed.

Only pull data through the _transform() process when the readable side
is being consumed.

Fix #4667
http: Don't dump twice
net: Initialize _connection, _handle in Socket ctor

The better to reduce the hidden classes
child_process: move binding init in constructor

Doing this in net.Socket constructor has much more overhead, and
error is actually may happen before the construction of socket object.
cluster: support datagram sockets