Skip to content

Commit

Permalink
[stable][dart2js] Handle MarkerValue in NegateValue binary operations.
Browse files Browse the repository at this point in the history
The MarkerValue class was added fairly recently: 404edd9

Bug: #54453
Change-Id: I10d327a24425cecb2f0b44c0ea04bafa4cbf0698
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/343800
Cherry-pick-request: #54494
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344241
Commit-Queue: Nate Biggs <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
  • Loading branch information
natebiggs authored and Commit Queue committed Jan 5, 2024
1 parent af44883 commit 719a36e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 3.2.5

This is a patch release that:

- Fixes a Dart2js issue with values updated in a loop. (issue [#54494][])

[#54494]: https://github.com/dart-lang/sdk/issues/54494

## 3.2.4 - 2023-12-21

This is a patch release that:
Expand Down
4 changes: 2 additions & 2 deletions pkg/compiler/lib/src/ssa/value_range_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class NegateValue extends Value {
}
return info.newSubtractValue(other, value);
}
if (other is InstructionValue) {
if (other is VariableValue) {
return info.newSubtractValue(other, value);
}
return other - value;
Expand All @@ -548,7 +548,7 @@ class NegateValue extends Value {
}
return info.newSubtractValue(this, other);
}
if (other is InstructionValue) {
if (other is VariableValue) {
return info.newSubtractValue(this, other);
}
if (other is NegateValue) return this + other.value;
Expand Down
13 changes: 13 additions & 0 deletions tests/web/regress/issue/54453_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Make sure binary operations are correctly handled for range-like values in
// SSA's value range analyzer.

void main() {
int counter = 0;
for (int i = 0; i < 5; i++) {
counter += counter;
}
}

0 comments on commit 719a36e

Please sign in to comment.