@@ -939,6 +939,8 @@ impl Function {
939939impl < ' a > std:: fmt:: Display for FunctionPrinter < ' a > {
940940 fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
941941 let fun = & self . fun ;
942+ let iseq_name = iseq_name ( fun. iseq ) ;
943+ writeln ! ( f, "fn {iseq_name}:" ) ?;
942944 for block_id in fun. rpo ( ) {
943945 write ! ( f, "{block_id}(" ) ?;
944946 if !fun. blocks [ block_id. 0 ] . params . is_empty ( ) {
@@ -1740,6 +1742,7 @@ mod tests {
17401742 fn test_putobject ( ) {
17411743 eval ( "def test = 123" ) ;
17421744 assert_method_hir ( "test" , expect ! [ [ r#"
1745+ fn test:
17431746 bb0():
17441747 v1:Fixnum[123] = Const Value(123)
17451748 Return v1
@@ -1750,6 +1753,7 @@ mod tests {
17501753 fn test_new_array ( ) {
17511754 eval ( "def test = []" ) ;
17521755 assert_method_hir ( "test" , expect ! [ [ r#"
1756+ fn test:
17531757 bb0():
17541758 v1:ArrayExact = NewArray 0
17551759 Return v1
@@ -1760,6 +1764,7 @@ mod tests {
17601764 fn test_array_dup ( ) {
17611765 eval ( "def test = [1, 2, 3]" ) ;
17621766 assert_method_hir ( "test" , expect ! [ [ r#"
1767+ fn test:
17631768 bb0():
17641769 v1:ArrayExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
17651770 v2:ArrayExact = ArrayDup v1
@@ -1773,6 +1778,7 @@ mod tests {
17731778 fn test_string_copy ( ) {
17741779 eval ( "def test = \" hello\" " ) ;
17751780 assert_method_hir ( "test" , expect ! [ [ r#"
1781+ fn test:
17761782 bb0():
17771783 v1:StringExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
17781784 v2:StringExact = StringCopy v1
@@ -1784,6 +1790,7 @@ mod tests {
17841790 fn test_bignum ( ) {
17851791 eval ( "def test = 999999999999999999999999999999999999" ) ;
17861792 assert_method_hir ( "test" , expect ! [ [ r#"
1793+ fn test:
17871794 bb0():
17881795 v1:Bignum[VALUE(0x1000)] = Const Value(VALUE(0x1000))
17891796 Return v1
@@ -1794,6 +1801,7 @@ mod tests {
17941801 fn test_flonum ( ) {
17951802 eval ( "def test = 1.5" ) ;
17961803 assert_method_hir ( "test" , expect ! [ [ r#"
1804+ fn test:
17971805 bb0():
17981806 v1:Flonum[VALUE(0x1000)] = Const Value(VALUE(0x1000))
17991807 Return v1
@@ -1804,6 +1812,7 @@ mod tests {
18041812 fn test_heap_float ( ) {
18051813 eval ( "def test = 1.7976931348623157e+308" ) ;
18061814 assert_method_hir ( "test" , expect ! [ [ r#"
1815+ fn test:
18071816 bb0():
18081817 v1:HeapFloat[VALUE(0x1000)] = Const Value(VALUE(0x1000))
18091818 Return v1
@@ -1814,6 +1823,7 @@ mod tests {
18141823 fn test_static_sym ( ) {
18151824 eval ( "def test = :foo" ) ;
18161825 assert_method_hir ( "test" , expect ! [ [ r#"
1826+ fn test:
18171827 bb0():
18181828 v1:StaticSymbol[VALUE(0x1000)] = Const Value(VALUE(0x1000))
18191829 Return v1
@@ -1824,6 +1834,7 @@ mod tests {
18241834 fn test_opt_plus ( ) {
18251835 eval ( "def test = 1+2" ) ;
18261836 assert_method_hir ( "test" , expect ! [ [ r#"
1837+ fn test:
18271838 bb0():
18281839 v1:Fixnum[1] = Const Value(1)
18291840 v3:Fixnum[2] = Const Value(2)
@@ -1841,6 +1852,7 @@ mod tests {
18411852 end
18421853 " ) ;
18431854 assert_method_hir ( "test" , expect ! [ [ r#"
1855+ fn test:
18441856 bb0():
18451857 v0:NilClassExact = Const Value(nil)
18461858 v2:Fixnum[1] = Const Value(1)
@@ -1860,6 +1872,7 @@ mod tests {
18601872 end
18611873 " ) ;
18621874 assert_method_hir ( "test" , expect ! [ [ r#"
1875+ fn test:
18631876 bb0(v0:BasicObject):
18641877 v3:CBool = Test v0
18651878 IfFalse v3, bb1(v0)
@@ -1884,6 +1897,7 @@ mod tests {
18841897 end
18851898 " ) ;
18861899 assert_method_hir ( "test" , expect ! [ [ r#"
1900+ fn test:
18871901 bb0(v0:BasicObject):
18881902 v1:NilClassExact = Const Value(nil)
18891903 v4:CBool = Test v0
@@ -1905,6 +1919,7 @@ mod tests {
19051919 test(1, 2); test(1, 2)
19061920 " ) ;
19071921 assert_method_hir ( "test" , expect ! [ [ r#"
1922+ fn test:
19081923 bb0(v0:BasicObject, v1:BasicObject):
19091924 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
19101925 v6:Fixnum = GuardType v0, Fixnum
@@ -1921,6 +1936,7 @@ mod tests {
19211936 test(1, 2); test(1, 2)
19221937 " ) ;
19231938 assert_method_hir ( "test" , expect ! [ [ r#"
1939+ fn test:
19241940 bb0(v0:BasicObject, v1:BasicObject):
19251941 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_MINUS)
19261942 v6:Fixnum = GuardType v0, Fixnum
@@ -1937,6 +1953,7 @@ mod tests {
19371953 test(1, 2); test(1, 2)
19381954 " ) ;
19391955 assert_method_hir ( "test" , expect ! [ [ r#"
1956+ fn test:
19401957 bb0(v0:BasicObject, v1:BasicObject):
19411958 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_MULT)
19421959 v6:Fixnum = GuardType v0, Fixnum
@@ -1953,6 +1970,7 @@ mod tests {
19531970 test(1, 2); test(1, 2)
19541971 " ) ;
19551972 assert_method_hir ( "test" , expect ! [ [ r#"
1973+ fn test:
19561974 bb0(v0:BasicObject, v1:BasicObject):
19571975 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_DIV)
19581976 v6:Fixnum = GuardType v0, Fixnum
@@ -1969,6 +1987,7 @@ mod tests {
19691987 test(1, 2); test(1, 2)
19701988 " ) ;
19711989 assert_method_hir ( "test" , expect ! [ [ r#"
1990+ fn test:
19721991 bb0(v0:BasicObject, v1:BasicObject):
19731992 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_MOD)
19741993 v6:Fixnum = GuardType v0, Fixnum
@@ -1985,6 +2004,7 @@ mod tests {
19852004 test(1, 2); test(1, 2)
19862005 " ) ;
19872006 assert_method_hir ( "test" , expect ! [ [ r#"
2007+ fn test:
19882008 bb0(v0:BasicObject, v1:BasicObject):
19892009 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_EQ)
19902010 v6:Fixnum = GuardType v0, Fixnum
@@ -2001,6 +2021,7 @@ mod tests {
20012021 test(1, 2); test(1, 2)
20022022 " ) ;
20032023 assert_method_hir ( "test" , expect ! [ [ r#"
2024+ fn test:
20042025 bb0(v0:BasicObject, v1:BasicObject):
20052026 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_NEQ)
20062027 v6:Fixnum = GuardType v0, Fixnum
@@ -2017,6 +2038,7 @@ mod tests {
20172038 test(1, 2); test(1, 2)
20182039 " ) ;
20192040 assert_method_hir ( "test" , expect ! [ [ r#"
2041+ fn test:
20202042 bb0(v0:BasicObject, v1:BasicObject):
20212043 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_LT)
20222044 v6:Fixnum = GuardType v0, Fixnum
@@ -2033,6 +2055,7 @@ mod tests {
20332055 test(1, 2); test(1, 2)
20342056 " ) ;
20352057 assert_method_hir ( "test" , expect ! [ [ r#"
2058+ fn test:
20362059 bb0(v0:BasicObject, v1:BasicObject):
20372060 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_LE)
20382061 v6:Fixnum = GuardType v0, Fixnum
@@ -2049,6 +2072,7 @@ mod tests {
20492072 test(1, 2); test(1, 2)
20502073 " ) ;
20512074 assert_method_hir ( "test" , expect ! [ [ r#"
2075+ fn test:
20522076 bb0(v0:BasicObject, v1:BasicObject):
20532077 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_GT)
20542078 v6:Fixnum = GuardType v0, Fixnum
@@ -2073,6 +2097,7 @@ mod tests {
20732097 test
20742098 " ) ;
20752099 assert_method_hir ( "test" , expect ! [ [ r#"
2100+ fn test:
20762101 bb0():
20772102 v0:NilClassExact = Const Value(nil)
20782103 v1:NilClassExact = Const Value(nil)
@@ -2111,6 +2136,7 @@ mod tests {
21112136 test(1, 2); test(1, 2)
21122137 " ) ;
21132138 assert_method_hir ( "test" , expect ! [ [ r#"
2139+ fn test:
21142140 bb0(v0:BasicObject, v1:BasicObject):
21152141 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_GE)
21162142 v6:Fixnum = GuardType v0, Fixnum
@@ -2133,6 +2159,7 @@ mod tests {
21332159 end
21342160 " ) ;
21352161 assert_method_hir ( "test" , expect ! [ [ r#"
2162+ fn test:
21362163 bb0():
21372164 v0:NilClassExact = Const Value(nil)
21382165 v2:TrueClassExact = Const Value(true)
@@ -2143,7 +2170,7 @@ mod tests {
21432170 bb1(v12):
21442171 v14 = Const Value(4)
21452172 Return v14
2146- "# ] ] ) ;
2173+ "# ] ] ) ;
21472174 }
21482175
21492176 #[ test]
@@ -2158,6 +2185,7 @@ mod tests {
21582185 test
21592186 " ) ;
21602187 assert_method_hir ( "test" , expect ! [ [ r#"
2188+ fn test:
21612189 bb0():
21622190 v1:BasicObject = PutSelf
21632191 v3:Fixnum[2] = Const Value(2)
@@ -2178,6 +2206,7 @@ mod tests {
21782206 test([1,2,3])
21792207 " ) ;
21802208 assert_method_hir ( "test" , expect ! [ [ r#"
2209+ fn test:
21812210 bb0(v0:BasicObject):
21822211 v3:BasicObject = Send v0, 0x1000, :each
21832212 Return v3
@@ -2190,6 +2219,7 @@ mod tests {
21902219
21912220 // The 2 string literals have the same address because they're deduped.
21922221 assert_method_hir ( "test" , expect ! [ [ r#"
2222+ fn test:
21932223 bb0():
21942224 v1:BasicObject = PutSelf
21952225 v3:ArrayExact[VALUE(0x1000)] = Const Value(VALUE(0x1000))
@@ -2233,13 +2263,14 @@ mod opt_tests {
22332263 end
22342264 " ) ;
22352265 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2266+ fn test:
22362267 bb0():
22372268 v0:NilClassExact = Const Value(nil)
22382269 v2:TrueClassExact = Const Value(true)
22392270 v17:CBool[true] = Const CBool(true)
22402271 v9:Fixnum[3] = Const Value(3)
22412272 Return v9
2242- "# ] ] ) ;
2273+ "# ] ] ) ;
22432274 }
22442275
22452276 #[ test]
@@ -2255,6 +2286,7 @@ mod opt_tests {
22552286 end
22562287 " ) ;
22572288 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2289+ fn test:
22582290 bb0():
22592291 v0:NilClassExact = Const Value(nil)
22602292 v2:FalseClassExact = Const Value(false)
@@ -2263,7 +2295,7 @@ mod opt_tests {
22632295 bb1(v12:FalseClassExact):
22642296 v14:Fixnum[4] = Const Value(4)
22652297 Return v14
2266- "# ] ] ) ;
2298+ "# ] ] ) ;
22672299 }
22682300
22692301 #[ test]
@@ -2275,6 +2307,7 @@ mod opt_tests {
22752307 test; test
22762308 " ) ;
22772309 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2310+ fn test:
22782311 bb0():
22792312 v1:Fixnum[1] = Const Value(1)
22802313 v3:Fixnum[2] = Const Value(2)
@@ -2284,7 +2317,7 @@ mod opt_tests {
22842317 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
22852318 v19:Fixnum[6] = Const Value(6)
22862319 Return v19
2287- "# ] ] ) ;
2320+ "# ] ] ) ;
22882321 }
22892322
22902323 #[ test]
@@ -2300,6 +2333,7 @@ mod opt_tests {
23002333 test; test
23012334 " ) ;
23022335 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2336+ fn test:
23032337 bb0():
23042338 v1:Fixnum[1] = Const Value(1)
23052339 v3:Fixnum[2] = Const Value(2)
@@ -2308,7 +2342,7 @@ mod opt_tests {
23082342 v21:CBool[true] = Const CBool(true)
23092343 v13:Fixnum[3] = Const Value(3)
23102344 Return v13
2311- "# ] ] ) ;
2345+ "# ] ] ) ;
23122346 }
23132347
23142348 #[ test]
@@ -2324,6 +2358,7 @@ mod opt_tests {
23242358 test; test
23252359 " ) ;
23262360 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2361+ fn test:
23272362 bb0():
23282363 v1:Fixnum[1] = Const Value(1)
23292364 v3:Fixnum[2] = Const Value(2)
@@ -2334,7 +2369,7 @@ mod opt_tests {
23342369 bb1():
23352370 v17:Fixnum[4] = Const Value(4)
23362371 Return v17
2337- "# ] ] ) ;
2372+ "# ] ] ) ;
23382373 }
23392374
23402375 #[ test]
@@ -2350,6 +2385,7 @@ mod opt_tests {
23502385 test; test
23512386 " ) ;
23522387 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2388+ fn test:
23532389 bb0():
23542390 v1:Fixnum[2] = Const Value(2)
23552391 v3:Fixnum[2] = Const Value(2)
@@ -2358,7 +2394,7 @@ mod opt_tests {
23582394 v21:CBool[true] = Const CBool(true)
23592395 v13:Fixnum[3] = Const Value(3)
23602396 Return v13
2361- "# ] ] ) ;
2397+ "# ] ] ) ;
23622398 }
23632399
23642400 #[ test]
@@ -2370,12 +2406,13 @@ mod opt_tests {
23702406 test(2); test(3)
23712407 " ) ;
23722408 assert_optimized_method_hir ( "test" , expect ! [ [ r#"
2409+ fn test:
23732410 bb0(v0:BasicObject):
23742411 v3:Fixnum[1] = Const Value(1)
23752412 PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
23762413 v6:Fixnum = GuardType v0, Fixnum
23772414 v8:Fixnum = FixnumAdd v6, v3
23782415 Return v8
2379- "# ] ] ) ;
2416+ "# ] ] ) ;
23802417 }
23812418}
0 commit comments