(file, tickIndex)
| 442 | } |
| 443 | |
| 444 | addStack(file, tickIndex) { |
| 445 | if (!this.functionCodeId) return; |
| 446 | |
| 447 | let { tm : timestamp, vm : vmState, s : stack } = file.ticks[tickIndex]; |
| 448 | let functionCode = file.code[this.functionCodeId]; |
| 449 | |
| 450 | // Find if the function is on the stack, and its position on the stack, |
| 451 | // ignoring any filtered entries. |
| 452 | let stackCode = undefined; |
| 453 | let functionPosInStack = -1; |
| 454 | let filteredI = 0; |
| 455 | for (let i = 0; i < stack.length - 1; i += 2) { |
| 456 | let codeId = stack[i]; |
| 457 | let code = codeId >= 0 ? file.code[codeId] : undefined; |
| 458 | let type = code ? code.type : undefined; |
| 459 | let kind = code ? code.kind : undefined; |
| 460 | if (!this.filter(type, kind)) continue; |
| 461 | |
| 462 | // Match other instances of the same function (e.g. unoptimised, various |
| 463 | // different optimised versions). |
| 464 | if (codeEquals(code, functionCode, true)) { |
| 465 | functionPosInStack = filteredI; |
| 466 | stackCode = code; |
| 467 | break; |
| 468 | } |
| 469 | filteredI++; |
| 470 | } |
| 471 | |
| 472 | if (functionPosInStack >= 0) { |
| 473 | let stackKind = resolveCodeKindAndVmState(stackCode, vmState); |
| 474 | |
| 475 | let codeIsTopOfStack = (functionPosInStack === 0); |
| 476 | |
| 477 | if (this.currentBlock !== null) { |
| 478 | this.currentBlock.end = timestamp; |
| 479 | |
| 480 | if (codeIsTopOfStack === this.currentBlock.topOfStack |
| 481 | && stackKind === this.currentBlock.kind) { |
| 482 | // If we haven't changed the stack top or the function kind, then |
| 483 | // we're happy just extending the current block and not starting |
| 484 | // a new one. |
| 485 | return; |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | // Start a new block at the current timestamp. |
| 490 | this.currentBlock = { |
| 491 | start: timestamp, |
| 492 | end: timestamp, |
| 493 | code: stackCode, |
| 494 | kind: stackKind, |
| 495 | topOfStack: codeIsTopOfStack |
| 496 | }; |
| 497 | this.blocks.push(this.currentBlock); |
| 498 | } else { |
| 499 | this.currentBlock = null; |
| 500 | } |
| 501 | } |
nothing calls this directly
no test coverage detected