Commit 51af323d authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

AIX: base: Add Stack utilities

Port da409929

Original Commit Message:

    Adds:
    - GetStackStart
    - GetCurrentStackPosition
    - GetStackSlot which translates a stack slot through ASAN
      if needed

R=mlippautz@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Icdf50db1c4d0b6ce3c9819cda4663dc640ec6f43
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2144292Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#67092}
parent affc3646
......@@ -129,5 +129,46 @@ void OS::SignalCodeMovingGC() {}
void OS::AdjustSchedulingParams() {}
// static
void* Stack::GetStackStart() {
// Info about this subroutine can be found here:
// https://www.ibm.com/support/knowledgecenter/ssw_aix_72/p_bostechref/pthread_getthrds_np.html
// as well as the header file located under /usr/include/pthread.h in AIX.
// pthread_getthrds_np creates 3 values:
// __pi_stackaddr, __pi_stacksize, __pi_stackend
// __pi_stackend points to the higher address, stack base, since stack grows
// downwards.
// __pi_stackaddr points to the lower address, current sp location.
// __pi_stacksize is the size of the stack from the base in bytes.
// higher address ---------------- __pi_stackend
//
// |
// |
// |
// | __pi_stacksize, stack grows downwards
// |
// |
// |
// V
//
// lower address ---------------- __pi_stackaddr
pthread_t tid = pthread_self();
struct __pthrdsinfo buf;
// clear buf
memset(&buf, 0, sizeof(buf));
char regbuf[1];
int regbufsize = sizeof(regbuf);
const int rc = pthread_getthrds_np(&tid, PTHRDSINFO_QUERY_ALL, &buf,
sizeof(buf), regbuf, &regbufsize);
CHECK(!rc);
if (buf.__pi_stackend == NULL || buf.__pi_stackaddr == NULL) {
return nullptr;
}
return reinterpret_cast<void*>(buf.__pi_stackend);
}
} // namespace base
} // namespace v8
......@@ -970,7 +970,7 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
// pthread_getattr_np used below is non portable (hence the _np suffix). We
// keep this version in POSIX as most Linux-compatible derivatives will
// support it. MacOS and FreeBSD are different here.
#if !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX)
#if !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) && !defined(_AIX)
// static
void* Stack::GetStackStart() {
......@@ -996,7 +996,7 @@ void* Stack::GetStackStart() {
return nullptr;
}
#endif // !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX)
#endif // !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) && !defined(_AIX)
// static
void* Stack::GetCurrentStackPosition() { return __builtin_frame_address(0); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment