@@ -113,9 +113,7 @@ static Persistent<String> listeners_symbol;
113113static Persistent<String> uncaught_exception_symbol;
114114static Persistent<String> emit_symbol;
115115
116- static Persistent<String> enter_symbol;
117- static Persistent<String> exit_symbol;
118- static Persistent<String> disposed_symbol;
116+ static Persistent<Function> process_makeCallback;
119117
120118
121119static bool print_eval = false ;
@@ -1010,42 +1008,27 @@ MakeCallback(const Handle<Object> object,
10101008
10111009 TryCatch try_catch;
10121010
1013- if (enter_symbol.IsEmpty ()) {
1014- enter_symbol = NODE_PSYMBOL (" enter" );
1015- exit_symbol = NODE_PSYMBOL (" exit" );
1016- disposed_symbol = NODE_PSYMBOL (" _disposed" );
1017- }
1018-
1019- Local<Value> domain_v = object->Get (domain_symbol);
1020- Local<Object> domain;
1021- Local<Function> enter;
1022- Local<Function> exit;
1023- if (!domain_v->IsUndefined ()) {
1024- domain = domain_v->ToObject ();
1025- if (domain->Get (disposed_symbol)->BooleanValue ()) {
1026- // domain has been disposed of.
1027- return Undefined ();
1011+ if (process_makeCallback.IsEmpty ()) {
1012+ Local<Value> cb_v = process->Get (String::New (" _makeCallback" ));
1013+ if (!cb_v->IsFunction ()) {
1014+ fprintf (stderr, " process._makeCallback assigned to non-function\n " );
1015+ abort ();
10281016 }
1029- enter = Local <Function>:: Cast (domain-> Get (enter_symbol) );
1030- enter-> Call (domain, 0 , NULL );
1017+ Local<Function> cb = cb_v. As <Function>( );
1018+ process_makeCallback = Persistent<Function>:: New (cb );
10311019 }
10321020
1033- if (try_catch. HasCaught ()) {
1034- FatalException (try_catch);
1035- return Undefined ( );
1021+ Local<Array> argArray = Array::New (argc);
1022+ for ( int i = 0 ; i < argc; i++) {
1023+ argArray-> Set ( Integer::New (i), argv[i] );
10361024 }
10371025
1038- Local<Value> ret = callback->Call (object, argc, argv);
1026+ Local<Value> object_l = Local<Value>::New (object);
1027+ Local<Value> callback_l = Local<Value>::New (callback);
10391028
1040- if (try_catch.HasCaught ()) {
1041- FatalException (try_catch);
1042- return Undefined ();
1043- }
1029+ Local<Value> args[3 ] = { object_l, callback_l, argArray };
10441030
1045- if (!domain_v->IsUndefined ()) {
1046- exit = Local<Function>::Cast (domain->Get (exit_symbol));
1047- exit->Call (domain, 0 , NULL );
1048- }
1031+ Local<Value> ret = process_makeCallback->Call (process, ARRAY_SIZE (args), args);
10491032
10501033 if (try_catch.HasCaught ()) {
10511034 FatalException (try_catch);
@@ -1858,9 +1841,6 @@ void FatalException(TryCatch &try_catch) {
18581841 ReportException (event_try_catch, true );
18591842 exit (1 );
18601843 }
1861-
1862- // This makes sure uncaught exceptions don't interfere with process.nextTick
1863- StartTickSpinner ();
18641844}
18651845
18661846
0 commit comments