Changeset 0ef03fc in OpenModelica


Ignore:
Timestamp:
2019-01-19T13:31:28+01:00 (5 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
683050ef
Parents:
23d8d265
git-author:
Anatoly Trosinenko <anatoly.trosinenko@…> (01/19/19 13:31:28)
git-committer:
hudson <openmodelica@…> (01/19/19 13:31:28)
Message:

Use the stack bottom value from the old threadData, if available

On linux, fetching the stack bottom involves huge amounts of user
and kernel CPU time. Assuming the stack bottom does not change over
time, copy it from the old threadData structure.

Belonging to [master]:

  • OpenModelica/OMCompiler#2884
Location:
SimulationRuntime/c/meta
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • SimulationRuntime/c/meta/meta_modelica_data.h

    rf5e1d77 r0ef03fc  
    249249#define MMC_ELSE() } else { threadData->mmc_jumper = old_jumper;
    250250
    251 #define MMC_TRY_TOP() { threadData_t threadDataOnStack = {0}, *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key),*threadData = &threadDataOnStack; pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow(threadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper; /* Let the default stack overflow handler be the top-level handler */
    252 
    253 #define MMC_TRY_TOP_SET(X) { threadData_t threadDataOnStack = *((threadData_t*)X), *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key),*threadData = &threadDataOnStack; pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow(threadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper; /* Let the default stack overflow handler be the top-level handler */
    254 
    255 #define MMC_TRY_TOP_INTERNAL() { threadData_t *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key); pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow(threadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper;
     251#define MMC_TRY_TOP() { threadData_t threadDataOnStack = {0}, *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key),*threadData = &threadDataOnStack; pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow_fast(threadData, oldThreadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper; /* Let the default stack overflow handler be the top-level handler */
     252
     253#define MMC_TRY_TOP_SET(X) { threadData_t threadDataOnStack = *((threadData_t*)X), *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key),*threadData = &threadDataOnStack; pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow_fast(threadData, oldThreadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper; /* Let the default stack overflow handler be the top-level handler */
     254
     255#define MMC_TRY_TOP_INTERNAL() { threadData_t *oldThreadData = (threadData_t*)pthread_getspecific(mmc_thread_data_key); pthread_setspecific(mmc_thread_data_key,threadData); pthread_mutex_init(&threadData->parentMutex,NULL); mmc_init_stackoverflow_fast(threadData, oldThreadData); MMC_TRY_INTERNAL(mmc_jumper) threadData->mmc_stack_overflow_jumper = threadData->mmc_jumper;
    256256#define MMC_CATCH_TOP(X) pthread_setspecific(mmc_thread_data_key,oldThreadData); } else {pthread_setspecific(mmc_thread_data_key,oldThreadData);X;}}}
    257257
  • SimulationRuntime/c/meta/meta_modelica_segv.h

    r80e3d34f r0ef03fc  
    5858#endif
    5959
     60#if defined(linux)
     61static inline void mmc_init_stackoverflow_fast(threadData_t *threadData, threadData_t *oldThreadData)
     62{
     63  if (oldThreadData)
     64    threadData->stackBottom = oldThreadData->stackBottom;
     65  else
     66    mmc_init_stackoverflow(threadData);
     67}
     68#else
     69static inline void mmc_init_stackoverflow_fast(threadData_t *threadData, threadData_t *oldThreadData)
     70{
     71  mmc_init_stackoverflow(threadData);
     72}
     73#endif
     74
    6075#ifndef __has_builtin
    6176  #define __has_builtin(x) 0  /* Compatibility with non-clang compilers */
Note: See TracChangeset for help on using the changeset viewer.