Skip to content

Instantly share code, notes, and snippets.

@aam
Last active March 12, 2024 15:29
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/d4be2cde1ce59fd9bb29d460859af880 to your computer and use it in GitHub Desktop.
Save aam/d4be2cde1ce59fd9bb29d460859af880 to your computer and use it in GitHub Desktop.
osr example
```
main() {
var x = 123;
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 int catch (e) {
print("x: $x e: $e");
} finally {
print('and finally');
}
}
```
```
==== file:///usr/local/google/home/aam/p/d/sdk3/sdk/tryosr.dart_::_main (RegularFunction)
0: B0[graph]:0 {
v0 <- Constant(#null) T{Null?}
v1 <- Constant(#<optimized out>) T{Sentinel~}
v15 <- Constant(#and finally) T{_OneByteString}
v21 <- Constant(#Type: int) T{_Type}
v23 <- Constant(#true) T{bool}
v24 <- Constant(#4) [4, 4] T{_Smi}
v26 <- Constant(#0) [0, 0] T{_Smi}
v27 <- Constant(#x: ) T{_OneByteString}
v28 <- Constant(#1) [1, 1] T{_Smi}
v29 <- Constant(#2) [2, 2] T{_Smi}
v30 <- Constant(# e: ) T{_OneByteString}
v31 <- Constant(#3) [3, 3] T{_Smi}
v36 <- Constant(#Type: String) T{_Type}
v39 <- Constant(#got string ) T{_OneByteString}
v51 <- Constant(#x is negative? impossible) T{_OneByteString}
v83 <- Constant(#1000000000) [1000000000, 1000000000] T{_Smi}
v86 <- Constant(#-1) [-1, -1] T{_Smi}
} <0: 2>
2: B1[osr entry]:2 stack_depth=0 {
v2 <- Parameter(env_index:0 @fp[-3] param_index: -1) T{*?~}
v3 <- Parameter(env_index:1 @fp[-4] param_index: -1) T{*?~}
v4 <- Parameter(env_index:2 @fp[-5] param_index: -1) T{*?~}
v5 <- Parameter(env_index:3 @fp[-6] param_index: -1) T{*?~}
v6 <- Parameter(env_index:4 @fp[-7] param_index: -1) T{*?~}
v7 <- Parameter(env_index:5 @fp[-8] param_index: -1) T{*?~}
v8 <- Parameter(env_index:6 @fp[-9] param_index: -1) T{*?~}
v9 <- Parameter(env_index:7 @fp[-10] param_index: -1) T{*?~}
} <2: 8>
3: ParallelMove rax <- fp[-9]
4: CheckSmi:96(v8)
5: ParallelMove rdx <- fp[-5] , rcx <- fp[-6]
6: ParallelMove rbx <- rax, rdx <- rcx, rcx <- rdx, rax <- fp[-3] goto:96 B17
8: B3[try_entry]:14 try_block:[B4] catches:[B27] pred(B1)
10: B4[target try_idx 0]:18
12: ParallelMove goto:24 B6
14: B6[try_entry]:22 try_block:[B7] catches:[B23] pred(B4)
16: B7[target try_idx 1]:26
18: ParallelMove goto:32 B9
20: B9[try_entry]:30 try_block:[B10] catches:[B20] pred(B7)
22: B10[target try_idx 2]:34
24: Branch if RelationalOp:40(<, v8 T{_Smi}, v86 T{_Smi}) T{bool} goto (12, 13)
26: B12[target try_idx 2]:48
28: MoveArgument(v51, SP+0)
30: StaticCall:50( print<0> v51)
32: ParallelMove goto:56 B14
34: B13[target try_idx 2]:52
36: ParallelMove goto:58 B14
38: B14[join try_idx 2]:54 pred(B12, B13) ParallelMove rax <- fp[-3]
40: ParallelMove rbx <- fp[-9] , rdx <- rax, rcx <- rax goto:96 B17
42: B17[join try_idx 2]:90 pred(B1, B14, B16) {
v74 <- phi(v8 T{_Smi}, v8 T{_Smi}, v76 T{_Smi}) alive [-4611686018427387904, 4611686018427387903] T{_Smi}
v71 <- phi(v5, v2 T{*?~}, v71) alive T{*?~}
v70 <- phi(v4, v2 T{*?~}, v70) alive T{*?~}
}
43: ParallelMove fp[-12] <- rdx, fp[-13] <- rcx
44: CheckStackOverflow:94(stack=0, loop=1)
46: ParallelMove rsi <- rbx
46: v76 <- BinarySmiOp:66(+, v74 T{_Smi}, v28) [-4611686018427387903, 4611686018427387903] T{_Smi}
47: ParallelMove fp[-11] <- rsi
48: Branch if RelationalOp:72(>, v76, v83 T{_Smi}) T{bool} goto (15, 16)
50: B15[target try_idx 2]:80
52: MoveArgument(v76 T{_Smi}, SP+0)
54: v81 <- StaticCall:82( _interpolateSingle@0150898<0> v76 T{_Smi}) T{String}
55: ParallelMove rax <- rax, rcx <- rax
56: ParallelMove fp[-14] <- rcx
56: Throw:84(v81)
58: B16[target try_idx 2]:86
60: ParallelMove rbx <- fp[-11] , rdx <- fp[-12] , rcx <- fp[-13] , rax <- fp[-3] goto:92 B17
62: B20[catch] {
v33 <- Parameter(env_index:4 @rax param_index: -1) T{*?~}
v34 <- Parameter(env_index:5 @rdx param_index: -1) T{*?~}
v35 <- Parameter(env_index:6 @fp[-9] param_index: -1) T{*?~}
} <62: 76>
63: ParallelMove rbx <- rdx, fp[-11] <- rax, fp[-12] <- rdx
64: MoveArgument(v33, SP+3)
66: MoveArgument(v0, SP+2)
68: MoveArgument(v0, SP+1)
70: MoveArgument(v36, SP+0)
72: v37 <- InstanceCall:112( _instanceOf@0150898<0>, v33, v0, v0, v36 IC[0: ]) T{*?}
74: Branch if StrictCompare:114(===, v37, v23) goto (11, 22)
76: B11[target try_idx 1]:118 ParallelMove rax <- fp[-11]
77: ParallelMove rbx <- C, r10 <- C
78: v38 <- CreateArray:104(v0, v29) T{_List}
80: StoreIndexed(v38, v26, v39 T{_OneByteString}, NoStoreBarrier)
81: ParallelMove rcx <- fp[-11]
82: StoreIndexed(v38, v28, v33 T{String}, NoStoreBarrier)
84: MoveArgument(v38, SP+0)
86: v40 <- StaticCall:106( _interpolate@0150898<0> v38, recognized_kind = StringBaseInterpolate) T{String}
88: MoveArgument(v40, SP+0)
90: StaticCall:108( print<0> v40)
92: ParallelMove rax <- fp[-3] goto:124 B8
94: B22[target try_idx 1]:120
95: ParallelMove rax <- fp[-11] , rbx <- fp[-12]
96: ReThrow:122(v33, v34)
98: B23[catch] {
v16 <- Parameter(env_index:0 @fp[-3] param_index: -1)
v17 <- Parameter(env_index:3 @fp[-6] param_index: -1) T{*?~}
v18 <- Parameter(env_index:4 @rax param_index: -1) T{*?~}
v19 <- Parameter(env_index:5 @rdx param_index: -1) T{*?~}
v20 <- Parameter(env_index:7 @fp[-10] param_index: -1)
} <98: 112>
99: ParallelMove rbx <- rdx, fp[-11] <- rax, fp[-12] <- rdx
100: MoveArgument(v18, SP+3)
102: MoveArgument(v0, SP+2)
104: MoveArgument(v0, SP+1)
106: MoveArgument(v21, SP+0)
108: v22 <- InstanceCall:136( _instanceOf@0150898<0>, v18, v0, v0, v21 IC[0: ]) T{*?}
110: Branch if StrictCompare:138(===, v22, v23) goto (24, 25)
112: B24[target try_idx 0]:142 ParallelMove rcx <- fp[-9] , rdx <- fp[-6] , rax <- fp[-11]
113: ParallelMove rbx <- C, r10 <- C
114: v25 <- CreateArray:128(v0, v24) T{_List}
116: StoreIndexed(v25, v26, v27 T{_OneByteString}, NoStoreBarrier)
117: ParallelMove rcx <- fp[-9]
118: StoreIndexed(v25, v28, v8 T{_Smi}, NoStoreBarrier)
120: StoreIndexed(v25, v29, v30 T{_OneByteString}, NoStoreBarrier)
121: ParallelMove rdx <- fp[-11]
122: StoreIndexed(v25, v31, v18 T{int}, NoStoreBarrier)
124: MoveArgument(v25, SP+0)
126: v32 <- StaticCall:130( _interpolate@0150898<0> v25, recognized_kind = StringBaseInterpolate) T{String}
128: MoveArgument(v32, SP+0)
130: StaticCall:132( print<0> v32)
132: ParallelMove rax <- fp[-6] goto:134 B8
134: B8[join try_idx 0]:28 pred(B11, B24) {
v55 <- phi(v2 T{*?~}, v17) alive T{*?~}
}
135: ParallelMove fp[-13] <- rax
136: ParallelMove goto:150 B5
138: B5[join]:148 pred(B8)
140: MoveArgument(v15, SP+0)
142: StaticCall:152( print<0> v15)
143: ParallelMove rax <- C
144: Return:164(v0)
146: B25[target try_idx 0]:144
147: ParallelMove rax <- fp[-11] , rbx <- fp[-12]
148: ReThrow:146(v18, v19)
150: B27[catch] {
v10 <- Parameter(env_index:0 @fp[-3] param_index: -1)
v11 <- Parameter(env_index:2 @fp[-5] param_index: -1)
v12 <- Parameter(env_index:4 @rax param_index: -1) T{*?~}
v13 <- Parameter(env_index:5 @rdx param_index: -1) T{*?~}
v14 <- Parameter(env_index:7 @fp[-10] param_index: -1)
} <150: 158>
151: ParallelMove rbx <- rdx, fp[-11] <- rax, fp[-12] <- rdx
152: MoveArgument(v15, SP+0)
154: StaticCall:158( print<0> v15)
155: ParallelMove rax <- fp[-11] , rbx <- fp[-12]
156: ReThrow:160(v12, v13)
*** END CFG
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment