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. 4 5class State { 6 _timeSelection = {start: 0, end: Infinity}; 7 _map; 8 _ic; 9 _selectedMapLogEntries; 10 _selectedIcLogEntries; 11 _selectedDeoptLogEntries; 12 _selecteCodeLogEntries; 13 _selectedSourcePositions; 14 _nofChunks; 15 _chunks; 16 _icTimeline; 17 _mapTimeline; 18 _deoptTimeline; 19 _codeTimeline; 20 _tickTimeline; 21 _timerTimeline; 22 _minStartTime = Number.POSITIVE_INFINITY; 23 _maxEndTime = Number.NEGATIVE_INFINITY; 24 25 get minStartTime() { 26 return this._minStartTime; 27 } 28 29 get maxEndTime() { 30 return this._maxEndTime; 31 } 32 33 selectTimeRange(start, end) { 34 this.timeSelection.start = start; 35 this.timeSelection.end = end; 36 if (start == 0 && end == Infinity) { 37 this.timelines.forEach(each => each.clearSelection()); 38 } else { 39 this.timelines.forEach(each => each.selectTimeRange(start, end)); 40 } 41 } 42 43 setTimelines( 44 mapTimeline, icTimeline, deoptTimeline, codeTimeline, tickTimeline, 45 timerTimeline) { 46 this._mapTimeline = mapTimeline; 47 this._icTimeline = icTimeline; 48 this._deoptTimeline = deoptTimeline; 49 this._codeTimeline = codeTimeline; 50 this._tickTimeline = tickTimeline; 51 this._timerTimeline = timerTimeline; 52 for (let timeline of arguments) { 53 if (timeline === undefined) return; 54 this._minStartTime = Math.min(this._minStartTime, timeline.startTime); 55 this._maxEndTime = Math.max(this._maxEndTime, timeline.endTime); 56 } 57 for (let timeline of arguments) { 58 timeline.startTime = this._minStartTime; 59 timeline.endTime = this._maxEndTime; 60 } 61 } 62 63 get mapTimeline() { 64 return this._mapTimeline; 65 } 66 67 get icTimeline() { 68 return this._icTimeline; 69 } 70 71 get deoptTimeline() { 72 return this._deoptTimeline; 73 } 74 75 get codeTimeline() { 76 return this._codeTimeline; 77 } 78 79 get tickTimeline() { 80 return this._tickTimeline; 81 } 82 83 get timerTimeline() { 84 return this._timerTimeline; 85 } 86 87 get timelines() { 88 return [ 89 this._mapTimeline, this._icTimeline, this._deoptTimeline, 90 this._codeTimeline, this._tickTimeline, this._timerTimeline 91 ]; 92 } 93 94 set chunks(value) { 95 // TODO(zcankara) split up between maps and ics, and every timeline track 96 this._chunks = value; 97 } 98 99 get chunks() { 100 // TODO(zcankara) split up between maps and ics, and every timeline track 101 return this._chunks; 102 } 103 104 get nofChunks() { 105 return this._nofChunks; 106 } 107 set nofChunks(count) { 108 this._nofChunks = count; 109 } 110 get map() { 111 // TODO(zcankara) rename as selectedMapEvents, array of selected events 112 return this._map; 113 } 114 set map(value) { 115 // TODO(zcankara) rename as selectedMapEvents, array of selected events 116 if (!value) return; 117 this._map = value; 118 } 119 get ic() { 120 // TODO(zcankara) rename selectedICEvents, array of selected events 121 return this._ic; 122 } 123 set ic(value) { 124 // TODO(zcankara) rename selectedIcEvents, array of selected events 125 if (!value) return; 126 this._ic = value; 127 } 128 get selectedMapLogEntries() { 129 return this._selectedMapLogEntries; 130 } 131 set selectedMapLogEntries(value) { 132 if (!value) return; 133 this._selectedMapLogEntries = value; 134 } 135 get selectedSourcePositions() { 136 return this._selectedSourcePositions; 137 } 138 set selectedSourcePositions(value) { 139 this._selectedSourcePositions = value; 140 } 141 get selectedIcLogEntries() { 142 return this._selectedIcLogEntries; 143 } 144 set selectedIcLogEntries(value) { 145 if (!value) return; 146 this._selectedIcLogEntries = value; 147 } 148 get timeSelection() { 149 return this._timeSelection; 150 } 151 get entries() { 152 if (!this.map) return {}; 153 return { 154 map: this.map.id, time: this.map.time 155 } 156 } 157} 158 159export {State}; 160