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,8 +118,16 @@ 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)
return *v; {
if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
{
return GC::ReadBarrier(*v);
}
else
{
return *v;
}
} }
else else
{ {
@ -148,7 +156,14 @@ 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) {
return *v; if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
{
return GC::ReadBarrier(*v);
}
else
{
return *v;
}
} }
else else
{ {
@ -177,7 +192,14 @@ 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)) {
return *v; if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
{
return GC::ReadBarrier(*v);
}
else
{
return *v;
}
} }
else else
{ {
@ -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)
{ {
return self->GetValue(); if constexpr(std::is_same_v<typename I::ValueType, DObject*>)
{
return GC::ReadBarrier(self->GetValue());
}
else
{
return self->GetValue();
}
} }
template<typename I> void MapIteratorGetValueString(I * self, FString &out) template<typename I> void MapIteratorGetValueString(I * self, FString &out)