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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 .. (plugin_args or "") | 107 .. (plugin_args or "") |
105 .. " -Xclang -triple -Xclang " .. triple | 108 .. " -Xclang -triple -Xclang " .. triple |
106 .. " -D" .. arch_define | 109 .. " -D" .. arch_define |
107 .. " -DENABLE_DEBUGGER_SUPPORT" | 110 .. " -DENABLE_DEBUGGER_SUPPORT" |
108 .. " -DV8_I18N_SUPPORT" | 111 .. " -DV8_I18N_SUPPORT" |
109 .. " -I./" | 112 .. " -I./" |
110 .. " -Ithird_party/icu/source/common" | 113 .. " -Ithird_party/icu/source/common" |
111 .. " -Ithird_party/icu/source/i18n" | 114 .. " -Ithird_party/icu/source/i18n" |
112 end | 115 end |
113 | 116 |
117 function IterTable(t) | |
Vyacheslav Egorov (Google)
2015/02/18 10:56:49
I'd write it
local function IterTable(t)
retur
Vyacheslav Egorov (Google)
2015/02/18 10:59:51
my comment should obviously read:
Michael Achenbach
2015/02/18 14:48:59
Done.
| |
118 -- Iterator for arrays. Compatible with lua 5.0 and 5.1 as it doesn't | |
119 -- use getn. | |
120 local n = 0 | |
121 for _ in pairs(t) do n = n + 1 end | |
122 | |
123 local i = 0 | |
124 return function () | |
125 i = i + 1 | |
126 if i <= n then return t[i] end | |
127 end | |
128 end | |
129 | |
130 local function SplitResults(lines, func) | |
131 -- Splits the output of parallel.py and calls func on each result. | |
132 -- Bails out in case of an error in one of the executions. | |
133 local current = {} | |
134 local filename = "" | |
135 for line in lines do | |
136 local new_file = line:match "^______________ (.*)$" | |
137 local code = line:match "^______________ finish (%d+) ______________$" | |
138 if code then | |
139 if tonumber(code) > 0 then | |
140 log(table.concat(current, "\n")) | |
141 log("Failed to examine " .. filename) | |
142 return false | |
143 end | |
144 log("-- %s", filename) | |
145 func(filename, IterTable(current)) | |
146 elseif new_file then | |
147 filename = new_file | |
148 current = {} | |
149 else | |
150 table.insert(current, line) | |
151 end | |
152 end | |
153 return true | |
154 end | |
155 | |
114 function InvokeClangPluginForEachFile(filenames, cfg, func) | 156 function InvokeClangPluginForEachFile(filenames, cfg, func) |
115 local cmd_line = MakeClangCommandLine(cfg.plugin, | 157 local cmd_line = MakeClangCommandLine(cfg.plugin, |
116 cfg.plugin_args, | 158 cfg.plugin_args, |
117 cfg.triple, | 159 cfg.triple, |
118 cfg.arch_define) | 160 cfg.arch_define) |
119 for _, filename in ipairs(filenames) do | 161 if FLAGS.sequential then |
120 log("-- %s", filename) | 162 log("** Sequential execution.") |
Michael Achenbach
2015/02/18 10:04:54
This is the original piece of code c/p 1:1 (codere
| |
121 local action = cmd_line .. " " .. filename .. " 2>&1" | 163 for _, filename in ipairs(filenames) do |
164 log("-- %s", filename) | |
165 local action = cmd_line .. " " .. filename .. " 2>&1" | |
166 if FLAGS.verbose then print('popen ', action) end | |
167 local pipe = io.popen(action) | |
168 func(filename, pipe:lines()) | |
169 local success = pipe:close() | |
170 if not success then error("Failed to run: " .. action) end | |
171 end | |
172 else | |
173 log("** Parallel execution.") | |
174 local parallel_cmd_line = { | |
175 "python", | |
176 "tools/gcmole/parallel.py", | |
177 "\"" .. cmd_line .. "\"" | |
178 } | |
179 for _, filename in ipairs(filenames) do | |
180 table.insert(parallel_cmd_line, filename) | |
181 end | |
182 action = table.concat(parallel_cmd_line, " ") | |
Vyacheslav Egorov (Google)
2015/02/18 10:56:49
arguably you can just do
action = table.concat(pa
Michael Achenbach
2015/02/18 14:48:59
Made it even shorter.
| |
122 if FLAGS.verbose then print('popen ', action) end | 183 if FLAGS.verbose then print('popen ', action) end |
123 local pipe = io.popen(action) | 184 local pipe = io.popen(action) |
124 func(filename, pipe:lines()) | 185 local success = SplitResults(pipe:lines(), func) and pipe:close() |
Vyacheslav Egorov (Google)
2015/02/18 10:56:49
pipe will not be closed if SplitResults returns fa
Michael Achenbach
2015/02/18 14:48:59
Done.
| |
125 local success = pipe:close() | |
126 if not success then error("Failed to run: " .. action) end | 186 if not success then error("Failed to run: " .. action) end |
127 end | 187 end |
128 end | 188 end |
129 | 189 |
130 ------------------------------------------------------------------------------- | 190 ------------------------------------------------------------------------------- |
131 -- GYP file parsing | 191 -- GYP file parsing |
132 | 192 |
133 local function ParseGYPFile() | 193 local function ParseGYPFile() |
134 local gyp = "" | 194 local gyp = "" |
135 local gyp_files = { "tools/gyp/v8.gyp", "test/cctest/cctest.gyp" } | 195 local gyp_files = { "tools/gyp/v8.gyp", "test/cctest/cctest.gyp" } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 local function CheckCorrectnessForArch(arch) | 399 local function CheckCorrectnessForArch(arch) |
340 local files = FilesForArch(arch) | 400 local files = FilesForArch(arch) |
341 local cfg = ARCHITECTURES[arch] | 401 local cfg = ARCHITECTURES[arch] |
342 | 402 |
343 if not FLAGS.reuse_gcsuspects then | 403 if not FLAGS.reuse_gcsuspects then |
344 GenerateGCSuspects(arch, files, cfg) | 404 GenerateGCSuspects(arch, files, cfg) |
345 end | 405 end |
346 | 406 |
347 local processed_files = 0 | 407 local processed_files = 0 |
348 local errors_found = false | 408 local errors_found = false |
349 local function SearchForErrors(filename, lines) | 409 local function SearchForErrors(filename, lines) |
Vyacheslav Egorov (Google)
2015/02/18 10:56:49
if you change signature of this function and `pars
Michael Achenbach
2015/02/18 11:42:03
hmm but that would lead to
for l in ipairs(current
Vyacheslav Egorov (Google)
2015/02/18 11:58:11
Yeah, true. Guh.
Yeah, this does not work result
| |
350 processed_files = processed_files + 1 | 410 processed_files = processed_files + 1 |
351 for l in lines do | 411 for l in lines do |
352 errors_found = errors_found or | 412 errors_found = errors_found or |
353 l:match "^[^:]+:%d+:%d+:" or | 413 l:match "^[^:]+:%d+:%d+:" or |
354 l:match "error" or | 414 l:match "error" or |
355 l:match "warning" | 415 l:match "warning" |
356 print(l) | 416 print(l) |
357 end | 417 end |
358 end | 418 end |
359 | 419 |
(...skipping 26 matching lines...) Expand all Loading... | |
386 | 446 |
387 for _, arch in ipairs(ARCHS) do | 447 for _, arch in ipairs(ARCHS) do |
388 if not ARCHITECTURES[arch] then | 448 if not ARCHITECTURES[arch] then |
389 error ("Unknown arch: " .. arch) | 449 error ("Unknown arch: " .. arch) |
390 end | 450 end |
391 | 451 |
392 errors = SafeCheckCorrectnessForArch(arch, report) or errors | 452 errors = SafeCheckCorrectnessForArch(arch, report) or errors |
393 end | 453 end |
394 | 454 |
395 os.exit(errors and 1 or 0) | 455 os.exit(errors and 1 or 0) |
OLD | NEW |