@ -374,6 +374,26 @@
scheduleMicrotasks ( ) ;
}
function _ combinedTickCallback ( args , callback ) {
if ( args === undefined ) {
callback ( ) ;
} else {
switch ( args . length ) {
case 1 :
callback ( args [ 0 ] ) ;
break ;
case 2 :
callback ( args [ 0 ] , args [ 1 ] ) ;
break ;
case 3 :
callback ( args [ 0 ] , args [ 1 ] , args [ 2 ] ) ;
break ;
default :
callback . apply ( null , args ) ;
}
}
}
// Run callbacks that have no domain.
// Using domains will cause this to be overridden.
function _ tickCallback ( ) {
@ -384,27 +404,10 @@
tock = nextTickQueue [ tickInfo [ kIndex ] ++ ] ;
callback = tock . callback ;
args = tock . args ;
// Using separate callback execution functions helps to limit the
// scope of DEOPTs caused by using try blocks and allows direct
// Using separate callback execution functions allows direct
// callback invocation with small numbers of arguments to avoid the
// performance hit associated with using `fn.apply()`
if ( args === undefined ) {
nextTickCallbackWith0Args ( callback ) ;
} else {
switch ( args . length ) {
case 1 :
nextTickCallbackWith1Arg ( callback , args [ 0 ] ) ;
break ;
case 2 :
nextTickCallbackWith2Args ( callback , args [ 0 ] , args [ 1 ] ) ;
break ;
case 3 :
nextTickCallbackWith3Args ( callback , args [ 0 ] , args [ 1 ] , args [ 2 ] ) ;
break ;
default :
nextTickCallbackWithManyArgs ( callback , args ) ;
}
}
_ combinedTickCallback ( args , callback ) ;
if ( 1e4 < tickInfo [ kIndex ] )
tickDone ( ) ;
}
@ -425,27 +428,10 @@
args = tock . args ;
if ( domain )
domain . enter ( ) ;
// Using separate callback execution functions helps to limit the
// scope of DEOPTs caused by using try blocks and allows direct
// Using separate callback execution functions allows direct
// callback invocation with small numbers of arguments to avoid the
// performance hit associated with using `fn.apply()`
if ( args === undefined ) {
nextTickCallbackWith0Args ( callback ) ;
} else {
switch ( args . length ) {
case 1 :
nextTickCallbackWith1Arg ( callback , args [ 0 ] ) ;
break ;
case 2 :
nextTickCallbackWith2Args ( callback , args [ 0 ] , args [ 1 ] ) ;
break ;
case 3 :
nextTickCallbackWith3Args ( callback , args [ 0 ] , args [ 1 ] , args [ 2 ] ) ;
break ;
default :
nextTickCallbackWithManyArgs ( callback , args ) ;
}
}
_ combinedTickCallback ( args , callback ) ;
if ( 1e4 < tickInfo [ kIndex ] )
tickDone ( ) ;
if ( domain )
@ -457,61 +443,6 @@
} while ( tickInfo [ kLength ] !== 0 ) ;
}
function nextTickCallbackWith0Args ( callback ) {
var threw = true ;
try {
callback ( ) ;
threw = false ;
} finally {
if ( threw )
tickDone ( ) ;
}
}
function nextTickCallbackWith1Arg ( callback , arg1 ) {
var threw = true ;
try {
callback ( arg1 ) ;
threw = false ;
} finally {
if ( threw )
tickDone ( ) ;
}
}
function nextTickCallbackWith2Args ( callback , arg1 , arg2 ) {
var threw = true ;
try {
callback ( arg1 , arg2 ) ;
threw = false ;
} finally {
if ( threw )
tickDone ( ) ;
}
}
function nextTickCallbackWith3Args ( callback , arg1 , arg2 , arg3 ) {
var threw = true ;
try {
callback ( arg1 , arg2 , arg3 ) ;
threw = false ;
} finally {
if ( threw )
tickDone ( ) ;
}
}
function nextTickCallbackWithManyArgs ( callback , args ) {
var threw = true ;
try {
callback . apply ( null , args ) ;
threw = false ;
} finally {
if ( threw )
tickDone ( ) ;
}
}
function TickObject ( c , args ) {
this . callback = c ;
this . domain = process . domain || null ;
@ -527,9 +458,9 @@
var args ;
if ( arguments . length > 1 ) {
args = [ ] ;
args = new Array ( arguments . length - 1 ) ;
for ( var i = 1 ; i < arguments . length ; i ++ )
args . push ( arguments [ i ] ) ;
args [ i - 1 ] = arguments [ i ] ;
}
nextTickQueue . push ( new TickObject ( callback , args ) ) ;