首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

MMTk代码学习(通体结构)

2012-12-25 
MMTk代码学习(整体结构)必要的整体模块对于一个完整的内存管理工具,主要涉及:内存映射(Address)内存组织结

MMTk代码学习(整体结构)
必要的整体模块

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

内存映射(Address)内存组织结构(Resource,Page)基于内存结构的策略:分配、回收(Alloc, Collect)
内存跟踪(Trace, Log)对应到MMTk的具体模块系统结构Plan
MMTk代码学习(通体结构)
?CollectorContext, MutatorContext 上下文环境所有collector都继承于CollectorContext(包含有run()方法接口用于线程化) TLS(Thread Local storage)
MMTk代码学习(通体结构)
?所有mutator都继承于MutatorContext
MMTk代码学习(通体结构)
?Phase, ConcurrentPhase, ComplexPhase:将GC分成多个过程,整个GC由若干Phase组成内存映射Address内存组织结构PageResourceFreeListPageResourceMonotonePageResource主要流程初始化
    enableAllocation: allow allocation (but not collection).processOptions: the VM has parsed/prepared options for MMTk to react to.
    enableCollection: the VM can support the spawning of MMTk collector contexts.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;  }
    checkAllocator: 选择一个合适的allocatorallocateSpace: mutator.alloc(allocSlow:可能调用GC)初始化对象数据mutator.postAlloc
垃圾收集Alloc时触发

allocSlow

主动调用

org.jikesrvm.mm.mminterface.MemoryManager

  /**   * External call to force a garbage collection.   */  @Interruptible  public static void gc() {    Selected.Plan.handleUserCollectionRequest();  }

热点排行