Compute stack and frames automatically