docs: fix smalloc.dispose() example

Also couple of additions about dispose and limitations of smalloc'ed
objects.

Fixes: https://github.com/joyent/node/pull/8625
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
net: add pauseOnConnect option to createServer()

Currently when a server receives a new connection the underlying socket
handle begins reading data immediately. This causes problems when
sockets are passed between processes, as data can be read by the first
process and thus never read by the second process.

This commit allows sockets that are constructed with a handle to be
paused initially.

PR-URL: https://github.com/joyent/node/pull/8576
Fixes: https://github.com/joyent/node/issues/7905
Fixes: https://github.com/joyent/node/issues/7784
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
smalloc: fix copyOnto optimization

copyOnto is broken when one argument has 1 byte size and the other > 1
byte.

PR-URL: https://github.com/joyent/node/pull/8637
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
smalloc: check if obj has external data

PR-URL: https://github.com/joyent/node/pull/8655
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
build: fix build for SmartOS

This change in V8: https://code.google.com/p/v8/source/detail?r=22210
has introduced a method named OS::GetCurrentThreadId which fails to
compile on OSes where a "gettid" syscall does not exist.

This build issue has been fixed upstream by several changes:
- https://code.google.com/p/v8/source/detail?r=23459.
- https://codereview.chromium.org/649553002
- https://codereview.chromium.org/642223003

Another minor fix to the upstream changes was also necessary.
See https://code.google.com/p/v8/issues/detail?id=3620 for
more information.

The other build issue was due to the fact that alloca.h is not included
by other system includes on SmartOS, which is assumed by V8.

Built and tested on Linux, MacOS X, Windows and SmartOS.
test: more thorough tests for npm
npm: Upgrade to v2.1.6
deps: update uv to v1.0.0-rc2

PR-URL: https://github.com/joyent/node/pull/8566
Reviewed-by: Fedor Indutny <fedor@indutny.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
core: replace uv_fs_readdir with uv_fs_scandir

PR-URL: https://github.com/joyent/node/pull/8566
Reviewed-by: Fedor Indutny <fedor@indutny.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
core: fix usage of uv_cwd

It was modified in libuv to be consistent with uv_exepath and not
include the trailing NULL byte in the returned size.

PR-URL: https://github.com/joyent/node/pull/8566
Reviewed-by: Fedor Indutny <fedor@indutny.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
async-wrap: add functionality, rm tracing module

* Generalize the ASYNC_PROVIDER being passed by the category to which
  it belongs. Instead of having specialized providers for classes like
  ConnectWrap.

* When instantiating a class in cases like receiving an incoming TCP
  connection the activeContext of the parent is no longer available
  because of the asynchronous call. In these cases manually set the
  parent class that contains the context that should propagate to the
  instantiated class.
  * Currently this only happens in tcp_wrap, pipe_wrap and stream_wrap.
    Though careful attention will need to be made in the future that
    other initializations of the same form are also wrapped.

* Force before/after callbacks to run when a class is instantiated, not
  only when a callback is about to be called from MakeCallback.

* Add asyncRemoveQueue() method so handles can disable async_flags_ when
  there are no longer any items in the queue.

* Remove all public facing API for the tracing module and replace with a
  process.binding('async_listener') to initialize hooks into the
  AsyncWrap class.

* Remove flag states of AsyncWrap::ProviderType. It's impossible to have
  and AsyncWrap instance with more than one PROVIDER.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
async-wrap: macro-ify AsyncWrap::ProviderType's

Making all the provider types a macro expansion allows them to be
declared in one location but used in many places. This makes maintenance
easier as more providers are added.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
async-wrap: all new instances get a unique id

Every AsyncWrap instance recieves a unique id. A new C++ and JS API have
been exposed to retrieve this value:

* AsyncWrap::id()
* handle.asyncId()

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
node: fn to add undefined prototype properties

Add convenience function to add undefined properties to a
FunctionTemplate's prototype. This is useful when properties will be set
in the future on the instantiated object, without V8 changing the object
map.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
dgram: SendWrap now has FunctionTemplate

In order for SendWrap to have access to the additional methods in
AsyncWrap, the request object needs to be an instance of a
FunctionTemplate.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
net: ConnectWrap now has FunctionTemplate

Created classes PipeConnectWrap and TCPConnectWrap so each one could run
AsyncWrap::AddMethods() during instantiation.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
fs: use FSReqWrap JS object

When instantiating FSReqWrap use a constructed JS object instead of
generating a new object in the C++ API in order to attach the oncomplete
callback.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
async-wrap: pass id to create callback

Since the object isn't passed to the create callback, pass the id() as
an argument.

Also, switch async_id_ to be a uint32_t instead of a double.
stream_wrap: ShutdownWrap now a FunctionTemplate

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
stream_wrap: WriteWrap now has FunctionTemplate