Skip to content

Commit 3db6ec5

Browse files
authored
[interp] Add IL seq points (#56137)
* [interp] Generate il seq points Interpreter was generating only sdb seq points for implementing debugger support. Add also il seq points which are used for stack traces when debugging information is not present. We add IL seq points in locations where IL stack is empty, same as JIT. * [interp] Use interp_prev_ins in more places It skips over NOPs * [tests] Disable all tests in readytorun folder on mono We were disabling some of them all over the place. They shouldn'd be running on mono.
1 parent 1bd4e4b commit 3db6ec5

File tree

6 files changed

+26
-38
lines changed

6 files changed

+26
-38
lines changed

src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ public void ToString_NullFrame_ThrowsNullReferenceException()
313313
}
314314

315315
[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
316-
[ActiveIssue("https://github.com/dotnet/runtime/issues/51096", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoInterpreter))]
317316
public void ToString_ShowILOffset()
318317
{
319318
string AssemblyName = "ExceptionTestAssembly.dll";

src/mono/mono/mini/interp/interp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,6 +3294,7 @@ interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs
32943294
ip += 3;
32953295
MINT_IN_BREAK;
32963296
MINT_IN_CASE(MINT_NOP)
3297+
MINT_IN_CASE(MINT_IL_SEQ_POINT)
32973298
MINT_IN_CASE(MINT_NIY)
32983299
MINT_IN_CASE(MINT_DEF)
32993300
MINT_IN_CASE(MINT_DUMMY_USE)

src/mono/mono/mini/interp/mintops.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
OPDEF(MINT_NOP, "nop", 1, 0, 0, MintOpNoArgs)
1212
OPDEF(MINT_NIY, "niy", 1, 0, 0, MintOpNoArgs)
1313
OPDEF(MINT_DEF, "def", 2, 1, 0, MintOpNoArgs)
14+
OPDEF(MINT_IL_SEQ_POINT, "il_seq_point", 1, 0, 0, MintOpNoArgs)
1415
OPDEF(MINT_DUMMY_USE, "dummy_use", 2, 0, 1, MintOpNoArgs)
1516
OPDEF(MINT_BREAK, "break", 1, 0, 0, MintOpNoArgs)
1617
OPDEF(MINT_BREAKPOINT, "breakpoint", 1, 0, 0, MintOpNoArgs)

src/mono/mono/mini/interp/transform.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static InterpInst*
293293
interp_prev_ins (InterpInst *ins)
294294
{
295295
ins = ins->prev;
296-
while (ins && ins->opcode == MINT_NOP)
296+
while (ins && (ins->opcode == MINT_NOP || ins->opcode == MINT_IL_SEQ_POINT))
297297
ins = ins->prev;
298298
return ins;
299299
}
@@ -2475,9 +2475,11 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
24752475
} else if (in_corlib && target_method->klass == mono_defaults.enum_class && !strcmp (tm, "HasFlag")) {
24762476
gboolean intrinsify = FALSE;
24772477
MonoClass *base_klass = NULL;
2478+
InterpInst *prev_ins = interp_prev_ins (td->last_ins);
2479+
InterpInst *prev_prev_ins = prev_ins ? interp_prev_ins (prev_ins) : NULL;
24782480
if (td->last_ins && td->last_ins->opcode == MINT_BOX &&
2479-
td->last_ins->prev && interp_ins_is_ldc (td->last_ins->prev) &&
2480-
td->last_ins->prev->prev && td->last_ins->prev->prev->opcode == MINT_BOX &&
2481+
prev_ins && interp_ins_is_ldc (prev_ins) &&
2482+
prev_prev_ins && prev_prev_ins->opcode == MINT_BOX &&
24812483
td->sp [-2].klass == td->sp [-1].klass &&
24822484
interp_ip_in_cbb (td, td->ip - td->il_code)) {
24832485
// csc pattern : box, ldc, box, call HasFlag
@@ -2486,12 +2488,12 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
24862488
base_klass = mono_class_from_mono_type_internal (base_type);
24872489

24882490
// Remove the boxing of valuetypes, by replacing them with moves
2489-
td->last_ins->prev->prev->opcode = get_mov_for_type (mint_type (base_type), FALSE);
2491+
prev_prev_ins->opcode = get_mov_for_type (mint_type (base_type), FALSE);
24902492
td->last_ins->opcode = get_mov_for_type (mint_type (base_type), FALSE);
24912493

24922494
intrinsify = TRUE;
24932495
} else if (td->last_ins && td->last_ins->opcode == MINT_BOX &&
2494-
td->last_ins->prev && interp_ins_is_ldc (td->last_ins->prev) &&
2496+
prev_ins && interp_ins_is_ldc (prev_ins) && prev_prev_ins &&
24952497
constrained_class && td->sp [-1].klass == constrained_class &&
24962498
interp_ip_in_cbb (td, td->ip - td->il_code)) {
24972499
// mcs pattern : ldc, box, constrained Enum, call HasFlag
@@ -2502,7 +2504,7 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
25022504

25032505
// Remove boxing and load the value of this
25042506
td->last_ins->opcode = get_mov_for_type (mt, FALSE);
2505-
InterpInst *ins = interp_insert_ins (td, td->last_ins->prev->prev, interp_get_ldind_for_mt (mt));
2507+
InterpInst *ins = interp_insert_ins (td, prev_prev_ins, interp_get_ldind_for_mt (mt));
25062508
interp_ins_set_sreg (ins, td->sp [-2].local);
25072509
interp_ins_set_dreg (ins, td->sp [-2].local);
25082510
intrinsify = TRUE;
@@ -3798,7 +3800,7 @@ save_seq_points (TransformData *td, MonoJitInfo *jinfo)
37983800
GSList **next = NULL;
37993801
GList *bblist;
38003802

3801-
if (!td->gen_sdb_seq_points)
3803+
if (!td->gen_seq_points)
38023804
return;
38033805

38043806
/*
@@ -4580,10 +4582,14 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
45804582
(td->sp > td->stack && (td->sp [-1].type == STACK_TYPE_O || td->sp [-1].type == STACK_TYPE_VT)) ? (td->sp [-1].klass == NULL ? "?" : m_class_get_name (td->sp [-1].klass)) : "");
45814583
}
45824584

4583-
if (td->gen_sdb_seq_points && ((!sym_seq_points && td->stack == td->sp) || (sym_seq_points && mono_bitset_test_fast (seq_point_locs, td->ip - header->code)))) {
4584-
if (in_offset == 0 || (header->num_clauses && !td->cbb->last_ins))
4585-
interp_add_ins (td, MINT_SDB_INTR_LOC);
4586-
last_seq_point = interp_add_ins (td, MINT_SDB_SEQ_POINT);
4585+
if (td->gen_seq_points && ((!sym_seq_points && td->stack == td->sp) || (sym_seq_points && mono_bitset_test_fast (seq_point_locs, td->ip - header->code)))) {
4586+
if (td->gen_sdb_seq_points) {
4587+
if (in_offset == 0 || (header->num_clauses && !td->cbb->last_ins))
4588+
interp_add_ins (td, MINT_SDB_INTR_LOC);
4589+
last_seq_point = interp_add_ins (td, MINT_SDB_SEQ_POINT);
4590+
} else {
4591+
last_seq_point = interp_add_ins (td, MINT_IL_SEQ_POINT);
4592+
}
45874593
}
45884594

45894595
if (td->prof_coverage) {
@@ -7664,7 +7670,7 @@ emit_compacted_instruction (TransformData *td, guint16* start_ip, InterpInst *in
76647670
}
76657671
if (opcode == MINT_CALL_HANDLER)
76667672
*ip++ = ins->data [2];
7667-
} else if (opcode == MINT_SDB_SEQ_POINT) {
7673+
} else if (opcode == MINT_SDB_SEQ_POINT || opcode == MINT_IL_SEQ_POINT) {
76687674
SeqPoint *seqp = (SeqPoint*)mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint));
76697675
InterpBasicBlock *cbb;
76707676

@@ -7687,6 +7693,9 @@ emit_compacted_instruction (TransformData *td, guint16* start_ip, InterpInst *in
76877693

76887694
cbb->seq_points = g_slist_prepend_mempool (td->mempool, cbb->seq_points, seqp);
76897695
cbb->last_seq_point = seqp;
7696+
// IL_SEQ_POINT shouldn't exist in the emitted code, we undo the ip position
7697+
if (opcode == MINT_IL_SEQ_POINT)
7698+
return ip - 1;
76907699
} else if (opcode == MINT_MOV_OFF) {
76917700
int foff = ins->data [0];
76927701
int mt = ins->data [1];
@@ -9453,6 +9462,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
94539462
#ifdef ENABLE_EXPERIMENT_TIERED
94549463
td->patchsite_hash = g_hash_table_new (NULL, NULL);
94559464
#endif
9465+
td->gen_seq_points = !mini_debug_options.no_seq_points_compact_data || mini_debug_options.gen_sdb_seq_points;
94569466
td->gen_sdb_seq_points = mini_debug_options.gen_sdb_seq_points;
94579467
td->seq_points = g_ptr_array_new ();
94589468
td->verbose_level = mono_interp_traceopt;

src/mono/mono/mini/interp/transform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ typedef struct
191191
#endif
192192
int *clause_indexes;
193193
int *clause_vars;
194+
gboolean gen_seq_points;
194195
gboolean gen_sdb_seq_points;
195196
GPtrArray *seq_points;
196197
InterpBasicBlock **offset_to_bb;

src/tests/issues.targets

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,21 +1541,9 @@
15411541
<ExcludeList Include="$(XunitTestBinBase)/profiler/rejit/rejit/rejit.sh">
15421542
<Issue>needs triage</Issue>
15431543
</ExcludeList>
1544-
<ExcludeList Include="$(XunitTestBinBase)/readytorun/r2rdump/FrameworkTests/R2RDumpTests/*">
1544+
<ExcludeList Include="$(XunitTestBinBase)/readytorun/**">
15451545
<Issue>These tests are not supposed to be run with mono.</Issue>
15461546
</ExcludeList>
1547-
<ExcludeList Include="$(XunitTestBinBase)/readytorun/crossgen2/crossgen2smoke/**">
1548-
<Issue>needs triage</Issue>
1549-
</ExcludeList>
1550-
<ExcludeList Include="$(XunitTestBinBase)/readytorun/crossgen2/crossgen2smoke_donotalwaysusecrossgen2/**">
1551-
<Issue>needs triage</Issue>
1552-
</ExcludeList>
1553-
<ExcludeList Include="$(XunitTestBinBase)/readytorun/tests/mainv1/**">
1554-
<Issue>needs triage</Issue>
1555-
</ExcludeList>
1556-
<ExcludeList Include="$(XunitTestBinBase)/readytorun/tests/mainv2/**">
1557-
<Issue>needs triage</Issue>
1558-
</ExcludeList>
15591547
<ExcludeList Include="$(XunitTestBinBase)/reflection/DefaultInterfaceMethods/Emit/**">
15601548
<Issue>needs triage</Issue>
15611549
</ExcludeList>
@@ -1604,9 +1592,6 @@
16041592
<ExcludeList Include="$(XunitTestBinBase)/tracing/eventpipe/gcdump/gcdump/**">
16051593
<Issue>needs triage</Issue>
16061594
</ExcludeList>
1607-
<ExcludeList Include="$(XunitTestBinBase)/readytorun/coreroot_determinism/coreroot_determinism/**">
1608-
<Issue>needs triage</Issue>
1609-
</ExcludeList>
16101595
<ExcludeList Include="$(XunitTestBinBase)/Interop/DllImportAttribute/DllImportPath/**">
16111596
<Issue>needs triage</Issue>
16121597
</ExcludeList>
@@ -2657,9 +2642,6 @@
26572642
<ExcludeList Include = "$(XunitTestBinBase)/GC/Coverage/LargeObjectAlloc2/**">
26582643
<Issue>needs triage</Issue>
26592644
</ExcludeList>
2660-
<ExcludeList Include = "$(XunitTestBinBase)/readytorun/tests/fileversionpreservation/fileversionpreservation/**">
2661-
<Issue>needs triage</Issue>
2662-
</ExcludeList>
26632645
<ExcludeList Include = "$(XunitTestBinBase)/tracing/eventactivityidcontrol/eventactivityidcontrol/**">
26642646
<Issue>needs triage</Issue>
26652647
</ExcludeList>
@@ -2843,15 +2825,9 @@
28432825
<ExcludeList Include = "$(XunitTestBinBase)/JIT/Regression/JitBlue/GitHub_36614/GitHub_36614/**">
28442826
<Issue>needs triage</Issue>
28452827
</ExcludeList>
2846-
<ExcludeList Include = "$(XunitTestBinBase)/readytorun/determinism/crossgen2determinism/**">
2847-
<Issue>Need crossgen folder under Core_Root</Issue>
2848-
</ExcludeList>
28492828
<ExcludeList Include = "$(XunitTestBinBase)/readytorun/multifolder/multifolder/**">
28502829
<Issue>needs triage</Issue>
28512830
</ExcludeList>
2852-
<ExcludeList Include = "$(XunitTestBinBase)/readytorun/tests/fileversionpreservation/fileversionpreservation/**">
2853-
<Issue>needs triage</Issue>
2854-
</ExcludeList>
28552831
<ExcludeList Include = "$(XunitTestBinBase)/GC/Features/HeapExpansion/bestfit-finalize/*">
28562832
<Issue>https://github.com/dotnet/runtime/issues/44643</Issue>
28572833
</ExcludeList>

0 commit comments

Comments
 (0)