| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import itertools | 6 import itertools |
| 7 import js2c | 7 import js2c |
| 8 import multiprocessing | 8 import multiprocessing |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| 11 import random | 11 import random |
| 12 import re | 12 import re |
| 13 import shutil | 13 import shutil |
| 14 import signal | 14 import signal |
| 15 import string | 15 import string |
| 16 import subprocess | 16 import subprocess |
| 17 import sys | 17 import sys |
| 18 import time | 18 import time |
| 19 | 19 |
| 20 FILENAME = "src/runtime.cc" | 20 FILENAME = "src/runtime.cc" |
| 21 HEADERFILENAME = "src/runtime.h" | 21 HEADERFILENAME = "src/runtime.h" |
| 22 FUNCTION = re.compile("^RUNTIME_FUNCTION\(Runtime_(\w+)") | 22 FUNCTION = re.compile("^RUNTIME_FUNCTION\(Runtime_(\w+)") |
| 23 ARGSLENGTH = re.compile(".*ASSERT\(.*args\.length\(\) == (\d+)\);") | 23 ARGSLENGTH = re.compile(".*DCHECK\(.*args\.length\(\) == (\d+)\);") |
| 24 FUNCTIONEND = "}\n" | 24 FUNCTIONEND = "}\n" |
| 25 MACRO = re.compile(r"^#define ([^ ]+)\(([^)]*)\) *([^\\]*)\\?\n$") | 25 MACRO = re.compile(r"^#define ([^ ]+)\(([^)]*)\) *([^\\]*)\\?\n$") |
| 26 FIRST_WORD = re.compile("^\s*(.*?)[\s({\[]") | 26 FIRST_WORD = re.compile("^\s*(.*?)[\s({\[]") |
| 27 | 27 |
| 28 WORKSPACE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) | 28 WORKSPACE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) |
| 29 BASEPATH = os.path.join(WORKSPACE, "test", "mjsunit", "runtime-gen") | 29 BASEPATH = os.path.join(WORKSPACE, "test", "mjsunit", "runtime-gen") |
| 30 THIS_SCRIPT = os.path.relpath(sys.argv[0]) | 30 THIS_SCRIPT = os.path.relpath(sys.argv[0]) |
| 31 | 31 |
| 32 # Expand these macros, they define further runtime functions. | 32 # Expand these macros, they define further runtime functions. |
| 33 EXPAND_MACROS = [ | 33 EXPAND_MACROS = [ |
| 34 "BUFFER_VIEW_GETTER", | 34 "BUFFER_VIEW_GETTER", |
| 35 "DATA_VIEW_GETTER", | 35 "DATA_VIEW_GETTER", |
| 36 "DATA_VIEW_SETTER", | 36 "DATA_VIEW_SETTER", |
| 37 "RUNTIME_UNARY_MATH", | 37 "RUNTIME_UNARY_MATH", |
| 38 ] | 38 ] |
| 39 # TODO(jkummerow): We could also whitelist the following macros, but the | 39 # TODO(jkummerow): We could also whitelist the following macros, but the |
| 40 # functions they define are so trivial that it's unclear how much benefit | 40 # functions they define are so trivial that it's unclear how much benefit |
| 41 # that would provide: | 41 # that would provide: |
| 42 # ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 42 # ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
| 43 # FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 43 # FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 44 # TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 44 # TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
| 45 | 45 |
| 46 # Counts of functions in each detection state. These are used to assert | 46 # Counts of functions in each detection state. These are used to assert |
| 47 # that the parser doesn't bit-rot. Change the values as needed when you add, | 47 # that the parser doesn't bit-rot. Change the values as needed when you add, |
| 48 # remove or change runtime functions, but make sure we don't lose our ability | 48 # remove or change runtime functions, but make sure we don't lose our ability |
| 49 # to parse them! | 49 # to parse them! |
| 50 EXPECTED_FUNCTION_COUNT = 425 | 50 EXPECTED_FUNCTION_COUNT = 425 |
| 51 EXPECTED_FUZZABLE_COUNT = 338 | 51 EXPECTED_FUZZABLE_COUNT = 328 |
| 52 EXPECTED_CCTEST_COUNT = 9 | 52 EXPECTED_CCTEST_COUNT = 7 |
| 53 EXPECTED_UNKNOWN_COUNT = 4 | 53 EXPECTED_UNKNOWN_COUNT = 16 |
| 54 EXPECTED_BUILTINS_COUNT = 816 | 54 EXPECTED_BUILTINS_COUNT = 816 |
| 55 | 55 |
| 56 | 56 |
| 57 # Don't call these at all. | 57 # Don't call these at all. |
| 58 BLACKLISTED = [ | 58 BLACKLISTED = [ |
| 59 "Abort", # Kills the process. | 59 "Abort", # Kills the process. |
| 60 "AbortJS", # Kills the process. | 60 "AbortJS", # Kills the process. |
| 61 "CompileForOnStackReplacement", # Riddled with ASSERTs. | 61 "CompileForOnStackReplacement", # Riddled with DCHECK. |
| 62 "IS_VAR", # Not implemented in the runtime. | 62 "IS_VAR", # Not implemented in the runtime. |
| 63 "ListNatives", # Not available in Release mode. | 63 "ListNatives", # Not available in Release mode. |
| 64 "SetAllocationTimeout", # Too slow for fuzzing. | 64 "SetAllocationTimeout", # Too slow for fuzzing. |
| 65 "SystemBreak", # Kills (int3) the process. | 65 "SystemBreak", # Kills (int3) the process. |
| 66 | 66 |
| 67 # These are weird. They violate some invariants when called after | 67 # These are weird. They violate some invariants when called after |
| 68 # bootstrapping. | 68 # bootstrapping. |
| 69 "DisableAccessChecks", | 69 "DisableAccessChecks", |
| 70 "EnableAccessChecks", | 70 "EnableAccessChecks", |
| 71 | 71 |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 for i in range(len(processes)): | 1401 for i in range(len(processes)): |
| 1402 processes[i].join() | 1402 processes[i].join() |
| 1403 except KeyboardInterrupt: | 1403 except KeyboardInterrupt: |
| 1404 stop_running.set() | 1404 stop_running.set() |
| 1405 for i in range(len(processes)): | 1405 for i in range(len(processes)): |
| 1406 processes[i].join() | 1406 processes[i].join() |
| 1407 return 0 | 1407 return 0 |
| 1408 | 1408 |
| 1409 if __name__ == "__main__": | 1409 if __name__ == "__main__": |
| 1410 sys.exit(Main()) | 1410 sys.exit(Main()) |
| OLD | NEW |