Remove snapshot log parsing and option from tools.

LOG=N

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

Cr-Commit-Position: refs/heads/master@{#35268}
This commit is contained in:
ssanfilippo 2016-04-05 08:29:49 -07:00 committed by Commit bot
parent 34c4e27e91
commit 9e39a9fff1
14 changed files with 13 additions and 246 deletions

View File

@ -509,9 +509,6 @@ action("run_mksnapshot") {
"./" + rebase_path(get_label_info(":mksnapshot($snapshot_toolchain)",
"root_out_dir") + "/mksnapshot",
root_build_dir),
"--log-snapshot-positions",
"--logfile",
rebase_path("$target_gen_dir/snapshot.log", root_build_dir),
"--startup_src",
rebase_path("$target_gen_dir/snapshot.cc", root_build_dir),
]

View File

@ -1003,8 +1003,6 @@ DEFINE_BOOL(log_code, false,
DEFINE_BOOL(log_gc, false,
"Log heap samples on garbage collection for the hp2ps tool.")
DEFINE_BOOL(log_handles, false, "Log global handle events.")
DEFINE_BOOL(log_snapshot_positions, false,
"log positions of (de)serialized objects in the snapshot.")
DEFINE_BOOL(log_suspect, false, "Log suspect operations.")
DEFINE_BOOL(prof, false,
"Log statistical profiling information (implies --log-code).")

View File

@ -326,14 +326,6 @@ class LowLevelLogger : public CodeEventLogger {
};
struct SnapshotPositionStruct {
static const char kTag = 'P';
Address address;
int32_t position;
};
static const char kCodeMovingGCTag = 'G';
@ -426,17 +418,6 @@ void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) {
LogWriteStruct(event);
}
void LowLevelLogger::SnapshotPositionEvent(HeapObject* obj, int pos) {
if (obj->IsAbstractCode()) {
SnapshotPositionStruct event;
event.address =
obj->address() +
(obj->IsCode() ? Code::kHeaderSize : BytecodeArray::kHeaderSize);
event.position = pos;
LogWriteStruct(event);
}
}
void LowLevelLogger::LogWriteBytes(const char* bytes, int size) {
size_t rv = fwrite(bytes, 1, size, ll_output_handle_);
@ -1296,17 +1277,6 @@ void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) {
msg.WriteToLogFile();
}
void Logger::SnapshotPositionEvent(HeapObject* obj, int pos) {
if (!log_->IsEnabled()) return;
LL_LOG(SnapshotPositionEvent(obj, pos));
if (!FLAG_log_snapshot_positions) return;
Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]);
msg.AppendAddress(obj->address());
msg.Append(",%d", pos);
msg.WriteToLogFile();
}
void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
if (!is_logging_code_events()) return;
@ -1781,11 +1751,6 @@ bool Logger::SetUp(Isolate* isolate) {
if (is_initialized_) return true;
is_initialized_ = true;
// --ll-prof implies --log-code and --log-snapshot-positions.
if (FLAG_ll_prof) {
FLAG_log_snapshot_positions = true;
}
std::ostringstream log_file_name;
PrepareLogFileName(log_file_name, isolate, FLAG_logfile);
log_->Initialize(log_file_name.str().c_str());

View File

@ -89,7 +89,6 @@ struct TickSample;
V(CODE_DELETE_EVENT, "code-delete") \
V(CODE_MOVING_GC, "code-moving-gc") \
V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \
V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \
V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \
V(TICK_EVENT, "tick") \
V(REPEAT_META_EVENT, "repeat") \
@ -260,7 +259,6 @@ class Logger {
void SharedFunctionInfoMoveEvent(Address from, Address to);
void CodeNameEvent(Address addr, int pos, const char* code_name);
void SnapshotPositionEvent(HeapObject* obj, int pos);
// ==== Events logged by --log-gc. ====
// Heap sampling events: start, end, and individual types.

View File

@ -373,15 +373,11 @@ void Deserializer::ReadObject(int space_number, Object** write_back) {
isolate_->heap()->OnAllocationEvent(obj, size);
Object** current = reinterpret_cast<Object**>(address);
Object** limit = current + (size >> kPointerSizeLog2);
int position = source_.position();
if (ReadData(current, limit, space_number, address)) {
// Only post process if object content has not been deferred.
obj = PostProcessNewObject(obj, space_number);
}
if (FLAG_log_snapshot_positions) {
LOG(isolate_, SnapshotPositionEvent(obj, position));
}
Object* write_back_obj = obj;
UnalignedCopy(write_back, &write_back_obj);

View File

@ -136,11 +136,9 @@ char* GetExtraCode(char* filename, const char* description) {
int main(int argc, char** argv) {
// By default, log code create information in the snapshot.
i::FLAG_log_code = true;
i::FLAG_logfile_per_isolate = false;
// Make mksnapshot runs predictable to create reproducible snapshots.
i::FLAG_predictable = true;
// Print the usage if an error occurs when parsing the command line
// flags or if the help flag is set.
int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);

View File

@ -318,8 +318,6 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space,
serializer_->code_address_map_->Lookup(object_->address());
LOG(serializer_->isolate_,
CodeNameEvent(object_->address(), sink_->Position(), code_name));
LOG(serializer_->isolate_,
SnapshotPositionEvent(object_, sink_->Position()));
}
BackReference back_reference;

View File

@ -384,7 +384,6 @@ function driveTickProcessorTest(
TickProcessor.CALL_GRAPH_SIZE,
ignoreUnknown,
stateFilter,
undefined,
"0",
"auto,auto",
false,

View File

@ -211,10 +211,6 @@
'<(INTERMEDIATE_DIR)/snapshot.cc',
],
'variables': {
'mksnapshot_flags': [
'--log-snapshot-positions',
'--logfile', '<(INTERMEDIATE_DIR)/snapshot.log',
],
'conditions': [
['v8_random_seed!=0', {
'mksnapshot_flags': ['--random-seed', '<(v8_random_seed)'],
@ -311,8 +307,6 @@
# variable.
'mksnapshot_flags_ignition': [
'--ignition',
'--log-snapshot-positions',
'--logfile', '<(INTERMEDIATE_DIR)/snapshot_ignition.log',
],
'conditions': [
['v8_random_seed!=0', {
@ -376,10 +370,6 @@
'action_name': 'run_mksnapshot (external)',
'inputs': ['<(mksnapshot_exec)'],
'variables': {
'mksnapshot_flags': [
'--log-snapshot-positions',
'--logfile', '<(INTERMEDIATE_DIR)/snapshot.log',
],
'conditions': [
['v8_random_seed!=0', {
'mksnapshot_flags': ['--random-seed', '<(v8_random_seed)'],

View File

@ -66,20 +66,20 @@ We have a convenience script that handles all of the above for you:
Examples:
# Print flat profile with annotated disassembly for the 10 top
# symbols. Use default log names and include the snapshot log.
$ %prog --snapshot --disasm-top=10
# symbols. Use default log names.
$ %prog --disasm-top=10
# Print flat profile with annotated disassembly for all used symbols.
# Use default log names and include kernel symbols into analysis.
$ %prog --disasm-all --kernel
# Print flat profile. Use custom log names.
$ %prog --log=foo.log --snapshot-log=snap-foo.log --trace=foo.data --snapshot
$ %prog --log=foo.log --trace=foo.data
"""
JS_ORIGIN = "js"
JS_SNAPSHOT_ORIGIN = "js-snapshot"
class Code(object):
"""Code object."""
@ -199,12 +199,8 @@ class Code(object):
self.origin)
def _GetDisasmLines(self, arch, options):
if self.origin == JS_ORIGIN or self.origin == JS_SNAPSHOT_ORIGIN:
inplace = False
filename = options.log + ".ll"
else:
inplace = True
filename = self.origin
inplace = True
filename = self.origin
return disasm.GetDisasmLines(filename,
self.origin_offset,
self.end_address - self.start_address,
@ -328,30 +324,6 @@ class CodeInfo(object):
self.header_size = header_size
class SnapshotLogReader(object):
"""V8 snapshot log reader."""
_SNAPSHOT_CODE_NAME_RE = re.compile(
r"snapshot-code-name,(\d+),\"(.*)\"")
def __init__(self, log_name):
self.log_name = log_name
def ReadNameMap(self):
log = open(self.log_name, "r")
try:
snapshot_pos_to_name = {}
for line in log:
match = SnapshotLogReader._SNAPSHOT_CODE_NAME_RE.match(line)
if match:
pos = int(match.group(1))
name = match.group(2)
snapshot_pos_to_name[pos] = name
finally:
log.close()
return snapshot_pos_to_name
class LogReader(object):
"""V8 low-level (binary) log reader."""
@ -365,16 +337,13 @@ class LogReader(object):
_CODE_CREATE_TAG = "C"
_CODE_MOVE_TAG = "M"
_SNAPSHOT_POSITION_TAG = "P"
_CODE_MOVING_GC_TAG = "G"
def __init__(self, log_name, code_map, snapshot_pos_to_name):
def __init__(self, log_name, code_map):
self.log_file = open(log_name, "r")
self.log = mmap.mmap(self.log_file.fileno(), 0, mmap.MAP_PRIVATE)
self.log_pos = 0
self.code_map = code_map
self.snapshot_pos_to_name = snapshot_pos_to_name
self.address_to_snapshot_name = {}
self.arch = self.log[:self.log.find("\0")]
self.log_pos += len(self.arch) + 1
@ -394,17 +363,12 @@ class LogReader(object):
self.code_delete_struct = LogReader._DefineStruct([
("address", pointer_type)])
self.snapshot_position_struct = LogReader._DefineStruct([
("address", pointer_type),
("position", ctypes.c_int32)])
def ReadUpToGC(self):
while self.log_pos < self.log.size():
tag = self.log[self.log_pos]
self.log_pos += 1
if tag == LogReader._CODE_MOVING_GC_TAG:
self.address_to_snapshot_name.clear()
return
if tag == LogReader._CODE_CREATE_TAG:
@ -412,12 +376,8 @@ class LogReader(object):
self.log_pos += ctypes.sizeof(event)
start_address = event.code_address
end_address = start_address + event.code_size
if start_address in self.address_to_snapshot_name:
name = self.address_to_snapshot_name[start_address]
origin = JS_SNAPSHOT_ORIGIN
else:
name = self.log[self.log_pos:self.log_pos + event.name_size]
origin = JS_ORIGIN
name = self.log[self.log_pos:self.log_pos + event.name_size]
origin = JS_ORIGIN
self.log_pos += event.name_size
origin_offset = self.log_pos
self.log_pos += event.code_size
@ -458,17 +418,6 @@ class LogReader(object):
self.code_map.Add(code)
continue
if tag == LogReader._SNAPSHOT_POSITION_TAG:
event = self.snapshot_position_struct.from_buffer(self.log,
self.log_pos)
self.log_pos += ctypes.sizeof(event)
start_address = event.address
snapshot_pos = event.position
if snapshot_pos in self.snapshot_pos_to_name:
self.address_to_snapshot_name[start_address] = \
self.snapshot_pos_to_name[snapshot_pos]
continue
assert False, "Unknown tag %s" % tag
def Dispose(self):
@ -884,16 +833,9 @@ def PrintDot(code_map, options):
if __name__ == "__main__":
parser = optparse.OptionParser(USAGE)
parser.add_option("--snapshot-log",
default="obj/release/snapshot.log",
help="V8 snapshot log file name [default: %default]")
parser.add_option("--log",
default="v8.log",
help="V8 log file name [default: %default]")
parser.add_option("--snapshot",
default=False,
action="store_true",
help="process V8 snapshot log [default: %default]")
parser.add_option("--trace",
default="perf.data",
help="perf trace file name [default: %default]")
@ -931,12 +873,7 @@ if __name__ == "__main__":
options, args = parser.parse_args()
if not options.quiet:
if options.snapshot:
print "V8 logs: %s, %s, %s.ll" % (options.snapshot_log,
options.log,
options.log)
else:
print "V8 log: %s, %s.ll (no snapshot)" % (options.log, options.log)
print "V8 log: %s, %s.ll" % (options.log, options.log)
print "Perf trace file: %s" % options.trace
V8_GC_FAKE_MMAP = options.gc_fake_mmap
@ -958,17 +895,10 @@ if __name__ == "__main__":
mmap_time = 0
sample_time = 0
# Process the snapshot log to fill the snapshot name map.
snapshot_name_map = {}
if options.snapshot:
snapshot_log_reader = SnapshotLogReader(log_name=options.snapshot_log)
snapshot_name_map = snapshot_log_reader.ReadNameMap()
# Initialize the log reader.
code_map = CodeMap()
log_reader = LogReader(log_name=options.log + ".ll",
code_map=code_map,
snapshot_pos_to_name=snapshot_name_map)
code_map=code_map)
if not options.quiet:
print "Generated code architecture: %s" % log_reader.arch
print

View File

@ -106,7 +106,6 @@ function run(args) {
var callGraphSize = 5;
var ignoreUnknown = true;
var stateFilter = null;
var snapshotLogProcessor = null;
var range = range_start_override + "," + range_end_override;
var tickProcessor = new TickProcessor(entriesProvider,
@ -114,7 +113,6 @@ function run(args) {
callGraphSize,
ignoreUnknown,
stateFilter,
snapshotLogProcessor,
distortion,
range);
for (var i = 0; i < content_lines.length; i++) {

View File

@ -82,7 +82,6 @@ function print(arg) {
function start_process() {
ArgumentsProcessor.DEFAULTS = {
logFileName: 'v8.log',
snapshotLogFileName: null,
platform: 'unix',
stateFilter: null,
callGraphSize: 5,
@ -98,8 +97,6 @@ function start_process() {
'mac': MacCppEntriesProvider
};
var snapshotLogProcessor; // not used
var tickProcessor = new TickProcessor(
new (entriesProviders[ArgumentsProcessor.DEFAULTS.platform])(
ArgumentsProcessor.DEFAULTS.nm,
@ -107,8 +104,7 @@ function start_process() {
ArgumentsProcessor.DEFAULTS.separateIc,
ArgumentsProcessor.DEFAULTS.callGraphSize,
ArgumentsProcessor.DEFAULTS.ignoreUnknown,
ArgumentsProcessor.DEFAULTS.stateFilter,
snapshotLogProcessor);
ArgumentsProcessor.DEFAULTS.stateFilter);
tickProcessor.processLogChunk(v8log_content);
tickProcessor.printStatistics();

View File

@ -61,18 +61,12 @@ if (params.sourceMap) {
initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap);
}
var snapshotLogProcessor;
if (params.snapshotLogFileName) {
snapshotLogProcessor = new SnapshotLogProcessor();
snapshotLogProcessor.processLogFile(params.snapshotLogFileName);
}
var tickProcessor = new TickProcessor(
new (entriesProviders[params.platform])(params.nm, params.targetRootFS),
params.separateIc,
params.callGraphSize,
params.ignoreUnknown,
params.stateFilter,
snapshotLogProcessor,
params.distortion,
params.range,
sourceMap,

View File

@ -70,88 +70,12 @@ function parseState(s) {
}
function SnapshotLogProcessor() {
LogReader.call(this, {
'code-creation': {
parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'],
processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove },
'code-delete': { parsers: [parseInt],
processor: this.processCodeDelete },
'function-creation': null,
'function-move': null,
'function-delete': null,
'sfi-move': null,
'snapshot-pos': { parsers: [parseInt, parseInt],
processor: this.processSnapshotPosition }});
V8Profile.prototype.handleUnknownCode = function(operation, addr) {
var op = Profile.Operation;
switch (operation) {
case op.MOVE:
print('Snapshot: Code move event for unknown code: 0x' +
addr.toString(16));
break;
case op.DELETE:
print('Snapshot: Code delete event for unknown code: 0x' +
addr.toString(16));
break;
}
};
this.profile_ = new V8Profile();
this.serializedEntries_ = [];
}
inherits(SnapshotLogProcessor, LogReader);
SnapshotLogProcessor.prototype.processCodeCreation = function(
type, kind, start, size, name, maybe_func) {
if (maybe_func.length) {
var funcAddr = parseInt(maybe_func[0]);
var state = parseState(maybe_func[1]);
this.profile_.addFuncCode(type, name, start, size, funcAddr, state);
} else {
this.profile_.addCode(type, name, start, size);
}
};
SnapshotLogProcessor.prototype.processCodeMove = function(from, to) {
this.profile_.moveCode(from, to);
};
SnapshotLogProcessor.prototype.processCodeDelete = function(start) {
this.profile_.deleteCode(start);
};
SnapshotLogProcessor.prototype.processSnapshotPosition = function(addr, pos) {
this.serializedEntries_[pos] = this.profile_.findEntry(addr);
};
SnapshotLogProcessor.prototype.processLogFile = function(fileName) {
var contents = readFile(fileName);
this.processLogChunk(contents);
};
SnapshotLogProcessor.prototype.getSerializedEntryName = function(pos) {
var entry = this.serializedEntries_[pos];
return entry ? entry.getRawName() : null;
};
function TickProcessor(
cppEntriesProvider,
separateIc,
callGraphSize,
ignoreUnknown,
stateFilter,
snapshotLogProcessor,
distortion,
range,
sourceMap,
@ -170,8 +94,6 @@ function TickProcessor(
processor: this.processCodeDelete },
'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove },
'snapshot-pos': { parsers: [parseInt, parseInt],
processor: this.processSnapshotPosition },
'tick': {
parsers: [parseInt, parseInt, parseInt,
parseInt, parseInt, 'var-args'],
@ -202,7 +124,6 @@ function TickProcessor(
this.callGraphSize_ = callGraphSize;
this.ignoreUnknown_ = ignoreUnknown;
this.stateFilter_ = stateFilter;
this.snapshotLogProcessor_ = snapshotLogProcessor;
this.sourceMap = sourceMap;
this.deserializedEntriesNames_ = [];
var ticks = this.ticks_ =
@ -362,14 +283,6 @@ TickProcessor.prototype.processFunctionMove = function(from, to) {
};
TickProcessor.prototype.processSnapshotPosition = function(addr, pos) {
if (this.snapshotLogProcessor_) {
this.deserializedEntriesNames_[addr] =
this.snapshotLogProcessor_.getSerializedEntryName(pos);
}
};
TickProcessor.prototype.includeTick = function(vmState) {
return this.stateFilter_ == null || this.stateFilter_ == vmState;
};
@ -880,8 +793,6 @@ function ArgumentsProcessor(args) {
'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'],
'--target': ['targetRootFS', '',
'Specify the target root directory for cross environment'],
'--snapshot-log': ['snapshotLogFileName', 'snapshot.log',
'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'],
'--range': ['range', 'auto,auto',
'Specify the range limit as [start],[end]'],
'--distortion': ['distortion', 0,
@ -906,7 +817,6 @@ function ArgumentsProcessor(args) {
ArgumentsProcessor.DEFAULTS = {
logFileName: 'v8.log',
snapshotLogFileName: null,
platform: 'unix',
stateFilter: null,
callGraphSize: 5,