| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Tool used mainly by dart2js developers to debug the generated info and check | 5 /// Tool used mainly by dart2js developers to debug the generated info and check |
| 6 /// that it is consistent and that it covers all the data we expect it to cover. | 6 /// that it is consistent and that it covers all the data we expect it to cover. |
| 7 library dart2js_info.bin.debug_info; | 7 library dart2js_info.bin.debug_info; |
| 8 | 8 |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 if (diff2.length > 0) { | 41 if (diff2.length > 0) { |
| 42 _fail('some elements found in libraries weren\'t part of the global list' | 42 _fail('some elements found in libraries weren\'t part of the global list' |
| 43 ' (non-zero ${diff2.where((f) => f.size > 0).length})'); | 43 ' (non-zero ${diff2.where((f) => f.size > 0).length})'); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Validate that code-size adds up. | 47 // Validate that code-size adds up. |
| 48 int realTotal = info.program.size; | 48 int realTotal = info.program.size; |
| 49 int totalLib = info.libraries.fold(0, (n, lib) => n + lib.size); | 49 int totalLib = info.libraries.fold(0, (n, lib) => n + lib.size); |
| 50 if (totalLib != realTotal) { | 50 int constantsSize = info.constants.fold(0, (n, c) => n + c.size); |
| 51 var percent = ((realTotal - totalLib) * 100 / realTotal).toStringAsFixed(2); | 51 int accounted = totalLib + constantsSize; |
| 52 _fail('$percent% size missing (sum of all libs < total)'); | 52 |
| 53 if (accounted != realTotal) { |
| 54 var percent = ((realTotal - accounted) * 100 / realTotal) |
| 55 .toStringAsFixed(2); |
| 56 _fail('$percent% size missing: $accounted (all libs + consts) ' |
| 57 '< $realTotal (total)'); |
| 53 } | 58 } |
| 54 var missingTotal = tracker.missing.values.fold(0, (a, b) => a + b); | 59 var missingTotal = tracker.missing.values.fold(0, (a, b) => a + b); |
| 55 if (missingTotal > 0) { | 60 if (missingTotal > 0) { |
| 56 var percent = (missingTotal * 100 / realTotal).toStringAsFixed(2); | 61 var percent = (missingTotal * 100 / realTotal).toStringAsFixed(2); |
| 57 _fail('$percent% size missing in libraries (sum of elements > lib.size)'); | 62 _fail('$percent% size missing in libraries (sum of elements > lib.size)'); |
| 58 } | 63 } |
| 59 | 64 |
| 60 // Validate dependency data. | 65 // Validate dependency data. |
| 61 compareGraphs(info); | 66 compareGraphs(info); |
| 62 } | 67 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 _pass('dependency data is consistent'); | 246 _pass('dependency data is consistent'); |
| 242 } else { | 247 } else { |
| 243 _fail('inconsistencies in dependency data:\n' | 248 _fail('inconsistencies in dependency data:\n' |
| 244 ' $inUsesNotInDependencies edges missing from "dependencies" graph\n' | 249 ' $inUsesNotInDependencies edges missing from "dependencies" graph\n' |
| 245 ' $inDependenciesNotInUses edges missing from "uses" graph'); | 250 ' $inDependenciesNotInUses edges missing from "uses" graph'); |
| 246 } | 251 } |
| 247 } | 252 } |
| 248 | 253 |
| 249 _pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg'); | 254 _pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg'); |
| 250 _fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg'); | 255 _fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg'); |
| OLD | NEW |