1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 12:06:26 +00:00

[vm] Use atomics when setting RegExp bytecode.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/51305
Change-Id: I3e93716d31809be76a4017db68557a9b7263d2f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281560
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2023-02-08 17:07:43 +00:00 committed by Commit Queue
parent 8935cb0a53
commit e8842d862c
2 changed files with 17 additions and 15 deletions

View File

@ -27184,15 +27184,15 @@ void RegExp::set_bytecode(bool is_one_byte,
const TypedData& bytecode) const {
if (sticky) {
if (is_one_byte) {
untag()->set_one_byte_sticky(bytecode.ptr());
untag()->set_one_byte_sticky<std::memory_order_release>(bytecode.ptr());
} else {
untag()->set_two_byte_sticky(bytecode.ptr());
untag()->set_two_byte_sticky<std::memory_order_release>(bytecode.ptr());
}
} else {
if (is_one_byte) {
untag()->set_one_byte(bytecode.ptr());
untag()->set_one_byte<std::memory_order_release>(bytecode.ptr());
} else {
untag()->set_two_byte(bytecode.ptr());
untag()->set_two_byte<std::memory_order_release>(bytecode.ptr());
}
}
}

View File

@ -12484,8 +12484,9 @@ class RegExp : public Instance {
bool is_complex() const { return (type() == kComplex); }
intptr_t num_registers(bool is_one_byte) const {
return is_one_byte ? untag()->num_one_byte_registers_
: untag()->num_two_byte_registers_;
return LoadNonPointer<intptr_t, std::memory_order_relaxed>(
is_one_byte ? &untag()->num_one_byte_registers_
: &untag()->num_two_byte_registers_);
}
StringPtr pattern() const { return untag()->pattern(); }
@ -12496,11 +12497,13 @@ class RegExp : public Instance {
TypedDataPtr bytecode(bool is_one_byte, bool sticky) const {
if (sticky) {
return TypedData::RawCast(is_one_byte ? untag()->one_byte_sticky()
: untag()->two_byte_sticky());
return TypedData::RawCast(
is_one_byte ? untag()->one_byte_sticky<std::memory_order_acquire>()
: untag()->two_byte_sticky<std::memory_order_acquire>());
} else {
return TypedData::RawCast(is_one_byte ? untag()->one_byte()
: untag()->two_byte());
return TypedData::RawCast(
is_one_byte ? untag()->one_byte<std::memory_order_acquire>()
: untag()->two_byte<std::memory_order_acquire>());
}
}
@ -12590,11 +12593,10 @@ class RegExp : public Instance {
void set_is_simple() const { set_type(kSimple); }
void set_is_complex() const { set_type(kComplex); }
void set_num_registers(bool is_one_byte, intptr_t value) const {
if (is_one_byte) {
StoreNonPointer(&untag()->num_one_byte_registers_, value);
} else {
StoreNonPointer(&untag()->num_two_byte_registers_, value);
}
StoreNonPointer<intptr_t, intptr_t, std::memory_order_relaxed>(
is_one_byte ? &untag()->num_one_byte_registers_
: &untag()->num_two_byte_registers_,
value);
}
RegExpFlags flags() const {