`

MMTk代码学习(整体结构)

阅读更多

必要的整体模块

对于一个完整的内存管理工具,主要涉及:

  • 内存映射(Address)
  • 内存组织结构(Resource,Page)
  • 基于内存结构的策略:分配、回收(Alloc, Collect)
  • 内存跟踪(Trace, Log)

对应到MMTk的具体模块

系统结构

  • Plan

     
  • CollectorContext, MutatorContext 上下文环境
    • 所有collector都继承于CollectorContext(包含有run()方法接口用于线程化) TLS(Thread Local storage)

       
    • 所有mutator都继承于MutatorContext

       
  • Phase, ConcurrentPhase, ComplexPhase:将GC分成多个过程,整个GC由若干Phase组成

内存映射

  • Address

内存组织结构

  • PageResource
  • FreeListPageResource
  • MonotonePageResource

主要流程

初始化

  1. enableAllocation: allow allocation (but not collection).
  2. processOptions: the VM has parsed/prepared options for MMTk to react to.
  3. enableCollection: the VM can support the spawning of MMTk collector contexts.
  4. fullyBooted: control is jst about to be given to application code.

分配对象

org.jikesrvm.mm.mminterface.MemoryManager

  /**
   * Allocate a scalar object.
   *
   * @param size Size in bytes of the object, including any headers
   * that need space.
   * @param tib  Type of the object (pointer to TIB).
   * @param allocator Specify which allocation scheme/area JMTk should
   * allocate the memory from.
   * @param align the alignment requested; must be a power of 2.
   * @param offset the offset at which the alignment is desired.
   * @param site allocation site.
   * @return the initialized Object
   */
  @Inline
  public static Object allocateScalar(int size, TIB tib, int allocator, int align, int offset, int site) {
    Selected.Mutator mutator = Selected.Mutator.get();
    allocator = mutator.checkAllocator(org.jikesrvm.runtime.Memory.alignUp(size, MIN_ALIGNMENT), align, allocator);
    Address region = allocateSpace(mutator, size, align, offset, allocator, site);
    Object result = ObjectModel.initializeScalar(region, tib, size);
    mutator.postAlloc(ObjectReference.fromObject(result), ObjectReference.fromObject(tib), size, allocator);
    return result;
  }
  1. checkAllocator: 选择一个合适的allocator
  2. allocateSpace: mutator.alloc(allocSlow:可能调用GC)
  3. 初始化对象数据
  4. mutator.postAlloc

垃圾收集

Alloc时触发

allocSlow

主动调用

org.jikesrvm.mm.mminterface.MemoryManager

  /**
   * External call to force a garbage collection.
   */
  @Interruptible
  public static void gc() {
    Selected.Plan.handleUserCollectionRequest();
  }
  • 大小: 132.9 KB
  • 大小: 121.9 KB
  • 大小: 100.5 KB
分享到:
评论

相关推荐

    MMTK-2.7.9分子动力学模拟软件包

    这一款开源的优秀分子动力学模拟软件包,从事分子动力学研究的软件开发童鞋可以在此基础上进一步开发,或者将其作为科研工具也可以,采用编程语言为python和C。

    matlab说话代码-MMTK:适用于模拟方法工具包(MMTK)的MATLAB包装器

    matlab说话代码模拟方法工具包(MTK)的自述文件 作者: Eduardo J. Sanchez,博士。 -邮件点sdsu点edu上的esanchez __________________________________________________________________ 1.说明 我们定义了基于...

    mmtk-core:内存管理工具包

    MMTk MMTk是用于内存管理器设计和实现的框架。 该存储库托管MMTk的Rust端口。... 通过将--features标志传递给Rust编译器,我们可以有条件地编译与功能相关的代码。 例如,您可以选择通过将sanity添

    MMTk开发

    make vm=jdk build run gc=semispace benchmark=xalan发布版本make vm=jdk config profile=release make vm=jdk build run profile=release gc=semispace benchmark=xalan运行mmtk-core提交前CI make vm=jdk run-ci...

    MMTK-2.7.9-cp27-none-win32

    MMTK-2.7.9-cp27-none-win32

    MMTK-2.7.9-cp27-none-win_amd64

    MMTK-2.7.9-cp27-none-win_amd64

    MTK开发实例入门教程PART1

    压缩文件有18M,我只有15M权限,只好分2次压缩了。所以PART2不需要积分即可下载。http://download.csdn.net/source/974578

Global site tag (gtag.js) - Google Analytics