Skip to content

Commit 07bde11

Browse files
author
husihua
committed
objc runtime 787.1
1 parent d81d3e4 commit 07bde11

File tree

123 files changed

+4134
-1481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+4134
-1481
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# objc-runtime
2-
objc runtime 779.1
2+
objc runtime 787.1

libobjc.order

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ __objc_update_stubs_in_mach_header
1919
_sel_init
2020
___sel_registerName
2121
__objc_search_builtins
22-
__ZNK8objc_opt13objc_selopt_t3getEPKc
23-
__ZNK8objc_opt13objc_selopt_t4hashEPKc
2422
_sel_registerName
2523
_arr_init
2624
__ZN4objc8DenseMapIP11objc_objectmLb1ENS_12DenseMapInfoIS2_EENS3_ImEEE4initEj

objc.xcodeproj/project.pbxproj

+2-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
3044E26323D4626F006763E3 /* dyld_priv.h in Headers */ = {isa = PBXBuildFile; fileRef = 3044E22023D4626F006763E3 /* dyld_priv.h */; };
9999
3044E26423D4626F006763E3 /* OSCrossEndian.h in Headers */ = {isa = PBXBuildFile; fileRef = 3044E22223D4626F006763E3 /* OSCrossEndian.h */; };
100100
3044E26C23D47C0E006763E3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3044E26B23D47C0E006763E3 /* main.m */; };
101-
3044E27223D47C4F006763E3 /* libobjc.A.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC0630554660B00DB518D /* libobjc.A.dylib */; };
101+
309850AD25383A9700054FB3 /* libobjc.A.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC0630554660B00DB518D /* libobjc.A.dylib */; };
102102
393CEAC00DC69E3E000B69DE /* objc-references.mm in Sources */ = {isa = PBXBuildFile; fileRef = 393CEABF0DC69E3E000B69DE /* objc-references.mm */; };
103103
393CEAC60DC69E67000B69DE /* objc-references.h in Headers */ = {isa = PBXBuildFile; fileRef = 393CEAC50DC69E67000B69DE /* objc-references.h */; };
104104
39ABD72312F0B61800D1054C /* objc-weak.h in Headers */ = {isa = PBXBuildFile; fileRef = 39ABD71F12F0B61800D1054C /* objc-weak.h */; };
@@ -397,7 +397,7 @@
397397
isa = PBXFrameworksBuildPhase;
398398
buildActionMask = 2147483647;
399399
files = (
400-
3044E27223D47C4F006763E3 /* libobjc.A.dylib in Frameworks */,
400+
309850AD25383A9700054FB3 /* libobjc.A.dylib in Frameworks */,
401401
);
402402
runOnlyForDeploymentPostprocessing = 0;
403403
};
@@ -969,7 +969,6 @@
969969
08FB7793FE84155DC02AAC07 /* Project object */ = {
970970
isa = PBXProject;
971971
attributes = {
972-
BuildIndependentTargetsInParallel = NO;
973972
LastUpgradeCheck = 1130;
974973
TargetAttributes = {
975974
3044E26823D47C0E006763E3 = {

runtime/Messengers.subproj/objc-msg-arm.s

+73-7
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,40 @@ LExit$0:
222222
.endmacro
223223

224224

225+
//////////////////////////////////////////////////////////////////////
226+
//
227+
// SAVE_REGS
228+
//
229+
// Create a stack frame and save all argument registers in preparation
230+
// for a function call.
231+
//////////////////////////////////////////////////////////////////////
232+
233+
.macro SAVE_REGS
234+
235+
stmfd sp!, {r0-r3,r7,lr}
236+
add r7, sp, #16
237+
sub sp, #8 // align stack
238+
FP_SAVE
239+
240+
.endmacro
241+
242+
243+
//////////////////////////////////////////////////////////////////////
244+
//
245+
// RESTORE_REGS
246+
//
247+
// Restore all argument registers and pop the stack frame created by
248+
// SAVE_REGS.
249+
//////////////////////////////////////////////////////////////////////
250+
251+
.macro RESTORE_REGS
252+
253+
FP_RESTORE
254+
add sp, #8 // align stack
255+
ldmfd sp!, {r0-r3,r7,lr}
256+
257+
.endmacro
258+
225259
/////////////////////////////////////////////////////////////////////
226260
//
227261
// CacheLookup NORMAL|STRET <function>
@@ -666,10 +700,7 @@ LNilReceiver:
666700
667701
.macro MethodTableLookup
668702
669-
stmfd sp!, {r0-r3,r7,lr}
670-
add r7, sp, #16
671-
sub sp, #8 // align stack
672-
FP_SAVE
703+
SAVE_REGS
673704

674705
// lookUpImpOrForward(obj, sel, cls, LOOKUP_INITIALIZE | LOOKUP_RESOLVER)
675706
.if $0 == NORMAL
@@ -690,9 +721,7 @@ LNilReceiver:
690721
tst r12, r12 // set ne for stret forwarding
691722
.endif
692723

693-
FP_RESTORE
694-
add sp, #8 // align stack
695-
ldmfd sp!, {r0-r3,r7,lr}
724+
RESTORE_REGS
696725

697726
.endmacro
698727

@@ -819,18 +848,55 @@ LNilReceiver:
819848

820849

821850
ENTRY _method_invoke
851+
852+
// See if this is a small method.
853+
lsls r12, r1, #31
854+
bne.w L_method_invoke_small
855+
856+
// We can directly load the IMP from big methods.
822857
// r1 is method triplet instead of SEL
823858
ldr r12, [r1, #METHOD_IMP]
824859
ldr r1, [r1, #METHOD_NAME]
825860
bx r12
861+
862+
L_method_invoke_small:
863+
// Small methods require a call to handle swizzling.
864+
SAVE_REGS
865+
mov r0, r1
866+
bl __method_getImplementationAndName
867+
mov r12, r0
868+
mov r9, r1
869+
RESTORE_REGS
870+
mov r1, r9
871+
bx r12
872+
873+
826874
END_ENTRY _method_invoke
827875

828876

829877
ENTRY _method_invoke_stret
878+
879+
// See if this is a small method.
880+
lsls r12, r2, #31
881+
bne.w L_method_invoke_stret_small
882+
883+
// We can directly load the IMP from big methods.
830884
// r2 is method triplet instead of SEL
831885
ldr r12, [r2, #METHOD_IMP]
832886
ldr r2, [r2, #METHOD_NAME]
833887
bx r12
888+
889+
L_method_invoke_stret_small:
890+
// Small methods require a call to handle swizzling.
891+
SAVE_REGS
892+
mov r0, r2
893+
bl __method_getImplementationAndName
894+
mov r12, r0
895+
mov r9, r1
896+
RESTORE_REGS
897+
mov r2, r9
898+
bx r12
899+
834900
END_ENTRY _method_invoke_stret
835901
836902

runtime/Messengers.subproj/objc-msg-arm64.s

+86-31
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,63 @@ LExit$0:
169169
#define FrameWithNoSaves 0x04000000 // frame, no non-volatile saves
170170

171171

172+
//////////////////////////////////////////////////////////////////////
173+
//
174+
// SAVE_REGS
175+
//
176+
// Create a stack frame and save all argument registers in preparation
177+
// for a function call.
178+
//////////////////////////////////////////////////////////////////////
179+
180+
.macro SAVE_REGS
181+
182+
// push frame
183+
SignLR
184+
stp fp, lr, [sp, #-16]!
185+
mov fp, sp
186+
187+
// save parameter registers: x0..x8, q0..q7
188+
sub sp, sp, #(10*8 + 8*16)
189+
stp q0, q1, [sp, #(0*16)]
190+
stp q2, q3, [sp, #(2*16)]
191+
stp q4, q5, [sp, #(4*16)]
192+
stp q6, q7, [sp, #(6*16)]
193+
stp x0, x1, [sp, #(8*16+0*8)]
194+
stp x2, x3, [sp, #(8*16+2*8)]
195+
stp x4, x5, [sp, #(8*16+4*8)]
196+
stp x6, x7, [sp, #(8*16+6*8)]
197+
str x8, [sp, #(8*16+8*8)]
198+
199+
.endmacro
200+
201+
202+
//////////////////////////////////////////////////////////////////////
203+
//
204+
// RESTORE_REGS
205+
//
206+
// Restore all argument registers and pop the stack frame created by
207+
// SAVE_REGS.
208+
//////////////////////////////////////////////////////////////////////
209+
210+
.macro RESTORE_REGS
211+
212+
ldp q0, q1, [sp, #(0*16)]
213+
ldp q2, q3, [sp, #(2*16)]
214+
ldp q4, q5, [sp, #(4*16)]
215+
ldp q6, q7, [sp, #(6*16)]
216+
ldp x0, x1, [sp, #(8*16+0*8)]
217+
ldp x2, x3, [sp, #(8*16+2*8)]
218+
ldp x4, x5, [sp, #(8*16+4*8)]
219+
ldp x6, x7, [sp, #(8*16+6*8)]
220+
ldr x8, [sp, #(8*16+8*8)]
221+
222+
mov sp, fp
223+
ldp fp, lr, [sp], #16
224+
AuthenticateLR
225+
226+
.endmacro
227+
228+
172229
/********************************************************************
173230
*
174231
* CacheLookup NORMAL|GETIMP|LOOKUP <function>
@@ -494,22 +551,7 @@ LLookup_Nil:
494551

495552
.macro MethodTableLookup
496553
497-
// push frame
498-
SignLR
499-
stp fp, lr, [sp, #-16]!
500-
mov fp, sp
501-
502-
// save parameter registers: x0..x8, q0..q7
503-
sub sp, sp, #(10*8 + 8*16)
504-
stp q0, q1, [sp, #(0*16)]
505-
stp q2, q3, [sp, #(2*16)]
506-
stp q4, q5, [sp, #(4*16)]
507-
stp q6, q7, [sp, #(6*16)]
508-
stp x0, x1, [sp, #(8*16+0*8)]
509-
stp x2, x3, [sp, #(8*16+2*8)]
510-
stp x4, x5, [sp, #(8*16+4*8)]
511-
stp x6, x7, [sp, #(8*16+6*8)]
512-
str x8, [sp, #(8*16+8*8)]
554+
SAVE_REGS
513555

514556
// lookUpImpOrForward(obj, sel, cls, LOOKUP_INITIALIZE | LOOKUP_RESOLVER)
515557
// receiver and selector already in x0 and x1
@@ -519,21 +561,8 @@ LLookup_Nil:
519561

520562
// IMP in x0
521563
mov x17, x0
522-
523-
// restore registers and return
524-
ldp q0, q1, [sp, #(0*16)]
525-
ldp q2, q3, [sp, #(2*16)]
526-
ldp q4, q5, [sp, #(4*16)]
527-
ldp q6, q7, [sp, #(6*16)]
528-
ldp x0, x1, [sp, #(8*16+0*8)]
529-
ldp x2, x3, [sp, #(8*16+2*8)]
530-
ldp x4, x5, [sp, #(8*16+4*8)]
531-
ldp x6, x7, [sp, #(8*16+6*8)]
532-
ldr x8, [sp, #(8*16+8*8)]
533-
534-
mov sp, fp
535-
ldp fp, lr, [sp], #16
536-
AuthenticateLR
564+
565+
RESTORE_REGS
537566

538567
.endmacro
539568

@@ -615,11 +644,37 @@ LGetImpMiss:
615644

616645
617646
ENTRY _method_invoke
647+
648+
// See if this is a small method.
649+
tbnz p1, #0, L_method_invoke_small
650+
651+
// We can directly load the IMP from big methods.
618652
// x1 is method triplet instead of SEL
619653
add p16, p1, #METHOD_IMP
620654
ldr p17, [x16]
621655
ldr p1, [x1, #METHOD_NAME]
622656
TailCallMethodListImp x17, x16
657+
658+
L_method_invoke_small:
659+
// Small methods require a call to handle swizzling.
660+
SAVE_REGS
661+
mov p0, p1
662+
bl __method_getImplementationAndName
663+
// ARM64_32 packs both return values into x0, with SEL in the high bits and IMP in the low.
664+
// ARM64 just returns them in x0 and x1.
665+
mov x17, x0
666+
#if __LP64__
667+
mov x16, x1
668+
#endif
669+
RESTORE_REGS
670+
#if __LP64__
671+
mov x1, x16
672+
#else
673+
lsr x1, x17, #32
674+
mov w17, w17
675+
#endif
676+
TailCallFunctionPointer x17
677+
623678
END_ENTRY _method_invoke
624679

625680
#endif

0 commit comments

Comments
 (0)