EmissionCheckScope: Fix the operation order when closing
On `Open`, `EmissionCheckScope` will first block the pools and then put
a limit on code generation using `CodeBufferCheckScope`. This means that
on `Close`, we should do the opposite in the *opposite* order, which
wasn't the case.
This fixes a crash where a veneer pool is generated on `Release` of the
veneer pool, going above the limit set by the `CodeBufferCheckScope`.
Change-Id: I0b6ea0c97d9858f5000426f29b10145417505a46
diff --git a/src/code-generation-scopes-vixl.h b/src/code-generation-scopes-vixl.h
index 4fdfe1a..7e47d5e 100644
--- a/src/code-generation-scopes-vixl.h
+++ b/src/code-generation-scopes-vixl.h
@@ -179,10 +179,13 @@
// Nothing to do.
return;
}
+ // Perform the opposite of `Open`, which is:
+ // - Check the code generation limit was not exceeded.
+ // - Release the pools.
+ CodeBufferCheckScope::Close();
if (pool_policy_ == kCheckPools) {
masm_->ReleasePools();
}
- CodeBufferCheckScope::Close();
VIXL_ASSERT(!initialised_);
}