]> git.saurik.com Git - apple/objc4.git/blob - runtime/Messengers.subproj/objc-msg-arm.s
objc4-787.1.tar.gz
[apple/objc4.git] / runtime / Messengers.subproj / objc-msg-arm.s
1 /*
2 * @APPLE_LICENSE_HEADER_START@
3 *
4 * Copyright (c) 1999-2007 Apple Computer, Inc. All Rights Reserved.
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /********************************************************************
24 *
25 * objc-msg-arm.s - ARM code to support objc messaging
26 *
27 ********************************************************************/
28
29 #ifdef __arm__
30
31 #include <arm/arch.h>
32 #include "objc-config.h"
33 #include "isa.h"
34
35 #ifndef _ARM_ARCH_7
36 # error requires armv7
37 #endif
38
39 // Set FP=1 on architectures that pass parameters in floating-point registers
40 #if __ARM_ARCH_7K__
41 # define FP 1
42 #else
43 # define FP 0
44 #endif
45
46 #if FP
47
48 # if !__ARM_NEON__
49 # error sorry
50 # endif
51
52 # define FP_RETURN_ZERO \
53 vmov.i32 q0, #0 ; \
54 vmov.i32 q1, #0 ; \
55 vmov.i32 q2, #0 ; \
56 vmov.i32 q3, #0
57
58 # define FP_SAVE \
59 vpush {q0-q3}
60
61 # define FP_RESTORE \
62 vpop {q0-q3}
63
64 #else
65
66 # define FP_RETURN_ZERO
67 # define FP_SAVE
68 # define FP_RESTORE
69
70 #endif
71
72 .syntax unified
73
74 #define MI_EXTERN(var) \
75 .non_lazy_symbol_pointer ;\
76 L##var##$$non_lazy_ptr: ;\
77 .indirect_symbol var ;\
78 .long 0
79
80 #define MI_GET_EXTERN(reg,var) \
81 movw reg, :lower16:(L##var##$$non_lazy_ptr-7f-4) ;\
82 movt reg, :upper16:(L##var##$$non_lazy_ptr-7f-4) ;\
83 7: add reg, pc ;\
84 ldr reg, [reg]
85
86 #define MI_GET_ADDRESS(reg,var) \
87 movw reg, :lower16:(var-7f-4) ;\
88 movt reg, :upper16:(var-7f-4) ;\
89 7: add reg, pc ;\
90
91
92 .data
93
94 #if SUPPORT_INDEXED_ISA
95
96 .align 2
97 .globl _objc_indexed_classes
98 _objc_indexed_classes:
99 .fill ISA_INDEX_COUNT, 4, 0
100
101 #endif
102
103
104
105 // _objc_restartableRanges is used by method dispatch
106 // caching code to figure out whether any threads are actively
107 // in the cache for dispatching. The labels surround the asm code
108 // that do cache lookups. The tables are zero-terminated.
109
110 .macro RestartableEntry
111 .long LLookupStart$0
112 .long 0
113 .short LLookupEnd$0 - LLookupStart$0
114 .short 0xffff // poor ol' armv7 doesn't support kernel based recovery
115 .long 0
116 .endmacro
117
118 .align 4
119 .private_extern _objc_restartableRanges
120 _objc_restartableRanges:
121 RestartableEntry _cache_getImp
122 RestartableEntry _objc_msgSend
123 RestartableEntry _objc_msgSend_stret
124 RestartableEntry _objc_msgSendSuper
125 RestartableEntry _objc_msgSendSuper_stret
126 RestartableEntry _objc_msgSendSuper2
127 RestartableEntry _objc_msgSendSuper2_stret
128 RestartableEntry _objc_msgLookup
129 RestartableEntry _objc_msgLookup_stret
130 RestartableEntry _objc_msgLookupSuper2
131 RestartableEntry _objc_msgLookupSuper2_stret
132 .fill 16, 1, 0
133
134
135 /********************************************************************
136 * Names for relative labels
137 * DO NOT USE THESE LABELS ELSEWHERE
138 * Reserved labels: 6: 7: 8: 9:
139 ********************************************************************/
140 // 6: used by CacheLookup
141 // 7: used by MI_GET_ADDRESS etc
142 // 8: used by CacheLookup
143 #define LNilReceiver 9
144 #define LNilReceiver_f 9f
145 #define LNilReceiver_b 9b
146
147
148 /********************************************************************
149 * Macro parameters
150 ********************************************************************/
151
152 #define NORMAL 0
153 #define STRET 1
154
155
156 /********************************************************************
157 *
158 * Structure definitions.
159 *
160 ********************************************************************/
161
162 /* objc_super parameter to sendSuper */
163 #define RECEIVER 0
164 #define CLASS 4
165
166 /* Selected field offsets in class structure */
167 #define ISA 0
168 #define SUPERCLASS 4
169 #define CACHE 8
170 #define CACHE_MASK 12
171
172 /* Field offsets in method cache bucket */
173 #define CACHED_SEL 0
174 #define CACHED_IMP 4
175
176 /* Selected field offsets in method structure */
177 #define METHOD_NAME 0
178 #define METHOD_TYPES 4
179 #define METHOD_IMP 8
180
181
182 //////////////////////////////////////////////////////////////////////
183 //
184 // ENTRY functionName
185 //
186 // Assembly directives to begin an exported function.
187 //
188 // Takes: functionName - name of the exported function
189 //////////////////////////////////////////////////////////////////////
190
191 .macro ENTRY /* name */
192 .text
193 .thumb
194 .align 5
195 .globl $0
196 .thumb_func
197 $0:
198 .endmacro
199
200 .macro STATIC_ENTRY /*name*/
201 .text
202 .thumb
203 .align 5
204 .private_extern $0
205 .thumb_func
206 $0:
207 .endmacro
208
209
210 //////////////////////////////////////////////////////////////////////
211 //
212 // END_ENTRY functionName
213 //
214 // Assembly directives to end an exported function. Just a placeholder,
215 // a close-parenthesis for ENTRY, until it is needed for something.
216 //
217 // Takes: functionName - name of the exported function
218 //////////////////////////////////////////////////////////////////////
219
220 .macro END_ENTRY /* name */
221 LExit$0:
222 .endmacro
223
224
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
259 /////////////////////////////////////////////////////////////////////
260 //
261 // CacheLookup NORMAL|STRET <function>
262 // CacheLookup2 NORMAL|STRET <function>
263 //
264 // Locate the implementation for a selector in a class's method cache.
265 //
266 // Takes:
267 // $0 = NORMAL, STRET
268 // r0 or r1 (STRET) = receiver
269 // r1 or r2 (STRET) = selector
270 // r9 = class to search in
271 //
272 // On exit: r9 clobbered
273 // (found) continues after CacheLookup, IMP in r12, eq set
274 // (not found) continues after CacheLookup2
275 //
276 /////////////////////////////////////////////////////////////////////
277
278 .macro CacheLookup
279 //
280 // Restart protocol:
281 //
282 // As soon as we're past the LLookupStart$1 label we may have loaded
283 // an invalid cache pointer or mask.
284 //
285 // When task_restartable_ranges_synchronize() is called,
286 // (or when a signal hits us) before we're past LLookupEnd$1,
287 // then our PC will be reset to LCacheMiss$1 which forcefully
288 // jumps to the cache-miss codepath.
289 //
290 // It is assumed that the CacheMiss codepath starts right at the end
291 // of CacheLookup2 and will re-setup the registers to meet the cache-miss
292 // requirements:
293 //
294 // GETIMP:
295 // The cache-miss is just returning NULL (setting r9 to 0)
296 //
297 // NORMAL and STRET:
298 // - r0 or r1 (STRET) contains the receiver
299 // - r1 or r2 (STRET) contains the selector
300 // - r9 contains the isa (reloaded from r0/r1)
301 // - other registers are set as per calling conventions
302 //
303 LLookupStart$1:
304
305 ldrh r12, [r9, #CACHE_MASK] // r12 = mask
306 ldr r9, [r9, #CACHE] // r9 = buckets
307 .if $0 == STRET
308 and r12, r12, r2 // r12 = index = SEL & mask
309 .else
310 and r12, r12, r1 // r12 = index = SEL & mask
311 .endif
312 add r9, r9, r12, LSL #3 // r9 = bucket = buckets+index*8
313 ldr r12, [r9, #CACHED_SEL] // r12 = bucket->sel
314 6:
315 .if $0 == STRET
316 teq r12, r2
317 .else
318 teq r12, r1
319 .endif
320 bne 8f
321 ldr r12, [r9, #CACHED_IMP] // r12 = bucket->imp
322
323 .if $0 == STRET
324 tst r12, r12 // set ne for stret forwarding
325 .else
326 // eq already set for nonstret forwarding by `teq` above
327 .endif
328
329 .endmacro
330
331 .macro CacheLookup2
332 #if CACHED_SEL != 0
333 # error this code requires that SEL be at offset 0
334 #endif
335 8:
336 cmp r12, #1
337 blo LCacheMiss$1 // if (bucket->sel == 0) cache miss
338 it eq // if (bucket->sel == 1) cache wrap
339 ldreq r9, [r9, #CACHED_IMP] // bucket->imp is before first bucket
340 ldr r12, [r9, #8]! // r12 = (++bucket)->sel
341 b 6b
342
343 LLookupEnd$1:
344 LCacheMiss$1:
345
346 .endmacro
347
348 /////////////////////////////////////////////////////////////////////
349 //
350 // GetClassFromIsa return-type
351 //
352 // Given an Isa, return the class for the Isa.
353 //
354 // Takes:
355 // r9 = class
356 //
357 // On exit: r12 clobbered
358 // r9 contains the class for this Isa.
359 //
360 /////////////////////////////////////////////////////////////////////
361 .macro GetClassFromIsa
362
363 #if SUPPORT_INDEXED_ISA
364 // Note: We are doing a little wasted work here to load values we might not
365 // need. Branching turns out to be even worse when performance was measured.
366 MI_GET_ADDRESS(r12, _objc_indexed_classes)
367 tst.w r9, #ISA_INDEX_IS_NPI_MASK
368 itt ne
369 ubfxne r9, r9, #ISA_INDEX_SHIFT, #ISA_INDEX_BITS
370 ldrne.w r9, [r12, r9, lsl #2]
371 #endif
372
373 .endmacro
374
375
376 /********************************************************************
377 * IMP cache_getImp(Class cls, SEL sel)
378 *
379 * On entry: r0 = class whose cache is to be searched
380 * r1 = selector to search for
381 *
382 * If found, returns method implementation.
383 * If not found, returns NULL.
384 ********************************************************************/
385
386 STATIC_ENTRY _cache_getImp
387
388 mov r9, r0
389 CacheLookup NORMAL, _cache_getImp
390 // cache hit, IMP in r12
391 mov r0, r12
392 bx lr // return imp
393
394 CacheLookup2 GETIMP, _cache_getImp
395 // cache miss, return nil
396 mov r0, #0
397 bx lr
398
399 END_ENTRY _cache_getImp
400
401
402 /********************************************************************
403 *
404 * id objc_msgSend(id self, SEL _cmd, ...);
405 * IMP objc_msgLookup(id self, SEL _cmd, ...);
406 *
407 * objc_msgLookup ABI:
408 * IMP returned in r12
409 * Forwarding returned in Z flag
410 * r9 reserved for our use but not used
411 *
412 ********************************************************************/
413
414 ENTRY _objc_msgSend
415
416 cbz r0, LNilReceiver_f
417
418 ldr r9, [r0] // r9 = self->isa
419 GetClassFromIsa // r9 = class
420 CacheLookup NORMAL, _objc_msgSend
421 // cache hit, IMP in r12, eq already set for nonstret forwarding
422 bx r12 // call imp
423
424 CacheLookup2 NORMAL, _objc_msgSend
425 // cache miss
426 ldr r9, [r0] // r9 = self->isa
427 GetClassFromIsa // r9 = class
428 b __objc_msgSend_uncached
429
430 LNilReceiver:
431 // r0 is already zero
432 mov r1, #0
433 mov r2, #0
434 mov r3, #0
435 FP_RETURN_ZERO
436 bx lr
437
438 END_ENTRY _objc_msgSend
439
440
441 ENTRY _objc_msgLookup
442
443 cbz r0, LNilReceiver_f
444
445 ldr r9, [r0] // r9 = self->isa
446 GetClassFromIsa // r9 = class
447 CacheLookup NORMAL, _objc_msgLookup
448 // cache hit, IMP in r12, eq already set for nonstret forwarding
449 bx lr
450
451 CacheLookup2 NORMAL, _objc_msgLookup
452 // cache miss
453 ldr r9, [r0] // r9 = self->isa
454 GetClassFromIsa // r9 = class
455 b __objc_msgLookup_uncached
456
457 LNilReceiver:
458 MI_GET_ADDRESS(r12, __objc_msgNil)
459 bx lr
460
461 END_ENTRY _objc_msgLookup
462
463
464 STATIC_ENTRY __objc_msgNil
465
466 // r0 is already zero
467 mov r1, #0
468 mov r2, #0
469 mov r3, #0
470 FP_RETURN_ZERO
471 bx lr
472
473 END_ENTRY __objc_msgNil
474
475
476 /********************************************************************
477 * void objc_msgSend_stret(void *st_addr, id self, SEL op, ...);
478 * IMP objc_msgLookup_stret(void *st_addr, id self, SEL op, ...);
479 *
480 * objc_msgSend_stret is the struct-return form of msgSend.
481 * The ABI calls for r0 to be used as the address of the structure
482 * being returned, with the parameters in the succeeding registers.
483 *
484 * On entry: r0 is the address where the structure is returned,
485 * r1 is the message receiver,
486 * r2 is the selector
487 ********************************************************************/
488
489 ENTRY _objc_msgSend_stret
490
491 cbz r1, LNilReceiver_f
492
493 ldr r9, [r1] // r9 = self->isa
494 GetClassFromIsa // r9 = class
495 CacheLookup STRET, _objc_msgSend_stret
496 // cache hit, IMP in r12, ne already set for stret forwarding
497 bx r12
498
499 CacheLookup2 STRET, _objc_msgSend_stret
500 // cache miss
501 ldr r9, [r1] // r9 = self->isa
502 GetClassFromIsa // r9 = class
503 b __objc_msgSend_stret_uncached
504
505 LNilReceiver:
506 bx lr
507
508 END_ENTRY _objc_msgSend_stret
509
510
511 ENTRY _objc_msgLookup_stret
512
513 cbz r1, LNilReceiver_f
514
515 ldr r9, [r1] // r9 = self->isa
516 GetClassFromIsa // r9 = class
517 CacheLookup STRET, _objc_msgLookup_stret
518 // cache hit, IMP in r12, ne already set for stret forwarding
519 bx lr
520
521 CacheLookup2 STRET, _objc_msgLookup_stret
522 // cache miss
523 ldr r9, [r1] // r9 = self->isa
524 GetClassFromIsa // r9 = class
525 b __objc_msgLookup_stret_uncached
526
527 LNilReceiver:
528 MI_GET_ADDRESS(r12, __objc_msgNil_stret)
529 bx lr
530
531 END_ENTRY _objc_msgLookup_stret
532
533
534 STATIC_ENTRY __objc_msgNil_stret
535
536 bx lr
537
538 END_ENTRY __objc_msgNil_stret
539
540
541 /********************************************************************
542 * id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
543 *
544 * struct objc_super {
545 * id receiver;
546 * Class cls; // the class to search
547 * }
548 ********************************************************************/
549
550 ENTRY _objc_msgSendSuper
551
552 ldr r9, [r0, #CLASS] // r9 = struct super->class
553 CacheLookup NORMAL, _objc_msgSendSuper
554 // cache hit, IMP in r12, eq already set for nonstret forwarding
555 ldr r0, [r0, #RECEIVER] // load real receiver
556 bx r12 // call imp
557
558 CacheLookup2 NORMAL, _objc_msgSendSuper
559 // cache miss
560 ldr r9, [r0, #CLASS] // r9 = struct super->class
561 ldr r0, [r0, #RECEIVER] // load real receiver
562 b __objc_msgSend_uncached
563
564 END_ENTRY _objc_msgSendSuper
565
566
567 /********************************************************************
568 * id objc_msgSendSuper2(struct objc_super *super, SEL op, ...)
569 *
570 * struct objc_super {
571 * id receiver;
572 * Class cls; // SUBCLASS of the class to search
573 * }
574 ********************************************************************/
575
576 ENTRY _objc_msgSendSuper2
577
578 ldr r9, [r0, #CLASS] // class = struct super->class
579 ldr r9, [r9, #SUPERCLASS] // class = class->superclass
580 CacheLookup NORMAL, _objc_msgSendSuper2
581 // cache hit, IMP in r12, eq already set for nonstret forwarding
582 ldr r0, [r0, #RECEIVER] // load real receiver
583 bx r12 // call imp
584
585 CacheLookup2 NORMAL, _objc_msgSendSuper2
586 // cache miss
587 ldr r9, [r0, #CLASS] // class = struct super->class
588 ldr r9, [r9, #SUPERCLASS] // class = class->superclass
589 ldr r0, [r0, #RECEIVER] // load real receiver
590 b __objc_msgSend_uncached
591
592 END_ENTRY _objc_msgSendSuper2
593
594
595 ENTRY _objc_msgLookupSuper2
596
597 ldr r9, [r0, #CLASS] // class = struct super->class
598 ldr r9, [r9, #SUPERCLASS] // class = class->superclass
599 CacheLookup NORMAL, _objc_msgLookupSuper2
600 // cache hit, IMP in r12, eq already set for nonstret forwarding
601 ldr r0, [r0, #RECEIVER] // load real receiver
602 bx lr
603
604 CacheLookup2 NORMAL, _objc_msgLookupSuper2
605 // cache miss
606 ldr r9, [r0, #CLASS]
607 ldr r9, [r9, #SUPERCLASS] // r9 = class to search
608 ldr r0, [r0, #RECEIVER] // load real receiver
609 b __objc_msgLookup_uncached
610
611 END_ENTRY _objc_msgLookupSuper2
612
613
614 /********************************************************************
615 * void objc_msgSendSuper_stret(void *st_addr, objc_super *self, SEL op, ...);
616 *
617 * objc_msgSendSuper_stret is the struct-return form of msgSendSuper.
618 * The ABI calls for r0 to be used as the address of the structure
619 * being returned, with the parameters in the succeeding registers.
620 *
621 * On entry: r0 is the address where the structure is returned,
622 * r1 is the address of the objc_super structure,
623 * r2 is the selector
624 ********************************************************************/
625
626 ENTRY _objc_msgSendSuper_stret
627
628 ldr r9, [r1, #CLASS] // r9 = struct super->class
629 CacheLookup STRET, _objc_msgSendSuper_stret
630 // cache hit, IMP in r12, ne already set for stret forwarding
631 ldr r1, [r1, #RECEIVER] // load real receiver
632 bx r12 // call imp
633
634 CacheLookup2 STRET, _objc_msgSendSuper_stret
635 // cache miss
636 ldr r9, [r1, #CLASS] // r9 = struct super->class
637 ldr r1, [r1, #RECEIVER] // load real receiver
638 b __objc_msgSend_stret_uncached
639
640 END_ENTRY _objc_msgSendSuper_stret
641
642
643 /********************************************************************
644 * id objc_msgSendSuper2_stret
645 ********************************************************************/
646
647 ENTRY _objc_msgSendSuper2_stret
648
649 ldr r9, [r1, #CLASS] // class = struct super->class
650 ldr r9, [r9, #SUPERCLASS] // class = class->superclass
651 CacheLookup STRET, _objc_msgSendSuper2_stret
652 // cache hit, IMP in r12, ne already set for stret forwarding
653 ldr r1, [r1, #RECEIVER] // load real receiver
654 bx r12 // call imp
655
656 CacheLookup2 STRET, _objc_msgSendSuper2_stret
657 // cache miss
658 ldr r9, [r1, #CLASS] // class = struct super->class
659 ldr r9, [r9, #SUPERCLASS] // class = class->superclass
660 ldr r1, [r1, #RECEIVER] // load real receiver
661 b __objc_msgSend_stret_uncached
662
663 END_ENTRY _objc_msgSendSuper2_stret
664
665
666 ENTRY _objc_msgLookupSuper2_stret
667
668 ldr r9, [r1, #CLASS] // class = struct super->class
669 ldr r9, [r9, #SUPERCLASS] // class = class->superclass
670 CacheLookup STRET, _objc_msgLookupSuper2_stret
671 // cache hit, IMP in r12, ne already set for stret forwarding
672 ldr r1, [r1, #RECEIVER] // load real receiver
673 bx lr
674
675 CacheLookup2 STRET, _objc_msgLookupSuper2_stret
676 // cache miss
677 ldr r9, [r1, #CLASS]
678 ldr r9, [r9, #SUPERCLASS] // r9 = class to search
679 ldr r1, [r1, #RECEIVER] // load real receiver
680 b __objc_msgLookup_stret_uncached
681
682 END_ENTRY _objc_msgLookupSuper2_stret
683
684
685 /////////////////////////////////////////////////////////////////////
686 //
687 // MethodTableLookup NORMAL|STRET
688 //
689 // Locate the implementation for a selector in a class's method lists.
690 //
691 // Takes:
692 // $0 = NORMAL, STRET
693 // r0 or r1 (STRET) = receiver
694 // r1 or r2 (STRET) = selector
695 // r9 = class to search in
696 //
697 // On exit: IMP in r12, eq/ne set for forwarding
698 //
699 /////////////////////////////////////////////////////////////////////
700
701 .macro MethodTableLookup
702
703 SAVE_REGS
704
705 // lookUpImpOrForward(obj, sel, cls, LOOKUP_INITIALIZE | LOOKUP_RESOLVER)
706 .if $0 == NORMAL
707 // receiver already in r0
708 // selector already in r1
709 .else
710 mov r0, r1 // receiver
711 mov r1, r2 // selector
712 .endif
713 mov r2, r9 // class to search
714 mov r3, #3 // LOOKUP_INITIALIZE | LOOKUP_INITIALIZE
715 blx _lookUpImpOrForward
716 mov r12, r0 // r12 = IMP
717
718 .if $0 == NORMAL
719 cmp r12, r12 // set eq for nonstret forwarding
720 .else
721 tst r12, r12 // set ne for stret forwarding
722 .endif
723
724 RESTORE_REGS
725
726 .endmacro
727
728
729 /********************************************************************
730 *
731 * _objc_msgSend_uncached
732 * _objc_msgSend_stret_uncached
733 * _objc_msgLookup_uncached
734 * _objc_msgLookup_stret_uncached
735 * The uncached method lookup.
736 *
737 ********************************************************************/
738
739 STATIC_ENTRY __objc_msgSend_uncached
740
741 // THIS IS NOT A CALLABLE C FUNCTION
742 // Out-of-band r9 is the class to search
743
744 MethodTableLookup NORMAL // returns IMP in r12
745 bx r12
746
747 END_ENTRY __objc_msgSend_uncached
748
749
750 STATIC_ENTRY __objc_msgSend_stret_uncached
751
752 // THIS IS NOT A CALLABLE C FUNCTION
753 // Out-of-band r9 is the class to search
754
755 MethodTableLookup STRET // returns IMP in r12
756 bx r12
757
758 END_ENTRY __objc_msgSend_stret_uncached
759
760
761 STATIC_ENTRY __objc_msgLookup_uncached
762
763 // THIS IS NOT A CALLABLE C FUNCTION
764 // Out-of-band r9 is the class to search
765
766 MethodTableLookup NORMAL // returns IMP in r12
767 bx lr
768
769 END_ENTRY __objc_msgLookup_uncached
770
771
772 STATIC_ENTRY __objc_msgLookup_stret_uncached
773
774 // THIS IS NOT A CALLABLE C FUNCTION
775 // Out-of-band r9 is the class to search
776
777 MethodTableLookup STRET // returns IMP in r12
778 bx lr
779
780 END_ENTRY __objc_msgLookup_stret_uncached
781
782
783 /********************************************************************
784 *
785 * id _objc_msgForward(id self, SEL _cmd,...);
786 *
787 * _objc_msgForward and _objc_msgForward_stret are the externally-callable
788 * functions returned by things like method_getImplementation().
789 * _objc_msgForward_impcache is the function pointer actually stored in
790 * method caches.
791 *
792 ********************************************************************/
793
794 MI_EXTERN(__objc_forward_handler)
795 MI_EXTERN(__objc_forward_stret_handler)
796
797 STATIC_ENTRY __objc_msgForward_impcache
798 // Method cache version
799
800 // THIS IS NOT A CALLABLE C FUNCTION
801 // Out-of-band Z is 0 (EQ) for normal, 1 (NE) for stret
802
803 beq __objc_msgForward
804 b __objc_msgForward_stret
805
806 END_ENTRY __objc_msgForward_impcache
807
808
809 ENTRY __objc_msgForward
810 // Non-stret version
811
812 MI_GET_EXTERN(r12, __objc_forward_handler)
813 ldr r12, [r12]
814 bx r12
815
816 END_ENTRY __objc_msgForward
817
818
819 ENTRY __objc_msgForward_stret
820 // Struct-return version
821
822 MI_GET_EXTERN(r12, __objc_forward_stret_handler)
823 ldr r12, [r12]
824 bx r12
825
826 END_ENTRY __objc_msgForward_stret
827
828
829 ENTRY _objc_msgSend_noarg
830 b _objc_msgSend
831 END_ENTRY _objc_msgSend_noarg
832
833 ENTRY _objc_msgSend_debug
834 b _objc_msgSend
835 END_ENTRY _objc_msgSend_debug
836
837 ENTRY _objc_msgSendSuper2_debug
838 b _objc_msgSendSuper2
839 END_ENTRY _objc_msgSendSuper2_debug
840
841 ENTRY _objc_msgSend_stret_debug
842 b _objc_msgSend_stret
843 END_ENTRY _objc_msgSend_stret_debug
844
845 ENTRY _objc_msgSendSuper2_stret_debug
846 b _objc_msgSendSuper2_stret
847 END_ENTRY _objc_msgSendSuper2_stret_debug
848
849
850 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.
857 // r1 is method triplet instead of SEL
858 ldr r12, [r1, #METHOD_IMP]
859 ldr r1, [r1, #METHOD_NAME]
860 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
874 END_ENTRY _method_invoke
875
876
877 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.
884 // r2 is method triplet instead of SEL
885 ldr r12, [r2, #METHOD_IMP]
886 ldr r2, [r2, #METHOD_NAME]
887 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
900 END_ENTRY _method_invoke_stret
901
902
903 .section __DATA,__objc_msg_break
904 .long 0
905 .long 0
906
907 #endif