@@ -342,6 +342,11 @@ void BeamModuleAssembler::emit_aligned_label(const ArgLabel &Label,
342342 emit_label (Label);
343343}
344344
345+ void BeamModuleAssembler::emit_i_func_label (const ArgLabel &Label) {
346+ flush_last_error ();
347+ emit_aligned_label (Label, ArgVal (ArgVal::Word, sizeof (UWord)));
348+ }
349+
345350void BeamModuleAssembler::emit_on_load () {
346351 on_load = current_label;
347352}
@@ -362,22 +367,12 @@ void BeamModuleAssembler::emit_int_code_end() {
362367void BeamModuleAssembler::emit_line (const ArgWord &Loc) {
363368 /* There is no need to align the line instruction. In the loaded code, the
364369 * type of the pointer will be void* and that pointer will only be used in
365- * comparisons.
366- *
367- * We only need to do something when there's a possibility of raising an
368- * exception at the very end of the preceding instruction (and thus
369- * pointing at the start of this one). If we were to do nothing, the error
370- * would erroneously refer to this instead of the preceding line.
371- *
372- * Since line addresses are taken _after_ line instructions we can avoid
373- * this by adding a nop when we detect this condition. */
374- if (a.offset () == last_error_offset) {
375- a.nop ();
376- }
370+ * comparisons. */
371+
372+ flush_last_error ();
377373}
378374
379375void BeamModuleAssembler::emit_func_line (const ArgWord &Loc) {
380- emit_line (Loc);
381376}
382377
383378void BeamModuleAssembler::emit_empty_func_line () {
@@ -416,3 +411,16 @@ const Label &BeamModuleAssembler::resolve_fragment(void (*fragment)()) {
416411
417412 return it->second ;
418413}
414+
415+ void BeamModuleAssembler::flush_last_error () {
416+ /* When there's a possibility of raising an exception at the very end of the
417+ * preceding instruction (and thus pointing at the start of this one) and
418+ * this instruction has a new line registered, the error would erroneously
419+ * refer to this instead of the preceding line.
420+ *
421+ * By adding a nop when we detect this condition, the error will correctly
422+ * refer to the preceding line. */
423+ if (a.offset () == last_error_offset) {
424+ a.nop ();
425+ }
426+ }
0 commit comments