[vm/compiler] Avoid undefined evaluation order in IL deserialization

IL deserialization should not read 2 components of pair Location
via 2 sub-expressions as they can be swapped due to a different
evaluation order.

TEST=language/records/simple/constants_and_field_access_test/1
(on Windows)

Fixes https://github.com/dart-lang/sdk/issues/51548

Change-Id: I7f97dbb5ed10b700d4cdcea6fa5ebb873ca789c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285860
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Alexander Markov 2023-02-28 00:24:39 +00:00 committed by Commit Queue
parent 36ee2f3adb
commit e7af7ea88f

View file

@ -1252,7 +1252,9 @@ void Location::Write(FlowGraphSerializer* s) const {
Location Location::Read(FlowGraphDeserializer* d) {
const uword value = d->Read<uword>();
if (value == kPairLocationTag) {
return Location::Pair(Location::Read(d), Location::Read(d));
const Location first = Location::Read(d);
const Location second = Location::Read(d);
return Location::Pair(first, second);
} else if ((value & kConstantTag) == kConstantTag) {
ConstantInstr* instr = d->ReadRef<Definition*>()->AsConstant();
ASSERT(instr != nullptr);