• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4import {LogEntry} from './log.mjs';
5
6export class IcLogEntry extends LogEntry {
7  constructor(
8      type, fn_file, time, line, column, key, oldState, newState, map, reason,
9      modifier, codeEntry) {
10    super(type, time);
11    this.category = 'other';
12    if (this.type.indexOf('Store') !== -1) {
13      this.category = 'Store';
14    } else if (this.type.indexOf('Load') !== -1) {
15      this.category = 'Load';
16    }
17    const parts = fn_file.split(' ');
18    this.functionName = parts[0];
19    this.file = parts[1];
20    this.oldState = oldState;
21    this.newState = newState;
22    this.key = key;
23    this.map = map;
24    this.reason = reason;
25    this.modifier = modifier;
26    this.codeEntry = codeEntry;
27  }
28
29  get state() {
30    return this.oldState + ' → ' + this.newState;
31  }
32
33  get code() {
34    return this.codeEntry?.logEntry;
35  }
36
37  parseMapProperties(parts, offset) {
38    let next = parts[++offset];
39    if (!next.startsWith('dict')) return offset;
40    this.propertiesMode = next.substr(5) == '0' ? 'fast' : 'slow';
41    this.numberOfOwnProperties = parts[++offset].substr(4);
42    next = parts[++offset];
43    this.instanceType = next.substr(5, next.length - 6);
44    return offset;
45  }
46
47  parsePositionAndFile(parts, start) {
48    // find the position of 'at' in the parts array.
49    let offset = start;
50    for (let i = start + 1; i < parts.length; i++) {
51      offset++;
52      if (parts[i] == 'at') break;
53    }
54    if (parts[offset] !== 'at') return -1;
55    this.position = parts.slice(start, offset).join(' ');
56    offset += 1;
57    this.isNative = parts[offset] == 'native'
58    offset += this.isNative ? 1 : 0;
59    this.file = parts[offset];
60    return offset;
61  }
62
63  static get propertyNames() {
64    return [
65      'type', 'category', 'functionName', 'script', 'sourcePosition', 'code',
66      'state', 'key', 'map', 'reason'
67    ];
68  }
69}
70