Commit 96d85bb8 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Add better consistency check and error output to plot script.

R=jkummerow@chromium.org
BUG=

Review URL: https://codereview.chromium.org/23736004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16537 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 17d21a51
...@@ -67,4 +67,13 @@ cat $log_file | ...@@ -67,4 +67,13 @@ cat $log_file |
$tools_path/codemap.js $tools_path/profile.js $tools_path/profile_view.js \ $tools_path/codemap.js $tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \ $tools_path/logreader.js $tools_path/tickprocessor.js \
$tools_path/profviz/composer.js $tools_path/profviz/stdio.js \ $tools_path/profviz/composer.js $tools_path/profviz/stdio.js \
-- $@ $options 2>/dev/null | gnuplot > timer-events.png -- $@ $options 2>/dev/null > timer-events.plot
success=$?
if [[ $success != 0 ]] ; then
cat timer-events.plot
else
cat timer-events.plot | gnuplot > timer-events.png
fi
rm -f timer-events.plot
...@@ -31,7 +31,7 @@ Array.prototype.top = function() { ...@@ -31,7 +31,7 @@ Array.prototype.top = function() {
} }
function PlotScriptComposer(kResX, kResY) { function PlotScriptComposer(kResX, kResY, error_output) {
// Constants. // Constants.
var kV8BinarySuffixes = ["/d8", "/libv8.so"]; var kV8BinarySuffixes = ["/d8", "/libv8.so"];
var kStackFrames = 8; // Stack frames to display in the plot. var kStackFrames = 8; // Stack frames to display in the plot.
...@@ -149,7 +149,10 @@ function PlotScriptComposer(kResX, kResY) { ...@@ -149,7 +149,10 @@ function PlotScriptComposer(kResX, kResY) {
// Utility functions. // Utility functions.
function assert(something, message) { function assert(something, message) {
if (!something) print(new Error(message).stack); if (!something) {
var error = new Error(message);
error_output(error.stack);
}
} }
function FindCodeKind(kind) { function FindCodeKind(kind) {
...@@ -208,10 +211,15 @@ function PlotScriptComposer(kResX, kResY) { ...@@ -208,10 +211,15 @@ function PlotScriptComposer(kResX, kResY) {
// Public methods. // Public methods.
this.collectData = function(input, distortion_per_entry) { this.collectData = function(input, distortion_per_entry) {
var last_timestamp = 0;
// Parse functions. // Parse functions.
var parseTimeStamp = function(timestamp) { var parseTimeStamp = function(timestamp) {
int_timestamp = parseInt(timestamp);
assert(int_timestamp >= last_timestamp, "Inconsistent timestamps.");
last_timestamp = int_timestamp;
distortion += distortion_per_entry; distortion += distortion_per_entry;
return parseInt(timestamp) / 1000 - distortion; return int_timestamp / 1000 - distortion;
} }
var processTimerEventStart = function(name, start) { var processTimerEventStart = function(name, start) {
...@@ -260,65 +268,6 @@ function PlotScriptComposer(kResX, kResY) { ...@@ -260,65 +268,6 @@ function PlotScriptComposer(kResX, kResY) {
code_map.deleteCode(address); code_map.deleteCode(address);
}; };
var processSharedLibrary = function(name, start, end) {
var code_entry = new CodeMap.CodeEntry(end - start, name);
code_entry.kind = -2; // External code kind.
for (var i = 0; i < kV8BinarySuffixes.length; i++) {
var suffix = kV8BinarySuffixes[i];
if (name.indexOf(suffix, name.length - suffix.length) >= 0) {
code_entry.kind = -1; // V8 runtime code kind.
break;
}
}
code_map.addLibrary(start, code_entry);
};
var processTimerEventStart = function(name, start) {
// Find out the thread id.
var new_event = TimerEvents[name];
if (new_event === undefined) return;
var thread_id = new_event.thread_id;
start = Math.max(last_time_stamp[thread_id] + kMinRangeLength, start);
// Last event on this thread is done with the start of this event.
var last_event = event_stack[thread_id].top();
if (last_event !== undefined) {
var new_range = new Range(last_time_stamp[thread_id], start);
last_event.ranges.push(new_range);
}
event_stack[thread_id].push(new_event);
last_time_stamp[thread_id] = start;
};
var processTimerEventEnd = function(name, end) {
// Find out about the thread_id.
var finished_event = TimerEvents[name];
var thread_id = finished_event.thread_id;
assert(finished_event === event_stack[thread_id].pop(),
"inconsistent event stack");
end = Math.max(last_time_stamp[thread_id] + kMinRangeLength, end);
var new_range = new Range(last_time_stamp[thread_id], end);
finished_event.ranges.push(new_range);
last_time_stamp[thread_id] = end;
};
var processCodeCreateEvent = function(type, kind, address, size, name) {
var code_entry = new CodeMap.CodeEntry(size, name);
code_entry.kind = kind;
code_map.addCode(address, code_entry);
};
var processCodeMoveEvent = function(from, to) {
code_map.moveCode(from, to);
};
var processCodeDeleteEvent = function(address) {
code_map.deleteCode(address);
};
var processCodeDeoptEvent = function(time, size) { var processCodeDeoptEvent = function(time, size) {
deopts.push(new Deopt(time, size)); deopts.push(new Deopt(time, size));
} }
......
...@@ -96,7 +96,7 @@ your computer's performance."> ...@@ -96,7 +96,7 @@ your computer's performance.">
or alternatively,<br/> or alternatively,<br/>
Chrome with Chrome with
<span class="tt"> <span class="tt">
--no-sandbox --js-flags="--prof --noprof-lazy --log-timer-events --no-sandbox --js-flags="--prof --log-timer-events"
</span> to produce <span class="tt">v8.log</span>. </span> to produce <span class="tt">v8.log</span>.
</li> </li>
<li> <li>
...@@ -117,6 +117,11 @@ your computer's performance."> ...@@ -117,6 +117,11 @@ your computer's performance.">
command-line utility command-line utility
</a> instead. </a> instead.
</li> </li>
</ol>
If you expect multiple V8 instances to run concurrently, for example
with several tabs in Chrome,<br/>
add the V8 flag <span class="tt">--logfile=v8.%p.log</span>
so that each instance writes to its own log file.
</div> </div>
</div> </div>
......
...@@ -42,15 +42,6 @@ var worker_scripts = [ ...@@ -42,15 +42,6 @@ var worker_scripts = [
function plotWorker() { function plotWorker() {
var worker = null; var worker = null;
var delegateList = {
"log" : log,
"error" : logError,
"displayplot" : displayplot,
"displayprof" : displayprof,
"range" : setRange,
"script" : scriptLoaded
}
function initialize() { function initialize() {
ui.freeze(); ui.freeze();
worker = new Worker("worker.js"); worker = new Worker("worker.js");
...@@ -89,6 +80,16 @@ function plotWorker() { ...@@ -89,6 +80,16 @@ function plotWorker() {
if (worker) worker.terminate(); if (worker) worker.terminate();
initialize(); initialize();
} }
var delegateList = {
"log" : log,
"error" : logError,
"displayplot" : displayplot,
"displayprof" : displayprof,
"range" : setRange,
"script" : scriptLoaded,
"reset" : this.reset
}
} }
...@@ -233,9 +234,6 @@ function start(event) { ...@@ -233,9 +234,6 @@ function start(event) {
function getSelectedFile() { function getSelectedFile() {
var file = ui.file.files[0]; var file = ui.file.files[0];
if (!file) throw Error("No valid file selected."); if (!file) throw Error("No valid file selected.");
if (!file.type.toString().match(/text/)) {
throw Error("'" + escape(file.name) + "' is not a text file.");
}
return file; return file;
} }
......
...@@ -44,7 +44,11 @@ if (!isNaN(range_end)) range_end_override = range_end; ...@@ -44,7 +44,11 @@ if (!isNaN(range_end)) range_end_override = range_end;
var kResX = 1600; var kResX = 1600;
var kResY = 600; var kResY = 600;
var psc = new PlotScriptComposer(kResX, kResY); function log_error(text) {
print(text);
quit(1);
}
var psc = new PlotScriptComposer(kResX, kResY, log_error);
psc.collectData(readline, distortion_per_entry); psc.collectData(readline, distortion_per_entry);
psc.findPlotRange(range_start_override, range_end_override); psc.findPlotRange(range_start_override, range_end_override);
print("set terminal pngcairo size " + kResX + "," + kResY + print("set terminal pngcairo size " + kResX + "," + kResY +
......
...@@ -72,6 +72,12 @@ function load_scripts(scripts) { ...@@ -72,6 +72,12 @@ function load_scripts(scripts) {
} }
function log_error(text) {
self.postMessage({"call": "error", "args": text});
self.postMessage({"call": "reset"});
}
function run(args) { function run(args) {
var file = args["file"]; var file = args["file"];
var resx = args["resx"]; var resx = args["resx"];
...@@ -121,7 +127,7 @@ function run(args) { ...@@ -121,7 +127,7 @@ function run(args) {
var input_file_name = "input_temp"; var input_file_name = "input_temp";
var output_file_name = "output.svg"; var output_file_name = "output.svg";
var psc = new PlotScriptComposer(resx, resy); var psc = new PlotScriptComposer(resx, resy, log_error);
var objects = 0; var objects = 0;
time("Collecting events (" + content_lines.length + " entries)", time("Collecting events (" + content_lines.length + " entries)",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment