mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:48:25 +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:
parent
8935cb0a53
commit
e8842d862c
|
@ -27184,15 +27184,15 @@ void RegExp::set_bytecode(bool is_one_byte,
|
||||||
const TypedData& bytecode) const {
|
const TypedData& bytecode) const {
|
||||||
if (sticky) {
|
if (sticky) {
|
||||||
if (is_one_byte) {
|
if (is_one_byte) {
|
||||||
untag()->set_one_byte_sticky(bytecode.ptr());
|
untag()->set_one_byte_sticky<std::memory_order_release>(bytecode.ptr());
|
||||||
} else {
|
} else {
|
||||||
untag()->set_two_byte_sticky(bytecode.ptr());
|
untag()->set_two_byte_sticky<std::memory_order_release>(bytecode.ptr());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_one_byte) {
|
if (is_one_byte) {
|
||||||
untag()->set_one_byte(bytecode.ptr());
|
untag()->set_one_byte<std::memory_order_release>(bytecode.ptr());
|
||||||
} else {
|
} else {
|
||||||
untag()->set_two_byte(bytecode.ptr());
|
untag()->set_two_byte<std::memory_order_release>(bytecode.ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12484,8 +12484,9 @@ class RegExp : public Instance {
|
||||||
bool is_complex() const { return (type() == kComplex); }
|
bool is_complex() const { return (type() == kComplex); }
|
||||||
|
|
||||||
intptr_t num_registers(bool is_one_byte) const {
|
intptr_t num_registers(bool is_one_byte) const {
|
||||||
return is_one_byte ? untag()->num_one_byte_registers_
|
return LoadNonPointer<intptr_t, std::memory_order_relaxed>(
|
||||||
: untag()->num_two_byte_registers_;
|
is_one_byte ? &untag()->num_one_byte_registers_
|
||||||
|
: &untag()->num_two_byte_registers_);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringPtr pattern() const { return untag()->pattern(); }
|
StringPtr pattern() const { return untag()->pattern(); }
|
||||||
|
@ -12496,11 +12497,13 @@ class RegExp : public Instance {
|
||||||
|
|
||||||
TypedDataPtr bytecode(bool is_one_byte, bool sticky) const {
|
TypedDataPtr bytecode(bool is_one_byte, bool sticky) const {
|
||||||
if (sticky) {
|
if (sticky) {
|
||||||
return TypedData::RawCast(is_one_byte ? untag()->one_byte_sticky()
|
return TypedData::RawCast(
|
||||||
: untag()->two_byte_sticky());
|
is_one_byte ? untag()->one_byte_sticky<std::memory_order_acquire>()
|
||||||
|
: untag()->two_byte_sticky<std::memory_order_acquire>());
|
||||||
} else {
|
} else {
|
||||||
return TypedData::RawCast(is_one_byte ? untag()->one_byte()
|
return TypedData::RawCast(
|
||||||
: untag()->two_byte());
|
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_simple() const { set_type(kSimple); }
|
||||||
void set_is_complex() const { set_type(kComplex); }
|
void set_is_complex() const { set_type(kComplex); }
|
||||||
void set_num_registers(bool is_one_byte, intptr_t value) const {
|
void set_num_registers(bool is_one_byte, intptr_t value) const {
|
||||||
if (is_one_byte) {
|
StoreNonPointer<intptr_t, intptr_t, std::memory_order_relaxed>(
|
||||||
StoreNonPointer(&untag()->num_one_byte_registers_, value);
|
is_one_byte ? &untag()->num_one_byte_registers_
|
||||||
} else {
|
: &untag()->num_two_byte_registers_,
|
||||||
StoreNonPointer(&untag()->num_two_byte_registers_, value);
|
value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegExpFlags flags() const {
|
RegExpFlags flags() const {
|
||||||
|
|
Loading…
Reference in a new issue