summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2010-02-23 13:46:05 +0000
committerAndrei Popescu <andreip@google.com>2010-02-25 14:07:18 +0000
commit3100271588b61cbc1dc472a3f2f105d2eed8497f (patch)
tree05c3c54cf44b861d1d61dfcbb6b83e2ee2c13281 /tools
parent6b23cceca405474a281cdf61cbcd6ecf10944a82 (diff)
downloadandroid_external_v8-3100271588b61cbc1dc472a3f2f105d2eed8497f.tar.gz
android_external_v8-3100271588b61cbc1dc472a3f2f105d2eed8497f.tar.bz2
android_external_v8-3100271588b61cbc1dc472a3f2f105d2eed8497f.zip
Update to V8 with partial snapshots. This is taken from the partial_snapshot branch of V8.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/js2c.py44
-rwxr-xr-xtools/linux-tick-processor11
-rw-r--r--tools/logreader.js45
-rw-r--r--tools/tickprocessor.js29
-rwxr-xr-xtools/windows-tick-processor.bat26
5 files changed, 117 insertions, 38 deletions
diff --git a/tools/js2c.py b/tools/js2c.py
index b889530d..64de7d31 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -220,8 +220,8 @@ namespace internal {
}
template <>
- int NativesCollection<%(type)s>::GetDelayCount() {
- return %(delay_count)i;
+ int NativesCollection<%(type)s>::GetDebuggerCount() {
+ return %(debugger_count)i;
}
template <>
@@ -252,23 +252,23 @@ SOURCE_DECLARATION = """\
"""
-GET_DELAY_INDEX_CASE = """\
+GET_DEBUGGER_INDEX_CASE = """\
if (strcmp(name, "%(id)s") == 0) return %(i)i;
"""
-GET_DELAY_SCRIPT_SOURCE_CASE = """\
+GET_DEBUGGER_SCRIPT_SOURCE_CASE = """\
if (index == %(i)i) return Vector<const char>(%(id)s, %(length)i);
"""
-GET_DELAY_SCRIPT_NAME_CASE = """\
+GET_DEBUGGER_SCRIPT_NAME_CASE = """\
if (index == %(i)i) return Vector<const char>("%(name)s", %(length)i);
"""
def JS2C(source, target, env):
ids = []
- delay_ids = []
+ debugger_ids = []
modules = []
# Locate the macros file name.
consts = {}
@@ -287,7 +287,7 @@ def JS2C(source, target, env):
source_lines_empty = []
for module in modules:
filename = str(module)
- delay = filename.endswith('-delay.js')
+ debugger = filename.endswith('-debugger.js')
lines = ReadFile(filename)
lines = ExpandConstants(lines, consts)
lines = ExpandMacros(lines, macros)
@@ -295,29 +295,29 @@ def JS2C(source, target, env):
lines = minifier.JSMinify(lines)
data = ToCArray(lines)
id = (os.path.split(filename)[1])[:-3]
- if delay: id = id[:-6]
- if delay:
- delay_ids.append((id, len(lines)))
+ if debugger: id = id[:-9]
+ if debugger:
+ debugger_ids.append((id, len(lines)))
else:
ids.append((id, len(lines)))
source_lines.append(SOURCE_DECLARATION % { 'id': id, 'data': data })
source_lines_empty.append(SOURCE_DECLARATION % { 'id': id, 'data': data })
- # Build delay support functions
+ # Build debugger support functions
get_index_cases = [ ]
get_script_source_cases = [ ]
get_script_name_cases = [ ]
i = 0
- for (id, length) in delay_ids:
+ for (id, length) in debugger_ids:
native_name = "native %s.js" % id
- get_index_cases.append(GET_DELAY_INDEX_CASE % { 'id': id, 'i': i })
- get_script_source_cases.append(GET_DELAY_SCRIPT_SOURCE_CASE % {
+ get_index_cases.append(GET_DEBUGGER_INDEX_CASE % { 'id': id, 'i': i })
+ get_script_source_cases.append(GET_DEBUGGER_SCRIPT_SOURCE_CASE % {
'id': id,
'length': length,
'i': i
})
- get_script_name_cases.append(GET_DELAY_SCRIPT_NAME_CASE % {
+ get_script_name_cases.append(GET_DEBUGGER_SCRIPT_NAME_CASE % {
'name': native_name,
'length': len(native_name),
'i': i
@@ -326,13 +326,13 @@ def JS2C(source, target, env):
for (id, length) in ids:
native_name = "native %s.js" % id
- get_index_cases.append(GET_DELAY_INDEX_CASE % { 'id': id, 'i': i })
- get_script_source_cases.append(GET_DELAY_SCRIPT_SOURCE_CASE % {
+ get_index_cases.append(GET_DEBUGGER_INDEX_CASE % { 'id': id, 'i': i })
+ get_script_source_cases.append(GET_DEBUGGER_SCRIPT_SOURCE_CASE % {
'id': id,
'length': length,
'i': i
})
- get_script_name_cases.append(GET_DELAY_SCRIPT_NAME_CASE % {
+ get_script_name_cases.append(GET_DEBUGGER_SCRIPT_NAME_CASE % {
'name': native_name,
'length': len(native_name),
'i': i
@@ -342,8 +342,8 @@ def JS2C(source, target, env):
# Emit result
output = open(str(target[0]), "w")
output.write(HEADER_TEMPLATE % {
- 'builtin_count': len(ids) + len(delay_ids),
- 'delay_count': len(delay_ids),
+ 'builtin_count': len(ids) + len(debugger_ids),
+ 'debugger_count': len(debugger_ids),
'source_lines': "\n".join(source_lines),
'get_index_cases': "".join(get_index_cases),
'get_script_source_cases': "".join(get_script_source_cases),
@@ -355,8 +355,8 @@ def JS2C(source, target, env):
if len(target) > 1:
output = open(str(target[1]), "w")
output.write(HEADER_TEMPLATE % {
- 'builtin_count': len(ids) + len(delay_ids),
- 'delay_count': len(delay_ids),
+ 'builtin_count': len(ids) + len(debugger_ids),
+ 'debugger_count': len(debugger_ids),
'source_lines': "\n".join(source_lines_empty),
'get_index_cases': "".join(get_index_cases),
'get_script_source_cases': "".join(get_script_source_cases),
diff --git a/tools/linux-tick-processor b/tools/linux-tick-processor
index ca1c7212..17157050 100755
--- a/tools/linux-tick-processor
+++ b/tools/linux-tick-processor
@@ -16,8 +16,17 @@ else
[ -x $d8_exec ] || scons -j4 -C $D8_PATH -Y $tools_path/.. d8
fi
+# find the name of the log file to process, it must not start with a dash.
+log_file="v8.log"
+for arg in "$@"
+do
+ if [[ "${arg}" != -* ]]; then
+ log_file=${arg}
+ fi
+done
+
# nm spits out 'no symbols found' messages to stderr.
-$d8_exec $tools_path/splaytree.js $tools_path/codemap.js \
+cat $log_file | $d8_exec $tools_path/splaytree.js $tools_path/codemap.js \
$tools_path/csvparser.js $tools_path/consarray.js \
$tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \
diff --git a/tools/logreader.js b/tools/logreader.js
index 20a1f544..b2aca73d 100644
--- a/tools/logreader.js
+++ b/tools/logreader.js
@@ -76,6 +76,18 @@ devtools.profiler.LogReader = function(dispatchTable) {
* @type {Array.<string>}
*/
this.backRefs_ = [];
+
+ /**
+ * Current line.
+ * @type {number}
+ */
+ this.lineNum_ = 0;
+
+ /**
+ * CSV lines parser.
+ * @type {devtools.profiler.CsvParser}
+ */
+ this.csvParser_ = new devtools.profiler.CsvParser();
};
@@ -136,6 +148,16 @@ devtools.profiler.LogReader.prototype.processLogChunk = function(chunk) {
/**
+ * Processes a line of V8 profiler event log.
+ *
+ * @param {string} line A line of log.
+ */
+devtools.profiler.LogReader.prototype.processLogLine = function(line) {
+ this.processLog_([line]);
+};
+
+
+/**
* Processes stack record.
*
* @param {number} pc Program counter.
@@ -280,25 +302,20 @@ devtools.profiler.LogReader.prototype.processAlias_ = function(
* @private
*/
devtools.profiler.LogReader.prototype.processLog_ = function(lines) {
- var csvParser = new devtools.profiler.CsvParser();
- try {
- for (var i = 0, n = lines.length; i < n; ++i) {
- var line = lines[i];
- if (!line) {
- continue;
- }
+ for (var i = 0, n = lines.length; i < n; ++i, ++this.lineNum_) {
+ var line = lines[i];
+ if (!line) {
+ continue;
+ }
+ try {
if (line.charAt(0) == '#' ||
line.substr(0, line.indexOf(',')) in this.backRefsCommands_) {
line = this.expandBackRef_(line);
}
- var fields = csvParser.parseLine(line);
+ var fields = this.csvParser_.parseLine(line);
this.dispatchLogRow_(fields);
- }
- } catch (e) {
- // An error on the last line is acceptable since log file can be truncated.
- if (i < n - 1) {
- this.printError('line ' + (i + 1) + ': ' + (e.message || e));
- throw e;
+ } catch (e) {
+ this.printError('line ' + (this.lineNum_ + 1) + ': ' + (e.message || e));
}
}
};
diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js
index 35422e2e..40cee8a0 100644
--- a/tools/tickprocessor.js
+++ b/tools/tickprocessor.js
@@ -67,6 +67,9 @@ function SnapshotLogProcessor() {
processor: this.processCodeMove, backrefs: true },
'code-delete': { parsers: [this.createAddressParser('code')],
processor: this.processCodeDelete, backrefs: true },
+ 'function-creation': null,
+ 'function-move': null,
+ 'function-delete': null,
'snapshot-pos': { parsers: [this.createAddressParser('code'), parseInt],
processor: this.processSnapshotPosition, backrefs: true }});
@@ -157,6 +160,10 @@ function TickProcessor(
processor: this.processHeapSampleEnd },
'heap-js-prod-item': { parsers: [null, 'var-args'],
processor: this.processJSProducer, backrefs: true },
+ 'PAGE-LOAD-START': { parsers: [null, null],
+ processor: this.processPageLoadStart },
+ 'PAGE-LOAD-END': { parsers: [null, null],
+ processor: this.processPageLoadEnd },
// Ignored events.
'profiler': null,
'heap-sample-stats': null,
@@ -173,6 +180,7 @@ function TickProcessor(
this.stateFilter_ = stateFilter;
this.snapshotLogProcessor_ = snapshotLogProcessor;
this.deserializedEntriesNames_ = [];
+ this.handle_ticks_ = false;
var ticks = this.ticks_ =
{ total: 0, unaccounted: 0, excluded: 0, gc: 0 };
@@ -259,6 +267,16 @@ TickProcessor.prototype.isJsCode = function(name) {
TickProcessor.prototype.processLogFile = function(fileName) {
this.lastLogFileName_ = fileName;
+ var line;
+ while (line = readline()) {
+ this.processLogLine(line);
+ }
+};
+
+
+TickProcessor.prototype.processLogFileInTest = function(fileName) {
+ // Hack file name to avoid dealing with platform specifics.
+ this.lastLogFileName_ = 'v8.log';
var contents = readFile(fileName);
this.processLogChunk(contents);
};
@@ -326,6 +344,7 @@ TickProcessor.prototype.includeTick = function(vmState) {
TickProcessor.prototype.processTick = function(pc, sp, func, vmState, stack) {
+ if (!this.handle_ticks_) return;
this.ticks_.total++;
if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
if (!this.includeTick(vmState)) {
@@ -373,6 +392,16 @@ TickProcessor.prototype.processHeapSampleEnd = function(space, state) {
};
+TickProcessor.prototype.processPageLoadStart = function() {
+ this.handle_ticks_ = true;
+};
+
+
+TickProcessor.prototype.processPageLoadEnd = function() {
+ this.handle_ticks_ = false;
+};
+
+
TickProcessor.prototype.processJSProducer = function(constructor, stack) {
if (!this.currentProducerProfile_) return;
if (stack.length == 0) return;
diff --git a/tools/windows-tick-processor.bat b/tools/windows-tick-processor.bat
index 6743f68b..33b1f770 100755
--- a/tools/windows-tick-processor.bat
+++ b/tools/windows-tick-processor.bat
@@ -2,4 +2,28 @@
SET tools_dir=%~dp0
-%tools_dir%..\d8 %tools_dir%splaytree.js %tools_dir%codemap.js %tools_dir%csvparser.js %tools_dir%consarray.js %tools_dir%profile.js %tools_dir%profile_view.js %tools_dir%logreader.js %tools_dir%tickprocessor.js %tools_dir%tickprocessor-driver.js -- --windows %*
+SET log_file=v8.log
+
+rem find the name of the log file to process, it must not start with a dash.
+rem we prepend cmdline args with a number (in fact, any letter or number)
+rem to cope with empty arguments.
+SET arg1=1%1
+IF NOT %arg1:~0,2% == 1 (IF NOT %arg1:~0,2% == 1- SET log_file=%1)
+SET arg2=2%2
+IF NOT %arg2:~0,2% == 2 (IF NOT %arg2:~0,2% == 2- SET log_file=%2)
+SET arg3=3%3
+IF NOT %arg3:~0,2% == 3 (IF NOT %arg3:~0,2% == 3- SET log_file=%3)
+SET arg4=4%4
+IF NOT %arg4:~0,2% == 4 (IF NOT %arg4:~0,2% == 4- SET log_file=%4)
+SET arg5=5%5
+IF NOT %arg5:~0,2% == 5 (IF NOT %arg5:~0,2% == 5- SET log_file=%5)
+SET arg6=6%6
+IF NOT %arg6:~0,2% == 6 (IF NOT %arg6:~0,2% == 6- SET log_file=%6)
+SET arg7=7%7
+IF NOT %arg7:~0,2% == 7 (IF NOT %arg7:~0,2% == 7- SET log_file=%7)
+SET arg8=8%8
+IF NOT %arg8:~0,2% == 8 (IF NOT %arg8:~0,2% == 8- SET log_file=%8)
+SET arg9=9%9
+IF NOT %arg9:~0,2% == 9 (IF NOT %arg9:~0,2% == 9- SET log_file=%9)
+
+type %log_file% | %tools_dir%..\d8 %tools_dir%splaytree.js %tools_dir%codemap.js %tools_dir%csvparser.js %tools_dir%consarray.js %tools_dir%profile.js %tools_dir%profile_view.js %tools_dir%logreader.js %tools_dir%tickprocessor.js %tools_dir%tickprocessor-driver.js -- --windows %*