MCPcopy
hub / github.com/pyodide/pyodide / evictStackUpTo

Function evictStackUpTo

src/core/stack_switching/stack_state.mjs:98–119  ·  view source on GitHub ↗
(stop)

Source from the content-addressed store, hash-verified

96}
97
98function evictStackUpTo(stop) {
99 let total = 0;
100 // Search up the stack for things that need to be ejected in their entirety
101 // and save them
102 while (stackStates.length > 0 && stackStates.at(-1).stop < stop) {
103 total += stackStates.pop()._save();
104 }
105 // Part of one more object may need to be ejected.
106 const last = stackStates.at(-1);
107 if (last && last.stop !== stop) {
108 total += last._save_up_to(stop);
109 }
110 // If we just saved all of the last stackState it needs to be removed.
111 // Alternatively, the current StackState may be on the stackStates list.
112 // Technically it would make sense to leave it there, but we will add it
113 // back if we suspend again and if we exit normally it gets removed from the
114 // stack.
115 if (last && last.stop === stop) {
116 stackStates.pop();
117 }
118 return total;
119}
120
121/**
122 * A class to help us keep track of the argument stack data for our individual

Callers 2

setStackPositionFunction · 0.85
restoreMethod · 0.85

Calls 4

atMethod · 0.80
_saveMethod · 0.80
_save_up_toMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…