Skip to content

Commit

Permalink
Make React Profiler asm position independent
Browse files Browse the repository at this point in the history
Reviewed By: compnerd

Differential Revision: D4297098

fbshipit-source-id: 567f640f2d1ed4187e53356e7ca2d066f1412f9d
  • Loading branch information
stepanhruda authored and Facebook Github Bot committed Dec 8, 2016
1 parent 4a6f2ec commit 1642b38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion React/Profiler/RCTMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
#define _CONCAT(A, B) A##B
#define CONCAT(A, B) _CONCAT(A, B)

#define SYMBOL_NAME(S) CONCAT(__USER_LABEL_PREFIX__, S)
#if !defined(PIC_MODIFIER)
#define PIC_MODIFIER
#endif

#define SYMBOL_NAME(name) CONCAT(__USER_LABEL_PREFIX__, name)
#define SYMBOL_NAME_PIC(name) CONCAT(SYMBOL_NAME(name), PIC_MODIFIER)
10 changes: 5 additions & 5 deletions React/Profiler/RCTProfileTrampoline-x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
* This is a C function defined in `RCTProfile.m`, the object and the selector
* already have to be on %rdi and %rsi respectively, as in any ObjC call.
*/
callq SYMBOL_NAME(RCTProfileGetImplementation)
callq SYMBOL_NAME_PIC(RCTProfileGetImplementation)

// Restore/unalign the stack pointer, so we can access the registers we stored
movq %r12, %rsp
Expand Down Expand Up @@ -90,7 +90,7 @@ SYMBOL_NAME(RCTProfileTrampoline):

// allocate 16 bytes
movq $0x10, %rdi
callq SYMBOL_NAME(malloc)
callq SYMBOL_NAME_PIC(malloc)

// store the initial value of calle saved registers %r13 and %r14
movq %r13, 0x0(%rax)
Expand All @@ -108,7 +108,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
movq 0x38(%r12), %rsi // selector

// void RCTProfileTrampolineStart(id, SEL) in RCTProfile.m
callq SYMBOL_NAME(RCTProfileTrampolineStart)
callq SYMBOL_NAME_PIC(RCTProfileTrampolineStart)

// unalign the stack and restore %r12
movq %r12, %rsp
Expand Down Expand Up @@ -148,7 +148,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
movdqa %xmm1, 0x10(%rsp)

// void RCTProfileTrampolineEnd(void) in RCTProfile.m - just ends this profile
callq SYMBOL_NAME(RCTProfileTrampolineEnd)
callq SYMBOL_NAME_PIC(RCTProfileTrampolineEnd)

/**
* Restore the initial value of the callee saved registers, saved in the
Expand All @@ -169,7 +169,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
andq $-0x10, %rsp

// Free the memory allocated to stash callee saved registers
callq SYMBOL_NAME(free)
callq SYMBOL_NAME_PIC(free)

// unalign stack and restore %r12
movq %r12, %rsp
Expand Down

0 comments on commit 1642b38

Please sign in to comment.