Add Missing Read Barriers to Map Get Functions

This commit is contained in:
Ricardo Luís Vaz Silva 2023-01-18 21:05:47 -03:00 committed by Christoph Oelckers
parent fed2d11be5
commit a397a93c25

View file

@ -118,9 +118,17 @@ template<typename M> unsigned int MapCountUsed(M * self)
template<typename M> expand_types_vm<typename M::ValueType> MapGet(M * self,expand_types_vm<typename M::KeyType> key) template<typename M> expand_types_vm<typename M::ValueType> MapGet(M * self,expand_types_vm<typename M::KeyType> key)
{ {
typename M::ValueType * v = self->CheckKey(key); typename M::ValueType * v = self->CheckKey(key);
if (v) { if (v)
{
if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
{
return GC::ReadBarrier(*v);
}
else
{
return *v; return *v;
} }
}
else else
{ {
typename M::ValueType n {}; typename M::ValueType n {};
@ -148,8 +156,15 @@ template<typename M> expand_types_vm<typename M::ValueType> MapGetIfExists(M * s
{ {
typename M::ValueType * v = self->CheckKey(key); typename M::ValueType * v = self->CheckKey(key);
if (v) { if (v) {
if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
{
return GC::ReadBarrier(*v);
}
else
{
return *v; return *v;
} }
}
else else
{ {
return {}; return {};
@ -177,8 +192,15 @@ template<typename M> expand_types_vm<typename M::ValueType> MapCheckValue(M * se
{ {
typename M::ValueType * v = self->CheckKey(key); typename M::ValueType * v = self->CheckKey(key);
if ((*exists = !!v)) { if ((*exists = !!v)) {
if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
{
return GC::ReadBarrier(*v);
}
else
{
return *v; return *v;
} }
}
else else
{ {
return {}; return {};
@ -288,7 +310,14 @@ template<typename I> void MapIteratorGetKeyString(I * self, FString &out)
template<typename I> expand_types_vm<typename I::ValueType> MapIteratorGetValue(I * self) template<typename I> expand_types_vm<typename I::ValueType> MapIteratorGetValue(I * self)
{ {
if constexpr(std::is_same_v<typename I::ValueType, DObject*>)
{
return GC::ReadBarrier(self->GetValue());
}
else
{
return self->GetValue(); return self->GetValue();
}
} }
template<typename I> void MapIteratorGetValueString(I * self, FString &out) template<typename I> void MapIteratorGetValueString(I * self, FString &out)