Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2200 | 2200 |
| 2201 CompilerTask(Compiler compiler) | 2201 CompilerTask(Compiler compiler) |
| 2202 : this.compiler = compiler, | 2202 : this.compiler = compiler, |
| 2203 watch = (compiler.verbose) ? new Stopwatch() : null; | 2203 watch = (compiler.verbose) ? new Stopwatch() : null; |
| 2204 | 2204 |
| 2205 String get name => "Unknown task '${this.runtimeType}'"; | 2205 String get name => "Unknown task '${this.runtimeType}'"; |
| 2206 int get timing => (watch != null) ? watch.elapsedMilliseconds : 0; | 2206 int get timing => (watch != null) ? watch.elapsedMilliseconds : 0; |
| 2207 | 2207 |
| 2208 int get timingMicroseconds => (watch != null) ? watch.elapsedMicroseconds : 0; | 2208 int get timingMicroseconds => (watch != null) ? watch.elapsedMicroseconds : 0; |
| 2209 | 2209 |
| 2210 measure(action()) { | 2210 measure(action()) => watch == null ? action() : measureZoned(action); |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
| |
| 2211 // In verbose mode when watch != null. | 2211 |
| 2212 if (watch == null) return action(); | 2212 CompilerTask start() { |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
| |
| 2213 CompilerTask previous = compiler.measuredTask; | 2213 CompilerTask previous = compiler.measuredTask; |
| 2214 if (identical(this, previous)) return action(); | |
| 2215 compiler.measuredTask = this; | 2214 compiler.measuredTask = this; |
| 2216 if (previous != null) previous.watch.stop(); | 2215 if (previous != null) previous.watch.stop(); |
| 2217 watch.start(); | 2216 watch.start(); |
| 2218 try { | 2217 return previous; |
| 2219 return action(); | 2218 } |
| 2220 } finally { | 2219 |
| 2221 watch.stop(); | 2220 void stop(CompilerTask previous) { |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
| |
| 2222 if (previous != null) previous.watch.start(); | 2221 watch.stop(); |
| 2223 compiler.measuredTask = previous; | 2222 if (previous != null) previous.watch.start(); |
| 2223 compiler.measuredTask = previous; | |
| 2224 } | |
| 2225 | |
| 2226 measureZoned(action()) { | |
|
Johnni Winther
2015/11/19 10:02:18
Add doc.
| |
| 2227 assert(watch != null); | |
| 2228 if (identical(this, compiler.measuredTask)) return action(); | |
| 2229 | |
| 2230 run(Zone self, ZoneDelegate parent, Zone zone, f()) { | |
| 2231 CompilerTask previous = start(); | |
| 2232 try { | |
| 2233 return f(); | |
| 2234 } finally { | |
| 2235 stop(previous); | |
| 2236 } | |
| 2224 } | 2237 } |
| 2238 | |
| 2239 runUnary(Zone self, ZoneDelegate parent, Zone zone, f(arg), arg) { | |
| 2240 CompilerTask previous = start(); | |
| 2241 try { | |
| 2242 return f(arg); | |
| 2243 } finally { | |
| 2244 stop(previous); | |
| 2245 } | |
| 2246 } | |
| 2247 | |
| 2248 runBinary(Zone self, ZoneDelegate parent, Zone zone, f(a1, a2), a1, a2) { | |
| 2249 CompilerTask previous = start(); | |
| 2250 try { | |
| 2251 return f(a1, a2); | |
| 2252 } finally { | |
| 2253 stop(previous); | |
| 2254 } | |
| 2255 } | |
| 2256 | |
| 2257 return runZoned( | |
| 2258 action, zoneSpecification: new ZoneSpecification( | |
| 2259 run: run, runUnary: runUnary, runBinary: runBinary)); | |
| 2260 } | |
| 2261 | |
| 2262 measureIo(action()) => watch == null ? action() : measureIoHelper(action); | |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
| |
| 2263 | |
| 2264 Future measureIoHelper(Future action()) { | |
| 2265 assert(watch != null); | |
| 2266 if (identical(this, compiler.measuredTask)) return action(); | |
| 2267 CompilerTask previous = start(); | |
| 2268 return measure(action).whenComplete(() { | |
| 2269 stop(previous); | |
| 2270 }); | |
| 2225 } | 2271 } |
| 2226 | 2272 |
| 2227 measureElement(Element element, action()) { | 2273 measureElement(Element element, action()) { |
| 2228 compiler.withCurrentElement(element, () => measure(action)); | 2274 compiler.withCurrentElement(element, () => measure(action)); |
| 2229 } | 2275 } |
| 2230 } | 2276 } |
| 2231 | 2277 |
| 2232 class SourceSpan implements Spannable { | 2278 class SourceSpan implements Spannable { |
| 2233 final Uri uri; | 2279 final Uri uri; |
| 2234 final int begin; | 2280 final int begin; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2509 InterfaceType streamType([DartType elementType]) { | 2555 InterfaceType streamType([DartType elementType]) { |
| 2510 InterfaceType type = streamClass.computeType(compiler); | 2556 InterfaceType type = streamClass.computeType(compiler); |
| 2511 if (elementType == null) { | 2557 if (elementType == null) { |
| 2512 return streamClass.rawType; | 2558 return streamClass.rawType; |
| 2513 } | 2559 } |
| 2514 return type.createInstantiation([elementType]); | 2560 return type.createInstantiation([elementType]); |
| 2515 } | 2561 } |
| 2516 } | 2562 } |
| 2517 | 2563 |
| 2518 typedef void InternalErrorFunction(Spannable location, String message); | 2564 typedef void InternalErrorFunction(Spannable location, String message); |
| OLD | NEW |