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 6import re 7import os 8import sys 9 10DECLARE_FILE = "src/assembler.h" 11REGISTER_FILE = "src/serialize.cc" 12DECLARE_RE = re.compile("\s*static ExternalReference ([^(]+)\(") 13REGISTER_RE = re.compile("\s*Add\(ExternalReference::([^(]+)\(") 14 15WORKSPACE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) 16 17# Ignore those. 18BLACKLISTED = [ 19 "page_flags", 20 "math_exp_constants", 21 "math_exp_log_table", 22 "ForDeoptEntry", 23] 24 25def Find(filename, re): 26 references = [] 27 with open(filename, "r") as f: 28 for line in f: 29 match = re.match(line) 30 if match: 31 references.append(match.group(1)) 32 return references 33 34def Main(): 35 declarations = Find(DECLARE_FILE, DECLARE_RE) 36 registrations = Find(REGISTER_FILE, REGISTER_RE) 37 difference = list(set(declarations) - set(registrations) - set(BLACKLISTED)) 38 for reference in difference: 39 print("Declared but not registered: ExternalReference::%s" % reference) 40 return len(difference) > 0 41 42if __name__ == "__main__": 43 sys.exit(Main()) 44