aee5fb0990
This is a reland of commit efc1a98c53
Changes since revert:
- Handle "shared-library", "code-{deopt,move,delete}", "feedback-vector", "sfi-move" events
Original change's description:
> Use BigInts in processor.mjs and related code to avoid unsafe ints in
calculations
>
> Bug: v8:13440
> Change-Id: Ie03b831b511a49fb475b9f303ef8662189bdaf3d
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4017455
> Reviewed-by: Camillo Bruni <cbruni@chromium.org>
> Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#84698}
Change-Id: If45d38526cab887a59f60e3becfbcb084c3d41d0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4086641
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Vasili Skurydzin <vasili.skurydzin@ibm.com>
Cr-Commit-Position: refs/heads/main@{#84939}
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
// Copyright 2021 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.
|
|
import {Profile} from '../../profile.mjs'
|
|
|
|
import {LogEntry} from './log.mjs';
|
|
|
|
export class TickLogEntry extends LogEntry {
|
|
constructor(time, vmState, processedStack) {
|
|
super(TickLogEntry.extractType(vmState, processedStack), time);
|
|
/** @type {string} */
|
|
this.state = vmState;
|
|
/** @type {CodeEntry[]} */
|
|
this.stack = processedStack;
|
|
/** @type {number} */
|
|
this._endTime = time;
|
|
}
|
|
|
|
end(time) {
|
|
if (this.isInitialized) throw new Error('Invalid timer change');
|
|
this._endTime = time;
|
|
}
|
|
|
|
get isInitialized() {
|
|
return this._endTime !== this._time;
|
|
}
|
|
|
|
get startTime() {
|
|
return this._time;
|
|
}
|
|
|
|
get endTime() {
|
|
return this._endTime;
|
|
}
|
|
|
|
get duration() {
|
|
return this._endTime - this._time;
|
|
}
|
|
|
|
static extractType(vmState, processedStack) {
|
|
if (processedStack.length == 0 || vmState == Profile.VMState.IDLE) {
|
|
return 'Idle';
|
|
}
|
|
const topOfStack = processedStack[0];
|
|
if (typeof topOfStack === 'number' || typeof topOfStack === 'bigint') {
|
|
// TODO(cbruni): Handle VmStack and native ticks better.
|
|
return 'Other';
|
|
}
|
|
if (vmState != Profile.VMState.JS) {
|
|
topOfStack.vmState = vmState;
|
|
}
|
|
return this.extractCodeEntryType(topOfStack);
|
|
}
|
|
|
|
static extractCodeEntryType(entry) {
|
|
if (entry?.state !== undefined) {
|
|
return 'JS ' + Profile.getKindFromState(entry.state);
|
|
}
|
|
if (entry?.vmState) return Profile.vmStateString(entry.vmState);
|
|
return 'Other';
|
|
}
|
|
}
|