@@ -1323,46 +1323,6 @@ call_error_handler(Process* p, const ErtsCodeMFA *mfa, Eterm* reg, Eterm func)
13231323 return ep ;
13241324}
13251325
1326- static Export *
1327- apply_setup_error_handler (Process * p , Eterm module , Eterm function , Uint arity , Eterm * reg )
1328- {
1329- Export * ep ;
1330-
1331- /*
1332- * Find the export table index for the error handler. Return NULL if
1333- * there is no error handler module.
1334- */
1335-
1336- if ((ep = erts_active_export_entry (erts_proc_get_error_handler (p ),
1337- am_undefined_function , 3 )) == NULL ) {
1338- return NULL ;
1339- } else {
1340- int i ;
1341- Uint sz = 2 * arity ;
1342- Eterm * hp ;
1343- Eterm args = NIL ;
1344-
1345- /*
1346- * Always copy args from registers to a new list; this ensures
1347- * that we have the same behaviour whether or not this was
1348- * called from apply or fixed_apply (any additional last
1349- * THIS-argument will be included, assuming that arity has been
1350- * properly adjusted).
1351- */
1352-
1353- hp = HAlloc (p , sz );
1354- for (i = arity - 1 ; i >= 0 ; i -- ) {
1355- args = CONS (hp , reg [i ], args );
1356- hp += 2 ;
1357- }
1358- reg [0 ] = module ;
1359- reg [1 ] = function ;
1360- reg [2 ] = args ;
1361- }
1362-
1363- return ep ;
1364- }
1365-
13661326static ERTS_INLINE void
13671327apply_bif_error_adjustment (Process * p , Export * ep ,
13681328 Eterm * reg , Uint arity ,
@@ -1537,18 +1497,13 @@ apply(Process* p, Eterm* reg, ErtsCodePtr I, Uint stack_offset)
15371497 goto error ;
15381498 }
15391499
1540- /*
1541- * Get the index into the export table, or failing that the export
1542- * entry for the error handler.
1543- *
1544- * Note: All BIFs have export entries; thus, no special case is needed.
1545- */
1500+ /* Call the referenced function, if any: should the function not be found,
1501+ * create a stub entry which in turn calls the error handler. */
1502+ ep = erts_export_get_or_make_stub (module , function , arity );
15461503
1547- if ((ep = erts_active_export_entry (module , function , arity )) == NULL ) {
1548- if ((ep = apply_setup_error_handler (p , module , function , arity , reg )) == NULL ) goto error ;
1549- }
15501504 apply_bif_error_adjustment (p , ep , reg , arity , I , stack_offset );
15511505 DTRACE_GLOBAL_CALL_FROM_EXPORT (p , ep );
1506+
15521507 return ep ;
15531508}
15541509
@@ -1583,17 +1538,9 @@ fixed_apply(Process* p, Eterm* reg, Uint arity,
15831538 return apply (p , reg , I , stack_offset );
15841539 }
15851540
1586- /*
1587- * Get the index into the export table, or failing that the export
1588- * entry for the error handler module.
1589- *
1590- * Note: All BIFs have export entries; thus, no special case is needed.
1591- */
1592-
1593- if ((ep = erts_active_export_entry (module , function , arity )) == NULL ) {
1594- if ((ep = apply_setup_error_handler (p , module , function , arity , reg )) == NULL )
1595- goto error ;
1596- }
1541+ /* Call the referenced function, if any: should the function not be found,
1542+ * create a stub entry which in turn calls the error handler. */
1543+ ep = erts_export_get_or_make_stub (module , function , arity );
15971544
15981545 apply_bif_error_adjustment (p , ep , reg , arity , I , stack_offset );
15991546 DTRACE_GLOBAL_CALL_FROM_EXPORT (p , ep );
0 commit comments