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

[SR-9435] Calling -[CALayer setTransform:] generates ~34 more bytes of TEXT in Swift than ObjC #51899

Open
aroben opened this issue Dec 7, 2018 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code size compiler The Swift compiler in itself

Comments

@aroben
Copy link

aroben commented Dec 7, 2018

Previous ID SR-9435
Radar rdar://problem/46497517
Original Reporter @aroben
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CodeSize
Assignee None
Priority Medium

md5: c316cca9080286acd5dadd0018a54d15

Issue Description:

Calling -[CALayer setTransform:] generates ~34 more bytes of TEXT in Swift than ObjC

$ cat test.swift
import QuartzCore

@inline(never)
func blackHole<T>(_ x: T) {
}

let a = CALayer()
let b = CALayer()
let m = CATransform3DMakeRotation(0, 0, 0, 0)
a.transform = m
b.transform = m
blackHole(a)
blackHole(b)

$ cat test.m
#import <QuartzCore/QuartzCore.h>

int main(int argc, const char *argv[]) {
  CALayer *a = [[CALayer alloc] init];
  CALayer *b = [[CALayer alloc] init];
  CATransform3D m = CATransform3DMakeRotation(0, 0, 0, 0);
  a.transform = m;
  b.transform = m;
  [a release];
  [b release];
  return 0;
}

$ swiftc -Osize -whole-module-optimization -module-name test -o test test.swift
$ clang -lobjc -framework QuartzCore -Os -o testobjc test.m

Swift (232 bytes for the two setTransform: calls):

0000000100007e14    ldp x22, x21, [sp, #&#8203;0x48]
0000000100007e18    ldp x24, x23, [sp, #&#8203;0x58]
0000000100007e1c    ldp x26, x25, [sp, #&#8203;0x68]
0000000100007e20    ldp x28, x27, [sp, #&#8203;0x78]
0000000100007e24    ldp x20, x9, [sp, #&#8203;0x88]
0000000100007e28    ldp x10, x11, [sp, #&#8203;0x98]
0000000100007e2c    ldp x12, x13, [sp, #&#8203;0xa8]
0000000100007e30    ldp x14, x15, [sp, #&#8203;0xb8]
0000000100007e34    adr x8, #&#8203;0x264
0000000100007e38    nop
0000000100007e3c    stp x22, x21, [x8]
0000000100007e40    stp x24, x23, [x8, #&#8203;0x10]
0000000100007e44    stp x26, x25, [x8, #&#8203;0x20]
0000000100007e48    stp x28, x27, [x8, #&#8203;0x30]
0000000100007e4c    stp x20, x9, [x8, #&#8203;0x40]
0000000100007e50    mov x16, x9
0000000100007e54    stp x11, x9, [sp, #&#8203;0x8]
0000000100007e58    stp x12, x10, [sp, #&#8203;0x30]
0000000100007e5c    stp x10, x11, [x8, #&#8203;0x50]
0000000100007e60    stp x12, x13, [x8, #&#8203;0x60]
0000000100007e64    stp x13, x14, [sp, #&#8203;0x20]
0000000100007e68    stp x14, x15, [x8, #&#8203;0x70]
0000000100007e6c    str x15, [sp, #&#8203;0x18]
0000000100007e70    nop
0000000100007e74    ldr x1, #&#8203;0x204 ; Objc selector ref: setTransform:
0000000100007e78    stp x22, x21, [sp, #&#8203;0x48]
0000000100007e7c    stp x24, x23, [sp, #&#8203;0x58]
0000000100007e80    stp x26, x25, [sp, #&#8203;0x68]
0000000100007e84    stp x28, x27, [sp, #&#8203;0x78]
0000000100007e88    stp x20, x16, [sp, #&#8203;0x88]
0000000100007e8c    stp x10, x11, [sp, #&#8203;0x98]
0000000100007e90    stp x12, x13, [sp, #&#8203;0xa8]
0000000100007e94    stp x14, x15, [sp, #&#8203;0xb8]
0000000100007e98    add x2, sp, #&#8203;0x48
0000000100007e9c    mov x0, x19
0000000100007ea0    bl  0x100007f50 ; Objc message: -[x0 setTransform:]
0000000100007ea4    nop
0000000100007ea8    ldr x1, #&#8203;0x1d0 ; Objc selector ref: setTransform:
0000000100007eac    stp x22, x21, [sp, #&#8203;0x48]
0000000100007eb0    stp x24, x23, [sp, #&#8203;0x58]
0000000100007eb4    stp x26, x25, [sp, #&#8203;0x68]
0000000100007eb8    stp x28, x27, [sp, #&#8203;0x78]
0000000100007ebc    ldr x8, [sp, #&#8203;0x10]
0000000100007ec0    stp x20, x8, [sp, #&#8203;0x88]
0000000100007ec4    ldr x8, [sp, #&#8203;0x8]
0000000100007ec8    str x8, [sp, #&#8203;0xa0]
0000000100007ecc    ldp x8, x20, [sp, #&#8203;0x38]
0000000100007ed0    str x8, [sp, #&#8203;0x98]
0000000100007ed4    ldr x8, [sp, #&#8203;0x20]
0000000100007ed8    str x8, [sp, #&#8203;0xb0]
0000000100007edc    ldr x8, [sp, #&#8203;0x30]
0000000100007ee0    str x8, [sp, #&#8203;0xa8]
0000000100007ee4    ldr x8, [sp, #&#8203;0x18]
0000000100007ee8    str x8, [sp, #&#8203;0xc0]
0000000100007eec    ldr x8, [sp, #&#8203;0x28]
0000000100007ef0    str x8, [sp, #&#8203;0xb8]
0000000100007ef4    add x2, sp, #&#8203;0x48
0000000100007ef8    mov x0, x20
0000000100007efc    bl  0x100007f50 ; Objc message: -[x0 setTransform:]

ObjC (164 bytes for the two setTransform: calls):

0000000100007e68    ldur    q0, [x29, #-0x80]
0000000100007e6c    str q0, [sp, #&#8203;0xb0]
0000000100007e70    ldur    q0, [x29, #-0x90]
0000000100007e74    str q0, [sp, #&#8203;0xa0]
0000000100007e78    ldur    q0, [x29, #-0xa0]
0000000100007e7c    str q0, [sp, #&#8203;0x90]
0000000100007e80    ldur    q0, [x29, #-0xb0]
0000000100007e84    str q0, [sp, #&#8203;0x80]
0000000100007e88    ldur    q0, [x29, #-0x40]
0000000100007e8c    str q0, [sp, #&#8203;0xf0]
0000000100007e90    ldur    q0, [x29, #-0x50]
0000000100007e94    str q0, [sp, #&#8203;0xe0]
0000000100007e98    ldur    q0, [x29, #-0x60]
0000000100007e9c    str q0, [sp, #&#8203;0xd0]
0000000100007ea0    ldur    q0, [x29, #-0x70]
0000000100007ea4    str q0, [sp, #&#8203;0xc0]
0000000100007ea8    nop
0000000100007eac    ldr x21, #&#8203;0x18c ; Objc selector ref: setTransform:
0000000100007eb0    add x2, sp, #&#8203;0x80
0000000100007eb4    mov x0, x19
0000000100007eb8    mov x1, x21
0000000100007ebc    bl  0x100007f58 ; Objc message: -[x0 setTransform:]
0000000100007ec0    ldur    q0, [x29, #-0x80]
0000000100007ec4    str q0, [sp, #&#8203;0x30]
0000000100007ec8    ldur    q0, [x29, #-0x90]
0000000100007ecc    str q0, [sp, #&#8203;0x20]
0000000100007ed0    ldur    q0, [x29, #-0xa0]
0000000100007ed4    str q0, [sp, #&#8203;0x10]
0000000100007ed8    ldur    q0, [x29, #-0xb0]
0000000100007edc    str q0, [sp]
0000000100007ee0    ldur    q0, [x29, #-0x40]
0000000100007ee4    str q0, [sp, #&#8203;0x70]
0000000100007ee8    ldur    q0, [x29, #-0x50]
0000000100007eec    str q0, [sp, #&#8203;0x60]
0000000100007ef0    ldur    q0, [x29, #-0x60]
0000000100007ef4    str q0, [sp, #&#8203;0x50]
0000000100007ef8    ldur    q0, [x29, #-0x70]
0000000100007efc    str q0, [sp, #&#8203;0x40]
0000000100007f00    mov x2, sp
0000000100007f04    mov x0, x20
0000000100007f08    mov x1, x21
0000000100007f0c    bl  0x100007f58 ; Objc message: -[x0 setTransform:]

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code size compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant