Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vm/ffi] wrong alignment of stack arguments in iOS #39637

Closed
mkustermann opened this issue Dec 4, 2019 · 3 comments
Closed

[vm/ffi] wrong alignment of stack arguments in iOS #39637

mkustermann opened this issue Dec 4, 2019 · 3 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi P0 A serious issue requiring immediate resolution

Comments

@mkustermann
Copy link
Member

mkustermann commented Dec 4, 2019

The test (part of tests/ffi/function_test.dart)

void testNativeFunctionManyArguments3() {
  const double sum = 1 + 2.0 + 3 + 4.0 + 5 + 6.0 + 7 + 8.0 + 9 + 10.0 + 11 +
      12.0 + 13 + 14.0 + 15 + 16.0 + 17 + 18.0 + 19 + 20.0;
  Expect.approxEquals(
      sum,
      sumManyNumbers(1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9, 10.0, 11, 12.0, 13, 
          14.0, 15, 16.0, 17, 18.0, 19, 20.0));
}
DART_EXPORT double SumManyNumbers(int a,
                                  float b,
                                  int c,
                                  double d,
                                  int e,
                                  float f,
                                  int g,
                                  double h,
                                  int i,
                                  float j,
                                  int k,
                                  double l,
                                  int m,
                                  float n,
                                  int o,
                                  double p,
                                  int q,
                                  float r,
                                  int s,
                                  double t) {
  return a + b + c + d + e + f + g + h + i + j + k + l + m +  n + o + p + q + r + s + t;
}

ends up passing the 18.0 (aka r) in the wrong place (not where C++ code expects it).

=> Might be due to difference in iOS ABI.

The bug should be reproducible with the flutter/flutter FFI integration test, which is waiting as PR atm: flutter/flutter#46078

@mkustermann mkustermann added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P0 A serious issue requiring immediate resolution library-ffi labels Dec 4, 2019
@mkustermann
Copy link
Member Author

The generated code for the trampoline - which is huge:

Code for optimized function 'dart:ffi_::_FfiTrampoline' {
        ;; B0
        ;; B1
        ;; Enter frame
0x115d53290    a9bf79fd               stp fp, lr, [r15, #-16 ]!
0x115d53294    aa0f03fd               mov fp, r15
0x115d53298    d102a1ef               subi r15, r15, 0xa8
        ;; v25 <- LoadField(v23 . ArgumentsDescriptor.type_args_len {final}) T{_Smi}
0x115d5329c    f8417080               ldrx r0, [r4, #23]
        ;; Branch if StrictCompare:8(===, v25, v27) goto (3, 5)
0x115d532a0    f100001f               cmpi r0, 0x0
0x115d532a4    54004241               bne 0x115d53aec
        ;; B3
        ;; v28 <- LoadField(v23 . ArgumentsDescriptor.count {final}) T{_Smi}
0x115d532a8    f841f080               ldrx r0, [r4, #31]
        ;; Branch if StrictCompare:22(===, v28, v30) goto (7, 8)
0x115d532ac    f100a81f               cmpi r0, 0x2a
0x115d532b0    540041e1               bne 0x115d53aec
        ;; B7
        ;; v31 <- LoadField(v23 . ArgumentsDescriptor.positional_count {final}) T{_Smi}
0x115d532b4    f8427081               ldrx r1, [r4, #39]
        ;; Branch if StrictCompare:30(===, v28, v31) goto (11, 10)
0x115d532b8    eb01001f               cmp r0, r1
0x115d532bc    54004181               bne 0x115d53aec
        ;; B11
        ;; ParallelMove r2 <- S+22, r1 <- S+21, r0 <- S+20, ip0 <- S+19, r24 <- S+18, r23 <- S+17, r21 <- S+16, r20 <- S+15, r19 <- S+14, r14 <- S+13, r13 <- S+12, r12 <- S+11, r11 <- S+10, r10 <- S+9, r9 <- S+8, r8 <- S+7, r7 <- S+6, r6 <- S+5, r5 <- S+4, r4 <- S+3
0x115d532c0    f9405ba2               ldrx r2, [fp, #176]
0x115d532c4    f94057a1               ldrx r1, [fp, #168]
0x115d532c8    f94053a0               ldrx r0, [fp, #160]
0x115d532cc    f9404fb9               ldrx r25, [fp, #152]
0x115d532d0    f9404bb8               ldrx r24, [fp, #144]
0x115d532d4    f94047b7               ldrx r23, [fp, #136]
0x115d532d8    f94043b5               ldrx r21, [fp, #128]
0x115d532dc    f9403fb4               ldrx r20, [fp, #120]
0x115d532e0    f9403bb3               ldrx sp, [fp, #112]
0x115d532e4    f94037ae               ldrx r14, [fp, #104]
0x115d532e8    f94033ad               ldrx r13, [fp, #96]
0x115d532ec    f9402fac               ldrx r12, [fp, #88]
0x115d532f0    f9402bab               ldrx r11, [fp, #80]
0x115d532f4    f94027aa               ldrx r10, [fp, #72]
0x115d532f8    f94023a9               ldrx r9, [fp, #64]
0x115d532fc    f9401fa8               ldrx r8, [fp, #56]
0x115d53300    f9401ba7               ldrx r7, [fp, #48]
0x115d53304    f94017a6               ldrx r6, [fp, #40]
0x115d53308    f94013a5               ldrx r5, [fp, #32]
0x115d5330c    f9400fa4               ldrx r4, [fp, #24]
0x115d53310    f9400ba3               ldrx r3, [fp, #16]
        ;; CheckStackOverflow:48(stack=0, loop=0)
0x115d53314    f9402750               ldrx ip0, [thr, #72]
0x115d53318    eb1001ff               cmp r15, ip0
0x115d5331c    54003f29               bls 0x115d53b00
        ;; ParallelMove r0 <- r1, r1 <- C, r2 <- C, r3 <- r2
0x115d53320    aa0103e0               mov r0, r1
0x115d53324    aa0203e3               mov r3, r2
0x115d53328    aa1603e1               mov r1, nr
0x115d5332c    aa1603e2               mov r2, nr
        ;; AssertAssignable:50(v3, int, ':ffi_param1', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d53330    36000140               tbzw r0, #0, 0x115d53358
0x115d53334    78401004               ldrh r4, [r0, #1]
0x115d53338    d100c084               subi r4, r4, 0x30
0x115d5333c    f100049f               cmpi r4, 0x1
0x115d53340    540000c9               bls 0x115d53358
0x115d53344    f9479368               ldrx r8, [pp, #3872]
0x115d53348    f8407109               ldrx r9, [r8, #7]
0x115d5334c    9140ab63               addi r3, pp, 0x2a000
0x115d53350    f9476c63               ldrx r3, [r3, #3800]
0x115d53354    d63f0120               blr r9
        ;; ParallelMove r0 <- S+20, r1 <- C, r2 <- C
0x115d53358    f94053a0               ldrx r0, [fp, #160]
0x115d5335c    aa1603e1               mov r1, nr
0x115d53360    aa1603e2               mov r2, nr
        ;; AssertAssignable:52(v4, double, ':ffi_param2', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d53364    d2800604               movz r4, 0x30 
0x115d53368    36000040               tbzw r0, #0, 0x115d53370
0x115d5336c    78401004               ldrh r4, [r0, #1]
0x115d53370    f100c884               subis r4, r4, 0x32
0x115d53374    540000e0               beq 0x115d53390
0x115d53378    91402f68               addi r8, pp, 0xb000
0x115d5337c    f943f508               ldrx r8, [r8, #2024]
0x115d53380    f8407109               ldrx r9, [r8, #7]
0x115d53384    9140ab63               addi r3, pp, 0x2a000
0x115d53388    f9477463               ldrx r3, [r3, #3816]
0x115d5338c    d63f0120               blr r9
        ;; ParallelMove r0 <- S+19, r1 <- C, r2 <- C
0x115d53390    f9404fa0               ldrx r0, [fp, #152]
0x115d53394    aa1603e1               mov r1, nr
0x115d53398    aa1603e2               mov r2, nr
        ;; AssertAssignable:54(v5, int, ':ffi_param3', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d5339c    36000140               tbzw r0, #0, 0x115d533c4
0x115d533a0    78401004               ldrh r4, [r0, #1]
0x115d533a4    d100c084               subi r4, r4, 0x30
0x115d533a8    f100049f               cmpi r4, 0x1
0x115d533ac    540000c9               bls 0x115d533c4
0x115d533b0    f9479368               ldrx r8, [pp, #3872]
0x115d533b4    f8407109               ldrx r9, [r8, #7]
0x115d533b8    9140ab63               addi r3, pp, 0x2a000
0x115d533bc    f9477c63               ldrx r3, [r3, #3832]
0x115d533c0    d63f0120               blr r9
        ;; ParallelMove r0 <- S+18, r1 <- C, r2 <- C
0x115d533c4    f9404ba0               ldrx r0, [fp, #144]
0x115d533c8    aa1603e1               mov r1, nr
0x115d533cc    aa1603e2               mov r2, nr
        ;; AssertAssignable:56(v6, double, ':ffi_param4', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d533d0    d2800604               movz r4, 0x30 
0x115d533d4    36000040               tbzw r0, #0, 0x115d533dc
0x115d533d8    78401004               ldrh r4, [r0, #1]
0x115d533dc    f100c884               subis r4, r4, 0x32
0x115d533e0    540000e0               beq 0x115d533fc
0x115d533e4    91402f68               addi r8, pp, 0xb000
0x115d533e8    f943f508               ldrx r8, [r8, #2024]
0x115d533ec    f8407109               ldrx r9, [r8, #7]
0x115d533f0    9140ab63               addi r3, pp, 0x2a000
0x115d533f4    f9478463               ldrx r3, [r3, #3848]
0x115d533f8    d63f0120               blr r9
        ;; ParallelMove r0 <- S+17, r1 <- C, r2 <- C
0x115d533fc    f94047a0               ldrx r0, [fp, #136]
0x115d53400    aa1603e1               mov r1, nr
0x115d53404    aa1603e2               mov r2, nr
        ;; AssertAssignable:58(v7, int, ':ffi_param5', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d53408    36000140               tbzw r0, #0, 0x115d53430
0x115d5340c    78401004               ldrh r4, [r0, #1]
0x115d53410    d100c084               subi r4, r4, 0x30
0x115d53414    f100049f               cmpi r4, 0x1
0x115d53418    540000c9               bls 0x115d53430
0x115d5341c    f9479368               ldrx r8, [pp, #3872]
0x115d53420    f8407109               ldrx r9, [r8, #7]
0x115d53424    9140ab63               addi r3, pp, 0x2a000
0x115d53428    f9478c63               ldrx r3, [r3, #3864]
0x115d5342c    d63f0120               blr r9
        ;; ParallelMove r0 <- S+16, r1 <- C, r2 <- C
0x115d53430    f94043a0               ldrx r0, [fp, #128]
0x115d53434    aa1603e1               mov r1, nr
0x115d53438    aa1603e2               mov r2, nr
        ;; AssertAssignable:60(v8, double, ':ffi_param6', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d5343c    d2800604               movz r4, 0x30 
0x115d53440    36000040               tbzw r0, #0, 0x115d53448
0x115d53444    78401004               ldrh r4, [r0, #1]
0x115d53448    f100c884               subis r4, r4, 0x32
0x115d5344c    540000e0               beq 0x115d53468
0x115d53450    91402f68               addi r8, pp, 0xb000
0x115d53454    f943f508               ldrx r8, [r8, #2024]
0x115d53458    f8407109               ldrx r9, [r8, #7]
0x115d5345c    9140ab63               addi r3, pp, 0x2a000
0x115d53460    f9479463               ldrx r3, [r3, #3880]
0x115d53464    d63f0120               blr r9
        ;; ParallelMove r0 <- S+15, r1 <- C, r2 <- C
0x115d53468    f9403fa0               ldrx r0, [fp, #120]
0x115d5346c    aa1603e1               mov r1, nr
0x115d53470    aa1603e2               mov r2, nr
        ;; AssertAssignable:62(v9, int, ':ffi_param7', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d53474    36000140               tbzw r0, #0, 0x115d5349c
0x115d53478    78401004               ldrh r4, [r0, #1]
0x115d5347c    d100c084               subi r4, r4, 0x30
0x115d53480    f100049f               cmpi r4, 0x1
0x115d53484    540000c9               bls 0x115d5349c
0x115d53488    f9479368               ldrx r8, [pp, #3872]
0x115d5348c    f8407109               ldrx r9, [r8, #7]
0x115d53490    9140ab63               addi r3, pp, 0x2a000
0x115d53494    f9479c63               ldrx r3, [r3, #3896]
0x115d53498    d63f0120               blr r9
        ;; ParallelMove r0 <- S+14, r1 <- C, r2 <- C
0x115d5349c    f9403ba0               ldrx r0, [fp, #112]
0x115d534a0    aa1603e1               mov r1, nr
0x115d534a4    aa1603e2               mov r2, nr
        ;; AssertAssignable:64(v10, double, ':ffi_param8', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d534a8    d2800604               movz r4, 0x30 
0x115d534ac    36000040               tbzw r0, #0, 0x115d534b4
0x115d534b0    78401004               ldrh r4, [r0, #1]
0x115d534b4    f100c884               subis r4, r4, 0x32
0x115d534b8    540000e0               beq 0x115d534d4
0x115d534bc    91402f68               addi r8, pp, 0xb000
0x115d534c0    f943f508               ldrx r8, [r8, #2024]
0x115d534c4    f8407109               ldrx r9, [r8, #7]
0x115d534c8    9140ab63               addi r3, pp, 0x2a000
0x115d534cc    f947a463               ldrx r3, [r3, #3912]
0x115d534d0    d63f0120               blr r9
        ;; ParallelMove r0 <- S+13, r1 <- C, r2 <- C
0x115d534d4    f94037a0               ldrx r0, [fp, #104]
0x115d534d8    aa1603e1               mov r1, nr
0x115d534dc    aa1603e2               mov r2, nr
        ;; AssertAssignable:66(v11, int, ':ffi_param9', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d534e0    36000140               tbzw r0, #0, 0x115d53508
0x115d534e4    78401004               ldrh r4, [r0, #1]
0x115d534e8    d100c084               subi r4, r4, 0x30
0x115d534ec    f100049f               cmpi r4, 0x1
0x115d534f0    540000c9               bls 0x115d53508
0x115d534f4    f9479368               ldrx r8, [pp, #3872]
0x115d534f8    f8407109               ldrx r9, [r8, #7]
0x115d534fc    9140ab63               addi r3, pp, 0x2a000
0x115d53500    f947ac63               ldrx r3, [r3, #3928]
0x115d53504    d63f0120               blr r9
        ;; ParallelMove r0 <- S+12, r1 <- C, r2 <- C
0x115d53508    f94033a0               ldrx r0, [fp, #96]
0x115d5350c    aa1603e1               mov r1, nr
0x115d53510    aa1603e2               mov r2, nr
        ;; AssertAssignable:68(v12, double, ':ffi_param10', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d53514    d2800604               movz r4, 0x30 
0x115d53518    36000040               tbzw r0, #0, 0x115d53520
0x115d5351c    78401004               ldrh r4, [r0, #1]
0x115d53520    f100c884               subis r4, r4, 0x32
0x115d53524    540000e0               beq 0x115d53540
0x115d53528    91402f68               addi r8, pp, 0xb000
0x115d5352c    f943f508               ldrx r8, [r8, #2024]
0x115d53530    f8407109               ldrx r9, [r8, #7]
0x115d53534    9140ab63               addi r3, pp, 0x2a000
0x115d53538    f947b463               ldrx r3, [r3, #3944]
0x115d5353c    d63f0120               blr r9
        ;; ParallelMove r0 <- S+11, r1 <- C, r2 <- C
0x115d53540    f9402fa0               ldrx r0, [fp, #88]
0x115d53544    aa1603e1               mov r1, nr
0x115d53548    aa1603e2               mov r2, nr
        ;; AssertAssignable:70(v13, int, ':ffi_param11', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d5354c    36000140               tbzw r0, #0, 0x115d53574
0x115d53550    78401004               ldrh r4, [r0, #1]
0x115d53554    d100c084               subi r4, r4, 0x30
0x115d53558    f100049f               cmpi r4, 0x1
0x115d5355c    540000c9               bls 0x115d53574
0x115d53560    f9479368               ldrx r8, [pp, #3872]
0x115d53564    f8407109               ldrx r9, [r8, #7]
0x115d53568    9140ab63               addi r3, pp, 0x2a000
0x115d5356c    f947bc63               ldrx r3, [r3, #3960]
0x115d53570    d63f0120               blr r9
        ;; ParallelMove r0 <- S+10, r1 <- C, r2 <- C
0x115d53574    f9402ba0               ldrx r0, [fp, #80]
0x115d53578    aa1603e1               mov r1, nr
0x115d5357c    aa1603e2               mov r2, nr
        ;; AssertAssignable:72(v14, double, ':ffi_param12', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d53580    d2800604               movz r4, 0x30 
0x115d53584    36000040               tbzw r0, #0, 0x115d5358c
0x115d53588    78401004               ldrh r4, [r0, #1]
0x115d5358c    f100c884               subis r4, r4, 0x32
0x115d53590    540000e0               beq 0x115d535ac
0x115d53594    91402f68               addi r8, pp, 0xb000
0x115d53598    f943f508               ldrx r8, [r8, #2024]
0x115d5359c    f8407109               ldrx r9, [r8, #7]
0x115d535a0    9140ab63               addi r3, pp, 0x2a000
0x115d535a4    f947c463               ldrx r3, [r3, #3976]
0x115d535a8    d63f0120               blr r9
        ;; ParallelMove r0 <- S+9, r1 <- C, r2 <- C
0x115d535ac    f94027a0               ldrx r0, [fp, #72]
0x115d535b0    aa1603e1               mov r1, nr
0x115d535b4    aa1603e2               mov r2, nr
        ;; AssertAssignable:74(v15, int, ':ffi_param13', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d535b8    36000140               tbzw r0, #0, 0x115d535e0
0x115d535bc    78401004               ldrh r4, [r0, #1]
0x115d535c0    d100c084               subi r4, r4, 0x30
0x115d535c4    f100049f               cmpi r4, 0x1
0x115d535c8    540000c9               bls 0x115d535e0
0x115d535cc    f9479368               ldrx r8, [pp, #3872]
0x115d535d0    f8407109               ldrx r9, [r8, #7]
0x115d535d4    9140ab63               addi r3, pp, 0x2a000
0x115d535d8    f947cc63               ldrx r3, [r3, #3992]
0x115d535dc    d63f0120               blr r9
        ;; ParallelMove r0 <- S+8, r1 <- C, r2 <- C
0x115d535e0    f94023a0               ldrx r0, [fp, #64]
0x115d535e4    aa1603e1               mov r1, nr
0x115d535e8    aa1603e2               mov r2, nr
        ;; AssertAssignable:76(v16, double, ':ffi_param14', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d535ec    d2800604               movz r4, 0x30 
0x115d535f0    36000040               tbzw r0, #0, 0x115d535f8
0x115d535f4    78401004               ldrh r4, [r0, #1]
0x115d535f8    f100c884               subis r4, r4, 0x32
0x115d535fc    540000e0               beq 0x115d53618
0x115d53600    91402f68               addi r8, pp, 0xb000
0x115d53604    f943f508               ldrx r8, [r8, #2024]
0x115d53608    f8407109               ldrx r9, [r8, #7]
0x115d5360c    9140ab63               addi r3, pp, 0x2a000
0x115d53610    f947d463               ldrx r3, [r3, #4008]
0x115d53614    d63f0120               blr r9
        ;; ParallelMove r0 <- S+7, r1 <- C, r2 <- C
0x115d53618    f9401fa0               ldrx r0, [fp, #56]
0x115d5361c    aa1603e1               mov r1, nr
0x115d53620    aa1603e2               mov r2, nr
        ;; AssertAssignable:78(v17, int, ':ffi_param15', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d53624    36000140               tbzw r0, #0, 0x115d5364c
0x115d53628    78401004               ldrh r4, [r0, #1]
0x115d5362c    d100c084               subi r4, r4, 0x30
0x115d53630    f100049f               cmpi r4, 0x1
0x115d53634    540000c9               bls 0x115d5364c
0x115d53638    f9479368               ldrx r8, [pp, #3872]
0x115d5363c    f8407109               ldrx r9, [r8, #7]
0x115d53640    9140ab63               addi r3, pp, 0x2a000
0x115d53644    f947dc63               ldrx r3, [r3, #4024]
0x115d53648    d63f0120               blr r9
        ;; ParallelMove r0 <- S+6, r1 <- C, r2 <- C
0x115d5364c    f9401ba0               ldrx r0, [fp, #48]
0x115d53650    aa1603e1               mov r1, nr
0x115d53654    aa1603e2               mov r2, nr
        ;; AssertAssignable:80(v18, double, ':ffi_param16', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d53658    d2800604               movz r4, 0x30 
0x115d5365c    36000040               tbzw r0, #0, 0x115d53664
0x115d53660    78401004               ldrh r4, [r0, #1]
0x115d53664    f100c884               subis r4, r4, 0x32
0x115d53668    540000e0               beq 0x115d53684
0x115d5366c    91402f68               addi r8, pp, 0xb000
0x115d53670    f943f508               ldrx r8, [r8, #2024]
0x115d53674    f8407109               ldrx r9, [r8, #7]
0x115d53678    9140ab63               addi r3, pp, 0x2a000
0x115d5367c    f947e463               ldrx r3, [r3, #4040]
0x115d53680    d63f0120               blr r9
        ;; ParallelMove r0 <- S+5, r1 <- C, r2 <- C
0x115d53684    f94017a0               ldrx r0, [fp, #40]
0x115d53688    aa1603e1               mov r1, nr
0x115d5368c    aa1603e2               mov r2, nr
        ;; AssertAssignable:82(v19, int, ':ffi_param17', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d53690    36000140               tbzw r0, #0, 0x115d536b8
0x115d53694    78401004               ldrh r4, [r0, #1]
0x115d53698    d100c084               subi r4, r4, 0x30
0x115d5369c    f100049f               cmpi r4, 0x1
0x115d536a0    540000c9               bls 0x115d536b8
0x115d536a4    f9479368               ldrx r8, [pp, #3872]
0x115d536a8    f8407109               ldrx r9, [r8, #7]
0x115d536ac    9140ab63               addi r3, pp, 0x2a000
0x115d536b0    f947ec63               ldrx r3, [r3, #4056]
0x115d536b4    d63f0120               blr r9
        ;; ParallelMove r0 <- S+4, r1 <- C, r2 <- C
0x115d536b8    f94013a0               ldrx r0, [fp, #32]
0x115d536bc    aa1603e1               mov r1, nr
0x115d536c0    aa1603e2               mov r2, nr
        ;; AssertAssignable:84(v20, double, ':ffi_param18', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d536c4    d2800604               movz r4, 0x30 
0x115d536c8    36000040               tbzw r0, #0, 0x115d536d0
0x115d536cc    78401004               ldrh r4, [r0, #1]
0x115d536d0    f100c884               subis r4, r4, 0x32
0x115d536d4    540000e0               beq 0x115d536f0
0x115d536d8    91402f68               addi r8, pp, 0xb000
0x115d536dc    f943f508               ldrx r8, [r8, #2024]
0x115d536e0    f8407109               ldrx r9, [r8, #7]
0x115d536e4    9140ab63               addi r3, pp, 0x2a000
0x115d536e8    f947f463               ldrx r3, [r3, #4072]
0x115d536ec    d63f0120               blr r9
        ;; ParallelMove r0 <- S+3, r1 <- C, r2 <- C
0x115d536f0    f9400fa0               ldrx r0, [fp, #24]
0x115d536f4    aa1603e1               mov r1, nr
0x115d536f8    aa1603e2               mov r2, nr
        ;; AssertAssignable:86(v21, int, ':ffi_param19', instantiator_type_args(v0), function_type_args(v0)) T{int?}
0x115d536fc    36000140               tbzw r0, #0, 0x115d53724
0x115d53700    78401004               ldrh r4, [r0, #1]
0x115d53704    d100c084               subi r4, r4, 0x30
0x115d53708    f100049f               cmpi r4, 0x1
0x115d5370c    540000c9               bls 0x115d53724
0x115d53710    f9479368               ldrx r8, [pp, #3872]
0x115d53714    f8407109               ldrx r9, [r8, #7]
0x115d53718    9140ab63               addi r3, pp, 0x2a000
0x115d5371c    f947fc63               ldrx r3, [r3, #4088]
0x115d53720    d63f0120               blr r9
        ;; ParallelMove r0 <- S+2, r1 <- C, r2 <- C
0x115d53724    f9400ba0               ldrx r0, [fp, #16]
0x115d53728    aa1603e1               mov r1, nr
0x115d5372c    aa1603e2               mov r2, nr
        ;; AssertAssignable:88(v22, double, ':ffi_param20', instantiator_type_args(v0), function_type_args(v0)) T{double?}
0x115d53730    d2800604               movz r4, 0x30 
0x115d53734    36000040               tbzw r0, #0, 0x115d5373c
0x115d53738    78401004               ldrh r4, [r0, #1]
0x115d5373c    f100c884               subis r4, r4, 0x32
0x115d53740    540000e0               beq 0x115d5375c
0x115d53744    91402f68               addi r8, pp, 0xb000
0x115d53748    f943f508               ldrx r8, [r8, #2024]
0x115d5374c    f8407109               ldrx r9, [r8, #7]
0x115d53750    9140af63               addi r3, pp, 0x2b000
0x115d53754    f9400463               ldrx r3, [r3, #8]
0x115d53758    d63f0120               blr r9
        ;; ParallelMove r0 <- S+21
0x115d5375c    f94057a0               ldrx r0, [fp, #168]
        ;; t0 <- CheckNull:90(v3 T{int?}) T{int}
0x115d53760    eb16001f               cmp r0, nr
0x115d53764    54001d20               beq 0x115d53b08
        ;; v75 <- UnboxInt64(v3 T{int}) T{int}
0x115d53768    9341fc09               sbfm r9, r0, #1, #63
0x115d5376c    36000040               tbzw r0, #0, 0x115d53774
0x115d53770    f8407009               ldrx r9, [r0, #7]
        ;; ParallelMove r0 <- S+20, S-11 <- r9
0x115d53774    f94053a0               ldrx r0, [fp, #160]
0x115d53778    f81a83a9               strx r9, [fp, #-88]
        ;; t1 <- CheckNull:92(v4 T{double?}) T{double}
0x115d5377c    eb16001f               cmp r0, nr
0x115d53780    54001c60               beq 0x115d53b0c
        ;; v79 <- Unbox(v4 T{double}) T{_Double}
0x115d53784    fc407008               fldrd v8, [r0, #7]
0x115d53788    1e624108               fcvtsd v8, v8
        ;; ParallelMove r0 <- S+19, DS-21 <- v8
0x115d5378c    f9404fa0               ldrx r0, [fp, #152]
0x115d53790    fc1583a8               fstrd v8, [fp, #-168]
        ;; t2 <- CheckNull:94(v5 T{int?}) T{int}
0x115d53794    eb16001f               cmp r0, nr
0x115d53798    54001bc0               beq 0x115d53b10
        ;; v83 <- UnboxInt64(v5 T{int}) T{int}
0x115d5379c    9341fc0a               sbfm r10, r0, #1, #63
0x115d537a0    36000040               tbzw r0, #0, 0x115d537a8
0x115d537a4    f840700a               ldrx r10, [r0, #7]
        ;; ParallelMove r0 <- S+18, S-10 <- r10
0x115d537a8    f9404ba0               ldrx r0, [fp, #144]
0x115d537ac    f81b03aa               strx r10, [fp, #-80]
        ;; t3 <- CheckNull:96(v6 T{double?}) T{double}
0x115d537b0    eb16001f               cmp r0, nr
0x115d537b4    54001b00               beq 0x115d53b14
        ;; v87 <- Unbox(v6 T{double}) T{_Double}
0x115d537b8    fc407009               fldrd v9, [r0, #7]
        ;; ParallelMove r0 <- S+17, DS-20 <- v9
0x115d537bc    f94047a0               ldrx r0, [fp, #136]
0x115d537c0    fc1603a9               fstrd v9, [fp, #-160]
        ;; t4 <- CheckNull:98(v7 T{int?}) T{int}
0x115d537c4    eb16001f               cmp r0, nr
0x115d537c8    54001a80               beq 0x115d53b18
        ;; v91 <- UnboxInt64(v7 T{int}) T{int}
0x115d537cc    9341fc0b               sbfm r11, r0, #1, #63
0x115d537d0    36000040               tbzw r0, #0, 0x115d537d8
0x115d537d4    f840700b               ldrx r11, [r0, #7]
        ;; ParallelMove r0 <- S+16, S-9 <- r11
0x115d537d8    f94043a0               ldrx r0, [fp, #128]
0x115d537dc    f81b83ab               strx r11, [fp, #-72]
        ;; t5 <- CheckNull:100(v8 T{double?}) T{double}
0x115d537e0    eb16001f               cmp r0, nr
0x115d537e4    540019c0               beq 0x115d53b1c
        ;; v95 <- Unbox(v8 T{double}) T{_Double}
0x115d537e8    fc40700a               fldrd v10, [r0, #7]
0x115d537ec    1e62414a               fcvtsd v10, v10
        ;; ParallelMove r0 <- S+15, DS-19 <- v10
0x115d537f0    f9403fa0               ldrx r0, [fp, #120]
0x115d537f4    fc1683aa               fstrd v10, [fp, #-152]
        ;; t6 <- CheckNull:102(v9 T{int?}) T{int}
0x115d537f8    eb16001f               cmp r0, nr
0x115d537fc    54001920               beq 0x115d53b20
        ;; v99 <- UnboxInt64(v9 T{int}) T{int}
0x115d53800    9341fc0c               sbfm r12, r0, #1, #63
0x115d53804    36000040               tbzw r0, #0, 0x115d5380c
0x115d53808    f840700c               ldrx r12, [r0, #7]
        ;; ParallelMove r0 <- S+14, S-8 <- r12
0x115d5380c    f9403ba0               ldrx r0, [fp, #112]
0x115d53810    f81c03ac               strx r12, [fp, #-64]
        ;; t7 <- CheckNull:104(v10 T{double?}) T{double}
0x115d53814    eb16001f               cmp r0, nr
0x115d53818    54001860               beq 0x115d53b24
        ;; v103 <- Unbox(v10 T{double}) T{_Double}
0x115d5381c    fc40700b               fldrd v11, [r0, #7]
        ;; ParallelMove r0 <- S+13, DS-18 <- v11
0x115d53820    f94037a0               ldrx r0, [fp, #104]
0x115d53824    fc1703ab               fstrd v11, [fp, #-144]
        ;; t8 <- CheckNull:106(v11 T{int?}) T{int}
0x115d53828    eb16001f               cmp r0, nr
0x115d5382c    540017e0               beq 0x115d53b28
        ;; v107 <- UnboxInt64(v11 T{int}) T{int}
0x115d53830    9341fc0d               sbfm r13, r0, #1, #63
0x115d53834    36000040               tbzw r0, #0, 0x115d5383c
0x115d53838    f840700d               ldrx r13, [r0, #7]
        ;; ParallelMove r0 <- S+12, S-7 <- r13
0x115d5383c    f94033a0               ldrx r0, [fp, #96]
0x115d53840    f81c83ad               strx r13, [fp, #-56]
        ;; t9 <- CheckNull:108(v12 T{double?}) T{double}
0x115d53844    eb16001f               cmp r0, nr
0x115d53848    54001720               beq 0x115d53b2c
        ;; v111 <- Unbox(v12 T{double}) T{_Double}
0x115d5384c    fc40700c               fldrd v12, [r0, #7]
0x115d53850    1e62418c               fcvtsd v12, v12
        ;; ParallelMove r0 <- S+11, DS-17 <- v12
0x115d53854    f9402fa0               ldrx r0, [fp, #88]
0x115d53858    fc1783ac               fstrd v12, [fp, #-136]
        ;; t10 <- CheckNull:110(v13 T{int?}) T{int}
0x115d5385c    eb16001f               cmp r0, nr
0x115d53860    54001680               beq 0x115d53b30
        ;; v115 <- UnboxInt64(v13 T{int}) T{int}
0x115d53864    9341fc0e               sbfm r14, r0, #1, #63
0x115d53868    36000040               tbzw r0, #0, 0x115d53870
0x115d5386c    f840700e               ldrx r14, [r0, #7]
        ;; ParallelMove r0 <- S+10, S-6 <- r14
0x115d53870    f9402ba0               ldrx r0, [fp, #80]
0x115d53874    f81d03ae               strx r14, [fp, #-48]
        ;; t11 <- CheckNull:112(v14 T{double?}) T{double}
0x115d53878    eb16001f               cmp r0, nr
0x115d5387c    540015c0               beq 0x115d53b34
        ;; v119 <- Unbox(v14 T{double}) T{_Double}
0x115d53880    fc40700d               fldrd v13, [r0, #7]
        ;; ParallelMove r0 <- S+9, DS-16 <- v13
0x115d53884    f94027a0               ldrx r0, [fp, #72]
0x115d53888    fc1803ad               fstrd v13, [fp, #-128]
        ;; t12 <- CheckNull:114(v15 T{int?}) T{int}
0x115d5388c    eb16001f               cmp r0, nr
0x115d53890    54001540               beq 0x115d53b38
        ;; v123 <- UnboxInt64(v15 T{int}) T{int}
0x115d53894    9341fc13               sbfm sp, r0, #1, #63
0x115d53898    36000040               tbzw r0, #0, 0x115d538a0
0x115d5389c    f8407013               ldrx sp, [r0, #7]
        ;; ParallelMove r0 <- S+8, S-5 <- r19
0x115d538a0    f94023a0               ldrx r0, [fp, #64]
0x115d538a4    f81d83b3               strx sp, [fp, #-40]
        ;; t13 <- CheckNull:116(v16 T{double?}) T{double}
0x115d538a8    eb16001f               cmp r0, nr
0x115d538ac    54001480               beq 0x115d53b3c
        ;; v127 <- Unbox(v16 T{double}) T{_Double}
0x115d538b0    fc40700e               fldrd v14, [r0, #7]
0x115d538b4    1e6241ce               fcvtsd v14, v14
        ;; ParallelMove r0 <- S+7, DS-15 <- v14
0x115d538b8    f9401fa0               ldrx r0, [fp, #56]
0x115d538bc    fc1883ae               fstrd v14, [fp, #-120]
        ;; t14 <- CheckNull:118(v17 T{int?}) T{int}
0x115d538c0    eb16001f               cmp r0, nr
0x115d538c4    540013e0               beq 0x115d53b40
        ;; v131 <- UnboxInt64(v17 T{int}) T{int}
0x115d538c8    9341fc14               sbfm r20, r0, #1, #63
0x115d538cc    36000040               tbzw r0, #0, 0x115d538d4
0x115d538d0    f8407014               ldrx r20, [r0, #7]
        ;; ParallelMove r0 <- S+6, S-4 <- r20
0x115d538d4    f9401ba0               ldrx r0, [fp, #48]
0x115d538d8    f81e03b4               strx r20, [fp, #-32]
        ;; t15 <- CheckNull:120(v18 T{double?}) T{double}
0x115d538dc    eb16001f               cmp r0, nr
0x115d538e0    54001320               beq 0x115d53b44
        ;; v135 <- Unbox(v18 T{double}) T{_Double}
0x115d538e4    fc40700f               fldrd v15, [r0, #7]
        ;; ParallelMove r0 <- S+5, DS-14 <- v15
0x115d538e8    f94017a0               ldrx r0, [fp, #40]
0x115d538ec    fc1903af               fstrd v15, [fp, #-112]
        ;; t16 <- CheckNull:122(v19 T{int?}) T{int}
0x115d538f0    eb16001f               cmp r0, nr
0x115d538f4    540012a0               beq 0x115d53b48
        ;; v139 <- UnboxInt64(v19 T{int}) T{int}
0x115d538f8    9341fc15               sbfm r21, r0, #1, #63
0x115d538fc    36000040               tbzw r0, #0, 0x115d53904
0x115d53900    f8407015               ldrx r21, [r0, #7]
        ;; ParallelMove r0 <- S+4, S-3 <- r21
0x115d53904    f94013a0               ldrx r0, [fp, #32]
0x115d53908    f81e83b5               strx r21, [fp, #-24]
        ;; t17 <- CheckNull:124(v20 T{double?}) T{double}
0x115d5390c    eb16001f               cmp r0, nr
0x115d53910    540011e0               beq 0x115d53b4c
        ;; v143 <- Unbox(v20 T{double}) T{_Double}
0x115d53914    fc407010               fldrd v16, [r0, #7]
0x115d53918    1e624210               fcvtsd v16, v16
        ;; ParallelMove r0 <- S+3, DS-13 <- v16
0x115d5391c    f9400fa0               ldrx r0, [fp, #24]
0x115d53920    fc1983b0               fstrd v16, [fp, #-104]
        ;; t18 <- CheckNull:126(v21 T{int?}) T{int}
0x115d53924    eb16001f               cmp r0, nr
0x115d53928    54001140               beq 0x115d53b50
        ;; v147 <- UnboxInt64(v21 T{int}) T{int}
0x115d5392c    9341fc17               sbfm r23, r0, #1, #63
0x115d53930    36000040               tbzw r0, #0, 0x115d53938
0x115d53934    f8407017               ldrx r23, [r0, #7]
        ;; ParallelMove r0 <- S+2, S-2 <- r23
0x115d53938    f9400ba0               ldrx r0, [fp, #16]
0x115d5393c    f81f03b7               strx r23, [fp, #-16]
        ;; t19 <- CheckNull:128(v22 T{double?}) T{double}
0x115d53940    eb16001f               cmp r0, nr
0x115d53944    54001080               beq 0x115d53b54
        ;; v151 <- Unbox(v22 T{double}) T{_Double}
0x115d53948    fc407011               fldrd v17, [r0, #7]
        ;; ParallelMove r0 <- S+22, DS-12 <- v17
0x115d5394c    f9405ba0               ldrx r0, [fp, #176]
0x115d53950    fc1a03b1               fstrd v17, [fp, #-96]
        ;; v153 <- LoadField(v2 . Closure.context {final}) T{Context}
0x115d53954    f8427001               ldrx r1, [r0, #39]
        ;; v155 <- LoadField(v153 . this) T{Pointer<T>?}
0x115d53958    f8417020               ldrx r0, [r1, #23]
        ;; v157 <- UnboxInt64(v155) T{int}
0x115d5395c    9341fc18               sbfm r24, r0, #1, #63
0x115d53960    36000040               tbzw r0, #0, 0x115d53968
0x115d53964    f8407018               ldrx r24, [r0, #7]
        ;; ParallelMove r0 <- r9, v0 <- v8, r1 <- r10, v1 <- v9, r2 <- r11, v2 <- v10, r3 <- r12, v3 <- v11, r4 <- r13, v4 <- v12, r5 <- r14, v5 <- v13, r6 <- r19, v6 <- v14, r7 <- r20, v7 <- v15, r8 <- r24, S-1 <- r24
0x115d53968    aa0903e0               mov r0, r9
0x115d5396c    4ea81d00               vorr v0, v8, v8
0x115d53970    aa0a03e1               mov r1, r10
0x115d53974    4ea91d21               vorr v1, v9, v9
0x115d53978    aa0b03e2               mov r2, r11
0x115d5397c    4eaa1d42               vorr v2, v10, v10
0x115d53980    aa0c03e3               mov r3, r12
0x115d53984    4eab1d63               vorr v3, v11, v11
0x115d53988    aa0d03e4               mov r4, r13
0x115d5398c    4eac1d84               vorr v4, v12, v12
0x115d53990    aa0e03e5               mov r5, r14
0x115d53994    4ead1da5               vorr v5, v13, v13
0x115d53998    aa1303e6               mov r6, sp
0x115d5399c    4eae1dc6               vorr v6, v14, v14
0x115d539a0    aa1403e7               mov r7, r20
0x115d539a4    4eaf1de7               vorr v7, v15, v15
0x115d539a8    aa1803e8               mov r8, r24
0x115d539ac    f81f83b8               strx r24, [fp, #-8]
        ;; v159 <- FfiCall:130( pointer=v157, v75 (@r0), v79 (@v0), v83 (@r1), v87 (@v1), v91 (@r2), v95 (@v2), v99 (@r3), v103 (@v3), v107 (@r4), v111 (@v4), v115 (@r5), v119 (@v5), v123 (@r6), v127 (@v6), v131 (@r7), v135 (@v7), v139 (@S+0), v143 (@S+1), v147 (@S+
0x115d539b0    aa1d03e9               mov r9, fp
0x115d539b4    aa1603f8               mov r24, nr
0x115d539b8    a9bf79fd               stp fp, lr, [r15, #-16 ]!
0x115d539bc    aa0f03fd               mov fp, r15
0x115d539c0    d10081ef               subi r15, r15, 0x20
0x115d539c4    927cedef               andi r15, r15, 0xfffffffffffffff0
0x115d539c8    f85e8133               ldrx sp, [r9, #-24]
0x115d539cc    f90001f3               strx sp, [r15]
0x115d539d0    fc59813f               fldrd v31, [r9, #-104]
0x115d539d4    fd0005ff               fstrd v31, [r15, #8]
0x115d539d8    f85f0133               ldrx sp, [r9, #-16]
0x115d539dc    f90009f3               strx sp, [r15, #16]
0x115d539e0    fc5a013f               fldrd v31, [r9, #-96]
0x115d539e4    fd000dff               fstrd v31, [r15, #24]
0x115d539e8    10000033               adr sp, 0x115d539ec
0x115d539ec    f90007b3               strx sp, [fp, #8]
0x115d539f0    f900475d               strx fp, [thr, #136]
0x115d539f4    f9005748               strx r8, [thr, #168]
0x115d539f8    d2800053               movz sp, 0x2 
0x115d539fc    f902b753               strx sp, [thr, #1384]
0x115d53a00    d280ae11               movz ip1, 0x570 
0x115d53a04    8b110351               add ip1, thr, ip1
0x115d53a08    c85f7e33               ldxr sp, ip1
0x115d53a0c    f100027f               cmpi sp, 0x0
0x115d53a10    540000a1               bne 0x115d53a24
0x115d53a14    d2800033               movz sp, 0x1 
0x115d53a18    c8107e33               stxr ip0, sp, ip1
0x115d53a1c    b40000b0               cbz ip0, 0x115d53a30
0x115d53a20    54ffff4e               b 0x115d53a08
0x115d53a24    f940b751               ldrx ip1, [thr, #360]   Code([Stub] EnterSafepoint)
0x115d53a28    f8407231               ldrx ip1, [ip1, #7]
0x115d53a2c    d63f0220               blr ip1
0x115d53a30    910003f9               mov r25, csp
0x115d53a34    910001ff               mov csp, r15
0x115d53a38    d63f0100               blr r8
0x115d53a3c    910003ef               mov r15, csp
0x115d53a40    9100033f               mov csp, r25
0x115d53a44    d280ae11               movz ip1, 0x570 
0x115d53a48    8b110351               add ip1, thr, ip1
0x115d53a4c    c85f7e33               ldxr sp, ip1
0x115d53a50    f100067f               cmpi sp, 0x1
0x115d53a54    540000a1               bne 0x115d53a68
0x115d53a58    d2800013               movz sp, 0x0 
0x115d53a5c    c8107e33               stxr ip0, sp, ip1
0x115d53a60    b40000b0               cbz ip0, 0x115d53a74
0x115d53a64    54ffff4e               b 0x115d53a4c
0x115d53a68    f940bb51               ldrx ip1, [thr, #368]   Code([Stub] ExitSafepoint)
0x115d53a6c    f8407231               ldrx ip1, [ip1, #7]
0x115d53a70    d63f0220               blr ip1
0x115d53a74    d2800133               movz sp, 0x9 
0x115d53a78    f9005753               strx sp, [thr, #168]
0x115d53a7c    d2800033               movz sp, 0x1 
0x115d53a80    f902b753               strx sp, [thr, #1384]
0x115d53a84    f900475f               strx zr, [thr, #136]
0x115d53a88    f940335c               ldrx ctx, [thr, #96]
0x115d53a8c    f9406356               ldrx nr, [thr, #192]   null
0x115d53a90    aa1d03ef               mov r15, fp
0x115d53a94    a8c179fd               ldp fp, lr, [r15], #16 !
0x115d53a98    f942ab5b               ldrx pp, [thr, #1360]
0x115d53a9c    d100077b               subi pp, pp, 0x1
        ;; ParallelMove v0 <- v0
        ;; v161 <- Box(v159) T{_Double}
0x115d53aa0    f9403741               ldrx r1, [thr, #104]
0x115d53aa4    f9403821               ldrx r1, [r1, #112]
0x115d53aa8    f9400021               ldrx r1, [r1]
0x115d53aac    9100c821               addi r1, r1, 0x32
0x115d53ab0    39400021               ldrb r1, [r1]
0x115d53ab4    b5000521               cbnz r1, 0x115d53b58
0x115d53ab8    a947c340               ldp r0, ip0, [thr, #120 ]
0x115d53abc    91004001               addi r1, r0, 0x10
0x115d53ac0    eb01021f               cmp ip0, r1
0x115d53ac4    540004a9               bls 0x115d53b58
0x115d53ac8    f9003f41               strx r1, [thr, #120]
0x115d53acc    d2802090               movz ip0, 0x104 
0x115d53ad0    f2a00650               movk ip0, 0x32 lsl 16
0x115d53ad4    f9000010               strx ip0, [r0]
0x115d53ad8    91000400               addi r0, r0, 0x1
0x115d53adc    fc007000               fstrd v0, [r0, #7]
        ;; ParallelMove r0 <- r0
        ;; Return:132(v161)
0x115d53ae0    aa1d03ef               mov r15, fp
0x115d53ae4    a8c179fd               ldp fp, lr, [r15], #16 !
0x115d53ae8    d65f03c0               ret lr
        ;; B10
        ;; B8
        ;; B5
        ;; B2
        ;; ParallelMove r4 <- r4
        ;; TailCall(CallClosureNoSuchMethod(v23))
0x115d53aec    f9405778               ldrx r24, [pp, #168]
0x115d53af0    aa1d03ef               mov r15, fp
0x115d53af4    a8c179fd               ldp fp, lr, [r15], #16 !
0x115d53af8    f8407300               ldrx r0, [r24, #7]
0x115d53afc    d61f0000               br r0
        ;; CheckStackOverflowSlowPath
0x115d53b00    94000000               bl 0x115d53b00
0x115d53b04    54ffc0ee               b 0x115d53320
        ;; slow path check null operation
0x115d53b08    94000000               bl 0x115d53b08
        ;; slow path check null operation
0x115d53b0c    94000000               bl 0x115d53b0c
        ;; slow path check null operation
0x115d53b10    94000000               bl 0x115d53b10
        ;; slow path check null operation
0x115d53b14    94000000               bl 0x115d53b14
        ;; slow path check null operation
0x115d53b18    94000000               bl 0x115d53b18
        ;; slow path check null operation
0x115d53b1c    94000000               bl 0x115d53b1c
        ;; slow path check null operation
0x115d53b20    94000000               bl 0x115d53b20
        ;; slow path check null operation
0x115d53b24    94000000               bl 0x115d53b24
        ;; slow path check null operation
0x115d53b28    94000000               bl 0x115d53b28
        ;; slow path check null operation
0x115d53b2c    94000000               bl 0x115d53b2c
        ;; slow path check null operation
0x115d53b30    94000000               bl 0x115d53b30
        ;; slow path check null operation
0x115d53b34    94000000               bl 0x115d53b34
        ;; slow path check null operation
0x115d53b38    94000000               bl 0x115d53b38
        ;; slow path check null operation
0x115d53b3c    94000000               bl 0x115d53b3c
        ;; slow path check null operation
0x115d53b40    94000000               bl 0x115d53b40
        ;; slow path check null operation
0x115d53b44    94000000               bl 0x115d53b44
        ;; slow path check null operation
0x115d53b48    94000000               bl 0x115d53b48
        ;; slow path check null operation
0x115d53b4c    94000000               bl 0x115d53b4c
        ;; slow path check null operation
0x115d53b50    94000000               bl 0x115d53b50
        ;; slow path check null operation
0x115d53b54    94000000               bl 0x115d53b54
        ;; Box slow path allocation of _Double
0x115d53b58    3c9f0de0               fstrq v0, [r15, #-16] !
0x115d53b5c    94000000               bl 0x115d53b5c
0x115d53b60    3cc105e0               fldrq v0, [r15], #16 !
0x115d53b64    54fffbce               b 0x115d53adc
}
(No object pool for bare instructions.)
Source positions {
115d53290-115d5329b: Function 'FfiTrampoline': static ffi-trampoline-function.@-12 
115d5329c-115d532bf: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d532c0-115d53313: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53314-115d5331f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53320-115d5332f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53330-115d53357: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53358-115d53363: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53364-115d5338f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53390-115d5339b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5339c-115d533c3: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d533c4-115d533cf: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d533d0-115d533fb: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d533fc-115d53407: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53408-115d5342f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53430-115d5343b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5343c-115d53467: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53468-115d53473: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53474-115d5349b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5349c-115d534a7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d534a8-115d534d3: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d534d4-115d534df: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d534e0-115d53507: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53508-115d53513: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53514-115d5353f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53540-115d5354b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5354c-115d53573: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53574-115d5357f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53580-115d535ab: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d535ac-115d535b7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d535b8-115d535df: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d535e0-115d535eb: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d535ec-115d53617: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53618-115d53623: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53624-115d5364b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5364c-115d53657: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53658-115d53683: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53684-115d5368f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53690-115d536b7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d536b8-115d536c3: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d536c4-115d536ef: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d536f0-115d536fb: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d536fc-115d53723: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53724-115d5372f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53730-115d5375b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5375c-115d5375f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53760-115d53767: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53768-115d53773: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53774-115d5377b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5377c-115d53783: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53784-115d5378b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5378c-115d53793: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53794-115d5379b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5379c-115d537a7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537a8-115d537af: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537b0-115d537b7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537b8-115d537bb: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537bc-115d537c3: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537c4-115d537cb: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537cc-115d537d7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537d8-115d537df: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537e0-115d537e7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537e8-115d537ef: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537f0-115d537f7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d537f8-115d537ff: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53800-115d5380b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5380c-115d53813: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53814-115d5381b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5381c-115d5381f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53820-115d53827: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53828-115d5382f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53830-115d5383b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5383c-115d53843: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53844-115d5384b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5384c-115d53853: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53854-115d5385b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5385c-115d53863: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53864-115d5386f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53870-115d53877: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53878-115d5387f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53880-115d53883: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53884-115d5388b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5388c-115d53893: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53894-115d5389f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538a0-115d538a7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538a8-115d538af: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538b0-115d538b7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538b8-115d538bf: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538c0-115d538c7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538c8-115d538d3: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538d4-115d538db: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538dc-115d538e3: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538e4-115d538e7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538e8-115d538ef: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538f0-115d538f7: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d538f8-115d53903: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53904-115d5390b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5390c-115d53913: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53914-115d5391b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5391c-115d53923: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53924-115d5392b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5392c-115d53937: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53938-115d5393f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53940-115d53947: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53948-115d5394b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5394c-115d53953: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53954-115d5395b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d5395c-115d53967: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53968-115d539af: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d539b0-115d53a9f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53aa0-115d53adf: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53ae0-115d53aff: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b00-115d53b0b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b0c-115d53b0c: null check PP#22017
115d53b0c-115d53b0f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b10-115d53b10: null check PP#22017
115d53b10-115d53b13: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b14-115d53b14: null check PP#22017
115d53b14-115d53b17: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b18-115d53b18: null check PP#22017
115d53b18-115d53b1b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b1c-115d53b1c: null check PP#22017
115d53b1c-115d53b1f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b20-115d53b20: null check PP#22017
115d53b20-115d53b23: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b24-115d53b24: null check PP#22017
115d53b24-115d53b27: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b28-115d53b28: null check PP#22017
115d53b28-115d53b2b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b2c-115d53b2c: null check PP#22017
115d53b2c-115d53b2f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b30-115d53b30: null check PP#22017
115d53b30-115d53b33: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b34-115d53b34: null check PP#22017
115d53b34-115d53b37: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b38-115d53b38: null check PP#22017
115d53b38-115d53b3b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b3c-115d53b3c: null check PP#22017
115d53b3c-115d53b3f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b40-115d53b40: null check PP#22017
115d53b40-115d53b43: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b44-115d53b44: null check PP#22017
115d53b44-115d53b47: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b48-115d53b48: null check PP#22017
115d53b48-115d53b4b: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b4c-115d53b4c: null check PP#22017
115d53b4c-115d53b4f: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b50-115d53b50: null check PP#22017
115d53b50-115d53b53: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b54-115d53b54: null check PP#22017
115d53b54-115d53b57: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
115d53b58-115d53b58: null check PP#22017
115d53b58-115d53b67: Function 'FfiTrampoline': static ffi-trampoline-function.@-1 
}
PC Descriptors for function 'dart:ffi_::_FfiTrampoline' {
pc                	kind    	deopt-id	tok-ix	try-ix	yield-idx
empty PcDescriptors
}
StackMaps for function 'dart:ffi_::_FfiTrampoline' {
0x000000c8: 000000000000000000000
0x00000100: 000000000000000000000
0x00000134: 000000000000000000000
0x0000016c: 000000000000000000000
0x000001a0: 000000000000000000000
0x000001d8: 000000000000000000000
0x0000020c: 000000000000000000000
0x00000244: 000000000000000000000
0x00000278: 000000000000000000000
0x000002b0: 000000000000000000000
0x000002e4: 000000000000000000000
0x0000031c: 000000000000000000000
0x00000350: 000000000000000000000
0x00000388: 000000000000000000000
0x000003bc: 000000000000000000000
0x000003f4: 000000000000000000000
0x00000428: 000000000000000000000
0x00000460: 000000000000000000000
0x00000494: 000000000000000000000
0x000004cc: 000000000000000000000
0x0000075c: 000000000000000000000
0x00000874: 0000000000000000000000111111111111111110111
0x0000087c: 0000000000000000000000000000000000000000001
0x00000880: 0000000000000000000000000000000000000000001
0x00000884: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x00000888: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x0000088c: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x00000890: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x00000894: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x00000898: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x0000089c: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008a0: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008a4: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008a8: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008ac: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008b0: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008b4: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008b8: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008bc: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008c0: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008c4: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008c8: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
0x000008d0: 00000000000000000000000
}
Exception Handlers for function 'dart:ffi_::_FfiTrampoline' {
empty ExceptionHandlers
}
Entry points for function 'dart:ffi_::_FfiTrampoline' {
  [code+0x07] 115d53290 kNormal
  [code+0x0f] 115d53290 kMonomorphic
  [code+0x17] 115d53290 kUnchecked
  [code+0x1f] 115d53290 kMonomorphicUnchecked
}
Static call target functions {
  0x115d53b00: [unknown stub], (pc-relative-call)
  0x115d53b08: [unknown stub], (pc-relative-call)
  0x115d53b0c: [unknown stub], (pc-relative-call)
  0x115d53b10: [unknown stub], (pc-relative-call)
  0x115d53b14: [unknown stub], (pc-relative-call)
  0x115d53b18: [unknown stub], (pc-relative-call)
  0x115d53b1c: [unknown stub], (pc-relative-call)
  0x115d53b20: [unknown stub], (pc-relative-call)
  0x115d53b24: [unknown stub], (pc-relative-call)
  0x115d53b28: [unknown stub], (pc-relative-call)
  0x115d53b2c: [unknown stub], (pc-relative-call)
  0x115d53b30: [unknown stub], (pc-relative-call)
  0x115d53b34: [unknown stub], (pc-relative-call)
  0x115d53b38: [unknown stub], (pc-relative-call)
  0x115d53b3c: [unknown stub], (pc-relative-call)
  0x115d53b40: [unknown stub], (pc-relative-call)
  0x115d53b44: [unknown stub], (pc-relative-call)
  0x115d53b48: [unknown stub], (pc-relative-call)
  0x115d53b4c: [unknown stub], (pc-relative-call)
  0x115d53b50: [unknown stub], (pc-relative-call)
  0x115d53b54: [unknown stub], (pc-relative-call)
  0x115d53b5c: allocation stub for Library:'dart:core' Class: _Double@0150898, (pc-relative-call)
}

@mkustermann
Copy link
Member Author

If possible, it would be good to fix this before flutter stable is released. Not sure if it's possible to do fixes afterwards.

/cc @mit-mit

@dcharkes
Copy link
Contributor

dcharkes commented Dec 4, 2019

Probable cause is the difference in ABI:

iOS diverges from Procedure Call Standard for the ARM 64-bit Architecture in several ways, as described here.

In the generic procedure call standard, all function arguments passed on the stack consume slots in multiples of 8 bytes. In iOS, this requirement is dropped, and values consume only the space required.

https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html

stack_height_in_slots in runtime/vm/compiler/ffi.cc counts the stack height in 8-byte slots on 64-bit architectures. The iOS abi uses 4-byte slots for 4-byte sized values.

Update:

SumManyNumbers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1099956224, 9.38725e-323)
returning 1.09996e+09
2019-12-23 23:11:20.810434+0100 Runner[507:95257] flutter: FFI Tests failed
Exception:Expect.approxEquals(expected:<210.0>, actual:<1099956377.0>, tolerance:<0.021>) fails

float should be 18.0 (0x41900000) instead is 0x00000000
int should be 19 (0x0000000000000013) instead is 0x41900000
double should be 20 (0x4034000000000000) instead is 0x0000000000000013

The float is put into place of the int, instead of to the place where it is supposed to be.

FfiCall:130( pointer=v157, v75 (@r0 int64), v79 (@v0 float), v83 (@r1 int64), v87 (@v1 double), v91 (@r2 int64), v95 (@v2 float), v99 (@r3 int64), v103 (@V3 double), v107 (@r4 int64), v111 (@v4 float), v115 (@R5 int64), v119 (@v5 double), v123 (@r6 int64), v127 (@v6 float), v131 (@r7 int64), v135 (@v7 double), v139 (@s+0 int64), v143 (@s+8 float), v147 (@s+16 int64), v151 (@s+24 double)) T{*?}

Expected by iOS arm64 :

..., v139 (@s+0 int32), v143 (@s+4 float), v147 (@s+8 int32), v151 (@s+16 double)) T{*?}

The int type seems to be the culprit for this specific test.

Update #2:

The actual stack alignment problem is also fixed

v89 <- FfiCall:90( pointer=v87, v45 (@r0 int32[int8]), v49 (@r1 int32[int16]), v53 (@r2 int32[int8]), v57 (@r3 int32[int16]), v61 (@r4 int32[int8]), v65 (@R5 int32[int16]), v69 (@r6 int32[int8]), v73 (@r7 int32[int16]), v77 (@s+0 int8), v81 (@s+2 int16))

@dcharkes dcharkes changed the title Bug in FFI calling conversion in Dart -> C calls on iOS [vm/ffi] wrong alignment of stack arguments in iOS Dec 4, 2019
dart-bot pushed a commit that referenced this issue Jan 14, 2020
Test exercises alignment on stack, will currently fail on iOS arm64.

In addition, the Dart functions used as callbacks in tests now print their arguments for debugging purposes.

Issue: #39637

Splitting test off large CL (https://dart-review.googlesource.com/c/sdk/+/129081) to be able to land separately.

Change-Id: Iba3c63338f5d91d6e3819e54c166bbfade48d53f
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131074
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
dart-bot pushed a commit that referenced this issue Jan 21, 2020
sizeof(int) on iOS arm64 in Flutter test projects returns 4.

Issue: #36140
Issue: #39637

Change-Id: I7b471fa1da653e9bee169c34d1bd36a96fa6a704
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132607
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
tekknolagi pushed a commit to tekknolagi/dart-assembler that referenced this issue Nov 3, 2020
Introduces NativeRepresentation and NativeLocation for the compilation of FFI.

NativeRepresentations are able to express all representations (or types) of the native ABIs we bind to with FFI, this is more representations that than that are used in Dart itself.
NativeLocations are able to express all locations of the native ABIs we bind to with FFI, this is more types of locations than that are used for the Dart calling convention.
See the documentation in the respective files.

These NativeLocations and NativeRepresentations are computed by the NativeCallingConvention and consumed by the Marshaller and Assemblers.

This reenginering is required for go/dart-ffi-by-value, hardfp (Arm S and D fpu registers), and iOS 64 bit (non-word-aligned stack arguments).

In addition, by using the NativeRepresentations we also get slightly reduced code size:

* The tracking of sizes is improved, so less sign/zero-extension operations are required.
* UnboxedWidthExtenderInstr is fully removed, the size extension is done inside the native moves, coalescing moves and size extension when possible.
* BitCastInstr is only used when really needed. This reduces code-size on arm32 softfp.

This fixes the iOS arm64 calling convention, manually tested with flutter/flutter#46078 and https://dart-review.googlesource.com/c/sdk/+/131074.

Fixes: dart-lang#39637
Issue: dart-lang#36309
Issue: dart-lang#36730

Change-Id: I8878bc0f314277bab4ca22f417c6295ecc017720
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129081
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi P0 A serious issue requiring immediate resolution
Projects
None yet
Development

No branches or pull requests

2 participants