mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm] When marking an instruction as deopt to before an instruction, ensure prune-count=0
The [Environment] represents 2 different things: * before (env, deopt-id): The state of unoptimized frame right before the IL instruction is executed * after (env, deopt-id): The state of unoptimized frame right after the call machine instruction instruction (i.e. which may not be after the IL instruction - as it may still have to drop arguments) The environment's prune-count specifies the number of entries from the [Environment] to be removed to get from before-env to after-env. This prune-count includes generally most of `<IR>::InputCount()` - as most IR instructions consume their inputs (which location summary may e.g. require in registers) before doing any call. Though it doesn't include arguments as we currently have a stack-based calling convention and both optimized and unoptimized code will explicitly drop them after the machine call instruction. Our optimizing compiler may emit speculative instructions. Those will receive an environment that makes before (env, deopt-id) and after (env, deopt-id) the same - as both eager and lazy deopt will target a before (env, deopt-id). => We should ensure that the prune-count is set to 0, ensuring we won't prune anything in case an IL instruction was marked with `MarkAsLazyDeoptToBeforeDeoptId`. => This is a preparation for inlining force-optimized functions: If we inline them and some callee IL instruction performs lazy deopt it should re-try the call without any pruned inputs. TEST=ci Change-Id: I091c9fa962b376200dc5cfb6ea8c9a47ef43810f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319440 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
parent
27ad1a74dd
commit
07549ac9ab
|
@ -10839,6 +10839,9 @@ class Environment : public ZoneAllocated {
|
|||
|
||||
void MarkAsLazyDeoptToBeforeDeoptId() {
|
||||
bitfield_ = LazyDeoptToBeforeDeoptId::update(true, bitfield_);
|
||||
// As eager and lazy deopts will target the before environment, we do not
|
||||
// want to prune inputs on lazy deopts.
|
||||
bitfield_ = LazyDeoptPruningBits::update(0, bitfield_);
|
||||
}
|
||||
|
||||
// This environment belongs to an optimistically hoisted instruction.
|
||||
|
@ -10847,6 +10850,9 @@ class Environment : public ZoneAllocated {
|
|||
void MarkAsHoisted() { bitfield_ = Hoisted::update(true, bitfield_); }
|
||||
|
||||
Environment* GetLazyDeoptEnv(Zone* zone) {
|
||||
if (LazyDeoptToBeforeDeoptId()) {
|
||||
ASSERT(LazyDeoptPruneCount() == 0);
|
||||
}
|
||||
const intptr_t num_args_to_prune = LazyDeoptPruneCount();
|
||||
if (num_args_to_prune == 0) return this;
|
||||
return DeepCopy(zone, Length() - num_args_to_prune);
|
||||
|
|
Loading…
Reference in a new issue