MCPcopy Index your code
hub / github.com/nodejs/node / addStack

Method addStack

deps/v8/tools/profview/profile-utils.js:444–501  ·  view source on GitHub ↗
(file, tickIndex)

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls 4

codeEqualsFunction · 0.85
filterMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected