Skip to content

Commit f8b9fcf

Browse files
author
Joshua Warner
committed
split asm files by architecture (x86 -> i386,x86_64 ; arm -> arm,arm64)
1 parent ba4f4a0 commit f8b9fcf

10 files changed

+774
-261
lines changed

makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ vm-sources = \
12061206
$(src)/jnienv.cpp \
12071207
$(src)/process.cpp
12081208

1209-
vm-asm-sources = $(src)/$(asm).$(asm-format)
1209+
vm-asm-sources = $(src)/$(arch).$(asm-format)
12101210

12111211
target-asm = $(asm)
12121212

@@ -1257,7 +1257,7 @@ ifeq ($(process),compile)
12571257
endif
12581258
endif
12591259

1260-
vm-asm-sources += $(src)/compile-$(asm).$(asm-format)
1260+
vm-asm-sources += $(src)/compile-$(arch).$(asm-format)
12611261
endif
12621262
cflags += -DAVIAN_PROCESS_$(process)
12631263
ifeq ($(aot-only),true)

src/arm.S

-130
Original file line numberDiff line numberDiff line change
@@ -21,134 +21,6 @@
2121
# define GLOBAL(x) x
2222
#endif
2323

24-
#ifdef __aarch64__
25-
26-
.globl GLOBAL(vmNativeCall)
27-
.align 2
28-
GLOBAL(vmNativeCall):
29-
// arguments:
30-
// x0 -> x19 : function
31-
// w1 -> w20 : stackTotal
32-
// x2 : memoryTable
33-
// w3 : memoryCount
34-
// x4 -> x21 : gprTable
35-
// x5 -> x22 : vfpTable
36-
// w6 -> w23 : returnType
37-
38-
// allocate frame
39-
stp x29, x30, [sp,#-64]!
40-
41-
// save callee-saved register values so we can clobber them
42-
stp x19, x20, [sp,#16]
43-
stp x21, x22, [sp,#32]
44-
str x23, [sp,#48]
45-
46-
// move arguments into callee-saved registers
47-
mov x19, x0
48-
mov w20, w1
49-
mov x21, x4
50-
mov x22, x5
51-
mov w23, w6
52-
53-
// setup stack arguments if necessary
54-
sub sp, sp, w20, uxtw // allocate stack
55-
mov x9, sp
56-
LOCAL(loop):
57-
cmp w3, wzr
58-
b.eq LOCAL(populateGPRs)
59-
ldr x0, [x2], #8
60-
str x0, [x9], #8
61-
sub w3, w3, #8
62-
b LOCAL(loop)
63-
64-
LOCAL(populateGPRs):
65-
cmp x21, xzr
66-
b.eq LOCAL(populateVFPs)
67-
ldp x0, x1, [x21]
68-
ldp x2, x3, [x21,#16]
69-
ldp x4, x5, [x21,#32]
70-
ldp x6, x7, [x21,#48]
71-
72-
LOCAL(populateVFPs):
73-
cmp x22, xzr
74-
b.eq LOCAL(doCall)
75-
ldp d0, d1, [x22]
76-
ldp d2, d3, [x22,#16]
77-
ldp d4, d5, [x22,#32]
78-
ldp d6, d7, [x22,#48]
79-
80-
LOCAL(doCall):
81-
blr x19 // call function
82-
add sp, sp, w20, uxtw // deallocate stack
83-
84-
cmp w23,#FLOAT_TYPE
85-
b.ne LOCAL(double)
86-
fmov w0,s0
87-
b LOCAL(exit)
88-
89-
LOCAL(double):
90-
cmp w23,#DOUBLE_TYPE
91-
b.ne LOCAL(exit)
92-
fmov x0,d0
93-
94-
LOCAL(exit):
95-
ldp x19, x20, [sp,#16]
96-
ldp x21, x22, [sp,#32]
97-
ldr x23, [sp,#48]
98-
ldp x29, x30, [sp],#64
99-
ret
100-
101-
.globl GLOBAL(vmJump)
102-
.align 2
103-
GLOBAL(vmJump):
104-
mov x30, x0
105-
mov x0, x4
106-
mov x1, x5
107-
mov sp, x2
108-
mov x19, x3
109-
br x30
110-
111-
#define CHECKPOINT_THREAD 8
112-
#define CHECKPOINT_STACK 48
113-
114-
.globl GLOBAL(vmRun)
115-
.align 2
116-
GLOBAL(vmRun):
117-
// x0: function
118-
// x1: arguments
119-
// x2: checkpoint
120-
121-
// allocate frame
122-
stp x29, x30, [sp,#-96]!
123-
124-
// save callee-saved register values
125-
stp x19, x20, [sp,#16]
126-
stp x21, x22, [sp,#32]
127-
stp x23, x24, [sp,#48]
128-
stp x25, x26, [sp,#64]
129-
stp x27, x28, [sp,#80]
130-
131-
mov x19, sp
132-
str x19, [x2, #CHECKPOINT_STACK]
133-
134-
mov x19, x0
135-
ldr x0, [x2, #CHECKPOINT_THREAD]
136-
137-
blr x19
138-
139-
.globl GLOBAL(vmRun_returnAddress)
140-
.align 2
141-
GLOBAL(vmRun_returnAddress):
142-
ldp x19, x20, [sp,#16]
143-
ldp x21, x22, [sp,#32]
144-
ldp x23, x24, [sp,#48]
145-
ldp x25, x26, [sp,#64]
146-
ldp x27, x28, [sp,#80]
147-
ldp x29, x30, [sp],#96
148-
br x30
149-
150-
#elif defined __arm__
151-
15224
.globl GLOBAL(vmNativeCall)
15325
.align 2
15426
GLOBAL(vmNativeCall):
@@ -258,5 +130,3 @@ GLOBAL(vmRun_returnAddress):
258130
add sp, sp, #12
259131
ldmfd sp!, {r4-r11, lr}
260132
bx lr
261-
262-
#endif // __arm__

src/arm64.S

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/* arm.S: JNI gluecode for ARM
2+
Copyright (c) 2008-2014, Avian Contributors
3+
4+
Permission to use, copy, modify, and/or distribute this software
5+
for any purpose with or without fee is hereby granted, provided
6+
that the above copyright notice and this permission notice appear
7+
in all copies.
8+
9+
There is NO WARRANTY for this software. See license.txt for
10+
details. */
11+
12+
#include "avian/types.h"
13+
14+
.text
15+
16+
#define LOCAL(x) .L##x
17+
18+
#ifdef __APPLE__
19+
# define GLOBAL(x) _##x
20+
#else
21+
# define GLOBAL(x) x
22+
#endif
23+
24+
.globl GLOBAL(vmNativeCall)
25+
.align 2
26+
GLOBAL(vmNativeCall):
27+
// arguments:
28+
// x0 -> x19 : function
29+
// w1 -> w20 : stackTotal
30+
// x2 : memoryTable
31+
// w3 : memoryCount
32+
// x4 -> x21 : gprTable
33+
// x5 -> x22 : vfpTable
34+
// w6 -> w23 : returnType
35+
36+
// allocate frame
37+
stp x29, x30, [sp,#-64]!
38+
39+
// save callee-saved register values so we can clobber them
40+
stp x19, x20, [sp,#16]
41+
stp x21, x22, [sp,#32]
42+
str x23, [sp,#48]
43+
44+
// move arguments into callee-saved registers
45+
mov x19, x0
46+
mov w20, w1
47+
mov x21, x4
48+
mov x22, x5
49+
mov w23, w6
50+
51+
// setup stack arguments if necessary
52+
sub sp, sp, w20, uxtw // allocate stack
53+
mov x9, sp
54+
LOCAL(loop):
55+
cmp w3, wzr
56+
b.eq LOCAL(populateGPRs)
57+
ldr x0, [x2], #8
58+
str x0, [x9], #8
59+
sub w3, w3, #8
60+
b LOCAL(loop)
61+
62+
LOCAL(populateGPRs):
63+
cmp x21, xzr
64+
b.eq LOCAL(populateVFPs)
65+
ldp x0, x1, [x21]
66+
ldp x2, x3, [x21,#16]
67+
ldp x4, x5, [x21,#32]
68+
ldp x6, x7, [x21,#48]
69+
70+
LOCAL(populateVFPs):
71+
cmp x22, xzr
72+
b.eq LOCAL(doCall)
73+
ldp d0, d1, [x22]
74+
ldp d2, d3, [x22,#16]
75+
ldp d4, d5, [x22,#32]
76+
ldp d6, d7, [x22,#48]
77+
78+
LOCAL(doCall):
79+
blr x19 // call function
80+
add sp, sp, w20, uxtw // deallocate stack
81+
82+
cmp w23,#FLOAT_TYPE
83+
b.ne LOCAL(double)
84+
fmov w0,s0
85+
b LOCAL(exit)
86+
87+
LOCAL(double):
88+
cmp w23,#DOUBLE_TYPE
89+
b.ne LOCAL(exit)
90+
fmov x0,d0
91+
92+
LOCAL(exit):
93+
ldp x19, x20, [sp,#16]
94+
ldp x21, x22, [sp,#32]
95+
ldr x23, [sp,#48]
96+
ldp x29, x30, [sp],#64
97+
ret
98+
99+
.globl GLOBAL(vmJump)
100+
.align 2
101+
GLOBAL(vmJump):
102+
mov x30, x0
103+
mov x0, x4
104+
mov x1, x5
105+
mov sp, x2
106+
mov x19, x3
107+
br x30
108+
109+
#define CHECKPOINT_THREAD 8
110+
#define CHECKPOINT_STACK 48
111+
112+
.globl GLOBAL(vmRun)
113+
.align 2
114+
GLOBAL(vmRun):
115+
// x0: function
116+
// x1: arguments
117+
// x2: checkpoint
118+
119+
// allocate frame
120+
stp x29, x30, [sp,#-96]!
121+
122+
// save callee-saved register values
123+
stp x19, x20, [sp,#16]
124+
stp x21, x22, [sp,#32]
125+
stp x23, x24, [sp,#48]
126+
stp x25, x26, [sp,#64]
127+
stp x27, x28, [sp,#80]
128+
129+
mov x19, sp
130+
str x19, [x2, #CHECKPOINT_STACK]
131+
132+
mov x19, x0
133+
ldr x0, [x2, #CHECKPOINT_THREAD]
134+
135+
blr x19
136+
137+
.globl GLOBAL(vmRun_returnAddress)
138+
.align 2
139+
GLOBAL(vmRun_returnAddress):
140+
ldp x19, x20, [sp,#16]
141+
ldp x21, x22, [sp,#32]
142+
ldp x23, x24, [sp,#48]
143+
ldp x25, x26, [sp,#64]
144+
ldp x27, x28, [sp,#80]
145+
ldp x29, x30, [sp],#96
146+
br x30

src/compile-arm64.S

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Copyright (c) 2008-2014, Avian Contributors
2+
3+
Permission to use, copy, modify, and/or distribute this software
4+
for any purpose with or without fee is hereby granted, provided
5+
that the above copyright notice and this permission notice appear
6+
in all copies.
7+
8+
There is NO WARRANTY for this software. See license.txt for
9+
details. */
10+
11+
#include "avian/types.h"
12+
#include "avian/target-fields.h"
13+
14+
.text
15+
16+
#define BYTES_PER_WORD 4
17+
18+
#define LOCAL(x) .L##x
19+
20+
#ifdef __APPLE__
21+
# define GLOBAL(x) _##x
22+
#else
23+
# define GLOBAL(x) x
24+
#endif
25+
26+
#error not implemented
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)