by _mental_ » Wed Jan 23, 2019 9:03 am
I found one code generation issue that causes implicit initialization to fail.
Spoiler: Script
Code: Select all
class RegisterOverwrite : Actor
{
Array<int> testArray1;
Array<int> testArray2;
override void BeginPlay()
{
testArray1.copy(testArray2);
Actor testActor;
console.printf("actor = %p", testActor);
}
}
Spoiler: Generated code
Code: Select all
========================= RegisterOverwrite.BeginPlay =========================
Integer regs: 0 Float regs: 0 Address regs: 3 String regs: 0
Stack size: 3
Constant integers:
0. 1360 1. 1376
Constant addresses:
0. 000001F940649F20 1. 000001F9412296C0 2. 000001F93F852E20
Constant strings:
0. actor = %p
Disassembly @ 000001F9412296D0:
00000000: cf010000 add a1,a0,1360 ;1,0,0
00000004: cf020001 add a2,a0,1376 ;2,0,1
00000008: 4d030100 param a1 ;3,1,0
0000000c: 4d030200 param a2 ;3,2,0
00000010: 50000200 call [000001F940649F20],2,0 ;0,2,0 [DynArray_I32.Copy [Native]]
00000014: 4d060000 param "actor = %p" ;6,0,0
00000018: 4d030100 param a1 ;3,1,0 <---------------------------------------- apparently this is wrong
0000001c: 4d070100 param 000001F9412296C0 ;7,1,0
00000020: 50020300 call [000001F93F852E20],3,0 ;2,3,0 [Console.Printf [Native]]
00000024: 54808000 ret ;128,128,0
Looks like we have incorrect register allocation somewhere. Moving
testActor declaration before
Array.Copy() fixes the problem. Registers used in the function no longer overlap.
I found one code generation issue that causes implicit initialization to fail. [spoiler=Script][code]class RegisterOverwrite : Actor
{
Array<int> testArray1;
Array<int> testArray2;
override void BeginPlay()
{
testArray1.copy(testArray2);
Actor testActor;
console.printf("actor = %p", testActor);
}
}[/code][/spoiler][spoiler=Generated code][code]
========================= RegisterOverwrite.BeginPlay =========================
Integer regs: 0 Float regs: 0 Address regs: 3 String regs: 0
Stack size: 3
Constant integers:
0. 1360 1. 1376
Constant addresses:
0. 000001F940649F20 1. 000001F9412296C0 2. 000001F93F852E20
Constant strings:
0. actor = %p
Disassembly @ 000001F9412296D0:
00000000: cf010000 add a1,a0,1360 ;1,0,0
00000004: cf020001 add a2,a0,1376 ;2,0,1
00000008: 4d030100 param a1 ;3,1,0
0000000c: 4d030200 param a2 ;3,2,0
00000010: 50000200 call [000001F940649F20],2,0 ;0,2,0 [DynArray_I32.Copy [Native]]
00000014: 4d060000 param "actor = %p" ;6,0,0
00000018: 4d030100 param a1 ;3,1,0 <---------------------------------------- apparently this is wrong
0000001c: 4d070100 param 000001F9412296C0 ;7,1,0
00000020: 50020300 call [000001F93F852E20],3,0 ;2,3,0 [Console.Printf [Native]]
00000024: 54808000 ret ;128,128,0[/code][/spoiler]
Looks like we have incorrect register allocation somewhere. Moving [b]testActor[/b] declaration before [b]Array.Copy()[/b] fixes the problem. Registers used in the function no longer overlap.