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