Kaydet (Commit) e3c0b6e6 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Revert rtl_alloc_preInit back to boolean argument

This effectively reverts 271a663d "rtl: support
start/stop threads around pre-init" again, now that
df6ba650 "Remove 'officially dead now' rtl_cache
slab allocator mechanism" removed the wsupdate thread.

(rtl_alloc_preInit is an internal-use-only C function, so changing its arguments
doesn't affect URE compatibility.)

Change-Id: Ie9bce86377f9520e2600e4111ac525dddace10f8
Reviewed-on: https://gerrit.libreoffice.org/58443
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst df6270e9
...@@ -3815,9 +3815,9 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char ...@@ -3815,9 +3815,9 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
return 1; return 1;
if (eStage == PRE_INIT) if (eStage == PRE_INIT)
rtl_alloc_preInit(rtlAllocPreInitStart); rtl_alloc_preInit(true);
else if (eStage == SECOND_INIT) else if (eStage == SECOND_INIT)
rtl_alloc_preInit(rtlAllocPreInitEnd); rtl_alloc_preInit(false);
if (eStage != SECOND_INIT) if (eStage != SECOND_INIT)
comphelper::LibreOfficeKit::setActive(); comphelper::LibreOfficeKit::setActive();
......
...@@ -288,30 +288,6 @@ SAL_DLLPUBLIC void SAL_CALL rtl_cache_free ( ...@@ -288,30 +288,6 @@ SAL_DLLPUBLIC void SAL_CALL rtl_cache_free (
#ifdef LIBO_INTERNAL_ONLY #ifdef LIBO_INTERNAL_ONLY
/** @cond INTERNAL */
/** rtl_alloc_preInit_phase_t
*
* This is used to control the pre-init logic
* in rtl_alloc_preInit. The reason for this is
* to first initialize all caching and other memory
* logic from WSD (the Online daemon) at startup.
* All these pages will then be forked over when
* spawning per-document instances. This is done
* by calling rtl_alloc_preInit with rtlAllocPreInitStart.
*
* @since LibreOffice 6.1
*/
typedef enum
{
// Start phase I of pre-init.
rtlAllocPreInitStart,
// Finish phase I of pre-init (before forking).
rtlAllocPreInitEnd,
// Post pre-init and after forking; no longer used.
rtlAllocPostInit
} rtl_alloc_preInit_phase_t;
/** @cond INTERNAL */ /** @cond INTERNAL */
/** rtl_alloc_preInit /** rtl_alloc_preInit
* *
...@@ -319,8 +295,8 @@ typedef enum ...@@ -319,8 +295,8 @@ typedef enum
* at the end of LibreOfficeKit pre-initialization to enable * at the end of LibreOfficeKit pre-initialization to enable
* various optimizations. * various optimizations.
* *
* Its function is to annotate a section @phase = rtlAllocPreInitStart * Its function is to annotate a section @start = true
* to end (@phase = rtlAllocPreInitEnd) via. two calls. Inside this * to end (@start = false) via. two calls. Inside this
* section string allocators are replaced with ones which cause the * section string allocators are replaced with ones which cause the
* strings to be staticized at the end of the section. * strings to be staticized at the end of the section.
* *
...@@ -341,7 +317,7 @@ typedef enum ...@@ -341,7 +317,7 @@ typedef enum
* @since LibreOffice 6.1 * @since LibreOffice 6.1
*/ */
SAL_DLLPUBLIC void SAL_CALL rtl_alloc_preInit ( SAL_DLLPUBLIC void SAL_CALL rtl_alloc_preInit (
rtl_alloc_preInit_phase_t phase sal_Bool start
) SAL_THROW_EXTERN_C(); ) SAL_THROW_EXTERN_C();
/** @endcond */ /** @endcond */
......
...@@ -158,7 +158,7 @@ public: ...@@ -158,7 +158,7 @@ public:
const char *sample = "Hello World"; const char *sample = "Hello World";
std::vector<OUString> aStrings; std::vector<OUString> aStrings;
rtl_alloc_preInit(rtlAllocPreInitStart); rtl_alloc_preInit(true);
OUString aFoo("foo"); OUString aFoo("foo");
...@@ -183,7 +183,7 @@ public: ...@@ -183,7 +183,7 @@ public:
} }
// should static-ize all the strings. // should static-ize all the strings.
rtl_alloc_preInit(rtlAllocPreInitEnd); rtl_alloc_preInit(false);
for (size_t i = 0; i < aStrings.size(); ++i) for (size_t i = 0; i < aStrings.size(); ++i)
CPPUNIT_ASSERT_MESSAGE( "static after.", (aStrings[i].pData->refCount & SAL_STRING_STATIC_FLAG) ); CPPUNIT_ASSERT_MESSAGE( "static after.", (aStrings[i].pData->refCount & SAL_STRING_STATIC_FLAG) );
......
...@@ -94,36 +94,26 @@ static void mark_static(void *addr, sal_Size /* size */) ...@@ -94,36 +94,26 @@ static void mark_static(void *addr, sal_Size /* size */)
str->refCount |= SAL_STRING_STATIC_FLAG; str->refCount |= SAL_STRING_STATIC_FLAG;
} }
void SAL_CALL rtl_alloc_preInit (rtl_alloc_preInit_phase_t phase) SAL_THROW_EXTERN_C() void SAL_CALL rtl_alloc_preInit (sal_Bool start) SAL_THROW_EXTERN_C()
{ {
switch (phase) if (start)
{ {
case rtlAllocPreInitStart: rtl_allocateString = pre_allocateStringFn;
{ rtl_freeString = pre_freeStringFn;
rtl_allocateString = pre_allocateStringFn; pre_arena = rtl_arena_create("pre-init strings", 4, 0,
rtl_freeString = pre_freeStringFn; nullptr, rtl_arena_alloc,
pre_arena = rtl_arena_create("pre-init strings", 4, 0, rtl_arena_free, 0);
nullptr, rtl_arena_alloc,
rtl_arena_free, 0); // To be consistent (and to ensure the rtl_cache threads are started).
ensureCacheSingleton();
// To be consistent (and to ensure the rtl_cache threads are started). }
ensureCacheSingleton(); else
} {
break; rtl_arena_foreach(pre_arena, mark_static);
rtl_allocateString = rtl_allocateMemory;
case rtlAllocPreInitEnd: rtl_freeString = rtl_freeMemory;
// back to normal
{ // TODO: also re-initialize main allocator as well.
rtl_arena_foreach(pre_arena, mark_static);
rtl_allocateString = rtl_allocateMemory;
rtl_freeString = rtl_freeMemory;
// TODO: also re-initialize main allocator as well.
}
break;
case rtlAllocPostInit: // no longer used
break;
} }
} }
......
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