-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable direct methods and fast alloc calls for libobjc2.
These will be supported in the upcoming 2.2 release and so are gated on that version. Direct methods call `objc_send_initialize` if they are class methods that may not have called initialize. This is guarded by checking for the class flag bit that is set on initialisation in the class. This bit now forms part of the ABI, but it's been stable for 30+ years so that's fine as a contract going forwards.
- Loading branch information
1 parent
8f76f18
commit c8d7334
Showing
3 changed files
with
230 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm -fobjc-runtime=gnustep-2.2 -o - %s | FileCheck %s | ||
|
||
@interface X | ||
@end | ||
|
||
@implementation X | ||
//- (int)x __attribute__((objc_direct)) { return 12; } | ||
- (int)x __attribute__((objc_direct)) { return 12; } | ||
|
||
// Check that the name is mangled like Objective-C methods and contains a nil check | ||
// CHECK-LABEL: @_i_X__x | ||
// CHECK: icmp eq ptr %0, null | ||
|
||
+ (int)clsMeth __attribute__((objc_direct)) { return 42; } | ||
// Check that the name is mangled like Objective-C methods and contains an initialisation check | ||
// CHECK-LABEL: @_c_X__clsMeth | ||
// CHECK: getelementptr inbounds { ptr, ptr, ptr, i64, i64 }, ptr %0, i32 0, i32 4 | ||
// CHECK: load i64, ptr %1, align 64 | ||
// CHECK: and i64 %2, 256 | ||
// CHECK: objc_direct_method.send_initialize: | ||
// CHECK: call void @objc_send_initialize(ptr %0) | ||
|
||
@end | ||
|
||
// Check that the call sides are set up correctly. | ||
void callCls(void) | ||
{ | ||
// CHECK: call i32 @_c_X__clsMeth | ||
[X clsMeth]; | ||
} | ||
|
||
void callInstance(X *x) | ||
{ | ||
// CHECK: call i32 @_i_X__x | ||
[x x]; | ||
} | ||
|