-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfast-3.1.diff
More file actions
224 lines (206 loc) · 8.14 KB
/
fast-3.1.diff
File metadata and controls
224 lines (206 loc) · 8.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
Index: modules/asc/src/java/adobe/abc/GlobalOptimizer.java
===================================================================
--- modules/asc/src/java/adobe/abc/GlobalOptimizer.java (revision 3507)
+++ modules/asc/src/java/adobe/abc/GlobalOptimizer.java (working copy)
@@ -2162,7 +2162,21 @@
static final Metadata[] nometadata = new Metadata[0];
+ /**
+ * Methods ready for optimization.
+ * Populated by readyMethod(), called from readyType()
+ * and by initial processing of the OP_newfunction Expr.
+ */
List<Method> ready = new ArrayList<Method>();
+
+ /**
+ * Track already-processed methods so they never go on the ready list twice.
+ * @warn Methods are tracked by hashCode() b/c Method defines a compare function
+ * that can compare different Methods as equal (if they're in different types).
+ * If Method.hashCode() is modified, then Method will need a unique ID to
+ * make this set work.
+ */
+ Set<Integer> already_processed = new TreeSet<Integer>();
void readyType(Type t)
{
@@ -2174,8 +2188,11 @@
void readyMethod(Method m)
{
- if (m.entry != null)
+ if (m.entry != null && ! already_processed.contains(m.hashCode()) )
+ {
ready.add(m);
+ already_processed.add(m.hashCode());
+ }
}
void optimize(InputAbc a)
Index: modules/compiler/src/java/flex2/tools/Compiler.java
===================================================================
--- modules/compiler/src/java/flex2/tools/Compiler.java (revision 3507)
+++ modules/compiler/src/java/flex2/tools/Compiler.java (working copy)
@@ -239,9 +239,12 @@
// compile
List units = flex2.compiler.API.compile(fileSpec, sourceList, null, sourcePath, resources, bundlePath, swcContext,
configuration, compilers, new PreLink(), licenseMap, new ArrayList());
+ PostLink postLink = null;
- // link
- Movie movie = flex2.linker.API.link(units, new PostLink(configuration), configuration);
+ if (configuration.optimize() && !configuration.generateDebugTags())
+ {
+ postLink = new PostLink(configuration);
+ }
// output SWF
String name = configuration.getOutput();
@@ -263,11 +266,22 @@
if (projector != null)
{
- createProjector(projector, movie, swfOut);
+ ConsoleApplication app = flex2.linker.API.linkConsole(units, postLink, configuration);
+
+ createProjector(projector, app, swfOut);
}
else
{
- flex2.compiler.API.encode(movie, swfOut);
+ Movie movie = flex2.linker.API.link(units, postLink, configuration);
+
+ if (projector != null)
+ {
+ createProjector(projector, movie, swfOut);
+ }
+ else
+ {
+ flex2.compiler.API.encode(movie, swfOut);
+ }
}
swfOut.flush();
Index: modules/compiler/src/java/flex2/tools/oem/Application.java
===================================================================
--- modules/compiler/src/java/flex2/tools/oem/Application.java (revision 3507)
+++ modules/compiler/src/java/flex2/tools/oem/Application.java (working copy)
@@ -1163,12 +1163,18 @@
ApplicationCompilerConfiguration appConfig = (ApplicationCompilerConfiguration) data.configuration;
VirtualFile projector = appConfig.getProjector();
+ PostLink postLink = null;
+ if (config.optimize() && !config.generateDebugTags())
+ {
+ postLink = new PostLink(config);
+ }
+
// link
if (projector != null && projector.getName().endsWith("avmplus.exe"))
{
ConsoleApplication temp = data.app;
- data.app = flex2.linker.API.linkConsole(data.units, new PostLink(config), config);
+ data.app = flex2.linker.API.linkConsole(data.units, postLink, config);
size = encodeConsoleProjector(projector, out);
if (hasChanged && temp != null)
{
@@ -1178,7 +1184,7 @@
else
{
SimpleMovie temp = data.movie;
- data.movie = (FlexMovie) flex2.linker.API.link(data.units, new PostLink(config), config);
+ data.movie = (FlexMovie) flex2.linker.API.link(data.units, postLink, config);
size = (projector == null) ? encode(out) : encodeProjector(projector, out);
if (hasChanged && temp != null)
{
Index: modules/swfutils/src/java/flash/swf/SwfEncoder.java
===================================================================
--- modules/swfutils/src/java/flash/swf/SwfEncoder.java (revision 3507)
+++ modules/swfutils/src/java/flash/swf/SwfEncoder.java (working copy)
@@ -100,17 +100,42 @@
*/
public void compress() throws IOException
{
+ compress(false);
+ }
+
+ /**
+ * compress the marked section of our buffer, in place.
+ * @param isDebug If true, BEST_SPEED compression is used. Otherwise, BEST_COMPRESSION is used.
+ * @throws IOException
+ */
+ public void compress(boolean isDebug) throws IOException
+ {
if (compressPos != -1)
{
// compress in place from compressPos to pos
pos = compressPos;
+ deflate(this, isDebug);
+ compressPos = -1;
+ }
+ }
- DeflaterOutputStream deflater = new DeflaterOutputStream(this, new Deflater(Deflater.BEST_COMPRESSION));
+ private void deflate(OutputStream out, boolean isDebug) throws IOException
+ {
+ int compression;
- deflater.write(buf, compressPos, count-compressPos);
- deflater.finish();
- compressPos = -1;
+ if (isDebug)
+ {
+ compression = Deflater.BEST_SPEED;
}
+ else
+ {
+ compression = Deflater.BEST_COMPRESSION;
+ }
+
+ DeflaterOutputStream deflater = new DeflaterOutputStream(out, new Deflater(compression));
+
+ deflater.write(buf, compressPos, count-compressPos);
+ deflater.finish();
}
/**
@@ -121,6 +146,18 @@
*/
public synchronized void writeTo(OutputStream out) throws IOException
{
+ writeTo(out, false);
+ }
+
+ /**
+ * send buffer to the given stream. If markComp was called, bytes after that mark
+ * will be compressed.
+ * @param out
+ * @param isDebug If true, BEST_SPEED compression is used. Otherwise, BEST_COMPRESSION is used.
+ * @throws IOException
+ */
+ public synchronized void writeTo(OutputStream out, boolean isDebug) throws IOException
+ {
if (compressPos == -1)
{
super.writeTo(out);
@@ -129,11 +166,7 @@
{
count = pos;
out.write(buf, 0, compressPos);
-
- DeflaterOutputStream deflater = new DeflaterOutputStream(out, new Deflater(Deflater.BEST_COMPRESSION));
-
- deflater.write(buf, compressPos, count-compressPos);
- deflater.finish();
+ deflate(out, isDebug);
}
}
Index: modules/swfutils/src/java/flash/swf/TagEncoder.java
===================================================================
--- modules/swfutils/src/java/flash/swf/TagEncoder.java (revision 3507)
+++ modules/swfutils/src/java/flash/swf/TagEncoder.java (working copy)
@@ -210,7 +210,7 @@
public void writeTo(OutputStream out) throws IOException
{
- writer.writeTo(out);
+ writer.writeTo(out, isDebug());
}
@@ -250,9 +250,9 @@
{
try
{
- tagw.compress();
+ tagw.compress(isDebug());
encodeTagHeader(tag.code, tagw.getPos(), isLongHeader(tag));
- tagw.writeTo(writer);
+ tagw.writeTo(writer, isDebug());
tagw.reset();
}
catch (IOException e)