2020-11-30 10:34:28 +00:00
|
|
|
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2021-05-25 08:49:11 +00:00
|
|
|
import {formatBytes} from '../helper.mjs';
|
|
|
|
|
2020-11-30 10:34:28 +00:00
|
|
|
import {LogEntry} from './log.mjs';
|
|
|
|
|
|
|
|
export class DeoptLogEntry extends LogEntry {
|
|
|
|
constructor(
|
2020-12-14 09:41:32 +00:00
|
|
|
type, time, entry, deoptReason, deoptLocation, scriptOffset,
|
|
|
|
instructionStart, codeSize, inliningId) {
|
2020-11-30 10:34:28 +00:00
|
|
|
super(type, time);
|
2020-12-14 09:41:32 +00:00
|
|
|
this._entry = entry;
|
2020-12-07 08:44:54 +00:00
|
|
|
this._reason = deoptReason;
|
|
|
|
this._location = deoptLocation;
|
2020-11-30 10:34:28 +00:00
|
|
|
this._scriptOffset = scriptOffset;
|
|
|
|
this._instructionStart = instructionStart;
|
|
|
|
this._codeSize = codeSize;
|
|
|
|
this._inliningId = inliningId;
|
2020-12-14 09:41:32 +00:00
|
|
|
this.fileSourcePosition = undefined;
|
2020-11-30 10:34:28 +00:00
|
|
|
}
|
2020-12-01 19:37:17 +00:00
|
|
|
|
2020-12-07 08:44:54 +00:00
|
|
|
get reason() {
|
|
|
|
return this._reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
get location() {
|
|
|
|
return this._location;
|
|
|
|
}
|
|
|
|
|
2020-12-14 09:41:32 +00:00
|
|
|
get entry() {
|
|
|
|
return this._entry;
|
|
|
|
}
|
|
|
|
|
2021-06-15 21:27:47 +00:00
|
|
|
get code() {
|
2021-06-15 11:19:00 +00:00
|
|
|
return this._entry?.logEntry;
|
|
|
|
}
|
|
|
|
|
2020-12-14 09:41:32 +00:00
|
|
|
get functionName() {
|
|
|
|
return this._entry.functionName;
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:44:54 +00:00
|
|
|
static get propertyNames() {
|
2020-12-14 09:41:32 +00:00
|
|
|
return [
|
|
|
|
'type', 'reason', 'functionName', 'sourcePosition',
|
2021-06-15 21:27:47 +00:00
|
|
|
'functionSourcePosition', 'script', 'code'
|
2020-12-14 09:41:32 +00:00
|
|
|
];
|
2020-11-30 10:34:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class CodeLogEntry extends LogEntry {
|
2021-05-25 08:49:11 +00:00
|
|
|
constructor(type, time, kindName, kind, entry) {
|
2020-11-30 10:34:28 +00:00
|
|
|
super(type, time);
|
|
|
|
this._kind = kind;
|
2021-05-25 08:49:11 +00:00
|
|
|
this._kindName = kindName;
|
2020-11-30 10:34:28 +00:00
|
|
|
this._entry = entry;
|
2021-10-27 08:50:53 +00:00
|
|
|
this._feedbackVector = undefined;
|
2021-05-31 12:18:32 +00:00
|
|
|
entry.logEntry = this;
|
2020-11-30 10:34:28 +00:00
|
|
|
}
|
2020-12-01 19:37:17 +00:00
|
|
|
|
2020-12-07 08:44:54 +00:00
|
|
|
get kind() {
|
|
|
|
return this._kind;
|
|
|
|
}
|
|
|
|
|
2021-06-28 19:46:31 +00:00
|
|
|
get isBuiltinKind() {
|
|
|
|
return this._kindName === 'Builtin';
|
|
|
|
}
|
|
|
|
|
2022-03-02 09:56:03 +00:00
|
|
|
get isBytecodeKind() {
|
|
|
|
return this._kindName === 'Unopt';
|
|
|
|
}
|
|
|
|
|
2021-05-25 08:49:11 +00:00
|
|
|
get kindName() {
|
|
|
|
return this._kindName;
|
|
|
|
}
|
|
|
|
|
2020-12-09 08:01:26 +00:00
|
|
|
get entry() {
|
|
|
|
return this._entry;
|
2020-12-07 08:44:54 +00:00
|
|
|
}
|
|
|
|
|
2020-12-09 08:01:26 +00:00
|
|
|
get functionName() {
|
2021-06-28 19:46:31 +00:00
|
|
|
return this._entry.functionName ?? this._entry.getRawName();
|
2020-12-09 08:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get size() {
|
|
|
|
return this._entry.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
get source() {
|
|
|
|
return this._entry?.getSourceCode() ?? '';
|
2020-11-30 10:34:28 +00:00
|
|
|
}
|
2020-12-01 19:37:17 +00:00
|
|
|
|
2021-05-25 08:49:11 +00:00
|
|
|
get code() {
|
2020-12-01 19:37:17 +00:00
|
|
|
return this._entry?.source?.disassemble;
|
|
|
|
}
|
2020-12-07 08:44:54 +00:00
|
|
|
|
2021-06-15 21:27:47 +00:00
|
|
|
get variants() {
|
|
|
|
const entries = Array.from(this.entry?.func?.codeEntries ?? []);
|
|
|
|
return entries.map(each => each.logEntry);
|
|
|
|
}
|
|
|
|
|
2021-10-27 08:50:53 +00:00
|
|
|
get feedbackVector() {
|
|
|
|
return this._feedbackVector;
|
|
|
|
}
|
|
|
|
|
|
|
|
setFeedbackVector(fbv) {
|
|
|
|
if (this._feedbackVector) {
|
|
|
|
throw new Error('Double setting FeedbackVector');
|
|
|
|
}
|
|
|
|
this._feedbackVector = fbv;
|
|
|
|
}
|
|
|
|
|
2020-12-09 08:01:26 +00:00
|
|
|
toString() {
|
|
|
|
return `Code(${this.type})`;
|
|
|
|
}
|
|
|
|
|
2021-05-25 08:49:11 +00:00
|
|
|
get toolTipDict() {
|
|
|
|
const dict = super.toolTipDict;
|
|
|
|
dict.size = formatBytes(dict.size);
|
|
|
|
return dict;
|
2020-12-09 08:01:26 +00:00
|
|
|
}
|
|
|
|
|
2020-12-07 08:44:54 +00:00
|
|
|
static get propertyNames() {
|
2021-05-25 08:49:11 +00:00
|
|
|
return [
|
2021-05-31 12:18:32 +00:00
|
|
|
'functionName', 'sourcePosition', 'kindName', 'size', 'type', 'kind',
|
2021-10-27 08:50:53 +00:00
|
|
|
'script', 'source', 'code', 'feedbackVector', 'variants'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class FeedbackVectorEntry extends LogEntry {
|
|
|
|
constructor(
|
|
|
|
timestamp, codeEntry, fbvAddress, length, optimizationMarker,
|
|
|
|
optimizationTier, invocationCount, profilerTicks, string) {
|
|
|
|
super('FeedbackVector', timestamp);
|
|
|
|
this._length = length;
|
|
|
|
this._code = codeEntry;
|
|
|
|
this._string = string;
|
|
|
|
this._optimizationMarker = optimizationMarker;
|
|
|
|
this._optimizationTier = optimizationTier;
|
|
|
|
this._invocationCount = invocationCount;
|
|
|
|
this._profilerTicks = profilerTicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
toString() {
|
|
|
|
return `FeedbackVector(l=${this.length})`
|
|
|
|
}
|
|
|
|
|
|
|
|
get length() {
|
|
|
|
return this._length;
|
|
|
|
}
|
|
|
|
|
|
|
|
get code() {
|
|
|
|
return this._code;
|
|
|
|
}
|
|
|
|
|
|
|
|
get string() {
|
|
|
|
return this._string;
|
|
|
|
}
|
|
|
|
|
|
|
|
get optimizationMarker() {
|
|
|
|
return this._optimizationMarker;
|
|
|
|
}
|
|
|
|
|
|
|
|
get optimizationTier() {
|
|
|
|
return this._optimizationTier;
|
|
|
|
}
|
|
|
|
|
|
|
|
get invocationCount() {
|
|
|
|
return this._invocationCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
get profilerTicks() {
|
|
|
|
return this._profilerTicks;
|
|
|
|
}
|
|
|
|
|
|
|
|
static get propertyNames() {
|
|
|
|
return [
|
|
|
|
'length', 'length', 'code', 'optimizationMarker', 'optimizationTier',
|
|
|
|
'invocationCount', 'profilerTicks', 'string'
|
2021-05-25 08:49:11 +00:00
|
|
|
];
|
2020-12-07 08:44:54 +00:00
|
|
|
}
|
2020-11-30 10:34:28 +00:00
|
|
|
}
|
2021-06-14 10:10:17 +00:00
|
|
|
|
|
|
|
export class SharedLibLogEntry extends LogEntry {
|
2021-06-15 11:19:00 +00:00
|
|
|
constructor(entry) {
|
2021-06-14 10:10:17 +00:00
|
|
|
super('SHARED_LIB', 0);
|
2021-06-15 11:19:00 +00:00
|
|
|
this._entry = entry;
|
2021-06-14 10:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get name() {
|
2021-06-15 11:19:00 +00:00
|
|
|
return this._entry.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
get entry() {
|
|
|
|
return this._entry;
|
2021-06-14 10:10:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
toString() {
|
|
|
|
return `SharedLib`;
|
|
|
|
}
|
|
|
|
|
|
|
|
static get propertyNames() {
|
|
|
|
return ['name'];
|
|
|
|
}
|
|
|
|
}
|