Compiling Lazy Functional Programs to Java on the basis of Spineless Taxless G-Machine with Eval-Apply Model

Eval-Apply 모델의 STGM에 기반하여 지연 계산 함수형 프로그램을 자바로 컴파일하는 기법

  • 남병규 (한국전자통신연구원 시스템연결망연구팀) ;
  • 최광훈 (한국과학기술원 전산학과) ;
  • 한태숙 (한국과학기술원 전산학과)
  • Published : 2002.06.01

Abstract

Recently there have been a number of researches to provide code mobility to lazy functional language (LFL) programs by translating LFL programs to Java programs. These approaches are basically baled on architectural similarities between abstract machines of LFLs and Java. The abstract machines of LFLs and Java programming language, Spineless Tagless G-Machine(STGM) and Java Virtual Machine(JVM) respectively, share important common features such as built- in garbage collector and stack machine architecture. Thus, we can provide code mobility to LFLs by translating LFLs to Java utilizing these common features. In this paper, we propose a new translation scheme which fully utilizes architectural common features between STGM and JVM. By redefining STGM as an eval-apply evaluation model, we have defined a new translation scheme which utilizes Java Virtual Machine Stack for function evaluation and totally eliminates stack simulation which causes array manipulation overhead in Java. Benchmark program translated to Java programs by our translation scheme run faster on JDK 1.3 than those translated by the previous schemes.

최근에 지연 계산 함수형 언어를 자바 프로그램으로 변환함으로써 지연 계산 함수형 언어 프로그램에 대해 코드 이동성을 제공하려는 연구가 있었다. 이러한 연구들은 자바와 지연 계산형 함수형 언어의 추상 기계가 가지는 구조적 유사성에 바탕을 두고 있다. 지연 계산 함수형 언어에 대한 추상 기계인 STGM(Spineless Tagless G-machine)과 자바 언어에 대한 추상 기계인 JVM(Java Virtual Machine)은 기억장소 재활용 체계와 스택 기계 구조를 가진다는 점에서 공통된 특징을 가지고 있다. 그러나 현재가지의 지연 계산 함수형 언어로부터 자바로의 변환 구조는 이와 같은 추상 기계 구조상의 공통점을 충분히 이용하지 못하였다. 본 논문에서는 STGM의 계산 모델을 eval-apply 모델로 새로이 정의함으로써 STGM과 JVM의 공통점을 충분히 이용하는 새로운 변환 구도를 제안한다. 새로이 제안된 변환 구도에서는 자바 스택(Java Virtual Machine Stack)을 사용하여 함수 계산을 수행하도록 함으로써 스택 시뮬레이션으로 인해 나타나는 자바에서의 배열 접근 부담을 제거하였다. 본 논문의 변환 구도에 의해 자바로 변환된 벤치마크 프로그램들은 기존의 변환 구도에 의해 변환된 경우보다 JDK 1.3에서 빠르게 동작한다.

Keywords

References

  1. S.L.P. Jones. Implementing Lazy Functional Languages on Stock Hardware: the Spineless Tagless G-machine. Journal of Functional Programming. Vol 2, Part 2, pages 127-202, April 1992 https://doi.org/10.1017/S0956796800000319
  2. T. Lindholm and F. Yellin. The java Virtual $Machine^{TM}$ Specification (2nd Ed.). Addison Wesley, 1999
  3. J. Meyer and T. Downing. JAVA Virtual Machine, O'REILLY, 1997
  4. K. Choi, H. Lim and T. Han. Compiling Lazy Functional Programs Based on the Spinless Tagless G-machine for the Java Virtual Machine. In Fifth International Symposium on Functional and Logic Programming, Waseda University, Tokyo, Japan, March 7-9, 2001. (Lecture Notes in Computer Science 2024)
  5. R. Dounce and P. Fradet. A Systematic Study of Functional Language Implementations. ACH Transactions on Programming Languages and Systems, Vol 20. No 2, pages 344-387, March 1998 https://doi.org/10.1145/276393.276397
  6. M. Tullsen. Compiling Haskell to Java. 690 Project. September 1997
  7. A. Verner. The Jaskell Project. A diploma project, February 1999
  8. D. Wakeling. Compiling Lazy Functional Programs for the Java Virtual Machine. journal of' Functional Programming, Vol 9, Part 6, pages 579-603, November 1999 https://doi.org/10.1017/S0956796899003603
  9. D. Wakeling. A Haskell to Java Virtual Machine Code Compiler. In Proceedings of the 1997 Workshop on the Implementation of Functional Languages, pages 39-52, 1997