Skip to content

Commit b6fce4a

Browse files
tadeuzagallofacebook-github-bot-5
authored andcommitted
Prevent the profiler from hooking into stret methods
Summary: public In order to handle methods that returns struct in i386 and x86_64 we'd need to implement special methods (like objc_msgSend_stret), but we'll just bail out for now, since there's very few usages. Reviewed By: jspahrsummers Differential Revision: D2754732 fb-gh-sync-id: d3585d244633d918770ef79a52dee9cdf87a53da
1 parent c8108bd commit b6fce4a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

React/Profiler/RCTProfile.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,20 @@ void RCTProfileHookModules(RCTBridge *bridge)
232232
for (NSUInteger i = 0; i < methodCount; i++) {
233233
Method method = methods[i];
234234
SEL selector = method_getName(method);
235-
if ([NSStringFromSelector(selector) hasPrefix:@"rct"] || [NSObject instancesRespondToSelector:selector]) {
235+
236+
/**
237+
* Bail out on struct returns (except arm64) - we don't use it enough
238+
* to justify writing a stret version
239+
*/
240+
#ifdef __arm64__
241+
BOOL returnsStruct = NO;
242+
#else
243+
const char *typeEncoding = method_getTypeEncoding(method);
244+
// bail out on structs and unions (since they might contain structs)
245+
BOOL returnsStruct = typeEncoding[0] == '{' || typeEncoding[0] == '(';
246+
#endif
247+
248+
if ([NSStringFromSelector(selector) hasPrefix:@"rct"] || [NSObject instancesRespondToSelector:selector] || returnsStruct) {
236249
continue;
237250
}
238251
const char *types = method_getTypeEncoding(method);

0 commit comments

Comments
 (0)