You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
GDScript: Don't use pool for reference types
Since they need to be properly initialized and finalized to adjust the reference counter.
This commit is contained in:
committed by
Pedro J. Estébanez
parent
4ab0b38940
commit
59b8c70007
@@ -69,8 +69,7 @@ uint32_t GDScriptByteCodeGenerator::add_or_get_name(const StringName &p_name) {
|
|||||||
|
|
||||||
uint32_t GDScriptByteCodeGenerator::add_temporary(const GDScriptDataType &p_type) {
|
uint32_t GDScriptByteCodeGenerator::add_temporary(const GDScriptDataType &p_type) {
|
||||||
Variant::Type temp_type = Variant::NIL;
|
Variant::Type temp_type = Variant::NIL;
|
||||||
if (p_type.has_type) {
|
if (p_type.has_type && p_type.kind == GDScriptDataType::BUILTIN) {
|
||||||
if (p_type.kind == GDScriptDataType::BUILTIN) {
|
|
||||||
switch (p_type.builtin_type) {
|
switch (p_type.builtin_type) {
|
||||||
case Variant::NIL:
|
case Variant::NIL:
|
||||||
case Variant::BOOL:
|
case Variant::BOOL:
|
||||||
@@ -96,13 +95,13 @@ uint32_t GDScriptByteCodeGenerator::add_temporary(const GDScriptDataType &p_type
|
|||||||
case Variant::STRING_NAME:
|
case Variant::STRING_NAME:
|
||||||
case Variant::NODE_PATH:
|
case Variant::NODE_PATH:
|
||||||
case Variant::RID:
|
case Variant::RID:
|
||||||
case Variant::OBJECT:
|
|
||||||
case Variant::CALLABLE:
|
case Variant::CALLABLE:
|
||||||
case Variant::SIGNAL:
|
case Variant::SIGNAL:
|
||||||
case Variant::DICTIONARY:
|
|
||||||
case Variant::ARRAY:
|
|
||||||
temp_type = p_type.builtin_type;
|
temp_type = p_type.builtin_type;
|
||||||
break;
|
break;
|
||||||
|
case Variant::OBJECT:
|
||||||
|
case Variant::DICTIONARY:
|
||||||
|
case Variant::ARRAY:
|
||||||
case Variant::PACKED_BYTE_ARRAY:
|
case Variant::PACKED_BYTE_ARRAY:
|
||||||
case Variant::PACKED_INT32_ARRAY:
|
case Variant::PACKED_INT32_ARRAY:
|
||||||
case Variant::PACKED_INT64_ARRAY:
|
case Variant::PACKED_INT64_ARRAY:
|
||||||
@@ -113,13 +112,10 @@ uint32_t GDScriptByteCodeGenerator::add_temporary(const GDScriptDataType &p_type
|
|||||||
case Variant::PACKED_VECTOR3_ARRAY:
|
case Variant::PACKED_VECTOR3_ARRAY:
|
||||||
case Variant::PACKED_COLOR_ARRAY:
|
case Variant::PACKED_COLOR_ARRAY:
|
||||||
case Variant::VARIANT_MAX:
|
case Variant::VARIANT_MAX:
|
||||||
// Packed arrays are reference counted, so we don't use the pool for them.
|
// Arrays, dictionaries, and objects are reference counted, so we don't use the pool for them.
|
||||||
temp_type = Variant::NIL;
|
temp_type = Variant::NIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
temp_type = Variant::OBJECT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!temporaries_pool.has(temp_type)) {
|
if (!temporaries_pool.has(temp_type)) {
|
||||||
@@ -143,7 +139,7 @@ void GDScriptByteCodeGenerator::pop_temporary() {
|
|||||||
ERR_FAIL_COND(used_temporaries.is_empty());
|
ERR_FAIL_COND(used_temporaries.is_empty());
|
||||||
int slot_idx = used_temporaries.back()->get();
|
int slot_idx = used_temporaries.back()->get();
|
||||||
const StackSlot &slot = temporaries[slot_idx];
|
const StackSlot &slot = temporaries[slot_idx];
|
||||||
if (slot.type == Variant::OBJECT) {
|
if (slot.type == Variant::NIL) {
|
||||||
// Avoid keeping in the stack long-lived references to objects,
|
// Avoid keeping in the stack long-lived references to objects,
|
||||||
// which may prevent RefCounted objects from being freed.
|
// which may prevent RefCounted objects from being freed.
|
||||||
write_assign_false(Address(Address::TEMPORARY, slot_idx));
|
write_assign_false(Address(Address::TEMPORARY, slot_idx));
|
||||||
|
|||||||
Reference in New Issue
Block a user