ObjFW  Check-in [780d096371]

Overview
Comment:invocation: Make all offsets constants

This makes the assembly much more readable.

No difference between disassembled .o file before and after.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 780d0963712b39e53c30ac0e12ef7075cd993952b4fa530b8f7cc67ea937972c
User & Date: js on 2019-02-18 01:37:36
Other Links: manifest | tags
Context
2019-02-18
20:55
Replace a few movdqa with movaps check-in: a1da5c7b2d user: js tags: trunk
01:37
invocation: Make all offsets constants check-in: 780d096371 user: js tags: trunk
2019-02-17
22:44
tests: Only import ObjFW.h check-in: dc0c6c34ab user: js tags: trunk
Changes

Modified src/forwarding/forwarding-x86_64-elf.S from [024a3c3b09] to [bf0e91fafa].

91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105







-
+







	movq	-0x18(%rbp), %rsi
	movq	-0x10(%rbp), %rdi
	movq	-0x8(%rbp), %rax

	movq	%rbp, %rsp
	popq	%rbp

	jmpq     *%r11
	jmpq	*%r11

0:
	movq	-0x10(%rbp), %rdi
	movq	-0x18(%rbp), %rsi

	movq	%rbp, %rsp
	popq	%rbp
177
178
179
180
181
182
183
184

185
186
187
188
189
190
191
177
178
179
180
181
182
183

184
185
186
187
188
189
190
191







-
+







	movq	-0x18(%rbp), %rsi
	movq	-0x10(%rbp), %rdi
	movq	-0x8(%rbp), %rax

	movq	%rbp, %rsp
	popq	%rbp

	jmpq     *%r11
	jmpq	*%r11

0:
	movq	-0x10(%rbp), %rdi
	movq	-0x18(%rbp), %rsi
	movq	-0x20(%rbp), %rdx

	movq	%rbp, %rsp

Modified src/forwarding/forwarding-x86_64-macho.S from [dbba3c172d] to [4197c22f3e].

91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105







-
+







	movq	-0x18(%rbp), %rsi
	movq	-0x10(%rbp), %rdi
	movq	-0x8(%rbp), %rax

	movq	%rbp, %rsp
	popq	%rbp

	jmpq     *%r11
	jmpq	*%r11

0:
	movq	-0x10(%rbp), %rdi
	movq	-0x18(%rbp), %rsi

	movq	%rbp, %rsp
	popq	%rbp
175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
175
176
177
178
179
180
181

182
183
184
185
186
187
188
189







-
+







	movq	-0x18(%rbp), %rsi
	movq	-0x10(%rbp), %rdi
	movq	-0x8(%rbp), %rax

	movq	%rbp, %rsp
	popq	%rbp

	jmpq     *%r11
	jmpq	*%r11

0:
	movq	-0x10(%rbp), %rdi
	movq	-0x18(%rbp), %rsi
	movq	-0x20(%rbp), %rdx

	movq	%rbp, %rsp

Modified src/forwarding/forwarding-x86_64-win64.S from [0abe827006] to [be30bb9442].

77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
77
78
79
80
81
82
83

84
85
86
87
88
89
90
91







-
+







	movq	-0x38(%rbp), %rdx
	movq	-0x30(%rbp), %rcx
	movq	-0x28(%rbp), %rax

	movq	%rbp, %rsp
	popq	%rbp

	jmpq     *%r11
	jmpq	*%r11

0:
	movq	-0x30(%rbp), %rcx
	movq	-0x38(%rbp), %rdx

	movq	%rbp, %rsp
	popq	%rbp
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163







-
+







	movq	-0x38(%rbp), %rdx
	movq	-0x30(%rbp), %rcx
	movq	-0x28(%rbp), %rax

	movq	%rbp, %rsp
	popq	%rbp

	jmpq     *%r11
	jmpq	*%r11

0:
	movq	-0x30(%rbp), %rcx
	movq	-0x38(%rbp), %rdx
	movq	-0x40(%rbp), %r8

	movq	%rbp, %rsp

Modified src/invocation/apple-call-x86_64.S from [0efe8758d7] to [2b14e6dad4].

26
27
28
29
30
31
32
33
34


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59








60
61
62
63
64
65





66
67
68


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86




87
88

89
90
91
92
93
94
95
26
27
28
29
30
31
32


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

50
51








52
53
54
55
56
57
58
59
60





61
62
63
64
65
66


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82




83
84
85
86
87

88
89
90
91
92
93
94
95







-
-
+
+















-
+

-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+

-
-
+
+














-
-
-
-
+
+
+
+

-
+







	pushq	%rbp
	movq	%rsp, %rbp

	subq	$16, %rsp
	andq	$-16, %rsp
	movq	%rdi, -8(%rbp)

	leaq	240(%rdi), %rdx
	movq	232(%rdi), %rcx
	leaq	OFFSET_STACK(%rdi), %rdx
	movq	OFFSET_STACK_SIZE(%rdi), %rcx

	testq	$1, %rcx
	jnz	Lfix_align

Lfill_stack:
	testq	%rcx, %rcx
	jz	Lstack_filled

	decq	%rcx
	movq	(%rdx,%rcx,8), %r11
	pushq	%r11

	jmp	Lfill_stack

Lstack_filled:
	movb	224(%rdi), %al
	movb	OFFSET_NUM_SSE_USED(%rdi), %al

	movdqa	176(%rdi), %xmm7
	movdqa	160(%rdi), %xmm6
	movdqa	144(%rdi), %xmm5
	movdqa	128(%rdi), %xmm4
	movdqa	112(%rdi), %xmm3
	movdqa	96(%rdi), %xmm2
	movdqa	80(%rdi), %xmm1
	movdqa	64(%rdi), %xmm0
	movdqa	OFFSET_SSE_INOUT+112(%rdi), %xmm7
	movdqa	OFFSET_SSE_INOUT+96(%rdi), %xmm6
	movdqa	OFFSET_SSE_INOUT+80(%rdi), %xmm5
	movdqa	OFFSET_SSE_INOUT+64(%rdi), %xmm4
	movdqa	OFFSET_SSE_INOUT+48(%rdi), %xmm3
	movdqa	OFFSET_SSE_INOUT+32(%rdi), %xmm2
	movdqa	OFFSET_SSE_INOUT+16(%rdi), %xmm1
	movdqa	OFFSET_SSE_INOUT(%rdi), %xmm0

	movq	40(%rdi), %r9
	movq	32(%rdi), %r8
	movq	24(%rdi), %rcx
	movq	16(%rdi), %rdx
	movq	8(%rdi), %rsi
	movq	OFFSET_GPR_IN+40(%rdi), %r9
	movq	OFFSET_GPR_IN+32(%rdi), %r8
	movq	OFFSET_GPR_IN+24(%rdi), %rcx
	movq	OFFSET_GPR_IN+16(%rdi), %rdx
	movq	OFFSET_GPR_IN+8(%rdi), %rsi

	movb	225(%rdi), %r11b
	movq	0(%rdi), %rdi
	movb	OFFSET_RETURN_TYPE(%rdi), %r11b
	movq	OFFSET_GPR_IN(%rdi), %rdi

	cmpb	$RETURN_TYPE_STRET, %r11b
	je	Lcall_send_stret

	cmpb	$RETURN_TYPE_JMP, %r11b
	je	_objc_msgSend

	cmpb	$RETURN_TYPE_JMP_STRET, %r11b
	je	_objc_msgSend_stret

	call	_objc_msgSend

Lafter_send:
	movq	-8(%rbp), %rdi
	movq	%rax, 48(%rdi)
	movq	%rdx, 56(%rdi)
	movdqa	%xmm0, 64(%rdi)
	movdqa	%xmm1, 80(%rdi)
	movq	%rax, OFFSET_GPR_OUT(%rdi)
	movq	%rdx, OFFSET_GPR_OUT+8(%rdi)
	movdqa	%xmm0, OFFSET_SSE_INOUT(%rdi)
	movdqa	%xmm1, OFFSET_SSE_INOUT+16(%rdi)

	movb	225(%rdi), %r11b
	movb	OFFSET_RETURN_TYPE(%rdi), %r11b

	cmpb	$RETURN_TYPE_X87, %r11b
	je	Lpop_long_double

	cmpb	$RETURN_TYPE_COMPLEX_X87, %r11b
	je	Lpop_complex_long_double

105
106
107
108
109
110
111
112

113
114
115
116
117


118
105
106
107
108
109
110
111

112
113
114
115


116
117
118







-
+



-
-
+
+

	jmp	Lfill_stack

Lcall_send_stret:
	call	_objc_msgSend_stret
	jmp	Lafter_send

Lpop_long_double:
	fstpt	192(%rdi)
	fstpt	OFFSET_X87_OUT(%rdi)
	jmp	Lreturn

Lpop_complex_long_double:
	fstpt	192(%rdi)
	fstpt	208(%rdi)
	fstpt	OFFSET_X87_OUT(%rdi)
	fstpt	OFFSET_X87_OUT+16(%rdi)
	jmp	Lreturn

Modified src/invocation/call-x86_64-elf.S from [dd3cafda04] to [d3f8a4b569].

26
27
28
29
30
31
32
33

34
35
36
37
38
39
40


41
42
43
44
45
46
47
48


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72
73








74
75
76
77
78
79





80
81
82


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97




98
99

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120


121
122
123
124
125
126
127
128
129
130

131
132
133
134
135


136
137
138
139
140
26
27
28
29
30
31
32

33
34
35
36
37
38


39
40
41
42
43
44
45
46


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65








66
67
68
69
70
71
72
73
74





75
76
77
78
79
80


81
82
83
84
85
86
87
88
89
90
91
92
93




94
95
96
97
98

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118


119
120
121
122
123
124
125
126
127
128
129

130
131
132
133


134
135
136
137
138
139
140







-
+





-
-
+
+






-
-
+
+















-
+

-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+

-
-
+
+











-
-
-
-
+
+
+
+

-
+



















-
-
+
+









-
+



-
-
+
+





	pushq	%rbp
	movq	%rsp, %rbp

	subq	$16, %rsp
	andq	$-16, %rsp
	movq	%rdi, -8(%rbp)

	movb	225(%rdi), %r11b
	movb	OFFSET_RETURN_TYPE(%rdi), %r11b
	cmpb	$RETURN_TYPE_STRET, %r11b
	je	.lookup_stret
	cmpb	$RETURN_TYPE_JMP_STRET, %r11b
	je	.lookup_stret

	movq	8(%rdi), %rsi
	movq	0(%rdi), %rdi
	movq	OFFSET_GPR_IN+8(%rdi), %rsi
	movq	OFFSET_GPR_IN+0(%rdi), %rdi
	call	objc_msg_lookup@PLT

.after_lookup:
	movq	%rax, -16(%rbp)
	movq	-8(%rbp), %rdi

	leaq	240(%rdi), %rdx
	movq	232(%rdi), %rcx
	leaq	OFFSET_STACK(%rdi), %rdx
	movq	OFFSET_STACK_SIZE(%rdi), %rcx

	testq	$1, %rcx
	jnz	.fix_align

.fill_stack:
	testq	%rcx, %rcx
	jz	.stack_filled

	decq	%rcx
	movq	(%rdx,%rcx,8), %r11
	pushq	%r11

	jmp	.fill_stack

.stack_filled:
	movb	224(%rdi), %al
	movb	OFFSET_NUM_SSE_USED(%rdi), %al

	movdqa	176(%rdi), %xmm7
	movdqa	160(%rdi), %xmm6
	movdqa	144(%rdi), %xmm5
	movdqa	128(%rdi), %xmm4
	movdqa	112(%rdi), %xmm3
	movdqa	96(%rdi), %xmm2
	movdqa	80(%rdi), %xmm1
	movdqa	64(%rdi), %xmm0
	movdqa	OFFSET_SSE_INOUT+112(%rdi), %xmm7
	movdqa	OFFSET_SSE_INOUT+96(%rdi), %xmm6
	movdqa	OFFSET_SSE_INOUT+80(%rdi), %xmm5
	movdqa	OFFSET_SSE_INOUT+64(%rdi), %xmm4
	movdqa	OFFSET_SSE_INOUT+48(%rdi), %xmm3
	movdqa	OFFSET_SSE_INOUT+32(%rdi), %xmm2
	movdqa	OFFSET_SSE_INOUT+16(%rdi), %xmm1
	movdqa	OFFSET_SSE_INOUT(%rdi), %xmm0

	movq	40(%rdi), %r9
	movq	32(%rdi), %r8
	movq	24(%rdi), %rcx
	movq	16(%rdi), %rdx
	movq	8(%rdi), %rsi
	movq	OFFSET_GPR_IN+40(%rdi), %r9
	movq	OFFSET_GPR_IN+32(%rdi), %r8
	movq	OFFSET_GPR_IN+24(%rdi), %rcx
	movq	OFFSET_GPR_IN+16(%rdi), %rdx
	movq	OFFSET_GPR_IN+8(%rdi), %rsi

	movb	225(%rdi), %r11b
	movq	0(%rdi), %rdi
	movb	OFFSET_RETURN_TYPE(%rdi), %r11b
	movq	OFFSET_GPR_IN(%rdi), %rdi

	cmpb	$RETURN_TYPE_JMP, %r11b
	je	.jmp_into_method
	cmpb	$RETURN_TYPE_JMP_STRET, %r11b
	je	.jmp_into_method

	movq	-16(%rbp), %r11
	call	*%r11

.after_send:
	movq	-8(%rbp), %rdi
	movq	%rax, 48(%rdi)
	movq	%rdx, 56(%rdi)
	movdqa	%xmm0, 64(%rdi)
	movdqa	%xmm1, 80(%rdi)
	movq	%rax, OFFSET_GPR_OUT(%rdi)
	movq	%rdx, OFFSET_GPR_OUT+8(%rdi)
	movdqa	%xmm0, OFFSET_SSE_INOUT(%rdi)
	movdqa	%xmm1, OFFSET_SSE_INOUT+16(%rdi)

	movb	225(%rdi), %r11b
	movb	OFFSET_RETURN_TYPE(%rdi), %r11b

	cmpb	$RETURN_TYPE_X87, %r11b
	je	.pop_long_double

	cmpb	$RETURN_TYPE_COMPLEX_X87, %r11b
	je	.pop_complex_long_double

.return:
	movq	%rbp, %rsp
	popq	%rbp

	ret

.fix_align:
	xorq	%r11, %r11
	pushq	%r11
	jmp	.fill_stack

.lookup_stret:
	movq	16(%rdi), %rsi
	movq	8(%rdi), %rdi
	movq	OFFSET_GPR_IN+16(%rdi), %rsi
	movq	OFFSET_GPR_IN+8(%rdi), %rdi
	call	objc_msg_lookup_stret@PLT

	jmp	.after_lookup

.jmp_into_method:
	movq	-16(%rbp), %r11
	jmp	*%r11

.pop_long_double:
	fstpt	192(%rdi)
	fstpt	OFFSET_X87_OUT(%rdi)
	jmp	.return

.pop_complex_long_double:
	fstpt	192(%rdi)
	fstpt	208(%rdi)
	fstpt	OFFSET_X87_OUT(%rdi)
	fstpt	OFFSET_X87_OUT+16(%rdi)
	jmp	.return

#ifdef OF_LINUX
.section .note.GNU-stack, "", %progbits
#endif

Modified src/invocation/invoke-x86_64.h from [901f61cec1] to [e663702067].

17
18
19
20
21
22
23














17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37







+
+
+
+
+
+
+
+
+
+
+
+
+
+

#define RETURN_TYPE_NORMAL	0
#define RETURN_TYPE_STRET	1
#define RETURN_TYPE_X87		2
#define RETURN_TYPE_COMPLEX_X87	3
#define RETURN_TYPE_JMP		4
#define RETURN_TYPE_JMP_STRET	5

#define NUM_GPR_IN	6
#define NUM_GPR_OUT	2
#define NUM_SSE_INOUT	8
#define NUM_X87_OUT	2

#define OFFSET_GPR_IN		0
#define OFFSET_GPR_OUT		(OFFSET_GPR_IN + NUM_GPR_IN * 8)
#define OFFSET_SSE_INOUT	(OFFSET_GPR_OUT + NUM_GPR_OUT * 8)
#define OFFSET_X87_OUT		(OFFSET_SSE_INOUT + NUM_SSE_INOUT * 16)
#define OFFSET_NUM_SSE_USED	(OFFSET_X87_OUT + NUM_X87_OUT * 16)
#define OFFSET_RETURN_TYPE	(OFFSET_NUM_SSE_USED + 1)
#define OFFSET_STACK_SIZE	(OFFSET_RETURN_TYPE + 7)
#define OFFSET_STACK		(OFFSET_STACK_SIZE + 8)

Modified src/invocation/invoke-x86_64.m from [9312a70bd8] to [47d3793287].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
27
28
29
30
31
32
33





34
35

36
37
38
39
40
41
42
43







-
-
-
-
-


-
+







#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"

#import "invoke-x86_64.h"

#import "macros.h"

#define NUM_GPR_IN 6
#define NUM_GPR_OUT 2
#define NUM_SSE_IN 8
#define NUM_X87_OUT 2

struct call_context {
	uint64_t GPR[NUM_GPR_IN + NUM_GPR_OUT];
	__m128 SSE[NUM_SSE_IN];
	__m128 SSE[NUM_SSE_INOUT];
	long double X87[NUM_X87_OUT];
	uint8_t numSSEUsed;
	uint8_t returnType;
	uint64_t stackSize;
	uint64_t stack[];
};

72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81







-
+








static void
pushDouble(struct call_context **context, uint_fast8_t *currentSSE,
    double value)
{
	struct call_context *newContext;

	if (*currentSSE < NUM_SSE_IN) {
	if (*currentSSE < NUM_SSE_INOUT) {
		(*context)->SSE[(*currentSSE)++] = (__m128)_mm_set_sd(value);
		(*context)->numSSEUsed++;
		return;
	}

	if ((newContext = realloc(*context,
	    sizeof(**context) + ((*context)->stackSize + 1) * 8)) == NULL) {
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
92
93
94
95
96
97
98

99
100
101
102
103
104
105
106







-
+







static void
pushQuad(struct call_context **context, uint_fast8_t *currentSSE,
    double low, double high)
{
	size_t stackSize;
	struct call_context *newContext;

	if (*currentSSE + 1 < NUM_SSE_IN) {
	if (*currentSSE + 1 < NUM_SSE_INOUT) {
		(*context)->SSE[(*currentSSE)++] = (__m128)_mm_set_sd(low);
		(*context)->SSE[(*currentSSE)++] = (__m128)_mm_set_sd(high);
		(*context)->numSSEUsed += 2;
		return;
	}

	stackSize = (*context)->stackSize + 2;