| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 if (diff2.length > 0) { | 47 if (diff2.length > 0) { |
| 48 _fail("some elements found in libraries weren't part of the global list" | 48 _fail("some elements found in libraries weren't part of the global list" |
| 49 " (non-zero ${diff2.where((f) => f.size > 0).length})"); | 49 " (non-zero ${diff2.where((f) => f.size > 0).length})"); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Validate that code-size adds up. | 53 // Validate that code-size adds up. |
| 54 int realTotal = info.program.size; | 54 int realTotal = info.program.size; |
| 55 int totalLib = info.libraries.fold(0, (n, lib) => n + lib.size); | 55 int totalLib = info.libraries.fold(0, (n, lib) => n + lib.size); |
| 56 if (totalLib != realTotal) { | 56 int constantsSize = info.constants.fold(0, (n, c) => n + c.size); |
| 57 var percent = ((realTotal - totalLib) * 100 / realTotal).toStringAsFixed(2); | 57 int accounted = totalLib + constantsSize; |
| 58 _fail('$percent% size missing (sum of all libs < total)'); | 58 |
| 59 if (accounted != realTotal) { |
| 60 var percent = ((realTotal - accounted) * 100 / realTotal) |
| 61 .toStringAsFixed(2); |
| 62 _fail('$percent% size missing: $accounted (all libs + consts) ' |
| 63 '< $realTotal (total)'); |
| 59 } | 64 } |
| 60 var missingTotal = tracker.missing.values.fold(0, (a, b) => a + b); | 65 var missingTotal = tracker.missing.values.fold(0, (a, b) => a + b); |
| 61 if (missingTotal > 0) { | 66 if (missingTotal > 0) { |
| 62 var percent = (missingTotal * 100 / realTotal).toStringAsFixed(2); | 67 var percent = (missingTotal * 100 / realTotal).toStringAsFixed(2); |
| 63 _fail('$percent% size missing in libraries (sum of elements > lib.size)'); | 68 _fail('$percent% size missing in libraries (sum of elements > lib.size)'); |
| 64 } | 69 } |
| 65 | 70 |
| 66 // Validate dependency data. | 71 // Validate dependency data. |
| 67 compareGraphs(info); | 72 compareGraphs(info); |
| 68 } | 73 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 _pass('dependency data is consistent'); | 253 _pass('dependency data is consistent'); |
| 249 } else { | 254 } else { |
| 250 _fail('inconsistencies in dependency data:\n' | 255 _fail('inconsistencies in dependency data:\n' |
| 251 ' $inUsesNotInDependencies edges missing from "dependencies" graph\n' | 256 ' $inUsesNotInDependencies edges missing from "dependencies" graph\n' |
| 252 ' $inDependenciesNotInUses edges missing from "uses" graph'); | 257 ' $inDependenciesNotInUses edges missing from "uses" graph'); |
| 253 } | 258 } |
| 254 } | 259 } |
| 255 | 260 |
| 256 _pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg'); | 261 _pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg'); |
| 257 _fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg'); | 262 _fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg'); |
| OLD | NEW |