OLD | NEW |
1 -- Copyright 2011 the V8 project authors. All rights reserved. | 1 -- Copyright 2011 the V8 project authors. All rights reserved. |
2 -- Redistribution and use in source and binary forms, with or without | 2 -- Redistribution and use in source and binary forms, with or without |
3 -- modification, are permitted provided that the following conditions are | 3 -- modification, are permitted provided that the following conditions are |
4 -- met: | 4 -- met: |
5 -- | 5 -- |
6 -- * Redistributions of source code must retain the above copyright | 6 -- * Redistributions of source code must retain the above copyright |
7 -- notice, this list of conditions and the following disclaimer. | 7 -- notice, this list of conditions and the following disclaimer. |
8 -- * Redistributions in binary form must reproduce the above | 8 -- * Redistributions in binary form must reproduce the above |
9 -- copyright notice, this list of conditions and the following | 9 -- copyright notice, this list of conditions and the following |
10 -- disclaimer in the documentation and/or other materials provided | 10 -- disclaimer in the documentation and/or other materials provided |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 -- This is main driver for gcmole tool. See README for more details. | 28 -- This is main driver for gcmole tool. See README for more details. |
29 -- Usage: CLANG_BIN=clang-bin-dir lua tools/gcmole/gcmole.lua [arm|ia32|x64] | 29 -- Usage: CLANG_BIN=clang-bin-dir lua tools/gcmole/gcmole.lua [arm|ia32|x64] |
30 | 30 |
31 local DIR = arg[0]:match("^(.+)/[^/]+$") | 31 local DIR = arg[0]:match("^(.+)/[^/]+$") |
32 | 32 |
33 local FLAGS = { | 33 local FLAGS = { |
34 -- Do not build gcsuspects file and reuse previously generated one. | 34 -- Do not build gcsuspects file and reuse previously generated one. |
35 reuse_gcsuspects = false; | 35 reuse_gcsuspects = false; |
36 | 36 |
| 37 -- Don't use parallel python runner. |
| 38 sequential = false; |
| 39 |
37 -- Print commands to console before executing them. | 40 -- Print commands to console before executing them. |
38 verbose = false; | 41 verbose = false; |
39 | 42 |
40 -- Perform dead variable analysis (generates many false positives). | 43 -- Perform dead variable analysis (generates many false positives). |
41 -- TODO add some sort of whiteliste to filter out false positives. | 44 -- TODO add some sort of whiteliste to filter out false positives. |
42 dead_vars = false; | 45 dead_vars = false; |
43 | 46 |
44 -- When building gcsuspects whitelist certain functions as if they | 47 -- When building gcsuspects whitelist certain functions as if they |
45 -- can be causing GC. Currently used to reduce number of false | 48 -- can be causing GC. Currently used to reduce number of false |
46 -- positives in dead variables analysis. See TODO for WHITELIST | 49 -- positives in dead variables analysis. See TODO for WHITELIST |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 .. " -Xclang -triple -Xclang " .. triple | 109 .. " -Xclang -triple -Xclang " .. triple |
107 .. " -D" .. arch_define | 110 .. " -D" .. arch_define |
108 .. " -DENABLE_DEBUGGER_SUPPORT" | 111 .. " -DENABLE_DEBUGGER_SUPPORT" |
109 .. " -DV8_I18N_SUPPORT" | 112 .. " -DV8_I18N_SUPPORT" |
110 .. " -I./" | 113 .. " -I./" |
111 .. " -Ithird_party/icu/source/common" | 114 .. " -Ithird_party/icu/source/common" |
112 .. " -Ithird_party/icu/source/i18n" | 115 .. " -Ithird_party/icu/source/i18n" |
113 .. " " .. arch_options | 116 .. " " .. arch_options |
114 end | 117 end |
115 | 118 |
| 119 local function IterTable(t) |
| 120 return coroutine.wrap(function () |
| 121 for i, v in ipairs(t) do |
| 122 coroutine.yield(v) |
| 123 end |
| 124 end) |
| 125 end |
| 126 |
| 127 local function SplitResults(lines, func) |
| 128 -- Splits the output of parallel.py and calls func on each result. |
| 129 -- Bails out in case of an error in one of the executions. |
| 130 local current = {} |
| 131 local filename = "" |
| 132 for line in lines do |
| 133 local new_file = line:match "^______________ (.*)$" |
| 134 local code = line:match "^______________ finish (%d+) ______________$" |
| 135 if code then |
| 136 if tonumber(code) > 0 then |
| 137 log(table.concat(current, "\n")) |
| 138 log("Failed to examine " .. filename) |
| 139 return false |
| 140 end |
| 141 log("-- %s", filename) |
| 142 func(filename, IterTable(current)) |
| 143 elseif new_file then |
| 144 filename = new_file |
| 145 current = {} |
| 146 else |
| 147 table.insert(current, line) |
| 148 end |
| 149 end |
| 150 return true |
| 151 end |
| 152 |
116 function InvokeClangPluginForEachFile(filenames, cfg, func) | 153 function InvokeClangPluginForEachFile(filenames, cfg, func) |
117 local cmd_line = MakeClangCommandLine(cfg.plugin, | 154 local cmd_line = MakeClangCommandLine(cfg.plugin, |
118 cfg.plugin_args, | 155 cfg.plugin_args, |
119 cfg.triple, | 156 cfg.triple, |
120 cfg.arch_define, | 157 cfg.arch_define, |
121 cfg.arch_options) | 158 cfg.arch_options) |
122 for _, filename in ipairs(filenames) do | 159 if FLAGS.sequential then |
123 log("-- %s", filename) | 160 log("** Sequential execution.") |
124 local action = cmd_line .. " " .. filename .. " 2>&1" | 161 for _, filename in ipairs(filenames) do |
| 162 log("-- %s", filename) |
| 163 local action = cmd_line .. " " .. filename .. " 2>&1" |
| 164 if FLAGS.verbose then print('popen ', action) end |
| 165 local pipe = io.popen(action) |
| 166 func(filename, pipe:lines()) |
| 167 local success = pipe:close() |
| 168 if not success then error("Failed to run: " .. action) end |
| 169 end |
| 170 else |
| 171 log("** Parallel execution.") |
| 172 local action = "python tools/gcmole/parallel.py \"" |
| 173 .. cmd_line .. "\" " .. table.concat(filenames, " ") |
125 if FLAGS.verbose then print('popen ', action) end | 174 if FLAGS.verbose then print('popen ', action) end |
126 local pipe = io.popen(action) | 175 local pipe = io.popen(action) |
127 func(filename, pipe:lines()) | 176 local success = SplitResults(pipe:lines(), func) |
128 local success = pipe:close() | 177 local closed = pipe:close() |
129 if not success then error("Failed to run: " .. action) end | 178 if not (success and closed) then error("Failed to run: " .. action) end |
130 end | 179 end |
131 end | 180 end |
132 | 181 |
133 ------------------------------------------------------------------------------- | 182 ------------------------------------------------------------------------------- |
134 -- GYP file parsing | 183 -- GYP file parsing |
135 | 184 |
136 local function ParseGYPFile() | 185 local function ParseGYPFile() |
137 local gyp = "" | 186 local gyp = "" |
138 local gyp_files = { "tools/gyp/v8.gyp", "test/cctest/cctest.gyp" } | 187 local gyp_files = { "tools/gyp/v8.gyp", "test/cctest/cctest.gyp" } |
139 for i = 1, #gyp_files do | 188 for i = 1, #gyp_files do |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 442 |
394 for _, arch in ipairs(ARCHS) do | 443 for _, arch in ipairs(ARCHS) do |
395 if not ARCHITECTURES[arch] then | 444 if not ARCHITECTURES[arch] then |
396 error ("Unknown arch: " .. arch) | 445 error ("Unknown arch: " .. arch) |
397 end | 446 end |
398 | 447 |
399 errors = SafeCheckCorrectnessForArch(arch, report) or errors | 448 errors = SafeCheckCorrectnessForArch(arch, report) or errors |
400 end | 449 end |
401 | 450 |
402 os.exit(errors and 1 or 0) | 451 os.exit(errors and 1 or 0) |
OLD | NEW |