计算机科学 ›› 2015, Vol. 42 ›› Issue (11): 84-89.doi: 10.11896/j.issn.1002-137X.2015.11.017

• 2014年全国高性能计算机学术年会 • 上一篇    下一篇

面向Java锁机制的字节码自动重构框架

张杨,张冬雯,仇晶   

  1. 河北科技大学信息科学与工程学院 石家庄050000,河北科技大学信息科学与工程学院 石家庄050000,河北科技大学信息科学与工程学院 石家庄050000
  • 出版日期:2018-11-14 发布日期:2018-11-14
  • 基金资助:
    本文受国家自然科学基金项目(61440012),河北省高等学校青年拔尖人才计划项目(BJ2014023),河北省自然科学基金项目(F2012208016)资助

Automated Refactoring Framework for Java Locks

ZHANG Yang, ZHANG Dong-wen and QIU Jing   

  • Online:2018-11-14 Published:2018-11-14

摘要: Java语言提供了同步锁、可重入锁和读写锁等几种锁机制,在并行程序设计中不同的数据结构使用这几种锁机制时获得的性能通常是不同的。为了在不同的锁机制之间进行自动转换,进而帮助程序员了解程序的性能,提出了一种面向Java锁机制的字节码自动重构框架,并基于该框架实现了字节码重构工具Lock2Lock。Lock2Lock在Quad中间表示的基础上对字节码进行静态分析,并对分析的结果进行一致性验证,通过Javassist完成字节码的重构。使用红黑树、消费者生产者程序以及SPECjbb2005 3个测试程序对Lock2Lock重构工具进行了测试,结果表明,Lock2Lock可以成功地实现从同步锁到可重入锁或读写锁的重构。

关键词: Java锁,软件重构,程序分析,字节码转换

Abstract: Java locks,such as synchronized,ReentrantLock,and ReadWriteLock,often obtain different performances when applied on different data structures.To learn about which lock will obtain the best performance,there is a strong need to transform from one lock to another automatically.This paper presented an automated refactoring framework for the transformation of Java locks.The framework extensively relies on static program analysis to perform the refacto-ring.The evaluation was performed using three benchmarks,such as red-black tree,producer-consumer problem and SPECjbb2005.The successful refactoring results are observed and the time of the refactoring is acceptable.

Key words: Java lock,Software refactoring,Program analysis,Bytecode transformation

[1] Kiczales G,Lamping J,Mendhekar A,et al.Aspect-oriented programming[C]∥Proceedings of European Conference on Object-Oriented Programming.Jyvaskyla,Finland,1997:241-268
[2] Barnes G.A method for implementing lock-free shared-datastructures [C]∥Proceedings of the fifth annual ACM symposium on Parallel algorithms and architectures.Velen,Germany,1993:261-270
[3] Shavit N,Touitou D.Software transactional memory[J].Distributed Computing,1997,10(2):99-116
[4] Whaley J.Joeq:A virtual machine and compiler infrastructure[J].Science of Computer Programming,2005,57(3):339-356
[5] Chiba S.Javassist—a reflection-based programming wizard for Java[C]∥Proceedings of OOPSLA’98 Workshop on Reflective Programming in C++ and Java.Denver,Colorado,1998:92-115
[6] Oracle.Java API Specification [EB/OL].(2011-11-23).http://download.oracle.com/javase/6/docs/api/java/util/concurrent/locks/package-summary.html
[7] Herlihy M,Luchangco V,Moir M.A flexible framework for implementing software transactional memory[J].ACM Sigplan Notices,2006,11(2):253-262
[8] Zhang Y,Zhang J,Zhang D.Implementing and testing Producer-consumer problem using aspect-oriented programming[C]∥Proceedings of Fifth International Conference on Information Assurance and Security.Xi’an,China,2009:749-752
[9] Adamson A,Dagastine D,Sarne S.SPECjbb2005--A year in the life of a benchmark[C]∥Proceedings of 2007 SPEC Benchmark Workshop.Austin,USA,2007:151-160
[10] Dig D,Marrero J,Ernst M D.Refactoring sequential Java code for concurrency via concurrent libraries[C]∥Proceedings of IEEE 31st International Conference on Software Engineering.Vancouver,Canada,2009:397-407
[11] Franklin L,Gyori A,Lahoda J,et al.LAMBDAFICATOR:from imperative to functional programming through automated refactoring[C]∥Proceedings of the 2013 International Conference on Software Engineering.San Francisco,USA,2013:1287-1290
[12] Schafer M,Sridharan M,Dolby J,et al.Refactoring java programs for flexible locking[C]∥Proceedings of 33rd InternationalConference on Software Engineering (ICSE).Hawaii,USA,2011:71-80
[13] Brown C,Hammond K,Danelutto M,et al.Paraphrasing:Genera-ting Parallel Programs Using Refactoring[J].Formal Methods for Components and Objects,2013,10(8):237-256
[14] Zhang C.FlexSync:An aspect-oriented approach to Java syn-chronization[C]∥Proceedings of the 31st International Confe-rence on Software Engineering.Vancouver,Canada,2009:375-385
[15] McCloskey B,Zhou F,Gay D,et al.Autolocker:synchronization inference for atomic sections[J].ACM SIGPLAN Notices,2006,23(2):346-358
[16] 赵思奇.面向并发的程序重构技术研究[D].南京:东南大学,2010 Zhao Si-qi.A novel approach of concurrency-oriented software refactoring[D].Nanjing:Southeast University,2010
[17] 吕建,杨大军,廖宇,等.一种并发面向对象同步模型研究[J].软件学报,2002,13(1):71-80 Lv Jian,Yang Da-jun,Liao Yu,et al.Research on a Concurrent Object-Oriented Synchronization Model[J].Journal of Software,2002,13(1):71-80
[18] 陶彬贤,张磊,钱巨.Java程序自动锁分解重构[J].计算机科学与探索,2013,7(5):451-459 Tao Xian-bin,Zhang Lei,Qian Ju.Automated Split Lock Refactoring for Java Programs[J].Journal of Frontiers of Computer Science and Technology,2013,7(5):451-459

No related articles found!
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!