Skip to content

Clean up places that need to distinguish Q type from L type prefix #12237

Open

Description

@hzongaro

In the prototype implementation of value types support, the letter Q is used as a prefix in the bytecode for the signatures of classes that are value types, as distinguished from concrete identity type classes, interfaces and abstract classes, whose signatures are prefixed with the letter L.

Minimal changes to handle the Q prefix in the JIT compiler were merged into OpenJ9 in pull request #9030.

Charlene @Charlmzz prototyped additional changes in the JIT compiler for places in OpenJ9 and OMR where the JIT compiler checks for a prefix of L that likely should also check for a prefix of Q.

These changes need to be double-checked for correctness and completeness, and should be delivered with any necessary corrections. They can be found in commit 6fa5892 and OMR commit eclipse-omr/omr@b12967f

Activity

  1. Lawqup commented on Mar 18, 2021

    @Lawqup

    I'd like to work on this issue if anyone else isn't. I'm quite new to this so I would appreciate some clarification on what I should do.

    In 6fa5892 I see changes like this:

    - if (targetType[0] == 'L')
    + if (targetType[0] == 'L' || targetType[0] == 'Q')

    Where most cases with type 'L' are being replaced with "L or Q" behavior.

    Am I on the right track here? In which files do changes need to be made?

  2. hzongaro commented on Mar 18, 2021

    @hzongaro
    MemberAuthor

    Thanks for your interest in helping with this issue @teriyakiSauce23!

    Where most cases with type 'L' are being replaced with "L or Q" behavior.
    Am I on the right track here? In which files do changes need to be made?

    Yes, that's right. In most cases, I expect we will just need to check for 'Q' and treat it the same as 'L' is treated. However, there might be cases where we will need to treat 'Q' differently from 'L'. Each instance will have to be examined to understand how the test of the prefix character is being used.

    In OpenJ9, you'll want to look at files within the runtime/compiler directory and its subdirectories. In OMR, look at files within the compiler directory and its subdirectories.

    I think the first step will be to look at Charlene's commits, and rebase them on the latest version of the code. Then the second step will be to check whether there are additional cases of checks for an 'L' prefix that Charlene missed or that have crept in since she implemented her changes. The last, and most important step will be a careful analysis of each test to determine whether it can simply be expanded to treat 'Q' in the same way 'L' is treated, or if some different kind of treatment is required. I'd be happy to help with figuring that out, and if there are cases where I'm unsure, there are many other developers who can advise us.

    If you're still interested, I will assign the issue to you.

  3. Lawqup commented on Mar 18, 2021

    @Lawqup

    Thank you! Yes, I'd like you to assign this to me. I'll start working on it today.

  4. Lawqup commented on Mar 18, 2021

    @Lawqup

    I was rebasing some of the code, and I noticed this change in 6fa5892:

       for (i = 0; i < numDims; i++)
          sig[i] = '[';
       if (* name != '[')
    -      sig[i++] = 'L';
    -   memcpy(sig+i, name, len);
    +      if (isValueTypeClass(myClass))
    +         sig[i++] = 'Q';
    +      else
    +         sig[i++] = 'L';
       i += len;
       if (* name != '[')
          sig[i++] = ';';

    Is there a reason memcpy(sig+i, name, len); isn't moved to after the if statement? Seems like removing it would yield different behavior.

  5. hzongaro commented on Mar 19, 2021

    @hzongaro
    MemberAuthor

    Is there a reason memcpy(sig+i, name, len); isn't moved to after the if statement? Seems like removing it would yield different behavior.

    Hmmm - I don't see a reason why that memcopy should have been removed. Good catch!

  6. Lawqup commented on Mar 20, 2021

    @Lawqup

    I think I've changed nearly everything, but could have very well missed something as the compiler files are quite large. I looked at files that relate to classes mostly as I suspect the use of the prefixes would mostly be there. As for next steps, how would I go about testing everything?

  7. hzongaro commented on Mar 23, 2021

    @hzongaro
    MemberAuthor

    As for next steps, how would I go about testing everything?

    Thanks for the update, Lawrence @teriyakiSauce23 . For basic testing, if you haven't already read the following, you might want to check out https://github.com/eclipse/openj9/blob/master/test/docs/OpenJ9TestUserGuide.md. I'm by no means an expert on the contents of all the tests, but running _functional tests might be a good thing to try.

    In addition there are specific value types sanity tests that you can run specifying a functional/Valhalla as your BUILD_LIST. In order to run those value types tests, you'll need to enable the prototype value types support. You can do that by running the configure tool with the --enable-inline-types option included.

    Beyond that, as I said we'll probably need to go over each change carefully to understand the context in which the check is being performed, to verify that treating 'L' and 'Q' the same way is the right thing to do.

  8. hzongaro commented on Apr 16, 2021

    @hzongaro
    MemberAuthor

    @dsouzai Although I used the phrase "Clean up" in the title of this issue, it probably doesn't qualify as technical debt - it's part of the on-going prototype support for value types.

  9. hzongaro commented on Sep 1, 2021

    @hzongaro
    MemberAuthor

    Lawrence @Lawqup, are you still looking at this issue? Perhaps we could help you to get your changes through to delivery.

  10. a7ehuo commented on Sep 7, 2021

    @a7ehuo
    Contributor

    I'll take a look at Charlene's changes since more issues related to missing Q type descriptor is likely to surface when we do more tests

  11. a7ehuo commented on Sep 20, 2021

    @a7ehuo
    Contributor

    I updated Charlene's changes in openj9 #13535 and eclipse-omr/omr#6183. One left issue that's not covered in these two PR is the L reference in classNameToSignature in Aliases.cpp. The existing API classNameToSignature doesn't have a class pointer for us to distinguish if the class is a VT or not. It will not be a trivial change like the rest of them. It should be put in a separate PR.

    char *
    classNameToSignature(const char *name, int32_t &len, TR::Compilation * comp, TR_AllocationKind allocKind)
       {
       char * sig;
    
       if (name[0] == '[')
          {
    ...
          }
       else
          {
          len += 2;
          sig = (char *)comp->trMemory()->allocateMemory(len+1, allocKind);
          sig[0] = 'L';   <=== 
          memcpy(sig+1,name,len-2);
          sig[len-1]=';';
          }
  12. added 2 commits that reference this issue on Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions