@@ -1333,46 +1333,6 @@ call_error_handler(Process* p, const ErtsCodeMFA *mfa, Eterm* reg, Eterm func)
13331333 return ep ;
13341334}
13351335
1336- static Export *
1337- apply_setup_error_handler (Process * p , Eterm module , Eterm function , Uint arity , Eterm * reg )
1338- {
1339- Export * ep ;
1340-
1341- /*
1342- * Find the export table index for the error handler. Return NULL if
1343- * there is no error handler module.
1344- */
1345-
1346- if ((ep = erts_active_export_entry (erts_proc_get_error_handler (p ),
1347- am_undefined_function , 3 )) == NULL ) {
1348- return NULL ;
1349- } else {
1350- int i ;
1351- Uint sz = 2 * arity ;
1352- Eterm * hp ;
1353- Eterm args = NIL ;
1354-
1355- /*
1356- * Always copy args from registers to a new list; this ensures
1357- * that we have the same behaviour whether or not this was
1358- * called from apply or fixed_apply (any additional last
1359- * THIS-argument will be included, assuming that arity has been
1360- * properly adjusted).
1361- */
1362-
1363- hp = HAlloc (p , sz );
1364- for (i = arity - 1 ; i >= 0 ; i -- ) {
1365- args = CONS (hp , reg [i ], args );
1366- hp += 2 ;
1367- }
1368- reg [0 ] = module ;
1369- reg [1 ] = function ;
1370- reg [2 ] = args ;
1371- }
1372-
1373- return ep ;
1374- }
1375-
13761336static ERTS_INLINE void
13771337apply_bif_error_adjustment (Process * p , Export * ep ,
13781338 Eterm * reg , Uint arity ,
@@ -1547,18 +1507,13 @@ apply(Process* p, Eterm* reg, ErtsCodePtr I, Uint stack_offset)
15471507 goto error ;
15481508 }
15491509
1550- /*
1551- * Get the index into the export table, or failing that the export
1552- * entry for the error handler.
1553- *
1554- * Note: All BIFs have export entries; thus, no special case is needed.
1555- */
1510+ /* Call the referenced function, if any: should the function not be found,
1511+ * create a stub entry which in turn calls the error handler. */
1512+ ep = erts_export_get_or_make_stub (module , function , arity );
15561513
1557- if ((ep = erts_active_export_entry (module , function , arity )) == NULL ) {
1558- if ((ep = apply_setup_error_handler (p , module , function , arity , reg )) == NULL ) goto error ;
1559- }
15601514 apply_bif_error_adjustment (p , ep , reg , arity , I , stack_offset );
15611515 DTRACE_GLOBAL_CALL_FROM_EXPORT (p , ep );
1516+
15621517 return ep ;
15631518}
15641519
@@ -1593,17 +1548,9 @@ fixed_apply(Process* p, Eterm* reg, Uint arity,
15931548 return apply (p , reg , I , stack_offset );
15941549 }
15951550
1596- /*
1597- * Get the index into the export table, or failing that the export
1598- * entry for the error handler module.
1599- *
1600- * Note: All BIFs have export entries; thus, no special case is needed.
1601- */
1602-
1603- if ((ep = erts_active_export_entry (module , function , arity )) == NULL ) {
1604- if ((ep = apply_setup_error_handler (p , module , function , arity , reg )) == NULL )
1605- goto error ;
1606- }
1551+ /* Call the referenced function, if any: should the function not be found,
1552+ * create a stub entry which in turn calls the error handler. */
1553+ ep = erts_export_get_or_make_stub (module , function , arity );
16071554
16081555 apply_bif_error_adjustment (p , ep , reg , arity , I , stack_offset );
16091556 DTRACE_GLOBAL_CALL_FROM_EXPORT (p , ep );
0 commit comments