HGraph&HBasicBlock
来源:互联网 发布:dwg文件查看器 mac 编辑:程序博客网 时间:2024/06/03 19:28
HGraph是一个method的控制流图。包含a list of basic blocks。
该类的私有变量有:
328 ArenaAllocator* const arena_;//该图所在的arena 329 330 // List of blocks in insertion order.以插入顺序形成的基本块表 331 GrowableArray<HBasicBlock*> blocks_; 332 333 // List of blocks to perform a reverse post order tree traversal.形成倒序树型遍历的基本块表 334 GrowableArray<HBasicBlock*> reverse_post_order_; 335 336 // List of blocks to perform a linear order tree traversal.形成线性树型遍历的基本快表 337 GrowableArray<HBasicBlock*> linear_order_; 338 339 HBasicBlock* entry_block_;//入口块 340 HBasicBlock* exit_block_;//出口块 341 342 // The maximum number of virtual registers arguments passed to a HInvoke in this graph. //在该图中传递给HInvoke的虚拟寄存器参数的最大值。 343 uint16_t maximum_number_of_out_vregs_; 344 345 // The number of virtual registers in this method. Contains the parameters. //本方法中的虚拟寄存器的数量。包括参数。 346 uint16_t number_of_vregs_; 347 348 // The number of virtual registers used by parameters of this method. //本方法的参数所使用的虚拟寄存器的数量 349 uint16_t number_of_in_vregs_; 350 351 // Number of vreg size slots that the temporaries use (used in baseline compiler). //临时使用的vreg size slots的数量(在baseline compiler中使用,即无优化的编译器) 352 size_t temporaries_vreg_slots_; 353 354 // Has bounds checks. We can totally skip BCE if it's false. //边界检查。如果这一项是false的话,可以跳过BCE。 355 bool has_bounds_checks_; 356 357 // Indicates whether the graph should be compiled in a way that 358 // ensures full debuggability. If false, we can apply more 359 // aggressive optimizations that may limit the level of debugging. //该变量表明是否该图应该以一种保证完全debuggability的方式进行编译。如果false,就可以采取更多aggressive的优化措施,这些优化可能会限制debugging的级别。 360 const bool debuggable_; 361 362 // The current id to assign to a newly added instruction. See HInstruction.id_. //分配给新添加的instruction的当前的id。参见HInstruction.id_ 363 int32_t current_instruction_id_; 364 365 // The dex file from which the method is from. //该method来自的dexfile 366 const DexFile& dex_file_; 367 368 // The method index in the dex file. //dexfile中的method index 369 const uint32_t method_idx_; 370 371 const InstructionSet instruction_set_;//该图中包含的指令集 372 373 // Cached constants. 缓存好的常量,包括int/float/long/double这四种类型 374 HNullConstant* cached_null_constant_; 375 ArenaSafeMap<int32_t, HIntConstant*> cached_int_constants_; 376 ArenaSafeMap<int32_t, HFloatConstant*> cached_float_constants_; 377 ArenaSafeMap<int64_t, HLongConstant*> cached_long_constants_; 378 ArenaSafeMap<int64_t, HDoubleConstant*> cached_double_constants_; 379 380 friend class SsaBuilder; // For caching constants. 381 friend class SsaLivenessAnalysis; // For the linear order.
其中Arena allocator is a well known technique. An arbitrary sized memory block is preallocated at some point of execution. A pointer is maintained to track the next allocation position within the block. Subsequent allocations simply move that pointer to the next allocation position. The entire block is deallocated at once eliminating the need of individual deallocations.
参考文献:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763105392230e54f732618187573f89cb1fc2224c413037bee43a5150428894223040b24f5ae0f7346f444377ebc8df883caee5cc757edb6169300b863764b564cfdc4653927cc64de9d96eb8eaa764c5f984c4df22318a045624deadda0946439c78f06241a4f28d0d481f46b5be7032a30a6028ef701ee81aa8b3743347&p=8b2a97548ad900ff57ed977b49449e&newp=85769a4786cc41ac5da4db65467a94231610db2151d4d4116b82c825d7331b001c3bbfb423241000d2c479650aa94957eff33d70310123a3dda5c91d9fb4c57479&user=baidu&fm=sc&query=ArenaAllocator&qid=e4f095f8000168cf&p1=1
以及http://blog.sina.com.cn/s/blog_6b10e1740100rxnk.html
在类ArenaAllocator中,私有变量:
273 private:274 static constexpr size_t kAlignment = 8;275 276 void UpdateBytesAllocated();277 278 ArenaPool* pool_;279 uint8_t* begin_;280 uint8_t* end_;281 uint8_t* ptr_;282 Arena* arena_head_;283 bool running_on_valgrind_;284 285 template <typename U>286 friend class ArenaAllocatorAdapter;
类HBasicBlock:
在一个method中的block,包含形式为双向链表的指令队列。每一个block都知道它的前一块(predecessor)和后一块(successor).
私有变量包括:
758 private: 759 HGraph* graph_; 760 GrowableArray<HBasicBlock*> predecessors_; 761 GrowableArray<HBasicBlock*> successors_; 762 HInstructionList instructions_; 763 HInstructionList phis_; 764 HLoopInformation* loop_information_; 765 HBasicBlock* dominator_; 766 GrowableArray<HBasicBlock*> dominated_blocks_; 767 int block_id_; 768 // //该块中第一个instruction的dex program counter。 769 const uint32_t dex_pc_; 770 size_t lifetime_start_; 771 size_t lifetime_end_; 772 bool is_catch_block_;
以及一些public方法:
655 HBasicBlock* SplitAfter(HInstruction* cursor);/*在HInstruction* cursor后将该block分为两个块。返回新创建的块。注意:该method只会更新raw block information,如predecessors,successors,dominators以及instruction list。并不会对graph,reverse post order,loop information造成更新,也不保证两个blocks是consistent的(例如以一个control flow instruction结束)。*/ 656 662 void MergeWithInlined(HBasicBlock* other);/*将块other整合到this block后,所以other的successor和dominated 块都变为this块的successor和dominated块。注意:并不会对graph,reverse post order,loop information造成更新,也不保证两个blocks是consistent的(例如以一个control flow instruction结束)。*/ 663 669 void ReplaceWith(HBasicBlock* other);/*用other来代替this块。this块的predecessors,successors以及dominated块都被移到other块下。注意:并不会对graph,reverse post order,loop information造成更新,也不保证两个blocks是consistent的(例如以一个control flow instruction结束)。*/ 670 675 void MergeWith(HBasicBlock* other);/*将块other整合到this block后,该method会对loops,reverse post order,对predecessors/successors/dominators的链接都会进行更新,且this和other必须是相邻的,比如this是other的唯一的predecessor,other是this唯一的successor。*/ 676 681 void DisconnectAndDelete();/*将this与所有的predecessors/successors/dominators都断连,将它从所有的loops中移除掉,乃至从整个图中移除掉。该块不可以dominate其他块。predecessors和successors被安全的更新。*/741 bool Dominates(HBasicBlock* block) const;/*返回是否this块dominate作为参数被传递的那个块block。即this块总在block块之前被执行*/
类HInvoke:
对应dalvik的调用方法指令: invoke-virtual、invoke-direct、invoke-super。
参考文献:http://www.cnblogs.com/Fang3s/p/3782903.html
invoke-static 是类静态方法的调用,编译时,静态确定的;
invoke-virtual 虚方法调用,调用的方法运行时确认实际调用,和实例引用的实际对象有关,动态确认的,一般是带有修饰符protected或public的方法,不是private,static或者final,也不是constructor的方法。
invoke-direct 没有被覆盖方法的调用,即不用动态根据实例所引用的调用,编译时,静态确认的,一般是private或方法(constructor);
invoke-super 直接调用父类的虚方法,编译时,静态确认的。
invoke-interface 调用接口方法,调用的方法运行时确认实际调用,即会在运行时才确定一个实现此接口的对象。
例子:
invoke-direct {v2}, Ljava/lang/StringBuilder;->()V # 调用 StringBuilder 构造函数
invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File; #静态方法
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; #public方法
再此强调一遍对于非静态方法而言{}的结构是{当前实例对象,参数1,参数2,…参数n},而对于静态方法而言则是{参数1,参数2,…参数n}
- HGraph&HBasicBlock
- 从HGraph生成SSA
- ajax和asp判断用户登录
- 安装和使用hive时遇到的一些问题
- 06_细节_运算符符知识补充
- Linq语法
- List--和--Map
- HGraph&HBasicBlock
- React-----Composition(构造)VS Inheritance(继承)
- PMP考试【4】关于挣值管理的典型案例
- java.lang.IllegalStateException: commit already called
- 选择排序
- OpenGL学习脚印: 视变换(view transformation)
- 由“竞争”引发的一点思考 -- 读《ZERO TO ONE》
- 归一化函数mapminmax的讨论
- scrapy在Request之间传递参数