Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2014 the V8 project authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import re |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | DECLARE_FILE = "src/assembler.h" |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 11 | REGISTER_FILE = "src/external-reference-table.cc" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 12 | DECLARE_RE = re.compile("\s*static ExternalReference ([^(]+)\(") |
| 13 | REGISTER_RE = re.compile("\s*Add\(ExternalReference::([^(]+)\(") |
| 14 | |
| 15 | WORKSPACE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) |
| 16 | |
| 17 | # Ignore those. |
| 18 | BLACKLISTED = [ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 19 | "fixed_typed_array_base_data_offset", |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 20 | "page_flags", |
| 21 | "math_exp_constants", |
| 22 | "math_exp_log_table", |
| 23 | "ForDeoptEntry", |
| 24 | ] |
| 25 | |
| 26 | def Find(filename, re): |
| 27 | references = [] |
| 28 | with open(filename, "r") as f: |
| 29 | for line in f: |
| 30 | match = re.match(line) |
| 31 | if match: |
| 32 | references.append(match.group(1)) |
| 33 | return references |
| 34 | |
| 35 | def Main(): |
| 36 | declarations = Find(DECLARE_FILE, DECLARE_RE) |
| 37 | registrations = Find(REGISTER_FILE, REGISTER_RE) |
| 38 | difference = list(set(declarations) - set(registrations) - set(BLACKLISTED)) |
| 39 | for reference in difference: |
| 40 | print("Declared but not registered: ExternalReference::%s" % reference) |
| 41 | return len(difference) > 0 |
| 42 | |
| 43 | if __name__ == "__main__": |
| 44 | sys.exit(Main()) |