@@ -2143,14 +2143,13 @@ mini_method_check_context_used (MonoCompile *cfg, MonoMethod *method)
2143
2143
}
2144
2144
2145
2145
/*
2146
- * check_method_sharing :
2146
+ * need_mrgctx_arg :
2147
2147
*
2148
- * Check whenever the vtable or an mrgctx needs to be passed when calling CMETHOD.
2148
+ * Check whenever the mrgctx needs to be passed when calling CMETHOD.
2149
2149
*/
2150
- static void
2151
- check_method_sharing (MonoCompile * cfg , MonoMethod * cmethod , gboolean * out_pass_vtable , gboolean * out_pass_mrgctx )
2150
+ static gboolean
2151
+ need_mrgctx_arg (MonoCompile * cfg , MonoMethod * cmethod )
2152
2152
{
2153
- gboolean pass_vtable = FALSE;
2154
2153
gboolean pass_mrgctx = FALSE;
2155
2154
2156
2155
if (((cmethod -> flags & METHOD_ATTRIBUTE_STATIC ) || m_class_is_valuetype (cmethod -> klass )) &&
@@ -2161,22 +2160,17 @@ check_method_sharing (MonoCompile *cfg, MonoMethod *cmethod, gboolean *out_pass_
2161
2160
sharable = TRUE;
2162
2161
2163
2162
/*
2164
- * Pass vtable iff target method might
2163
+ * Pass mrgctx iff target method might
2165
2164
* be shared, which means that sharing
2166
2165
* is enabled for its class and its
2167
2166
* context is sharable (and it's not a
2168
2167
* generic method).
2169
2168
*/
2170
2169
if (sharable && !(mini_method_get_context (cmethod ) && mini_method_get_context (cmethod )-> method_inst ))
2171
- pass_vtable = TRUE;
2170
+ pass_mrgctx = TRUE;
2172
2171
}
2173
2172
2174
2173
if (mini_method_needs_mrgctx (cmethod )) {
2175
- if (mini_method_is_default_method (cmethod ))
2176
- pass_vtable = FALSE;
2177
- else
2178
- g_assert (!pass_vtable );
2179
-
2180
2174
if (mono_method_is_generic_sharable_full (cmethod , TRUE, TRUE, TRUE)) {
2181
2175
pass_mrgctx = TRUE;
2182
2176
} else {
@@ -2185,10 +2179,7 @@ check_method_sharing (MonoCompile *cfg, MonoMethod *cmethod, gboolean *out_pass_
2185
2179
}
2186
2180
}
2187
2181
2188
- if (out_pass_vtable )
2189
- * out_pass_vtable = pass_vtable ;
2190
- if (out_pass_mrgctx )
2191
- * out_pass_mrgctx = pass_mrgctx ;
2182
+ return pass_mrgctx ;
2192
2183
}
2193
2184
2194
2185
static gboolean
@@ -2490,8 +2481,6 @@ context_used_is_mrgctx (MonoCompile *cfg, int context_used)
2490
2481
static MonoInst *
2491
2482
emit_get_rgctx (MonoCompile * cfg , int context_used )
2492
2483
{
2493
- MonoMethod * method = cfg -> method ;
2494
-
2495
2484
g_assert (cfg -> gshared );
2496
2485
2497
2486
/* Data whose context contains method type vars is stored in the mrgctx */
@@ -2500,8 +2489,10 @@ emit_get_rgctx (MonoCompile *cfg, int context_used)
2500
2489
2501
2490
g_assert (cfg -> rgctx_access == MONO_RGCTX_ACCESS_MRGCTX );
2502
2491
2492
+ /*
2503
2493
if (!mini_method_is_default_method (method))
2504
2494
g_assert (method->is_inflated && mono_method_get_context (method)->method_inst);
2495
+ */
2505
2496
2506
2497
if (cfg -> llvm_only ) {
2507
2498
mrgctx_var = mono_get_mrgctx_var (cfg );
@@ -2536,20 +2527,6 @@ emit_get_rgctx (MonoCompile *cfg, int context_used)
2536
2527
EMIT_NEW_LOAD_MEMBASE (cfg , vtable_var , OP_LOAD_MEMBASE , vtable_reg , mrgctx_var -> dreg , MONO_STRUCT_OFFSET (MonoMethodRuntimeGenericContext , class_vtable ));
2537
2528
vtable_var -> type = STACK_PTR ;
2538
2529
return vtable_var ;
2539
- } else if (cfg -> rgctx_access == MONO_RGCTX_ACCESS_VTABLE ) {
2540
- MonoInst * vtable_loc , * vtable_var ;
2541
-
2542
- /* We are passed a vtable, return it */
2543
-
2544
- if (cfg -> llvm_only ) {
2545
- vtable_var = mono_get_vtable_var (cfg );
2546
- } else {
2547
- vtable_loc = mono_get_vtable_var (cfg );
2548
- g_assert (vtable_loc -> flags & MONO_INST_VOLATILE );
2549
- EMIT_NEW_TEMPLOAD (cfg , vtable_var , vtable_loc -> inst_c0 );
2550
- }
2551
- vtable_var -> type = STACK_PTR ;
2552
- return vtable_var ;
2553
2530
} else {
2554
2531
MonoInst * ins , * this_ins ;
2555
2532
int vtable_reg ;
@@ -3189,18 +3166,11 @@ handle_unbox_nullable (MonoCompile* cfg, MonoInst* val, MonoClass* klass, int co
3189
3166
return mini_emit_calli (cfg , mono_method_signature_internal (method ), & val , addr , NULL , rgctx );
3190
3167
}
3191
3168
} else {
3192
- gboolean pass_vtable , pass_mrgctx ;
3193
3169
MonoInst * rgctx_arg = NULL ;
3194
3170
3195
- check_method_sharing (cfg , method , & pass_vtable , & pass_mrgctx );
3196
- g_assert (!pass_mrgctx );
3197
-
3198
- if (pass_vtable ) {
3199
- MonoVTable * vtable = mono_class_vtable_checked (method -> klass , cfg -> error );
3200
-
3201
- mono_error_assert_ok (cfg -> error );
3202
- EMIT_NEW_VTABLECONST (cfg , rgctx_arg , vtable );
3203
- }
3171
+ if (need_mrgctx_arg (cfg , method ))
3172
+ rgctx_arg = emit_get_rgctx_method (cfg , context_used , method ,
3173
+ MONO_RGCTX_INFO_METHOD_RGCTX );
3204
3174
3205
3175
return mini_emit_method_call_full (cfg , method , NULL , FALSE, & val , NULL , NULL , rgctx_arg );
3206
3176
}
@@ -3441,18 +3411,11 @@ mini_emit_box (MonoCompile *cfg, MonoInst *val, MonoClass *klass, int context_us
3441
3411
return mini_emit_calli (cfg , mono_method_signature_internal (method ), & val , addr , NULL , rgctx );
3442
3412
}
3443
3413
} else {
3444
- gboolean pass_vtable , pass_mrgctx ;
3445
3414
MonoInst * rgctx_arg = NULL ;
3446
3415
3447
- check_method_sharing (cfg , method , & pass_vtable , & pass_mrgctx );
3448
- g_assert (!pass_mrgctx );
3449
-
3450
- if (pass_vtable ) {
3451
- MonoVTable * vtable = mono_class_vtable_checked (method -> klass , cfg -> error );
3452
-
3453
- mono_error_assert_ok (cfg -> error );
3454
- EMIT_NEW_VTABLECONST (cfg , rgctx_arg , vtable );
3455
- }
3416
+ if (need_mrgctx_arg (cfg , method ))
3417
+ rgctx_arg = emit_get_rgctx_method (cfg , context_used , method ,
3418
+ MONO_RGCTX_INFO_METHOD_RGCTX );
3456
3419
3457
3420
return mini_emit_method_call_full (cfg , method , NULL , FALSE, & val , NULL , NULL , rgctx_arg );
3458
3421
}
@@ -5697,7 +5660,7 @@ static void
5697
5660
handle_ctor_call (MonoCompile * cfg , MonoMethod * cmethod , MonoMethodSignature * fsig , int context_used ,
5698
5661
MonoInst * * sp , guint8 * ip , int * inline_costs )
5699
5662
{
5700
- MonoInst * vtable_arg = NULL , * callvirt_this_arg = NULL , * ins ;
5663
+ MonoInst * rgctx_arg = NULL , * callvirt_this_arg = NULL , * ins ;
5701
5664
5702
5665
if (cmethod && (ins = mini_emit_inst_for_ctor (cfg , cmethod , fsig , sp ))) {
5703
5666
g_assert (MONO_TYPE_IS_VOID (fsig -> ret ));
@@ -5709,24 +5672,15 @@ handle_ctor_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs
5709
5672
MonoRgctxAccess access = mini_get_rgctx_access_for_method (cmethod );
5710
5673
5711
5674
if (access == MONO_RGCTX_ACCESS_MRGCTX ) {
5712
- mono_class_vtable_checked (cmethod -> klass , cfg -> error );
5713
- CHECK_CFG_ERROR ;
5714
- CHECK_TYPELOAD (cmethod -> klass );
5715
-
5716
- vtable_arg = emit_get_rgctx_method (cfg , context_used ,
5675
+ rgctx_arg = emit_get_rgctx_method (cfg , context_used ,
5717
5676
cmethod , MONO_RGCTX_INFO_METHOD_RGCTX );
5718
- } else if (access == MONO_RGCTX_ACCESS_VTABLE ) {
5719
- vtable_arg = mini_emit_get_rgctx_klass (cfg , context_used ,
5720
- cmethod -> klass , MONO_RGCTX_INFO_VTABLE );
5721
- CHECK_CFG_ERROR ;
5722
- CHECK_TYPELOAD (cmethod -> klass );
5723
5677
} else {
5724
5678
g_assert (access == MONO_RGCTX_ACCESS_THIS );
5725
5679
}
5726
5680
}
5727
5681
5728
5682
/* Avoid virtual calls to ctors if possible */
5729
- if ((cfg -> opt & MONO_OPT_INLINE ) && cmethod && !context_used && !vtable_arg &&
5683
+ if ((cfg -> opt & MONO_OPT_INLINE ) && cmethod && !context_used && !rgctx_arg &&
5730
5684
mono_method_check_inlining (cfg , cmethod ) &&
5731
5685
!mono_class_is_subclass_of_internal (cmethod -> klass , mono_defaults .exception_class , FALSE)) {
5732
5686
int costs ;
@@ -5748,10 +5702,10 @@ handle_ctor_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs
5748
5702
addr = emit_get_rgctx_gsharedvt_call (cfg , context_used , fsig , cmethod , MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE );
5749
5703
5750
5704
if (cfg -> llvm_only ) {
5751
- // FIXME: Avoid initializing vtable_arg
5705
+ // FIXME: Avoid initializing rgctx_arg
5752
5706
mini_emit_llvmonly_calli (cfg , fsig , sp , addr );
5753
5707
} else {
5754
- mini_emit_calli (cfg , fsig , sp , addr , NULL , vtable_arg );
5708
+ mini_emit_calli (cfg , fsig , sp , addr , NULL , rgctx_arg );
5755
5709
}
5756
5710
} else if (context_used &&
5757
5711
((!mono_method_is_generic_sharable_full (cmethod , TRUE, FALSE, FALSE) ||
@@ -5772,15 +5726,14 @@ handle_ctor_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs
5772
5726
cmethod_addr = emit_get_rgctx_method (cfg , context_used ,
5773
5727
cmethod , MONO_RGCTX_INFO_GENERIC_METHOD_CODE );
5774
5728
5775
- mini_emit_calli (cfg , fsig , sp , cmethod_addr , NULL , vtable_arg );
5729
+ mini_emit_calli (cfg , fsig , sp , cmethod_addr , NULL , rgctx_arg );
5776
5730
}
5777
5731
} else {
5778
5732
INLINE_FAILURE ("ctor call" );
5779
5733
ins = mini_emit_method_call_full (cfg , cmethod , fsig , FALSE, sp ,
5780
- callvirt_this_arg , NULL , vtable_arg );
5734
+ callvirt_this_arg , NULL , rgctx_arg );
5781
5735
}
5782
5736
exception_exit :
5783
- mono_error_exit :
5784
5737
return ;
5785
5738
}
5786
5739
@@ -7439,7 +7392,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
7439
7392
gboolean virtual_ ; virtual_ = il_op == MONO_CEE_CALLVIRT ;
7440
7393
gboolean pass_imt_from_rgctx ; pass_imt_from_rgctx = FALSE;
7441
7394
MonoInst * imt_arg ; imt_arg = NULL ;
7442
- gboolean pass_vtable ; pass_vtable = FALSE;
7443
7395
gboolean pass_mrgctx ; pass_mrgctx = FALSE;
7444
7396
MonoInst * vtable_arg ; vtable_arg = NULL ;
7445
7397
gboolean check_this ; check_this = FALSE;
@@ -7751,7 +7703,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
7751
7703
}
7752
7704
}
7753
7705
7754
- check_method_sharing (cfg , cmethod , & pass_vtable , & pass_mrgctx );
7706
+ pass_mrgctx = need_mrgctx_arg (cfg , cmethod );
7755
7707
7756
7708
if (cfg -> gshared ) {
7757
7709
MonoGenericContext * cmethod_context = mono_method_get_context (cmethod );
@@ -7785,18 +7737,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
7785
7737
mono_get_vtable_var (cfg );
7786
7738
}
7787
7739
7788
- if (pass_vtable ) {
7789
- if (context_used ) {
7790
- vtable_arg = mini_emit_get_rgctx_klass (cfg , context_used , cmethod -> klass , MONO_RGCTX_INFO_VTABLE );
7791
- } else {
7792
- MonoVTable * vtable = mono_class_vtable_checked (cmethod -> klass , cfg -> error );
7793
- CHECK_CFG_ERROR ;
7794
-
7795
- CHECK_TYPELOAD (cmethod -> klass );
7796
- EMIT_NEW_VTABLECONST (cfg , vtable_arg , vtable );
7797
- }
7798
- }
7799
-
7800
7740
if (pass_mrgctx ) {
7801
7741
g_assert (!vtable_arg );
7802
7742
@@ -7819,8 +7759,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
7819
7759
}
7820
7760
7821
7761
if (pass_imt_from_rgctx ) {
7822
- g_assert (!pass_vtable );
7823
-
7824
7762
imt_arg = emit_get_rgctx_method (cfg , context_used ,
7825
7763
cmethod , MONO_RGCTX_INFO_METHOD );
7826
7764
g_assert (imt_arg );
0 commit comments