Are gtests executed on the primordial thread?

Thomas Stüfe thomas.stuefe at gmail.com
Thu Dec 15 10:03:32 UTC 2016


Hi David,

On Thu, Dec 15, 2016 at 9:48 AM, David Holmes <david.holmes at oracle.com>
wrote:

> Hi Thomas,
>
> On 15/12/2016 6:27 PM, Thomas Stüfe wrote:
>
>> Hi all,
>>
>> It seems to me the gtestLauncher executes its tests on the primordial
>> thread. Is that correct?
>>
>
> I think so, but I'm unclear how gtest hangs together.


I am trying to figure out the details. Unfortunately there does not seem to
be much documentation.

 It looks like there is this special version of the libjvm.so, containing
all gtests, and the gtestLauncher hard-links (-lvm) against this library.
The first TEST_VM.. test running seems to trigger CreateJavaVM, and this
seems to happen on the primordial thread. Confusingly though, when running
all tests and logging, I see CreateJavaVM running multiple times. But this
could stem from TEST_OTHER_VM type tests running.

There are still a number of things unclear to me, like which TEST_.. macros
to use when, which asserts to use (I see hotspot asserts in tests, but
would them firing not prevent any subsequent tests from being run?), how to
pass VM options to the launcher etc... I think I have a rough
understanding, but a documentation would still be nice.


>
>
> If yes, would it not be better to run the test on a separate thread,
>>
>
> That would then require some platform specific threading code ... unless
> we assume pthreads?
>
>
We could reuse the libjli. For that matter, I wonder if we could not just
have used the standard java launcher to run the gtests. But I am no expert
and there probably were good reasons.

similar to how the standard launcher creates the VM? That way the tests
>> would be closer to what the actual usage scenario of the VM.
>>
>> Depending on the platform, there are quite a bit of differences between
>> running on the primordial thread or on a secondary pthread. Currently
>> invoking the VM on AIX on the primordial thread does not work at all - we
>> excluded that scenario for a number of reasons when doing the initial
>> port,
>> and even though we could rethink this decision I would prefer not having
>> to
>> deal with that right now just to be able to run the gtests.
>>
>
> The only difference I'm aware of is the initial stack setup and the stack
> guard configuration. Are there others?
>
>
Primordial stack usually lives in the program stack segment, wheras the
pthread stacks are allocated from somewhere else, in case of AIX from the
data segment. On AIX, both may have different page sizes - which annoyingly
can be configured from the outside - so you would have to deal with that.

Also, we were not able to retrieve the stack dimensions for the primordial
thread, and I also think mprotect did not work either, so no guard pages
could be set. As I said, we could take another look, because things may
have changed in the last 10 years.

Thomas

David
> -----
>
> Thanks, Thomas
>>
>>


More information about the hotspot-runtime-dev mailing list