You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: InternalDocs/exception_handling.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The cost of raising an exception is increased, but not by much.
8
8
9
9
The following code:
10
10
11
-
```
11
+
```python
12
12
try:
13
13
g(0)
14
14
except:
@@ -18,7 +18,7 @@ except:
18
18
19
19
compiles into intermediate code like the following:
20
20
21
-
```
21
+
```python
22
22
RESUME0
23
23
24
24
1SETUP_FINALLY8 (to L1)
@@ -118,13 +118,13 @@ All offsets and lengths are in code units, not bytes.
118
118
119
119
We want the format to be compact, but quickly searchable.
120
120
For it to be compact, it needs to have variable sized entries so that we can store common (small) offsets compactly, but handle large offsets if needed.
121
-
For it to be searchable quickly, we need to support binary search giving us log(n) performance in all cases.
121
+
For it to be searchable quickly, we need to support binary search giving us `log(n)` performance in all cases.
122
122
Binary search typically assumes fixed size entries, but that is not necessary, as long as we can identify the start of an entry.
123
123
124
124
It is worth noting that the size (end-start) is always smaller than the end, so we encode the entries as:
125
125
`start, size, target, depth, push-lasti`.
126
126
127
-
Also, sizes are limited to 2**30 as the code length cannot exceed 2**31 and each code unit takes 2 bytes.
127
+
Also, sizes are limited to `2**30` as the code length cannot exceed `2**31` and each code unit takes 2 bytes.
128
128
It also happens that depth is generally quite small.
129
129
130
130
So, we need to encode:
@@ -140,7 +140,7 @@ lasti (1 bit)
140
140
We need a marker for the start of the entry, so the first byte of entry will have the most significant bit set.
141
141
Since the most significant bit is reserved for marking the start of an entry, we have 7 bits per byte to encode offsets.
142
142
Encoding uses a standard varint encoding, but with only 7 bits instead of the usual 8.
143
-
The 8 bits of a byte are (msb left) SXdddddd where S is the start bit. X is the extend bit meaning that the next byte is required to extend the offset.
143
+
The 8 bits of a byte are (msb left) `SXdddddd` where `S` is the start bit. `X` is the extend bit meaning that the next byte is required to extend the offset.
144
144
145
145
In addition, we combine `depth` and `lasti` into a single value, `((depth<<1)+lasti)`, before encoding.
0 commit comments