Commit 0f5ced3
committed
Update to avm1-types 0.10
This commit updates the AVM1 libraries to the version `0.10`.
With this version, the general structure of these libraries should be complete.
Initially, AVM1 support was included in the SWF libraries (`swf-types`, `swf-parser`). It used the model defined by Adobe's SWF spec were you can parse actions into a vec by simply reading them sequentially. It quickly occurred that this model is too simple and did not reflect how the player interprets bytecode. Adobe's interpret support jumps to arbitrary offsets, it treats the bytecode as an opaque buffer and reads only one action at a time. Because of this, parsing AVM1 actions ahead of time became much more complicated and AVM1 support was moved to its own libraries.
Initially, there was only support to read a single low-level action at a time. This was the only API provided by the version used until now by Flashback. And Flashback used it to read the actions sequentially (as in Adobe's spec). The issue with dropping support for reading all actions was that you were on your own to perform static analysis of AVM1 bytecode. It also meant that control-flow actions such as `Jump` or `If` were tightly dependant on the actual encoding because they included byte offsets. The various versions of the AVM1 libraries were focused on bringing back support for static analysis of AVM1 bytecode.
The version 0.10 solves it by providing two ways to view actions: `raw` and `cfg`. The raw mode corresponds to how the interpreter reads bytecode: a single action at a time and using byte offsets for control flow. The Control Flow Graph (CFG) mode represents the code as a graph were nodes represent linear sections of code (where you can safely advance through the sequence of actions) and edges represent jumps in the code. The graph itself is represented as a non-empty vector of blocks. Each block has a unique label, a list of simple actions (with no impact on control flow) and a flow action. The flow action describes the outgoing edges and how they are chosen. The target of the jump is identified by its label, the value `None` indicates the end of the current function. The two main variants are `CfgFlow::Simple` for unconditional jumps and `CfgFlow::If` for jumps based on truthiness of the top of the stack.
In the case of Flashback, AVM1 support was minimal. Thanks to this, updating the AVM1 libraries to their latest version was fairly easy. The behavior should be the same, except for a small difference around `WaitForFrame` and `WaitForFrame2`. The previous code simply ignored these actions and continued with what followed. The new code forces to treat them as actions affecting the flow. Because support for control flow is not implemented, it just stops at the end of the block and does not jump to the `ready_target`. Support for control-flow may require larger changes that are best left for some future commit in my opinion.1 parent 939a574 commit 0f5ced3
2 files changed
+46
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 60 | + | |
| 61 | + | |
65 | 62 | | |
66 | | - | |
| 63 | + | |
67 | 64 | | |
68 | 65 | | |
69 | | - | |
| 66 | + | |
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
| |||
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 93 | + | |
| 94 | + | |
102 | 95 | | |
103 | | - | |
| 96 | + | |
104 | 97 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
112 | 105 | | |
113 | 106 | | |
114 | | - | |
115 | | - | |
| 107 | + | |
| 108 | + | |
116 | 109 | | |
117 | 110 | | |
118 | | - | |
| 111 | + | |
119 | 112 | | |
120 | 113 | | |
121 | | - | |
| 114 | + | |
122 | 115 | | |
123 | 116 | | |
124 | 117 | | |
| |||
128 | 121 | | |
129 | 122 | | |
130 | 123 | | |
131 | | - | |
| 124 | + | |
132 | 125 | | |
133 | 126 | | |
134 | 127 | | |
| |||
141 | 134 | | |
142 | 135 | | |
143 | 136 | | |
144 | | - | |
| 137 | + | |
145 | 138 | | |
146 | 139 | | |
147 | 140 | | |
| |||
160 | 153 | | |
161 | 154 | | |
162 | 155 | | |
163 | | - | |
| 156 | + | |
164 | 157 | | |
165 | 158 | | |
166 | 159 | | |
| |||
195 | 188 | | |
196 | 189 | | |
197 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
198 | 202 | | |
199 | 203 | | |
200 | 204 | | |
0 commit comments