これらは, 動的に生成されるマシン語コード片を管理するためのクラス. 特に, 「生成後に滅多に破棄されないコード片」を担当する.
    ((cite: hotspot/src/share/vm/code/stubs.hpp))
    // The classes in this file provide a simple framework for the
    // management of little pieces of machine code - or stubs -
    // created on the fly and frequently discarded. In this frame-
    // work stubs are stored in a queue.
動的に生成されるマシンコード片を管理するクラスの基底クラス.
    ((cite: hotspot/src/share/vm/code/stubs.hpp))
    class Stub VALUE_OBJ_CLASS_SPEC {
なお, このクラス自体は abstract class であり, 実際に使われるのは以下のサブクラス.
Stub の中は以下のような構造になっている (なお, data section や code section は空であってもいい).
    ((cite: hotspot/src/share/vm/code/stubs.hpp))
    // Stub serves as abstract base class. A concrete stub
    // implementation is a subclass of Stub, implementing
    // all (non-virtual!) functions required sketched out
    // in the Stub class.
    //
    // A concrete stub layout may look like this (both data
    // and code sections could be empty as well):
    //
    //                ________
    // stub       -->|        | <--+
    //               |  data  |    |
    //               |________|    |
    // code_begin -->|        |    |
    //               |        |    |
    //               |  code  |    | size
    //               |        |    |
    //               |________|    |
    // code_end   -->|        |    |
    //               |  data  |    |
    //               |________|    |
    //                          <--+
See: here for details
Stub クラスのサブクラスのメソッドを呼び出すためのラッパークラス.
コメントによると 「Stub 自体のメソッドを virtual にすると Stub に vtable がついてしまってもったいないので, それぞれの Stub のサブクラス毎に対応する StubInterface というクラスを作っている」とのこと.
StubInterface のメソッドは virtual となっており, そこから対応する Stub サブクラスのメソッドが呼び出される.
    ((cite: hotspot/src/share/vm/code/stubs.hpp))
    // A stub interface defines the interface between a stub queue
    // and the stubs it queues. In order to avoid a vtable and
    // (and thus the extra word) in each stub, a concrete stub
    // interface object is created and associated with a stub
    // buffer which in turn uses the stub interface to interact
    // with its stubs.
    //
    // StubInterface serves as an abstract base class. A concrete
    // stub interface implementation is a subclass of StubInterface,
    // forwarding its virtual function calls to non-virtual calls
    // of the concrete stub (see also macro below). There's exactly
    // one stub interface instance required per stub queue.
    class StubInterface: public CHeapObj {
なお, このクラス自体は abstract class であり, 実際に使われるのは以下のサブクラス.
以下のマクロを使って, それぞれの Stub サブクラスに対応する StubInterface クラスが生成されている.
これで定義される StubInterface サブクラス内では, (Stub クラスのメソッドを virtual にする代わりに) cast() メソッドでそれぞれのサブクラスにキャストしてから呼び出している.
例: cast(self)->size();
この cast() はマクロにより型が確定しているので, コンパイル段階でそれぞれの Stub サブクラスのメソッドにリンクされる.
    ((cite: hotspot/src/share/vm/code/stubs.hpp))
    // DEF_STUB_INTERFACE is used to create a concrete stub interface
    // class, forwarding stub interface calls to the corresponding
    // stub calls.
    #define DEF_STUB_INTERFACE(stub)                           \
      class stub##Interface: public StubInterface {            \
       private:                                                \
        static stub*    cast(Stub* self)                       { return (stub*)self; }                 \
                                                               \
       public:                                                 \
        /* Initialization/finalization */                      \
        virtual void    initialize(Stub* self, int size)       { cast(self)->initialize(size); }       \
        virtual void    finalize(Stub* self)                   { cast(self)->finalize(); }             \
                                                               \
        /* General info */                                     \
        virtual int     size(Stub* self) const                 { return cast(self)->size(); }          \
        virtual int     code_size_to_size(int code_size) const { return stub::code_size_to_size(code_size); } \
                                                               \
        /* Code info */                                        \
        virtual address code_begin(Stub* self) const           { return cast(self)->code_begin(); }    \
        virtual address code_end(Stub* self) const             { return cast(self)->code_end(); }      \
                                                               \
        /* Debugging */                                        \
        virtual void    verify(Stub* self)                     { cast(self)->verify(); }               \
        virtual void    print(Stub* self)                      { cast(self)->print(); }                \
      };
See: here for details
生成した Stub を格納しておくためのキュー.
    ((cite: hotspot/src/share/vm/code/stubs.hpp))
    // A StubQueue maintains a queue of stubs.
    // Note: All sizes (spaces) are given in bytes.
    class StubQueue: public CHeapObj {
各 Stub サブクラスは, それぞれ以下の StubQueue に格納されて管理されている.
Stub のメモリは StubQueue 内に確保されたリングバッファ内に前から順に(キュー方式で)確保していく模様.
See: here for details
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.