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

Method finalize

deps/v8/tools/parse-processor.mjs:222–286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220 }
221
222 finalize() {
223 this.finalized = true;
224 // Compact funktions as we no longer need access via start byte position.
225 this.funktions = this.funktions.filter(each => true);
226 let parent = null;
227 let maxNesting = 0;
228 // Iterate over the Funktions in byte position order.
229 this.funktions.forEach(fn => {
230 fn.isEval = this.isEval;
231 if (parent === null) {
232 parent = fn;
233 } else {
234 // Walk up the nested chain of Funktions to find the parent.
235 while (parent !== null && !fn.isNestedIn(parent)) {
236 parent = parent.parent;
237 }
238 fn.parent = parent;
239 if (parent) {
240 maxNesting = Math.max(maxNesting, parent.addNestedFunktion(fn));
241 }
242 parent = fn;
243 }
244 });
245 // Sanity checks to ensure that scripts are executed and parsed before any
246 // of its funktions.
247 let funktionFirstParseEventTimestamp = -1;
248 // Second iteration step to finalize the funktions once the proper
249 // hierarchy has been set up.
250 this.funktions.forEach(fn => {
251 fn.finalize();
252
253 funktionFirstParseEventTimestamp = this.timestampMin(
254 funktionFirstParseEventTimestamp, fn.firstParseEventTimestamp);
255
256 this.lastParseEventTimestamp = this.timestampMax(
257 this.lastParseEventTimestamp, fn.lastParseEventTimestamp);
258
259 this.lastEventTimestamp =
260 this.timestampMax(this.lastEventTimestamp, fn.lastEventTimestamp);
261 });
262 this.maxNestingLevel = maxNesting;
263
264 // Initialize sizes.
265 if (this.ownBytes === -1) console.error('Invalid ownBytes');
266 if (this.funktions.length == 0) {
267 this.bytesTotal = this.ownBytes = 0;
268 return;
269 }
270 let toplevelFunktionBytes = this.funktions.reduce(
271 (bytes, each) => bytes + (each.isToplevel() ? each.getBytes() : 0), 0);
272 if (this.isDeserialized || this.isEval || this.isStreamingCompiled) {
273 if (this.getBytes() === -1) {
274 this.bytesTotal = toplevelFunktionBytes;
275 }
276 }
277 this.ownBytes = this.bytesTotal - toplevelFunktionBytes;
278 // Initialize common properties.
279 super.finalize();

Callers 4

finalizeMethod · 0.45
postProcessMethod · 0.45
processor.mjsFile · 0.45

Calls 11

getBytesMethod · 0.95
isNestedInMethod · 0.80
addNestedFunktionMethod · 0.80
timestampMinMethod · 0.80
timestampMaxMethod · 0.80
reduceMethod · 0.80
isToplevelMethod · 0.80
filterMethod · 0.65
forEachMethod · 0.65
maxMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected