Compiling Haskell to Java via an Intermediate Code L

중간언어 L-코드를 이용한 Haskell-Java 언어 번역기 구현

  • Choi, Kwang-Hoon (Dept. of Electronic Computer Science, Korea Advanced Institute of Science and Technology) ;
  • Han, Tai-Sook (Dept. of Electronic Computer Science, Korea Advanced Institute of Science and Technology)
  • 최광훈 (한국과학기술원 전자전산학과) ;
  • 한태숙 (한국과학기술원 전자전산학과)
  • Published : 2001.12.01

Abstract

We propose a systematic method of compiling Haskell based on the spineless Tagless G-machine (STGM) for the Java, Virtual Machine (JVM) We introduce an intermediate language called L-code to identify each micro-operation of the machine by its instruction, Each macro operation of the machine is identified by a binding Each instruction of the L-code can be easily translated into Java statements. After our determination on representation and L-code program from a STG program is translated into Java program according to out compilation rules. Our experiment shows that the execution times of translated benchmarks are competitive compared with those in Haskell interpreter Hugs, particularly when Glasgow Haskell compiler's STG -level optimizations are applied.

본 논문에서는 함수형 언어 Haskell 을 Java언어로 변환하여 Java Virtual Machine 에 수행하는 컴파일 방법을 제안한다. 이 컴파일 방법은 추상 기계 Spineless Tageless G-machine(STGM)을 수행 모델로 삼는다 L-code로 명명한 중간 언어를 도입하여 추상기계의 각각의 세부 동작을 이 언어의 명령어로 표현하고, 일견의 세부 동작들을 이 언어의 바인딩을 통해 표현한다. 각 명령어는 Java의 문장으로 변환하기 쉽도록 정의하였다. Java에서의 표현 방법을 결정하고. STS 프로그램의 L-code 프로그램으로의 컴파일 규칙과 Java 프로그램으로의 컴파일 규칙을 세안한다. 실험을 통해 제안한 컴파일러에 의해 Haskell 프로그램으로부터 생성된 Java 프로그램의 수행 성능은 Glasgow Haskell 컴파일러의 최적화 변환을 적용했을 때 기존의 Haskell 인터프리터인 Hugs와 대등함을 보인다

Keywords

References

  1. S. L. Peyton Jones. Implementing Lazy Functional Languages on Stock Hardware: the Spineless Tagless G-machine. journal of Functional Programming, 2(2):127-202, April 1992
  2. S. L. Peyton Jones and A. L. M. Santos. A Transformation' based Optimiser for Haskell. Science of Computer Programming, 32( I-3):3-47, 1998 https://doi.org/10.1016/S0167-6423(97)00029-4
  3. M. Tullsen. Compiling Haskell to Java. 690 Project. Yale University, September 1997
  4. A. Vernet, The Jaskell Project. A Diploma Project, Swiss Federal Institute of Technology, February 1998
  5. Bill Joy. Guy Steele, James Gosling, and Gilad Bracha. The Java (tm) Language Specification, Second Edition. Addison Wesley, June 2000
  6. G. Meehan and M. Joy. Compiling Lazy Functional Programs to Java Bytecode. Software-Practice and Experience, 29(7):617-645, June 1999 https://doi.org/10.1002/(SICI)1097-024X(199906)29:7<617::AID-SPE250>3.0.CO;2-E
  7. D. Wakeling. Compiling Lazy Functional Programs for the Java Virtual Machine. Journal of Functional Programming, 9(6):579-603, November 1999 https://doi.org/10.1017/S0956796899003603
  8. S. L. Peyton Jones. A Java Back End for Glasgow Haskell Compiler. The Haskell Mailing List haskell@chaskell.org (http://www.haskell.org/mailinglist.html), May 2000
  9. N. Benton and A. Kennedy. Interlanguage Working Without Tears: Blending SML with Java. In Proceedings of the 4th ACM SIGPLAN Conference on Functional Programming, pages 126-137, 1999 https://doi.org/10.1145/317636.317791
  10. N. Benton and A. Kennedy, and G. Russel. Compiling Standard ML to Java Byte-codes. In Proceedings of the 3rd ACM SIGPLAN Conference on Functional Programming, pages 129-140, 1998