@@ -1446,25 +1446,27 @@ dump_interp_compacted_ins (const guint16 *ip, const guint16 *start)
1446
1446
{
1447
1447
int opcode = * ip ;
1448
1448
int ins_offset = ip - start ;
1449
+ GString * str = g_string_new ("" );
1449
1450
1450
- g_print ( "IR_%04x: %-14s" , ins_offset , mono_interp_opname (opcode ));
1451
+ g_string_append_printf ( str , "IR_%04x: %-14s" , ins_offset , mono_interp_opname (opcode ));
1451
1452
ip ++ ;
1452
1453
1453
1454
if (mono_interp_op_dregs [opcode ] > 0 )
1454
- g_print ( " [%d <-" , * ip ++ );
1455
+ g_string_append_printf ( str , " [%d <-" , * ip ++ );
1455
1456
else
1456
- g_print ( " [nil <-" );
1457
+ g_string_append_printf ( str , " [nil <-" );
1457
1458
1458
1459
if (mono_interp_op_sregs [opcode ] > 0 ) {
1459
1460
for (int i = 0 ; i < mono_interp_op_sregs [opcode ]; i ++ )
1460
- g_print ( " %d" , * ip ++ );
1461
- g_print ( "]," );
1461
+ g_string_append_printf ( str , " %d" , * ip ++ );
1462
+ g_string_append_printf ( str , "]," );
1462
1463
} else {
1463
- g_print ( " nil]," );
1464
+ g_string_append_printf ( str , " nil]," );
1464
1465
}
1465
- char * ins = dump_interp_ins_data (NULL , ins_offset , ip , opcode );
1466
- g_print ("%s\n" , ins );
1467
- g_free (ins );
1466
+ char * ins_data = dump_interp_ins_data (NULL , ins_offset , ip , opcode );
1467
+ g_print ("%s%s\n" , str -> str , ins_data );
1468
+ g_string_free (str , TRUE);
1469
+ g_free (ins_data );
1468
1470
}
1469
1471
1470
1472
static void
@@ -1478,51 +1480,47 @@ dump_interp_code (const guint16 *start, const guint16* end)
1478
1480
}
1479
1481
1480
1482
static void
1481
- dump_interp_inst_no_newline (InterpInst * ins )
1483
+ dump_interp_inst (InterpInst * ins )
1482
1484
{
1483
1485
int opcode = ins -> opcode ;
1484
- g_print ("IL_%04x: %-14s" , ins -> il_offset , mono_interp_opname (opcode ));
1486
+ GString * str = g_string_new ("" );
1487
+ g_string_append_printf (str , "IL_%04x: %-14s" , ins -> il_offset , mono_interp_opname (opcode ));
1485
1488
1486
1489
if (mono_interp_op_dregs [opcode ] > 0 )
1487
- g_print ( " [%d <-" , ins -> dreg );
1490
+ g_string_append_printf ( str , " [%d <-" , ins -> dreg );
1488
1491
else
1489
- g_print ( " [nil <-" );
1492
+ g_string_append_printf ( str , " [nil <-" );
1490
1493
1491
1494
if (mono_interp_op_sregs [opcode ] > 0 ) {
1492
1495
for (int i = 0 ; i < mono_interp_op_sregs [opcode ]; i ++ ) {
1493
1496
if (ins -> sregs [i ] == MINT_CALL_ARGS_SREG ) {
1494
- g_print ( " c:" );
1497
+ g_string_append_printf ( str , " c:" );
1495
1498
int * call_args = ins -> info .call_args ;
1496
1499
if (call_args ) {
1497
1500
while (* call_args != -1 ) {
1498
- g_print ( " %d" , * call_args );
1501
+ g_string_append_printf ( str , " %d" , * call_args );
1499
1502
call_args ++ ;
1500
1503
}
1501
1504
}
1502
1505
} else {
1503
- g_print ( " %d" , ins -> sregs [i ]);
1506
+ g_string_append_printf ( str , " %d" , ins -> sregs [i ]);
1504
1507
}
1505
1508
}
1506
- g_print ( "]," );
1509
+ g_string_append_printf ( str , "]," );
1507
1510
} else {
1508
- g_print ( " nil]," );
1511
+ g_string_append_printf ( str , " nil]," );
1509
1512
}
1510
1513
1511
1514
if (opcode == MINT_LDLOCA_S ) {
1512
1515
// LDLOCA has special semantics, it has data in sregs [0], but it doesn't have any sregs
1513
- g_print ( " %d" , ins -> sregs [0 ]);
1516
+ g_string_append_printf ( str , " %d" , ins -> sregs [0 ]);
1514
1517
} else {
1515
1518
char * descr = dump_interp_ins_data (ins , ins -> il_offset , & ins -> data [0 ], ins -> opcode );
1516
- g_print ( "%s" , descr );
1519
+ g_string_append_printf ( str , "%s" , descr );
1517
1520
g_free (descr );
1518
1521
}
1519
- }
1520
-
1521
- static void
1522
- dump_interp_inst (InterpInst * ins )
1523
- {
1524
- dump_interp_inst_no_newline (ins );
1525
- g_print ("\n" );
1522
+ g_print ("%s\n" , str -> str );
1523
+ g_string_free (str , TRUE);
1526
1524
}
1527
1525
1528
1526
static G_GNUC_UNUSED void
@@ -1581,21 +1579,6 @@ interp_method_get_header (MonoMethod* method, MonoError *error)
1581
1579
return mono_method_get_header_internal (method , error );
1582
1580
}
1583
1581
1584
- /* stores top of stack as local and pushes address of it on stack */
1585
- static void
1586
- emit_store_value_as_local (TransformData * td , MonoType * src )
1587
- {
1588
- int local = create_interp_local (td , mini_native_type_replace_type (src ));
1589
-
1590
- store_local (td , local );
1591
-
1592
- interp_add_ins (td , MINT_LDLOCA_S );
1593
- push_simple_type (td , STACK_TYPE_MP );
1594
- interp_ins_set_dreg (td -> last_ins , td -> sp [-1 ].local );
1595
- interp_ins_set_sreg (td -> last_ins , local );
1596
- td -> locals [local ].indirects ++ ;
1597
- }
1598
-
1599
1582
static gboolean
1600
1583
interp_ip_in_cbb (TransformData * td , int il_offset )
1601
1584
{
@@ -1906,37 +1889,33 @@ interp_handle_magic_type_intrinsics (TransformData *td, MonoMethod *target_metho
1906
1889
int src_size = mini_magic_type_size (NULL , src );
1907
1890
int dst_size = mini_magic_type_size (NULL , dst );
1908
1891
1909
- gboolean store_value_as_local = FALSE;
1892
+ gboolean managed_fallback = FALSE;
1910
1893
1911
1894
switch (type_index ) {
1912
1895
case 0 : case 1 :
1913
1896
if (!mini_magic_is_int_type (src ) || !mini_magic_is_int_type (dst )) {
1914
1897
if (mini_magic_is_int_type (src ))
1915
- store_value_as_local = TRUE;
1898
+ managed_fallback = TRUE;
1916
1899
else if (mono_class_is_magic_float (src_klass ))
1917
- store_value_as_local = TRUE;
1900
+ managed_fallback = TRUE;
1918
1901
else
1919
1902
return FALSE;
1920
1903
}
1921
1904
break ;
1922
1905
case 2 :
1923
1906
if (!mini_magic_is_float_type (src ) || !mini_magic_is_float_type (dst )) {
1924
1907
if (mini_magic_is_float_type (src ))
1925
- store_value_as_local = TRUE;
1908
+ managed_fallback = TRUE;
1926
1909
else if (mono_class_is_magic_int (src_klass ))
1927
- store_value_as_local = TRUE;
1910
+ managed_fallback = TRUE;
1928
1911
else
1929
1912
return FALSE;
1930
1913
}
1931
1914
break ;
1932
1915
}
1933
1916
1934
- if (store_value_as_local ) {
1935
- emit_store_value_as_local (td , src );
1936
-
1937
- /* emit call to managed conversion method */
1917
+ if (managed_fallback )
1938
1918
return FALSE;
1939
- }
1940
1919
1941
1920
if (src_size > dst_size ) { // 8 -> 4
1942
1921
switch (type_index ) {
@@ -1993,15 +1972,6 @@ interp_handle_magic_type_intrinsics (TransformData *td, MonoMethod *target_metho
1993
1972
td -> ip += 5 ;
1994
1973
return TRUE;
1995
1974
} else if (!strcmp ("CompareTo" , tm ) || !strcmp ("Equals" , tm )) {
1996
- MonoType * arg = csignature -> params [0 ];
1997
- int mt = mint_type (arg );
1998
-
1999
- /* on 'System.n*::{CompareTo,Equals} (System.n*)' variant we need to push managed
2000
- * pointer instead of value */
2001
- if (mt != MINT_TYPE_O )
2002
- emit_store_value_as_local (td , arg );
2003
-
2004
- /* emit call to managed conversion method */
2005
1975
return FALSE;
2006
1976
} else if (!strcmp (".cctor" , tm )) {
2007
1977
return FALSE;
@@ -2836,8 +2806,7 @@ interp_method_check_inlining (TransformData *td, MonoMethod *method, MonoMethodS
2836
2806
if (method -> wrapper_type != MONO_WRAPPER_NONE )
2837
2807
return FALSE;
2838
2808
2839
- /* Our usage of `emit_store_value_as_local ()` for nint, nuint and nfloat
2840
- * is kinda hacky, and doesn't work with the inliner */
2809
+ // FIXME Re-enable this
2841
2810
if (mono_class_get_magic_index (method -> klass ) >= 0 )
2842
2811
return FALSE;
2843
2812
@@ -6059,6 +6028,8 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
6059
6028
td -> sp -- ;
6060
6029
interp_emit_sfld_access (td , field , field_klass , mt , TRUE, error );
6061
6030
goto_if_nok (error , exit );
6031
+ } else if (td -> sp [-1 ].type != STACK_TYPE_O && td -> sp [-1 ].type != STACK_TYPE_MP && (mono_class_is_magic_int (klass ) || mono_class_is_magic_float (klass ))) {
6032
+ // No need to load anything, the value is already on the execution stack
6062
6033
} else if (td -> sp [-1 ].type == STACK_TYPE_VT ) {
6063
6034
int size = 0 ;
6064
6035
/* First we pop the vt object from the stack. Then we push the field */
0 commit comments