mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 22:02:33 +01:00
Make function definitions allocate the body more lazily. (#2557)
Lazy allocation means that we can use a single node block for _all_ empty node blocks. The change in timing for when the definition node is emitted shouldn't affect semantic correctness; the signature is already present for recursive calls.
This commit is contained in:
@@ -16,18 +16,6 @@ auto SemanticsNodeBlockStack::Push() -> void {
|
||||
stack_.push_back(SemanticsNodeBlockId::Invalid);
|
||||
}
|
||||
|
||||
auto SemanticsNodeBlockStack::PushWithUnconditionalAlloc()
|
||||
-> SemanticsNodeBlockId {
|
||||
SemanticsNodeBlockId block_id(node_blocks_->size());
|
||||
CARBON_VLOG() << "NodeBlock Push " << stack_.size() << ": " << block_id
|
||||
<< "\n";
|
||||
CARBON_CHECK(stack_.size() < (1 << 20))
|
||||
<< "Excessive stack size: likely infinite loop";
|
||||
node_blocks_->resize(block_id.index + 1);
|
||||
stack_.push_back(block_id);
|
||||
return block_id;
|
||||
}
|
||||
|
||||
auto SemanticsNodeBlockStack::PeekForAdd() -> SemanticsNodeBlockId {
|
||||
auto& back = stack_.back();
|
||||
if (!back.is_valid()) {
|
||||
|
||||
Reference in New Issue
Block a user