Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8173070

Remove ValueObj class for allocation subclassing for runtime code

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P3
    • 11
    • 9
    • hotspot
    • None
    • b07

    Description

      The classes in src/share/vm/memory/allocation.hpp were created so that we could document and/or enforce memory allocation strategy for classes that subclass these classes.

      They are StackObj, CHeapObj, MetaspaceObj, ResourceObj as some examples.

      The ValueObj one was for classes that would be embedded in other objects or otherwise have no allocation through 'new'. This class has 'new' and 'delete' operators that assert.

      Then there's the problem where we have to use the macro
      // Base class for objects used as value objects.
      // Calling new or delete will result in fatal error.
      //
      // Portability note: Certain compilers (e.g. gcc) will
      // always make classes bigger if it has a superclass, even
      // if the superclass does not have any virtual methods or
      // instance fields. The HotSpot implementation relies on this
      // not to happen. So never make a ValueObj class a direct subclass
      // of this object, but use the VALUE_OBJ_CLASS_SPEC class instead, e.g.,
      // like this:
      //
      // class A VALUE_OBJ_CLASS_SPEC {
      // ...
      // }
      //
      // With gcc and possible other compilers the VALUE_OBJ_CLASS_SPEC can
      // be defined as a an empty string "".

      In the past, the global operators 'new' and 'delete' were broken for some reason so they were disabled. A couple years ago, we fixed that and there are global operators for 'new' and 'delete'. With this, you can declare an object without a superclass of ValueObj and get an error if you call 'new' to allocate instances of it.

      Because of this, we don't need VALUE_OBJ_CLASS_SPEC anymore and we should remove it because there are classes that don't have it in the sources and efforts for making people subclass this class were inconsistent. And it really doesn't matter because we have the global operators for new and delete variants. Removing this would clean up the code and resolve this area of questioning that we always have to explain to people.

      Attachments

        Issue Links

          Activity

            People

              coleenp Coleen Phillimore
              coleenp Coleen Phillimore
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: