초록
이 논문의 목적은 ML 프로그램의 소스(source)를 수정하여 ML의 예외상황 처리기의 수행속도를 개선하고자 하는 것이다. ML은 함수를 값으로 주고받을 수 있으며 타입을 이용하여 프로그램을 검사해 주는 언어이다. 이러한 ML의 예외상황 처리부분을 사용함으로서 프로그래머는 쉽게 자신의 프로그램의 예외적인 동작을 기술할 수 있다. 하지만, 이러한 예외상황을 처리하기 위해서는 많은 계산이 필요하기 때문에, 예외상황을 처리하는 프로그램 부분이 병목 현상을 일으키는 경우가 많다. 프로그램의 소스를 바꾸어서 예외상황 처리부분이 존재하지 않는 같은 동작을 하는 다른 프로그램으로 바꾸는 방법은 이미 알려져 있지만, 도리어 수행시간이 느려진다. 위의 바꾸는 방법은 '나중에 할 일을 넘겨주는 방식(Continuation Passing Style)'이라고 부르는 방식으로 프로그램의 소스를 바꾸는 방법을 조금 수정하여, 예외상황을 처리하는 부분을 위의 '나중에 할 일(continuation)'과 같은 방식으로 넘겨주어 예외상황 처리부분이 모두 사라지게 된다. 그러나, 이러한 방식은 모든 프로그램내 표현(expression)을 모두 위와 같은 방식으로 바꾸기 때문에, 이로 인해 발생하는 계산이 예외상황을 처리하는 계산보다 더 많아지게 된다. 이 논문에서는 이러한 단점을 개선하여 프로그램내에서 예외상황 처리부분을 없애는데 꼭 필요한 표현 만을 정적분석을 사용하여 골라내어 이를 선택적으로 변환하는 방법을 사용한다.
ML's exception handling makes it possible to describe exceptional execution flows conveniently. Sometimes, current implementation of exception handling introduces unnecessary overhead. Our goal is to reduce this overhead by source-level transformation. To this end, we transform source programs into variant of continuation-passing style(CPS), replacing handle and raise expressions by continuation-catching and throwing expressions, respectively. CPS-transforming every expression, however, introduces a new cost. We therefore use an exception analysis to transform expressions selectively: if an expression is statically determined to involve exceptions then it is CPS-transformed; otherwise, it is left in direct style. In this article, we formalize this selective CPS transformation, prove its correctness, and present possible improvement for our transformation.