Skip to content

Instantly share code, notes, and snippets.

@aam
Last active March 12, 2024 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aam/1edb069bc07e2d53ede7eaf9cbc72ec0 to your computer and use it in GitHub Desktop.
Save aam/1edb069bc07e2d53ede7eaf9cbc72ec0 to your computer and use it in GitHub Desktop.
Before OSR:
==== tryosr.dart_::_main (RegularFunction)
B0[graph]:0 <-1:-1>
B1[function entry]:2 <-1:-1>
CheckStackOverflow:8(stack=0, loop=0)
DebugStepCheck:10()
DebugStepCheck:12()
StoreLocal(x @-8, t0)
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var0 @-1, t0)
goto:16 B3
B3[try_entry]:14 try_block:[B4] catches:[B44] pred(B1)
B4[target try_idx 0]:18
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var1 @-2, t0)
goto:24 B6
B6[try_entry]:22 try_block:[B7] catches:[B40] pred(B4)
B7[target try_idx 1]:26
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var2 @-3, t0)
goto:32 B9
B9[try_entry]:30 try_block:[B10] catches:[B37] pred(B7)
B10[target try_idx 2]:34
goto:198 B35
B35[join try_idx 2]:192 pred(B10, B33)
CheckStackOverflow:196(stack=0, loop=1)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:38(t1)
Branch if StrictCompare:40(===, t0, t1) goto (34, 36)
B34[target try_idx 2]:190
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var3 @-4, t0)
goto:46 B12
B12[try_entry]:44 try_block:[B13] catches:[B29] pred(B34)
B13[target try_idx 3]:48
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var4 @-5, t0)
goto:54 B15
B15[try_entry]:52 try_block:[B16] catches:[B26] pred(B13)
B16[target try_idx 4]:56
t0 <- LoadLocal(x @-8)
t1 <- InstanceCall:60( unary-<0>, t1)
t0 <- InstanceCall:62( <<0>, t0, t1)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:64(t1)
Branch if StrictCompare:66(===, t0, t1) goto (18, 19)
B18[target try_idx 4]:70
StaticCall:72( print<0> t0)
goto:78 B20
B19[target try_idx 4]:74
goto:80 B20
B20[join try_idx 4]:76 pred(B18, B19)
goto:118 B24
B24[join try_idx 4]:112 pred(B20, B22)
CheckStackOverflow:116(stack=0, loop=2)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:82(t1)
Branch if StrictCompare:84(===, t0, t1) goto (23, 25)
B23[target try_idx 4]:110
t0 <- LoadLocal(x @-8)
t0 <- InstanceCall:88( +<0>, t0, t1)
StoreLocal(x @-8, t0)
t0 <- LoadLocal(x @-8)
t1 <- InstanceCall:90( *<0>, t1, t2)
t1 <- InstanceCall:92( *<0>, t1, t2)
t0 <- InstanceCall:94( ><0>, t0, t1)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:96(t1)
Branch if StrictCompare:98(===, t0, t1) goto (21, 22)
B21[target try_idx 4]:102
t0 <- LoadLocal(x @-8)
t0 <- StaticCall:104( _interpolateSingle@0150898<0> t0)
Throw:106(t0)
B22[target try_idx 4]:108
goto:114 B24
B25[target try_idx 4]:120
goto:122 B17
B26[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var4 @-5)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:134( _instanceOf@0150898<0>, t0, t1, t2, t3)
Branch if StrictCompare:136(===, t0, t1) goto (27, 28)
B27[target try_idx 3]:140
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:126(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:128( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:130( print<0> t0)
goto:132 B17
B17[join try_idx 3]:58 pred(B25, B27)
goto:146 B14
B28[target try_idx 3]:142
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:144(t0, t1)
B29[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var3 @-4)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:158( _instanceOf@0150898<0>, t0, t1, t2, t3)
Branch if StrictCompare:160(===, t0, t1) goto (30, 31)
B30[target try_idx 2]:164
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:150(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:152( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:154( print<0> t0)
goto:156 B14
B14[join try_idx 2]:50 pred(B17, B30)
t0 <- LoadLocal(x @-8)
t1 <- InstanceCall:170( *<0>, t1, t2)
t1 <- InstanceCall:172( *<0>, t1, t2)
t0 <- InstanceCall:174( ><0>, t0, t1)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:176(t1)
Branch if StrictCompare:178(===, t0, t1) goto (32, 33)
B32[target try_idx 2]:182
t0 <- LoadLocal(x @-8)
t0 <- InstanceCall:184( /<0>, t0, t1)
Throw:186(t0)
B33[target try_idx 2]:188
goto:194 B35
B31[target try_idx 2]:166
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:168(t0, t1)
B36[target try_idx 2]:200
goto:202 B11
B37[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var2 @-3)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:214( _instanceOf@0150898<0>, t0, t1, t2, t3)
Branch if StrictCompare:216(===, t0, t1) goto (38, 39)
B38[target try_idx 1]:220
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:206(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:208( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:210( print<0> t0)
goto:212 B11
B11[join try_idx 1]:36 pred(B36, B38)
goto:226 B8
B39[target try_idx 1]:222
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:224(t0, t1)
B40[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var1 @-2)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:238( _instanceOf@0150898<0>, t0, t1, t2, t3)
Branch if StrictCompare:240(===, t0, t1) goto (41, 42)
B41[target try_idx 0]:244
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:230(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(x @-8)
StoreIndexed(t1, t2, t3)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:232( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:234( print<0> t0)
goto:236 B8
B8[join try_idx 0]:28 pred(B11, B41)
goto:252 B43
B43[join]:250 pred(B8)
StaticCall:254( print<0> t0)
goto:256 B5
B5[join]:20 pred(B43)
DebugStepCheck:264()
Return:266(t0)
B42[target try_idx 0]:246
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:248(t0, t1)
B44[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var0 @-1)
StoreLocal(:current_context_var @0, t0)
StaticCall:260( print<0> t0)
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:262(t0, t1)
*** END CFG
After OSR:
==== tryosr.dart_::_main (RegularFunction)
B0[graph]:0 <-1:-1>
B1[osr entry]:2 stack_depth=0 <-1:-1>
goto:118 B24
B3[try_entry]:14 try_block:[B4] catches:[B44] pred(B1)
B4[target try_idx 0]:18
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var1 @-2, t0)
goto:24 B6
B6[try_entry]:22 try_block:[B7] catches:[B40] pred(B4)
B7[target try_idx 1]:26
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var2 @-3, t0)
goto:32 B9
B9[try_entry]:30 try_block:[B10] catches:[B37] pred(B7)
B10[target try_idx 2]:34
goto:198 B35
B35[join try_idx 2]:192 pred(B10, B33)
CheckStackOverflow:196(stack=0, loop=1)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:38(t1)
Branch if StrictCompare:40(===, t0, t1) goto (34, 36)
B34[target try_idx 2]:190
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var3 @-4, t0)
goto:46 B12
B12[try_entry]:44 try_block:[B13] catches:[B29] pred(B34)
B13[target try_idx 3]:48
t0 <- LoadLocal(:current_context_var @0)
StoreLocal(:saved_try_context_var4 @-5, t0)
goto:54 B15
B15[try_entry]:52 try_block:[B16] catches:[B26] pred(B13)
B16[target try_idx 4]:56
t0 <- LoadLocal(x @-8)
t1 <- InstanceCall:60( unary-<0>, t1 IC[1: _Smi@0150898 cnt:1 trgt:'_IntegerImplementation@0150898.unary-'])
t0 <- InstanceCall:62( <<0>, t0, t1 IC[1: _Smi@0150898, _Smi@0150898 cnt:1 trgt:'_IntegerImplementation@0150898.<'])
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:64(t1)
Branch if StrictCompare:66(===, t0, t1) goto (18, 19)
B18[target try_idx 4]:70
StaticCall:72( print<0> t0)
goto:78 B20
B19[target try_idx 4]:74
goto:80 B20
B20[join try_idx 4]:76 pred(B18, B19)
goto:118 B24
B24[join try_idx 4]:112 pred(B1, B20, B22)
CheckStackOverflow:116(stack=0, loop=2)
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:82(t1)
Branch if StrictCompare:84(===, t0, t1) goto (23, 25)
B23[target try_idx 4]:110
t0 <- LoadLocal(x @-8)
t0 <- InstanceCall:88( +<0>, t0, t1 IC[1: _Smi@0150898, _Smi@0150898 cnt:59 trgt:'_IntegerImplementation@0150898.+'])
StoreLocal(x @-8, t0)
t0 <- LoadLocal(x @-8)
t1 <- InstanceCall:90( *<0>, t1, t2 IC[1: _Smi@0150898, _Smi@0150898 cnt:59 trgt:'_IntegerImplementation@0150898.*'])
t1 <- InstanceCall:92( *<0>, t1, t2 IC[1: _Smi@0150898, _Smi@0150898 cnt:59 trgt:'_IntegerImplementation@0150898.*'])
t0 <- InstanceCall:94( ><0>, t0, t1 IC[1: _Smi@0150898, _Smi@0150898 cnt:59 trgt:'_IntegerImplementation@0150898.>'])
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:96(t1)
Branch if StrictCompare:98(===, t0, t1) goto (21, 22)
B21[target try_idx 4]:102
t0 <- LoadLocal(x @-8)
t0 <- StaticCall:104( _interpolateSingle@0150898<0> t0)
Throw:106(t0)
B22[target try_idx 4]:108
goto:114 B24
B25[target try_idx 4]:120
goto:122 B17
B26[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var4 @-5)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:134( _instanceOf@0150898<0>, t0, t1, t2, t3 IC[0: ])
Branch if StrictCompare:136(===, t0, t1) goto (27, 28)
B27[target try_idx 3]:140
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:126(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:128( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:130( print<0> t0)
goto:132 B17
B17[join try_idx 3]:58 pred(B25, B27)
goto:146 B14
B28[target try_idx 3]:142
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:144(t0, t1)
B29[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var3 @-4)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:158( _instanceOf@0150898<0>, t0, t1, t2, t3 IC[0: ])
Branch if StrictCompare:160(===, t0, t1) goto (30, 31)
B30[target try_idx 2]:164
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:150(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:152( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:154( print<0> t0)
goto:156 B14
B14[join try_idx 2]:50 pred(B17, B30)
t0 <- LoadLocal(x @-8)
t1 <- InstanceCall:170( *<0>, t1, t2 IC[0: ])
t1 <- InstanceCall:172( *<0>, t1, t2 IC[0: ])
t0 <- InstanceCall:174( ><0>, t0, t1 IC[0: ])
t1 <- LoadLocal(:t0 @-10)
AssertBoolean:176(t1)
Branch if StrictCompare:178(===, t0, t1) goto (32, 33)
B32[target try_idx 2]:182
t0 <- LoadLocal(x @-8)
t0 <- InstanceCall:184( /<0>, t0, t1 IC[0: ])
Throw:186(t0)
B33[target try_idx 2]:188
goto:194 B35
B31[target try_idx 2]:166
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:168(t0, t1)
B36[target try_idx 2]:200
goto:202 B11
B37[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var2 @-3)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:214( _instanceOf@0150898<0>, t0, t1, t2, t3 IC[0: ])
Branch if StrictCompare:216(===, t0, t1) goto (38, 39)
B38[target try_idx 1]:220
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:206(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:208( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:210( print<0> t0)
goto:212 B11
B11[join try_idx 1]:36 pred(B36, B38)
goto:226 B8
B39[target try_idx 1]:222
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:224(t0, t1)
B40[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var1 @-2)
StoreLocal(:current_context_var @0, t0)
t0 <- LoadLocal(:exception0 @-6)
t0 <- InstanceCall:238( _instanceOf@0150898<0>, t0, t1, t2, t3 IC[0: ])
Branch if StrictCompare:240(===, t0, t1) goto (41, 42)
B41[target try_idx 0]:244
t0 <- LoadLocal(:exception0 @-6)
StoreLocal(e @-9, t0)
t0 <- CreateArray:230(t0, t1)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(x @-8)
StoreIndexed(t1, t2, t3)
t1 <- LoadLocal(:t0 @-10)
StoreIndexed(t1, t2, t3, NoStoreBarrier)
t1 <- LoadLocal(:t0 @-10)
t3 <- LoadLocal(e @-9)
StoreIndexed(t1, t2, t3)
t0 <- StaticCall:232( _interpolate@0150898<0> t0, recognized_kind = StringBaseInterpolate)
StaticCall:234( print<0> t0)
goto:236 B8
B8[join try_idx 0]:28 pred(B11, B41)
goto:252 B43
B43[join]:250 pred(B8)
StaticCall:254( print<0> t0)
goto:256 B5
B5[join]:20 pred(B43)
DebugStepCheck:264()
Return:266(t0)
B42[target try_idx 0]:246
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:248(t0, t1)
B44[catch] <-1:-1>
t0 <- LoadLocal(:saved_try_context_var0 @-1)
StoreLocal(:current_context_var @0, t0)
StaticCall:260( print<0> t0)
t0 <- LoadLocal(:exception0 @-6)
t1 <- LoadLocal(:stack_trace0 @-7)
ReThrow:262(t0, t1)
*** END CFG
=== tryosr.dart ===
main() {
var x = 123;
try {
try {
while (true) {
try {
try {
if (x < -1) {
print('x is negative? impossible');
}
while(true) {
x += 1;
if (x > 1000*1000*1000) {
throw "$x";
}
}
} on String catch (e) {
print('got string $e');
}
} on List catch(e) {
print('on List: $e');
}
if (x > 1000*1000*1000) {
throw x/2;
}
}
} on double catch(e) {
print('on double: $e');
}
} on int catch (e) {
print("x: $x e: $e");
} finally {
print('and finally');
}
}
===
```
$ out/DebugX64/dart --print-flow-graph --print-flow-graph-optimized --print-flow-graph-filter="_main" --trace-osr --optimization-counter-threshold=100 --deterministic tryosr.dart 2> 1
got string 1000000001
on double: 500000000.5
and finally
$
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment