Skip to content

Commit b867157

Browse files
authored
Merge pull request #171 from madsmtm/better-assembly-tests
Better assembly tests
2 parents e2dc4b3 + bc5b235 commit b867157

25 files changed

+201
-181
lines changed

tests/assembly/test_msg_send_zero_cost/expected/aarch64-apple-darwin.s

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/aarch64-apple-ios-sim.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/aarch64-apple-ios.s

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.section __TEXT,__text,regular,pure_instructions
2+
.globl _handle
3+
.p2align 2
4+
_handle:
5+
b _objc_msgSend
6+
7+
.globl _handle_with_sel
8+
.p2align 2
9+
_handle_with_sel:
10+
Lloh0:
11+
adrp x8, _SEL_REF@PAGE
12+
Lloh1:
13+
ldr x1, [x8, _SEL_REF@PAGEOFF]
14+
b _objc_msgSend
15+
.loh AdrpLdr Lloh0, Lloh1
16+
17+
.section __TEXT,__const
18+
.globl _SEL
19+
_SEL:
20+
.asciz "someSelector"
21+
22+
.section __DATA,__const
23+
.globl _SEL_REF
24+
.p2align 3
25+
_SEL_REF:
26+
.quad _SEL
27+
28+
.subsections_via_symbols
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.section __TEXT,__text,regular,pure_instructions
2+
.syntax unified
3+
.globl _handle
4+
.p2align 2
5+
.code 32
6+
_handle:
7+
b _objc_msgSend
8+
9+
.globl _handle_with_sel
10+
.p2align 2
11+
.code 32
12+
_handle_with_sel:
13+
movw r1, :lower16:(_SEL_REF-(LPC1_0+8))
14+
movt r1, :upper16:(_SEL_REF-(LPC1_0+8))
15+
LPC1_0:
16+
ldr r1, [pc, r1]
17+
b _objc_msgSend
18+
19+
.section __TEXT,__const
20+
.globl _SEL
21+
_SEL:
22+
.asciz "someSelector"
23+
24+
.section __DATA,__const
25+
.globl _SEL_REF
26+
.p2align 2
27+
_SEL_REF:
28+
.long _SEL
29+
30+
.subsections_via_symbols
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.section __TEXT,__text,regular,pure_instructions
2+
.syntax unified
3+
.globl _handle
4+
.p2align 2
5+
.code 32
6+
_handle:
7+
push {r7, lr}
8+
mov r7, sp
9+
bl _objc_msgSend
10+
pop {r7, pc}
11+
12+
.globl _handle_with_sel
13+
.p2align 2
14+
.code 32
15+
_handle_with_sel:
16+
push {r7, lr}
17+
mov r7, sp
18+
movw r1, :lower16:(_SEL_REF-(LPC1_0+8))
19+
movt r1, :upper16:(_SEL_REF-(LPC1_0+8))
20+
LPC1_0:
21+
ldr r1, [pc, r1]
22+
bl _objc_msgSend
23+
pop {r7, pc}
24+
25+
.section __TEXT,__const
26+
.globl _SEL
27+
_SEL:
28+
.asciz "someSelector"
29+
30+
.section __DATA,__const
31+
.globl _SEL_REF
32+
.p2align 2
33+
_SEL_REF:
34+
.long _SEL
35+
36+
.subsections_via_symbols
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.section __TEXT,__text,regular,pure_instructions
2+
.intel_syntax noprefix
3+
.globl _handle
4+
.p2align 4, 0x90
5+
_handle:
6+
push ebp
7+
mov ebp, esp
8+
pop ebp
9+
jmp _objc_msgSend
10+
11+
.globl _handle_with_sel
12+
.p2align 4, 0x90
13+
_handle_with_sel:
14+
push ebp
15+
mov ebp, esp
16+
sub esp, 8
17+
call L1$pb
18+
L1$pb:
19+
pop eax
20+
sub esp, 8
21+
push dword ptr [eax + _SEL_REF-L1$pb]
22+
push dword ptr [ebp + 8]
23+
call _objc_msgSend
24+
add esp, 24
25+
pop ebp
26+
ret
27+
28+
.section __TEXT,__const
29+
.globl _SEL
30+
_SEL:
31+
.asciz "someSelector"
32+
33+
.section __DATA,__const
34+
.globl _SEL_REF
35+
.p2align 2
36+
_SEL_REF:
37+
.long _SEL
38+
39+
.subsections_via_symbols
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.section __TEXT,__text,regular,pure_instructions
2+
.intel_syntax noprefix
3+
.globl _handle
4+
.p2align 4, 0x90
5+
_handle:
6+
push rbp
7+
mov rbp, rsp
8+
pop rbp
9+
jmp _objc_msgSend
10+
11+
.globl _handle_with_sel
12+
.p2align 4, 0x90
13+
_handle_with_sel:
14+
push rbp
15+
mov rbp, rsp
16+
mov rsi, qword ptr [rip + _SEL_REF]
17+
pop rbp
18+
jmp _objc_msgSend
19+
20+
.section __TEXT,__const
21+
.globl _SEL
22+
_SEL:
23+
.asciz "someSelector"
24+
25+
.section __DATA,__const
26+
.globl _SEL_REF
27+
.p2align 3
28+
_SEL_REF:
29+
.quad _SEL
30+
31+
.subsections_via_symbols

tests/assembly/test_msg_send_zero_cost/expected/armv7-apple-ios.s

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/armv7s-apple-ios.s

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/i386-apple-ios.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/i686-apple-darwin.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/x86_64-apple-darwin.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/expected/x86_64-apple-ios.s

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/assembly/test_msg_send_zero_cost/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! Test that the inner part of msg_send! is inlined into an objc_msgSend
2+
use core::mem;
3+
use core::ptr;
24

35
use objc2::runtime::{Object, Sel};
46
use objc2::MessageReceiver;
@@ -7,3 +9,19 @@ use objc2::MessageReceiver;
79
pub fn handle(obj: &Object, sel: Sel) -> *mut Object {
810
unsafe { MessageReceiver::send_message(obj, sel, ()).unwrap() }
911
}
12+
13+
// This will definitely not work, but is useful for making the assembly look
14+
// closer to real-world.
15+
#[no_mangle]
16+
static SEL: [u8; 13] = *b"someSelector\0";
17+
#[no_mangle]
18+
static SEL_REF: Sel = unsafe { mem::transmute(SEL.as_ptr()) };
19+
20+
fn selector() -> Sel {
21+
unsafe { ptr::read_volatile(&SEL_REF) }
22+
}
23+
24+
#[no_mangle]
25+
pub fn handle_with_sel(obj: &Object) -> *mut Object {
26+
unsafe { MessageReceiver::send_message(obj, selector(), ()).unwrap() }
27+
}

tests/assembly/test_retain_autoreleased/expected/aarch64-apple-ios-sim.s

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/assembly/test_retain_autoreleased/expected/aarch64-apple-ios.s

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/assembly/test_retain_autoreleased/expected/i686-apple-darwin.s

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/assembly/test_retain_autoreleased/expected/x86_64-apple-ios.s

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)