@@ -1204,7 +1204,8 @@ ves_pinvoke_method (InterpFrame *frame, MonoMethodSignature *sig, MonoFuncV addr
1204
1204
g_print ("ICALL: mono_interp_to_native_trampoline = %p, addr = %p\n" , mono_interp_to_native_trampoline , addr );
1205
1205
#endif
1206
1206
1207
- INTERP_PUSH_LMF_WITH_CTX (frame , ext , & & exit_pinvoke );
1207
+ context -> current_frame = frame ;
1208
+ INTERP_PUSH_LMF_WITH_CTX (context -> current_frame , ext , & & exit_pinvoke );
1208
1209
#ifdef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
1209
1210
mono_interp_to_native_trampoline (addr , & ccontext );
1210
1211
#else
@@ -1601,7 +1602,7 @@ get_trace_ips (MonoDomain *domain, InterpFrame *top)
1601
1602
static MonoObject *
1602
1603
interp_runtime_invoke (MonoMethod * method , void * obj , void * * params , MonoObject * * exc , MonoError * error )
1603
1604
{
1604
- InterpFrame frame ;
1605
+ InterpFrame frame , * old_frame ;
1605
1606
ThreadContext * context = get_context ();
1606
1607
MonoMethodSignature * sig = mono_method_signature_internal (method );
1607
1608
MonoClass * klass = mono_class_from_mono_type_internal (sig -> ret );
@@ -1614,6 +1615,8 @@ interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject
1614
1615
1615
1616
frame .ex = NULL ;
1616
1617
1618
+ old_frame = context -> current_frame ;
1619
+
1617
1620
MonoDomain * domain = mono_domain_get ();
1618
1621
1619
1622
if (method -> flags & METHOD_ATTRIBUTE_PINVOKE_IMPL )
@@ -1640,6 +1643,8 @@ interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject
1640
1643
1641
1644
interp_exec_method (& frame , context );
1642
1645
1646
+ context -> current_frame = old_frame ;
1647
+
1643
1648
if (frame .ex ) {
1644
1649
if (exc ) {
1645
1650
* exc = (MonoObject * ) frame .ex ;
@@ -1666,6 +1671,7 @@ interp_entry (InterpEntryData *data)
1666
1671
InterpFrame frame ;
1667
1672
InterpMethod * rmethod = data -> rmethod ;
1668
1673
ThreadContext * context ;
1674
+ InterpFrame * old_frame ;
1669
1675
stackval result ;
1670
1676
stackval * args ;
1671
1677
MonoMethod * method ;
@@ -1687,6 +1693,7 @@ interp_entry (InterpEntryData *data)
1687
1693
//printf ("%s\n", mono_method_full_name (method, 1));
1688
1694
1689
1695
frame .ex = NULL ;
1696
+ old_frame = context -> current_frame ;
1690
1697
1691
1698
args = g_newa (stackval , sig -> param_count + (sig -> hasthis ? 1 : 0 ));
1692
1699
if (sig -> hasthis )
@@ -1737,6 +1744,7 @@ interp_entry (InterpEntryData *data)
1737
1744
}
1738
1745
1739
1746
interp_exec_method (& frame , context );
1747
+ context -> current_frame = old_frame ;
1740
1748
1741
1749
if (rmethod -> needs_thread_attach )
1742
1750
mono_threads_detach_coop (orig_domain , & attach_cookie );
@@ -1770,10 +1778,10 @@ interp_entry (InterpEntryData *data)
1770
1778
1771
1779
/* MONO_NO_OPTIMIATION is needed due to usage of INTERP_PUSH_LMF_WITH_CTX. */
1772
1780
static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE stackval *
1773
- do_icall (InterpFrame * frame , MonoMethodSignature * sig , int op , stackval * sp , gpointer ptr )
1781
+ do_icall (ThreadContext * context , MonoMethodSignature * sig , int op , stackval * sp , gpointer ptr )
1774
1782
{
1775
1783
MonoLMFExt ext ;
1776
- INTERP_PUSH_LMF_WITH_CTX (frame , ext , & & exit_icall );
1784
+ INTERP_PUSH_LMF_WITH_CTX (context -> current_frame , ext , & & exit_icall );
1777
1785
1778
1786
switch (op ) {
1779
1787
case MINT_ICALL_V_V : {
@@ -2360,6 +2368,7 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
2360
2368
{
2361
2369
InterpFrame frame ;
2362
2370
ThreadContext * context ;
2371
+ InterpFrame * old_frame ;
2363
2372
stackval result ;
2364
2373
stackval * args ;
2365
2374
MonoMethod * method ;
@@ -2378,6 +2387,7 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
2378
2387
sig = mono_method_signature_internal (method );
2379
2388
2380
2389
frame .ex = NULL ;
2390
+ old_frame = context -> current_frame ;
2381
2391
2382
2392
args = (stackval * )alloca (sizeof (stackval ) * (sig -> param_count + (sig -> hasthis ? 1 : 0 )));
2383
2393
@@ -2396,6 +2406,7 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
2396
2406
mono_arch_get_native_call_context_args (ccontext , & frame , sig );
2397
2407
2398
2408
interp_exec_method (& frame , context );
2409
+ context -> current_frame = old_frame ;
2399
2410
2400
2411
if (rmethod -> needs_thread_attach )
2401
2412
mono_threads_detach_coop (orig_domain , & attach_cookie );
@@ -2611,19 +2622,23 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
2611
2622
0 };
2612
2623
#endif
2613
2624
2625
+
2614
2626
frame -> ex = NULL ;
2627
+ frame -> ex_handler = NULL ;
2628
+ frame -> ip = NULL ;
2629
+ frame -> domain = mono_domain_get ();
2630
+ context -> current_frame = frame ;
2615
2631
2616
2632
debug_enter (frame , & tracing );
2617
2633
2618
2634
rtm = frame -> imethod ;
2619
- if (!rtm -> transformed ) {
2635
+ if (!frame -> imethod -> transformed ) {
2620
2636
#if DEBUG_INTERP
2621
2637
char * mn = mono_method_full_name (frame -> imethod -> method , TRUE);
2622
2638
g_print ("(%p) Transforming %s\n" , mono_thread_internal_current (), mn );
2623
2639
g_free (mn );
2624
2640
#endif
2625
2641
2626
- frame -> ip = NULL ;
2627
2642
do_transform_method (frame , context );
2628
2643
if (frame -> ex )
2629
2644
THROW_EX (frame -> ex , NULL );
@@ -2632,6 +2647,8 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
2632
2647
2633
2648
if (!start_with_ip ) {
2634
2649
frame -> args = g_newa (char , rtm -> alloca_size );
2650
+ memset (frame -> args , 0 , rtm -> alloca_size );
2651
+
2635
2652
ip = rtm -> code ;
2636
2653
} else {
2637
2654
ip = start_with_ip ;
@@ -2862,6 +2879,8 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
2862
2879
2863
2880
interp_exec_method (& child_frame , context );
2864
2881
2882
+ context -> current_frame = frame ;
2883
+
2865
2884
if (context -> has_resume_state ) {
2866
2885
if (frame == context -> handler_frame )
2867
2886
SET_RESUME_STATE (context );
@@ -2886,7 +2905,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
2886
2905
sp -- ;
2887
2906
frame -> ip = ip ;
2888
2907
2889
- sp = do_icall (frame , csignature , opcode , sp , target_ip );
2908
+ sp = do_icall (context , csignature , opcode , sp , target_ip );
2890
2909
EXCEPTION_CHECKPOINT ;
2891
2910
if (context -> has_resume_state ) {
2892
2911
if (frame == context -> handler_frame )
@@ -2941,6 +2960,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
2941
2960
} else {
2942
2961
ves_pinvoke_method (& child_frame , csignature , (MonoFuncV ) code , FALSE, context );
2943
2962
}
2963
+ context -> current_frame = frame ;
2944
2964
2945
2965
if (context -> has_resume_state ) {
2946
2966
if (frame == context -> handler_frame )
@@ -3000,6 +3020,8 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
3000
3020
3001
3021
interp_exec_method (& child_frame , context );
3002
3022
3023
+ context -> current_frame = frame ;
3024
+
3003
3025
if (context -> has_resume_state ) {
3004
3026
if (frame == context -> handler_frame )
3005
3027
SET_RESUME_STATE (context );
@@ -4044,6 +4066,8 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
4044
4066
4045
4067
interp_exec_method (& child_frame , context );
4046
4068
4069
+ context -> current_frame = frame ;
4070
+
4047
4071
if (context -> has_resume_state ) {
4048
4072
if (frame == context -> handler_frame )
4049
4073
SET_RESUME_STATE (context );
@@ -4126,6 +4150,8 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
4126
4150
4127
4151
interp_exec_method (& child_frame , context );
4128
4152
4153
+ context -> current_frame = frame ;
4154
+
4129
4155
if (context -> has_resume_state ) {
4130
4156
if (frame == context -> handler_frame )
4131
4157
SET_RESUME_STATE (context );
@@ -4230,6 +4256,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
4230
4256
MINT_IN_BREAK ;
4231
4257
MINT_IN_CASE (MINT_THROW )
4232
4258
-- sp ;
4259
+ frame -> ex_handler = NULL ;
4233
4260
if (!sp -> data .p )
4234
4261
sp -> data .p = mono_get_exception_null_reference ();
4235
4262
@@ -5232,6 +5259,11 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
5232
5259
}
5233
5260
frame -> ip = ip ;
5234
5261
5262
+ if (frame -> ex_handler != NULL && MONO_OFFSET_IN_HANDLER (frame -> ex_handler , frame -> ip - rtm -> code )) {
5263
+ frame -> ex_handler = NULL ;
5264
+ frame -> ex = NULL ;
5265
+ }
5266
+
5235
5267
if (frame -> imethod -> method -> wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE ) {
5236
5268
stackval tmp_sp ;
5237
5269
@@ -5242,7 +5274,9 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
5242
5274
* to check the abort threshold. For this to work we use child_frame as a
5243
5275
* dummy frame that is stored in the lmf and serves as the transition frame
5244
5276
*/
5245
- do_icall (& child_frame , NULL , MINT_ICALL_V_P , & tmp_sp , (gpointer )mono_thread_get_undeniable_exception );
5277
+ context -> current_frame = & child_frame ;
5278
+ do_icall (context , NULL , MINT_ICALL_V_P , & tmp_sp , (gpointer )mono_thread_get_undeniable_exception );
5279
+ context -> current_frame = frame ;
5246
5280
5247
5281
MonoException * abort_exc = (MonoException * )tmp_sp .data .p ;
5248
5282
if (abort_exc )
@@ -5272,7 +5306,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
5272
5306
MINT_IN_CASE (MINT_ICALL_PPPPPP_V )
5273
5307
MINT_IN_CASE (MINT_ICALL_PPPPPP_P )
5274
5308
frame -> ip = ip ;
5275
- sp = do_icall (frame , NULL , * ip , sp , rtm -> data_items [* (guint16 * )(ip + 1 )]);
5309
+ sp = do_icall (context , NULL , * ip , sp , rtm -> data_items [* (guint16 * )(ip + 1 )]);
5276
5310
EXCEPTION_CHECKPOINT ;
5277
5311
if (context -> has_resume_state ) {
5278
5312
if (frame == context -> handler_frame )
@@ -5769,6 +5803,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
5769
5803
* actually run the new found handler.
5770
5804
*/
5771
5805
int exvar_offset = * (guint16 * )(ip + 1 );
5806
+ frame -> ex_handler = NULL ;
5772
5807
THROW_EX_GENERAL (* (MonoException * * )(frame -> locals + exvar_offset ), ip - 1 , TRUE);
5773
5808
MINT_IN_BREAK ;
5774
5809
}
@@ -5782,6 +5817,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
5782
5817
*/
5783
5818
5784
5819
-- sp ;
5820
+ frame -> ex_handler = NULL ;
5785
5821
if (!sp -> data .p )
5786
5822
sp -> data .p = mono_get_exception_null_reference ();
5787
5823
@@ -5852,8 +5888,12 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, guint16 *st
5852
5888
5853
5889
if (endfinally_ip != NULL )
5854
5890
finally_ips = g_slist_prepend (finally_ips , (void * )endfinally_ip );
5891
+ for (i = 0 ; i < rtm -> num_clauses ; ++ i )
5892
+ if (frame -> ex_handler == & rtm -> clauses [i ])
5893
+ break ;
5855
5894
5856
- for (i = rtm -> num_clauses - 1 ; i >= 0 ; i -- ) {
5895
+ while (i > 0 ) {
5896
+ -- i ;
5857
5897
clause = & rtm -> clauses [i ];
5858
5898
if (MONO_OFFSET_IN_CLAUSE (clause , ip_offset ) && (endfinally_ip == NULL || !(MONO_OFFSET_IN_CLAUSE (clause , endfinally_ip - rtm -> code )))) {
5859
5899
if (clause -> flags == MONO_EXCEPTION_CLAUSE_FINALLY ) {
@@ -6051,7 +6091,7 @@ interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame)
6051
6091
return FALSE;
6052
6092
6053
6093
MonoMethod * method = iframe -> imethod -> method ;
6054
- frame -> domain = iframe -> imethod -> domain ;
6094
+ frame -> domain = iframe -> domain ;
6055
6095
frame -> interp_frame = iframe ;
6056
6096
frame -> method = method ;
6057
6097
frame -> actual_method = method ;
0 commit comments